Repository navigation
Conversation
44d7431 to
bb8097a
Compare
| static void check_hwaccel_support(void) | ||
| { | ||
| /* do not use hardware acceleration if a blacklisted device is the | ||
| * default and on 2 or more adapters */ | ||
| const wchar_t **device = blacklisted_devices; | ||
|
|
||
| if (adapterCount >= 2 || !is_intel(deviceId)) { | ||
| const bool isIntelArc = is_intel_arc(deviceId); | ||
| while (*device) { | ||
| if (!!wstrstri(deviceId.c_str(), *device)) { | ||
| if (!!wstrstri(deviceId.c_str(), *device) && !isIntelArc) { | ||
| hwaccel = false; | ||
| blog(LOG_INFO, "[obs-browser]: " | ||
| "Blacklisted device " | ||
| "detected, " | ||
| "disabling browser " | ||
| "source hardware " | ||
| "acceleration."); | ||
| blog(LOG_INFO, | ||
| "[obs-browser]: Blacklisted device detected, disabling browser source hardware acceleration."); |
There was a problem hiding this comment.
This logic is getting ugly enough it's worth pulling the check out into it's own function, which also gives us an excuse to update it to a range loop too.
| static void check_hwaccel_support(void) | |
| { | |
| /* do not use hardware acceleration if a blacklisted device is the | |
| * default and on 2 or more adapters */ | |
| const wchar_t **device = blacklisted_devices; | |
| if (adapterCount >= 2 || !is_intel(deviceId)) { | |
| const bool isIntelArc = is_intel_arc(deviceId); | |
| while (*device) { | |
| if (!!wstrstri(deviceId.c_str(), *device)) { | |
| if (!!wstrstri(deviceId.c_str(), *device) && !isIntelArc) { | |
| hwaccel = false; | |
| blog(LOG_INFO, "[obs-browser]: " | |
| "Blacklisted device " | |
| "detected, " | |
| "disabling browser " | |
| "source hardware " | |
| "acceleration."); | |
| blog(LOG_INFO, | |
| "[obs-browser]: Blacklisted device detected, disabling browser source hardware acceleration."); | |
| static inline bool is_blacklisted_device(const std::wstring &deviceId) | |
| { | |
| if (is_intel_arc(deviceId)) { | |
| return false; | |
| } | |
| for (const wchar_t **device = blacklisted_devices; *device; ++device) { | |
| if (wstrstri(deviceId.c_str(), *device)) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| static void check_hwaccel_support(void) | |
| { | |
| /* do not use hardware acceleration if a blacklisted device is the | |
| * default and on 2 or more adapters */ | |
| const bool shouldCheckBlacklist = adapterCount >= 2 || !is_intel(deviceId); | |
| if (shouldCheckBlacklist && is_blacklisted_device(deviceId)) { | |
| hwaccel = false; | |
| blog(LOG_INFO, | |
| "[obs-browser]: Blacklisted device detected, disabling browser source hardware acceleration."); | |
| } | |
| } |
bb8097a to
6d62d46
Compare
|
Rebasing first. |
Use a ranged-for instead of a while loop. As a trivial cleanup, unwrap this logged string.
The Intel entry in the blocklist here was intended for iGPUs because they could not handle browser hardware acceleration. Intel Arc GPUs are performant enough that they can run browser hardware acceleration. Do an additional check for those so that they can take advantage of hardware acceleration.
6d62d46 to
636d1dc
Compare
|
Applied the suggested changes. Simple testing with a FishGL page with 5000 fish at 1920x1080@30 shows reduced GPU utilization when checked in Task Manager on an Intel Arc GPU with this patch.
Someone with a non-Intel Arc system should test to make sure that the refactored code works as expected. |
| static inline bool is_intel_arc(const std::wstring &str) | ||
| { | ||
| return wstrstri(str.c_str(), L"Intel(R) Arc") != 0; | ||
| } | ||
|
|
||
| static inline bool is_blacklisted_device(const std::wstring &deviceId) | ||
| { | ||
| if (is_intel_arc(deviceId)) { | ||
| return false; | ||
| } | ||
| for (const wchar_t **device = blacklisted_devices; *device; ++device) { | ||
| if (wstrstri(deviceId.c_str(), *device)) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Functions with local visibility should be put in an anonymous namespace at the top of the file. Also inline should only be used in header files to resolve potential ODR violations.
Functions should be named isIntelArcGpu and isDeviceOnBlocklist, using camelCase per our code style guidelines.
| } | ||
| const bool shouldCheckBlacklist = adapterCount >= 2 || !is_intel(deviceId); | ||
| if (shouldCheckBlacklist && is_blacklisted_device(deviceId)) { | ||
| hwaccel = false; |
There was a problem hiding this comment.
I take it hwaccel is a magic global variable?
Description
The Intel entry in the blocklist here was intended for iGPUs because they could not handle browser hardware acceleration. Intel Arc GPUs are performant enough that they can run browser hardware acceleration. Do an additional check for those so that they can take advantage of hardware acceleration.
As a trivial cleanup, unwrap this logged string.
Motivation and Context
Want to unblock browser hardware acceleration on Intel Arc GPUs.
Simple testing with a FishGL page with 5000 fish at 1920x1080@30 shows reduced GPU utilization when checked in Task Manager on an Intel Arc GPU with this patch.
How Has This Been Tested?
Tested on Windows 11 with an Intel Arc A770M. Would welcome more testing.
Types of changes
Checklist: