Skip to content

feat(linux/glad): add EGL_IMG_context_priority & EGL_NV_context_priority_realtime#4857

Open
psyke83 wants to merge 1 commit intoLizardByte:masterfrom
psyke83:glad_priority
Open

feat(linux/glad): add EGL_IMG_context_priority & EGL_NV_context_priority_realtime#4857
psyke83 wants to merge 1 commit intoLizardByte:masterfrom
psyke83:glad_priority

Conversation

@psyke83
Copy link
Contributor

@psyke83 psyke83 commented Mar 16, 2026

Description

Resolves encoding throttling:

  • Try to create EGL context with realtime or high priority if supported.
  • Set CAP_SYS_NICE capability (needed for AMDGPU priority queues above NORMAL).

Currently has no effect on AMDGPU with Flatpak, AppImage and/or with
Portal capture. Other GPUs may behave differently.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@psyke83 psyke83 marked this pull request as ready for review March 16, 2026 02:27
@psyke83
Copy link
Contributor Author

psyke83 commented Mar 16, 2026

Pinging @inkatail to test a possible alternative to async_depth modification. Vulkan encoding won't be affected by this PR, but it may help resolve VAAPI encoder throttling during high GPU usage.

@codecov
Copy link

codecov bot commented Mar 16, 2026

Bundle Report

Bundle size has no change ✅

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 0% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.87%. Comparing base (2a5901b) to head (fd9d3ae).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/platform/linux/graphics.cpp 0.00% 36 Missing and 3 partials ⚠️
src/platform/linux/portalgrab.cpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4857      +/-   ##
==========================================
- Coverage   17.91%   17.87%   -0.04%     
==========================================
  Files         106      106              
  Lines       21980    22015      +35     
  Branches     9812     9838      +26     
==========================================
- Hits         3937     3935       -2     
- Misses      13335    14928    +1593     
+ Partials     4708     3152    -1556     
Flag Coverage Δ
Archlinux 12.28% <0.00%> (-0.04%) ⬇️
FreeBSD-14.3-aarch64 ?
FreeBSD-14.3-amd64 14.12% <0.00%> (-0.02%) ⬇️
Homebrew-ubuntu-22.04 14.63% <0.00%> (-0.04%) ⬇️
Linux-AppImage 12.78% <0.00%> (-0.04%) ⬇️
Windows-AMD64 14.98% <ø> (ø)
Windows-ARM64 13.39% <ø> (+0.01%) ⬆️
macOS-arm64 18.60% <ø> (ø)
macOS-x86_64 17.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/linux/portalgrab.cpp 3.55% <0.00%> (-0.01%) ⬇️
src/platform/linux/graphics.cpp 2.24% <0.00%> (-0.15%) ⬇️

... and 47 files with indirect coverage changes

@inkatail
Copy link

Pinging @inkatail to test a possible alternative to async_depth modification. Vulkan encoding won't be affected by this PR, but it may help resolve VAAPI encoder throttling during high GPU usage.

@psyke83 Unfortunately, this PR doesn't seem to improve it at least for me, logs seem to report that the Priority is HIGH but in games the performance is still weird

@psyke83 psyke83 marked this pull request as draft March 16, 2026 14:18
@psyke83
Copy link
Contributor Author

psyke83 commented Mar 16, 2026

Thanks for testing. I'll convert this to draft until I can test some more.

@inkatail I happen to have the same GPU as you; can you suggest the exact in-game settings that can reproduce the issue in ETS2? I have the game but never played it, so I might need some guidance on what scenario to load, etc.

@Romanychev
Copy link

Could you help me with the problem?

GPU performance drop tied to stream framerate on Linux #4567

@psyke83 psyke83 marked this pull request as ready for review March 16, 2026 14:51
@psyke83
Copy link
Contributor Author

psyke83 commented Mar 16, 2026

@Romanychev

I refreshed the PR to try setting realtime priority as well. I can't test this as the AMD drivers don't support this extension, but you could give it a try. I'm not sure how the nvenc encoder pipeline interacts with EGL.

If you don't see EGL Context Priority: REALTIME logged, more changes (setting CAP_SYS_NICE) might be needed. Realtime might also cause Sunshine to hang your system, so be careful.

@inkatail
Copy link

Thanks for testing. I'll convert this to draft until I can test some more.

@inkatail I happen to have the same GPU as you; can you suggest the exact in-game settings that can reproduce the issue in ETS2? I have the game but never played it, so I might need some guidance on what scenario to load, etc.

@psyke83 All I changed in graphics settings was using the Ultra preset, then for testing I were just driving around cities cause they are pretty intensive to run, I were also testing in the Driving Academy (which is basically a tutorial for ETS).

@psyke83
Copy link
Contributor Author

psyke83 commented Mar 17, 2026

@inkatail Please retest the latest version that adds CAP_SYS_NICE support. I was able to reproduce the lag in ETS2 that's now fixed by the PR, but only under specific conditions:

  • Using distro package only (no Flatpak or AppImage)
  • Not using Portal capture

Basically, VAAPI + KMS is currently the only confirmed working case on AMD.

@Romanychev

The NVIDIA drivers might not need CAP_SYS_NICE to increase the priority, so Flatpak, AppImage and Portal may work/benefit from this change as well as the distro packages.

@ReenigneArcher
Copy link
Member

@psyke83 I will wait to merge until I get the go-ahead from you.

@inkatail
Copy link

@inkatail Please retest the latest version that adds CAP_SYS_NICE support. I was able to reproduce the lag in ETS2 that's now fixed by the PR, but only under specific conditions:

* Using distro package only (no Flatpak or AppImage)

* Not using Portal capture

Basically, VAAPI + KMS is currently the only confirmed working case on AMD.

@Romanychev

The NVIDIA drivers might not need CAP_SYS_NICE to increase the priority, so Flatpak, AppImage and Portal may work/benefit from this change as well as the distro packages.

@psyke83 Did another test, now with CAP_SYS_NICE on VA-API + KMS and it indeed seems to fix the issue properly now.

@psyke83
Copy link
Contributor Author

psyke83 commented Mar 17, 2026

@psyke83 I will wait to merge until I get the go-ahead from you.

I think we should get some feedback from NVIDIA users. It may be risky to set realtime due to the risk of hangs. Aside from that, I'm investigating whether it's possible to make this work with Portal, but I suppose that can be refined in a later PR.

@psyke83 psyke83 changed the title fix(linux/glad): implement EGL_IMG_context_priority support fix(linux/glad): add EGL_IMG_context_priority & EGL_NV_context_priority_realtime Mar 17, 2026
…ity_realtime

Resolves encoding throttling:
* Try to create EGL context with realtime or high priority if supported.
* Set CAP_SYS_NICE capability (needed for AMDGPU priority queues above NORMAL).

Currently has no effect on AMDGPU with Flatpak, AppImage and/or with
Portal capture. Other GPUs may behave differently.
@psyke83 psyke83 changed the title fix(linux/glad): add EGL_IMG_context_priority & EGL_NV_context_priority_realtime feat(linux/glad): add EGL_IMG_context_priority & EGL_NV_context_priority_realtime Mar 17, 2026
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent FPS in Certain Games

4 participants