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

Add hint in tutorials that unused cbuffers in shaders are not reflected (i.e. GetStaticVariableByName,.. does not work) #129

Open
simsevi opened this issue Jan 22, 2024 · 1 comment

Comments

@simsevi
Copy link

simsevi commented Jan 22, 2024

One possible reason for this issue is that the HLSL compiler may optimize away unused cbuffer declarations, causing the shader reflection to overlook these buffers. As a result, when calling GetStaticVariableBy..., it returns a nullptr, and invoking ->Set subsequently triggers an exception.
This is probably common knowledge for some but it might be helpful :)
I am not sure if the same is true for other variable types.

@TheMostDiligent
Copy link
Contributor

Same is true for any shader resource - if you declare it but not use, the compiler will optimize it out as if it was not declared.

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

No branches or pull requests

2 participants