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

DCE shouldn't remove unused descriptors #827

Closed
expenses opened this issue Dec 15, 2021 · 5 comments · Fixed by #830
Closed

DCE shouldn't remove unused descriptors #827

expenses opened this issue Dec 15, 2021 · 5 comments · Fixed by #830
Labels
t: bug Something isn't working

Comments

@expenses
Copy link
Contributor

expenses commented Dec 15, 2021

I'm performing reflection on generated SPIR-V modules to create descriptor set layouts. Unfortunately, this is a little fiddly, because whenever I comment out some code to debug something, if it means that a descriptor is no longer used, this descriptor will not be output in the final module and the generated descriptor set layouts will be wrong.

In my opinion, this sort of Dead Code Elimination should not be performed, especially with SpirvMetadata::NameVariables or NameVariables::Full. Given that SpirvMetadata::NameVariables has the comment 'Only include OpNames for public interface variables (uniforms and the like), to allow shader reflection.', I think we can say that this DCE is unwanted behaviour.

@expenses expenses added the t: bug Something isn't working label Dec 15, 2021
@khyperia
Copy link
Contributor

We already looked into this quite a bit in #722, and tl;dr, we cannot fix this for SPIR-V versions <=1.3. Use >=1.4 if keeping unused entry parameters is needed.

@expenses
Copy link
Contributor Author

Oh, nice! That should probably be documented somewhere.

@expenses
Copy link
Contributor Author

Actually the DCE still seems to happen even when building for spirv-unknown-spv1.5, at least on da7c3ed.

@khyperia
Copy link
Contributor

Ah, that would be a spirv-opt issue then, it's removing it - this doesn't include samp, but removing the spirv-opt invocation makes it appear: https://shader-playground.timjones.io/05a24c0565ef5fd9b8dc51457c8ad135

@expenses
Copy link
Contributor Author

Ah, right! Looks like spirv_tools::opt::Options::preserve_bindings should be set to true then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants