Skip to content
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

[GLES3] Use temporary frag_color #84697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lawnjelly
Copy link
Member

@lawnjelly lawnjelly commented Nov 10, 2023

Some hardware exhibits a slowdown when shaders modify the frag_color output multiple times. In order to prevent this, we modify a temporary variable instead of the output, then write to the final output once at the end of the shader.

Partially addresses #84526.
Forward port of #84529.

Notes

  • Can lead to 2-4x increase in frame rate on affected hardware.
  • The problem shows most in fill rate limited circumstances, e.g. with MSAA, and where frag_color is read / modified more than once.
  • Should work with custom shaders as they write to e.g. ALBEDO rather than frag_color directly.
  • No changes needed for 2D as far as I can see.
  • See Write / reading frag_color multiple times in shader seems to cause performance problem #84526 (comment) for tests on different hardware.
  • Although I've only measured increases in performance through scene.glsl, I've included the fix for other potentially affected shaders, as there is no evidence of a drop in performance and potential for gain, especially if these shaders are later modified.
  • I've only included changes for GLES, as I'm not familiar with Vulkan.

Some hardware exhibits a slowdown when shaders modify the frag_color output multiple times. In order to prevent this, we modify a temporary variable instead of the output, then write to the final output once at the end of the shader.
@lawnjelly lawnjelly added this to the 4.x milestone Nov 10, 2023
@lawnjelly lawnjelly requested a review from a team as a code owner November 10, 2023 08:07
@akien-mga akien-mga changed the title [GLES3] - Use temporary frag_color [GLES3] Use temporary frag_color Nov 10, 2023
@akien-mga akien-mga changed the title [GLES3] Use temporary frag_color [GLES3] Use temporary frag_color Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant