Skip to content

GS/GL Shenannigans (Prep for obs-browser hwaccel on Linux ?)#11219

Merged
RytoEX merged 1 commit into
obsproject:masterfrom
tytan652:gl_shenannigans
Sep 12, 2024
Merged

GS/GL Shenannigans (Prep for obs-browser hwaccel on Linux ?)#11219
RytoEX merged 1 commit into
obsproject:masterfrom
tytan652:gl_shenannigans

Conversation

@tytan652

@tytan652 tytan652 commented Aug 29, 2024

Copy link
Copy Markdown
Collaborator

Description

Disclaimer: This is graphics code, do not consider that I know what I am doing.

  • Enable gs_shared_texture_available on all platforms, only Linux was missing which mainly use DMA-BUF.
    • obs-browser relies on it to enable hardware accel
  • Relax OpenGL texture format copy check
    • It allows to copy _UNORM to their non-_UNORM counterpart since CEF sends texture with SRGB.

Motivation and Context

Enable https://github.com/tytan652/obs-browser/tree/linux_hwaccel_2 to work without doing weird stuff like tytan652/obs-browser@1ca22d2 or other in https://github.com/tytan652/obs-browser/tree/linux_hwaccel

How Has This Been Tested?

Just built and ran OBS with this PR and my second hwaccel browser branch and their is no more SRGB gamma issues.

Types of changes

  • Tweak (non-breaking change to improve existing functionality)
  • Documentation (a change to documentation pages)

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.

@kkartaltepe

Copy link
Copy Markdown
Collaborator

This is used to guard access to device_texture_open_shared, which we do not and will never have on linux. It should be safe to simply always assume dmabuf is available on linux platforms.

And really every backend except windows opengl would report true, so maybe we should move the remaining 3 uses of this function behind windows if-def's instead of trying to make it more generally available?

@tytan652

tytan652 commented Aug 29, 2024

Copy link
Copy Markdown
Collaborator Author

to guard access to device_texture_open_shared, which we do not and will never have on linux. It should be safe to simply always assume dmabuf is available on linux platforms.

I think maybe replacing the true by checking if needed EGL (with DMA-BUF) extensions are available.
It looks like there is no function for check for import.

Also NVIDIA is not perfect when it comes to provide DMA-BUF on all cards…

@tytan652

Copy link
Copy Markdown
Collaborator Author

I can remove the gs_shared_texture_available changes, if there is no issue hard-coding it to true on the obs-browser side.

@kkartaltepe

Copy link
Copy Markdown
Collaborator

We already depend on EGL_EXT_image_dma_buf_import_modifiers, if the platform doesnt support it obs wont load anyway. This isnt a problem with nvidia. If you wanted a better check would need to actually manage the modifier format lists like we do in pipewire which again is not something a simple "texture_sharing_enabled" is going to be useful for.

@WizardCM WizardCM added kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. platform/macos Categorizes issue or PR as affecting macOS specifically platform/linux Categorizes issue or PR as affecting Linux specifically labels Aug 31, 2024

@WizardCM WizardCM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks to be the same change as D3D.

@Lain-B Lain-B left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Although this could be dangerous if used incorrectly, this is generally fine because the underlying memory layout should be identical, so if a use case calls for it, this is something I am probably fine with.

SRGB and non-SRGB formats are compatible for copy.
@RytoEX RytoEX added this to the OBS Studio 31 milestone Sep 12, 2024
@RytoEX RytoEX merged commit 26d2752 into obsproject:master Sep 12, 2024
@tytan652 tytan652 deleted the gl_shenannigans branch September 13, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. platform/linux Categorizes issue or PR as affecting Linux specifically platform/macos Categorizes issue or PR as affecting macOS specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants