This is undesirable in my use case. I'm making a tool for use with the Unity game engine, which in general doesn't support cbuffer's containing struct variables. I was planning to just work around this (I'm already doing some further analysis/cleanup of the output HLSL), but then I stumbled across this special case, which prevents this behavior https://github.com/shader-slang/slang/blob/8362c2d46e2da0c20fbd3daf511ccdf425f9a1f0/source/slang/slang-emit-hlsl.cpp#L224-L231 If one of the cbuffer members has a packoffset() modifier, you unpack the ParameterGroup struct. Since the logic to do this already exists in the compiler, I figured I'd ask whether this could be be put behind a flag, something like -hlsl-force-unpack-cbuffer-structs?
If you are willing to accept something like that, I could try making a PR to do it. If not, I'll find some workaround.
If you compile a program using a cbuffer with the HLSL target:
You get output like this, with the cbuffer containing a struct variable.
This is undesirable in my use case. I'm making a tool for use with the Unity game engine, which in general doesn't support cbuffer's containing struct variables. I was planning to just work around this (I'm already doing some further analysis/cleanup of the output HLSL), but then I stumbled across this special case, which prevents this behavior https://github.com/shader-slang/slang/blob/8362c2d46e2da0c20fbd3daf511ccdf425f9a1f0/source/slang/slang-emit-hlsl.cpp#L224-L231 If one of the cbuffer members has a
packoffset()
modifier, you unpack the ParameterGroup struct. Since the logic to do this already exists in the compiler, I figured I'd ask whether this could be be put behind a flag, something like-hlsl-force-unpack-cbuffer-structs
?If you are willing to accept something like that, I could try making a PR to do it. If not, I'll find some workaround.