Search Issue Tracker
Fixed in 2022.2.X
Votes
0
Found in
2020.3
2021.2.17f1
2021.3
2022.1
2022.2
Issue ID
1416880
Regression
No
Compute Shader is not using defined constants when setting data with SetConstantBuffer
How to reproduce:
1. Open project "ComputeShaderSetConstantBuffer.zip"
2. Enter Play Mode
3. Observe the Console
For Dx11 / 12 API: Run the project as is with above instructions.
For Vullkan/Metal/OpenGL API's :
#pragma enable_cbuffer needs to be added right after #pragma kernel Execute in ComputeShaderSetConstantBufferTest.compute under \Assets directory else all tests will fail
Expected result: Console shows: "Result is 3. Should be: 3"
Actual result: Console shows: "Result is 0. Should be: 3"
Note:
- Reproducible on Windows and macOS
Comments (1)
-
Ascended_Fern
Oct 23, 2022 16:40
Any chance of seeing this fix in 2021LTS ?
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Model and Prefab Preview icons are not updated after upgrading associated Materials to URP
- Game view is rendered white when viewing the Editor with HDR display and Post Proccesing is enabled on the Main Camera with 2D URP
- "GetPreferedValue" returns max value when using auto-sizing
- UI Builder doesn't update the style sheet when using "Extract inline style" right-click option
- “Assertion failed on expression” errors thrown when undoing Nodes creation with keyboard shortcut
Resolution Note (fix version 2022.2):
Fixed in: 2022.2.0a14
Not all shader apis support cbuffers by default. In these apis, anything declared in a cbuffer using the macro will actually be declared at global scope in a special named cbuffer (e.g. CGlobals, this is different per shader API). Trying to set these by buffer name fails because these platforms didn't preserve the cbuffers. You can forcibly enable cbuffers by using "#pragma enable_cbuffer" with this fix. In addition, DX11 had an issue with cbuffers of size < 16 which is now fixed. Alternatively, you can use the hlsl cbuffer syntax instead of the macros.