Closed satoshiSchubert closed 8 months ago
Yeah, if you want to share struct definitions in both c++ and slang code, you have to make sure you respect the layout rules of hlsl/slang. See here: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules
When testing the
SceneDebuggerPass
, I found that changing the order of variables in the structSceneDebuggerParams
inSource\RenderPasses\SceneDebugger\SharedTypes.slang
can cause rendering errors, later I discovered that some variables inSceneDebuggerParams
were not being assigned correctly. Upon further examination, under certain variable arrangement orders, inShaderVar var = mpDebugPass->getRootVar()["CB"]["gSceneDebugger"]
, there is a mismatch in dataSize betweenmByteSize
and actual size ofSceneDebuggerParams
(specifically,mByteSize
was 4 bytes larger than the actual size), which caused an error when callingvar["params"].setBlob(mParams)
. Here is an example:correct case:
};
debug info:
and it will cause:
which resulted in assignment errors.
the followings are scripts mentioned above:
Falcor version: 7.0 Win11 VS2022 CPU: i5 12400F GPU: RTX4060 Ti Driver Version: 532.03
CUDA Version: 12.1