Skip to content

Add hardware accel support under Linux#453

Merged
RytoEX merged 3 commits into
obsproject:masterfrom
tytan652:linux_hwaccel_pr
Apr 1, 2025
Merged

Add hardware accel support under Linux#453
RytoEX merged 3 commits into
obsproject:masterfrom
tytan652:linux_hwaccel_pr

Conversation

@tytan652

@tytan652 tytan652 commented Sep 11, 2024

Copy link
Copy Markdown
Contributor

Description

Requires:

Required by:

Add hwaccel support on Linux with CEF 6533 and later

Caution

NVIDIA might need to be blacklisted due to their inconsistency on supporting GBM and incomplete DRI3.
TLDR: Only latest generations with latest driver has a likelihood to work
NVIDIA driver has been blacklisted

Unlike Intel and AMD (so mainly Mesa), NVIDIA themself created a feature disparity between generation even in the same series of driver.

The blacklist is indeed quite wide but I don't have to all the card series to pinpoint what works and what does not. Including that when it "works" it needs to work under Wayland and X11 (yes both, not only one).

Motivation and Context

Just wanted to try to make it somehow work for fun, ended up making it for real…

How Has This Been Tested?

Tested under Wayland and X11.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Comment thread browser-client.cpp Outdated
@tytan652 tytan652 force-pushed the linux_hwaccel_pr branch 2 times, most recently from 3ee8f81 to 5496ec4 Compare September 12, 2024 11:35
jmickelonis added a commit to jmickelonis/obs-browser that referenced this pull request Sep 30, 2024
@RytoEX RytoEX requested a review from kkartaltepe October 17, 2024 19:11

@kkartaltepe kkartaltepe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine overall, i really wish we could pin down the modifier issue on x11 to something in cef's codebase... at least then we could see if it ever got fixed in the future.

@kkartaltepe

Copy link
Copy Markdown
Contributor

Doesnt compile with ENABLE_BROWSER_SHARED_TEXTURE set to 0 because this is used to avoid compiling the drm-formats stuff, but they are still referenced. Just remove the conditionals and always build these functions.

@kkartaltepe

kkartaltepe commented Oct 20, 2024

Copy link
Copy Markdown
Contributor

Maybe i'm missing something on how this was tested, but current master sets the BrowserHwaccel option to false so nothing here takes effect until https://github.com/obsproject/obs-studio/blob/master/UI/obs-app.cpp#L1268-L1278 is flipped.
--- edit
I see this is the dependent PR you mention.

@kkartaltepe

Copy link
Copy Markdown
Contributor

https://gist.github.com/kkartaltepe/ebf66527a38f188c8b07eb43b2d37de6 I dont remember if this happened as well on my original test months ago. But on my steamdeck tier setup there is significant rendering performance loss so rendering is twice as slow for a scene with 10 browser sources.

@tytan652

tytan652 commented Oct 20, 2024

Copy link
Copy Markdown
Contributor Author

Doesnt compile with ENABLE_BROWSER_SHARED_TEXTURE set to 0 because this is used to avoid compiling the drm-formats stuff, but they are still referenced. Just remove the conditionals and always build these functions.

#if ENABLE_BROWSER_SHARED_TEXTURE should have been #ifdef ENABLE_BROWSER_SHARED_TEXTURE, I fixed it.
The code relies on whether it's define or not, not its value.

I dont remember if this happened as well on my original test months ago. But on my steamdeck tier setup there is significant rendering performance loss so rendering is twice as slow for a scene with 10 browser sources.

This is why we test, I don't know I would be able to reproduce…

@tytan652

Copy link
Copy Markdown
Contributor Author

Changes:

  • Avoid linking libdrm but expose it's include directory since we only need DRM_FORMAT_
  • Blacklist NVIDIA driver since it does not work well on both Wayland and X11

@fatalgoth

Copy link
Copy Markdown

Just streamed for six hours with these patches, minus the NVIDIA blacklisting and it solved some framedrops when certain browser overlays would draw to the screen for me. Instead of a blacklist, can it be a warning or something? It worked really well for me.

Comment thread browser-client.cpp Outdated
Comment thread drm-format.cpp Outdated
Comment thread drm-format.cpp Outdated
Comment thread obs-browser-plugin.cpp Outdated
Comment thread browser-client.cpp Outdated
Comment thread browser-client.cpp Outdated
@tytan652 tytan652 force-pushed the linux_hwaccel_pr branch 2 times, most recently from fe24257 to 7b44d6f Compare January 24, 2025 06:56
@RytoEX

RytoEX commented Jan 30, 2025

Copy link
Copy Markdown
Member

https://gist.github.com/kkartaltepe/ebf66527a38f188c8b07eb43b2d37de6 I dont remember if this happened as well on my original test months ago. But on my steamdeck tier setup there is significant rendering performance loss so rendering is twice as slow for a scene with 10 browser sources.

@kkartaltepe If the original test was done with CEF 103 and the test in October was done with CEF 126/127, then could this be the issue with Qt message loop (obsproject/obs-studio#11485 et al)? Or is it a separate issue?

Would still like to know if this is good enough to merge, or if there's something else we need to address first.

Comment thread drm-format.hpp Outdated
@kkartaltepe

Copy link
Copy Markdown
Contributor

https://gist.github.com/kkartaltepe/ebf66527a38f188c8b07eb43b2d37de6 I dont remember if this happened as well on my original test months ago. But on my steamdeck tier setup there is significant rendering performance loss so rendering is twice as slow for a scene with 10 browser sources.

@kkartaltepe If the original test was done with CEF 103 and the test in October was done with CEF 126/127, then could this be the issue with Qt message loop (obsproject/obs-studio#11485 et al)? Or is it a separate issue?

Would still like to know if this is good enough to merge, or if there's something else we need to address first.

No I think its unrelated to that. When i profiled it, graphics stuff was just really slow.

@RytoEX RytoEX self-assigned this Feb 4, 2025
@RytoEX RytoEX merged commit 00b920f into obsproject:master Apr 1, 2025
@tytan652 tytan652 deleted the linux_hwaccel_pr branch April 30, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

6 participants