-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize native video detection #3686
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -369,6 +369,66 @@ function get_rpi_video() { | |
export PKG_CONFIG_PATH="$pkgconfig" | ||
} | ||
|
||
function has_video_output_device() { | ||
# check if there is a video output device with a connected display | ||
if [[ -d /sys/class/drm ]]; then | ||
local d | ||
for d in /sys/class/drm/*/ ; | ||
do | ||
[[ -f "$d/status" ]] && [[ $(cat "$d/status") == "connected" ]] && return 0 | ||
done | ||
fi | ||
return 1 | ||
} | ||
|
||
function has_render_device() { | ||
# check if there is a render note | ||
[[ -n "$(ls /dev/dri/render*)" ]] && return 0 | ||
return 1 | ||
} | ||
|
||
function get_graphics_platform() { | ||
case "$(systemctl get-default)" in | ||
multi-user.target) | ||
# for kmsdrm we need a card for video output and a render device for gl/gles acceleration | ||
has_video_output_device && __platform_flags+=(kms) | ||
;; | ||
graphical.target) | ||
__platform_flags+=(x11) | ||
# Only allow wayland if drm-backend.so can be used. Video output device is mandatory. | ||
has_video_output_device && __platform_flags+=(wayland) | ||
;; | ||
esac | ||
} | ||
|
||
function get_opengl_target_platform() { | ||
if isPlatform "x11"; then | ||
# glxinfo only runs under x11 | ||
! hasPackage "mesa-utils" && aptInstall mesa-utils | ||
|
||
local gl_info=$(sudo -u $user DISPLAY=:0 glxinfo -B) | ||
local glcore_ver=$(echo "$gl_info" | grep -oP 'Max core profile version:\s\K.*') | ||
local gl_ver=$(echo "$gl_info" | grep -oP 'Max compat profile version:\s\K.*') | ||
local gles_ver=$(echo "$gl_info" | grep -oP 'Max GLES\[23\] profile version:\s\K.*') | ||
|
||
# use $glcore_ver as $gl_ver if version is higher | ||
compareVersions "$glcore_ver" gt "$gl_ver" && gl_ver="$glcore_ver" | ||
if compareVersions "$gles_ver" gt "1.1" && compareVersions "$gl_ver" lt "4.2"; then | ||
compareVersions "$gles_ver" gt "3.1" && __platform_flags+=(gles3 gles31 gles32) | ||
__platform_flags+=(gles) | ||
else | ||
compareVersions "$gl_ver" gt "2.0" && __platform_flags+=(gl2) | ||
__platform_flags+=(gl) | ||
fi | ||
else | ||
# Fallback for other platforms | ||
# Use GL for x86. Most x86 platforms have better GL support. | ||
# Use GLES for arm. Most arm platforms have better GLES support. | ||
isPlatform "x86" && __platform_flags+=(gl) || __platform_flags+=(gles) | ||
isPlatform "kms" && ! has_render_device && __platform_flags+=(softpipe) | ||
fi | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think this is needed as a standalone function. This PR relies too much on "something && something &&" and it isn't that readable imho. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved it into platform_native() and removed get_native_video.sh. get_graphics_platform really just checks if there is a lvds/hdmi/lcd display controller with a kms driver which can be used to output something. On arm platforms display controller and gpus can be separate devices. Display controllers are kms devices and gpus are kms render only (kmsro) devices. With get_opengl_target_platform we check capabilities of the render device. |
||
function get_platform() { | ||
local architecture="$(uname --machine)" | ||
if [[ -z "$__platform" ]]; then | ||
|
@@ -626,14 +686,15 @@ function platform_tinker() { | |
|
||
function platform_native() { | ||
__default_cpu_flags="-march=native" | ||
__platform_flags+=(gl vulkan) | ||
# add x86 platform flag for x86/x86_64 archictures. | ||
[[ "$__platform_arch" =~ (i386|i686|x86_64) ]] && __platform_flags+=(x86) | ||
# get native video platform flags | ||
if [[ "$__has_kms" -eq 1 ]]; then | ||
__platform_flags+=(kms) | ||
__platform_flags+=(kms gl vulkan) | ||
else | ||
__platform_flags+=(x11) | ||
get_graphics_platform | ||
get_opengl_target_platform | ||
fi | ||
# add x86 platform flag for x86/x86_64 archictures. | ||
[[ "$__platform_arch" =~ (i386|i686|x86_64) ]] && __platform_flags+=(x86) | ||
} | ||
|
||
function platform_armv7-mali() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing local declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed