IssueRaiser

Performance problems I found

Btw I tested master branch 4.2.dev 6588a4a29af1621086feac0117d5d4d37af957fd which is basically from Friday. I tested Bistro and the TPS demo. Note: I couldn't "play" the Bistro demo (it always shows a grey screen), so I evaluated the rendering in the Editor. I could play the TPS demo. # Every pixel shader is using Discard (Fixed) https://github.com/godotengine/godot/pull/79865 <details> I wanted to start with this one because it was the biggest one that raised all red flags: \*\*\***YOU CANNOT USE GLSL'S DISCARD CARELESSLY.**\*\*\* Almost every pixel shader has this snippet needlesly enabled: ```cpp #ifdef USE_OPAQUE_PREPASS if (alpha < scene_data.opaque_prepass_threshold) { discard; } #endif ``` This applies even when alpha = 1. This is **very bad**. Even Alpha Blended objects have this snippet! (which makes very little sense) I spoke with Juan. He told me this is likely a bug. If he recalls correctly this feature should only be used for things like grass and foliage (which makes sense). Here's the thing. When a pixel shader uses discard (it doesn't matter if the shader never actually hits it, just its presence alone is enough): 1. Early Depth Rejection is disabled. - This negates any benefit from doing the depth pre-pass! - Desktop suffers a lot but mobile is just a no-go. Discard is very expensive for TBDRs. - Some advanced GPUs are able to avoid this by doing two Z evaluations: An early depth test before running the pixel shader, and then a late

Posted by darksylinc on Jul 24, 2023, 6:14 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

pricing (Software)

Performance problems I found

darksylincJul 24, 2023, 6:14 PM

Btw I tested master branch 4.2.dev 6588a4a29af1621086feac0117d5d4d37af957fd which is basically from Friday. I tested Bistro and the TPS demo. Note: I couldn't "play" the Bistro demo (it always shows a grey screen), so I evaluated the rendering in the Editor. I could play the TPS demo. # Every pixel shader is using Discard (Fixed) https://github.com/godotengine/godot/pull/79865 <details> I wanted to start with this one because it was the biggest one that raised all red flags: \*\*\***YOU CANNOT USE GLSL'S DISCARD CARELESSLY.**\*\*\* Almost every pixel shader has this snippet needlesly enabled: ```cpp #ifdef USE_OPAQUE_PREPASS if (alpha < scene_data.opaque_prepass_threshold) { discard; } #endif ``` This applies even when alpha = 1. This is **very bad**. Even Alpha Blended objects have this snippet! (which makes very little sense) I spoke with Juan. He told me this is likely a bug. If he recalls correctly this feature should only be used for things like grass and foliage (which makes sense). Here's the thing. When a pixel shader uses discard (it doesn't matter if the shader never actually hits it, just its presence alone is enough): 1. Early Depth Rejection is disabled. - This negates any benefit from doing the depth pre-pass! - Desktop suffers a lot but mobile is just a no-go. Discard is very expensive for TBDRs. - Some advanced GPUs are able to avoid this by doing two Z evaluations: An early depth test before running the pixel shader, and then a late

Comments (0)

No comments yet. Start the discussion.

Comment on this issue