Skip to content

Add NDEBUG & disable some DXIL optimizations.#23

Merged
bruvzg merged 1 commit intogodotengine:masterfrom
blueskythlikesclouds:ndebug-and-no-dxil-opt
Nov 3, 2025
Merged

Add NDEBUG & disable some DXIL optimizations.#23
bruvzg merged 1 commit intogodotengine:masterfrom
blueskythlikesclouds:ndebug-and-no-dxil-opt

Conversation

@blueskythlikesclouds
Copy link
Contributor

Without NDEBUG, the compiled binaries include all assertions and NIR validation passes, which significantly slow down the conversion process.

We can also remove the optimizations applied during the SPIR-V -> NIR pass to save even more time, with barely any impact on the DXIL output.

With both of these changes, conversion times decrease by 2x - 2.5x depending on the project. For example, in the TPS Demo, with both Godot and driver shader caches cleared, the loading time drops from 82 seconds to 33 seconds on my system. For reference, Vulkan is 15 seconds.

Note: Since the validation passes are going to be compiled out, the explicit call to nir_validate_shader needs to be removed in Godot. I'll do that in this PR.

@akien-mga akien-mga requested a review from bruvzg October 31, 2025 13:30
@clayjohn
Copy link
Member

clayjohn commented Oct 31, 2025

Are we sure we want to eliminate dead code elimination and constant folding? I know the driver will do those at pipeline compilation time. But we have seen a lot of drivers handle them quite poorly. In fact, we are adding re-spirv in Godot to do both those optimizations on SPIRV to save the drivers from having to do them at pipeline compilation time

edit actually, I just answered myself. We might be able to run re-spirv in D3D12 too before the NIR step which might actually help reduce the cost of the NIR translation step further and avoid us relying on these optimizations

@blueskythlikesclouds
Copy link
Contributor Author

blueskythlikesclouds commented Oct 31, 2025

I only disabled the optimizations done during the SPIR-V -> NIR step. There is still an optimization pass done inside NIR -> DXIL. Like I mention in the main post, the output DXIL is barely different. It just adds some redundant control flow (like jumping to a jump) that the driver compiler should easily be able to optimize out.

@clayjohn
Copy link
Member

I only disabled the optimizations done during the SPIR-V -> NIR step. There is still an optimization pass done inside NIR -> DXIL. Like I mention in the main post, the output DXIL is barely different. It just adds some redundant control flow (like jumping to a jump) that the driver compiler should easily be able to optimize out.

Oh, good to know. Its strange that they would be doing redundant optimizations, but maybe it catches some edge cases in more complex shaders. At any rate, it would be worth exploring doing a re-spirv pass before NIR to see if we can trim down the cost of the SPIRV->DXIL conversion even more as a follow up. I can ask Dario to do that after he is back from vacation

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Content wise the changes look good from my end. I will leave it up to Bruvzg to make the final call on merging

@bruvzg
Copy link
Member

bruvzg commented Oct 31, 2025

I have updated CI config so it should work now, please rebase PR to make sure all CI builds are running fine.

@blueskythlikesclouds
Copy link
Contributor Author

The MSVC artifacts seem to be missing the bin folders?

@bruvzg
Copy link
Member

bruvzg commented Oct 31, 2025

It seems to be not building with MSVC at all (there's GCC in the logs), so likely something with never MSVC detection, I'll check it tomorrow.

@bruvzg
Copy link
Member

bruvzg commented Nov 1, 2025

I'll check it tomorrow.

MSVC detection should be fixed now (#25), artifacts have correct libs.

@bruvzg bruvzg merged commit 7719abc into godotengine:master Nov 3, 2025
9 checks passed
akien-mga added a commit to godotengine/godot-build-scripts that referenced this pull request Nov 3, 2025
akien-mga added a commit to godotengine/godot-build-scripts that referenced this pull request Nov 4, 2025
akien-mga added a commit to godotengine/godot-build-scripts that referenced this pull request Jan 9, 2026
@blueskythlikesclouds blueskythlikesclouds deleted the ndebug-and-no-dxil-opt branch January 15, 2026 09:15
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.

3 participants