Original Post
I am trying this approach to querying the ID3DBlob* that is returned from compiling a shader. I have a cbuffer that contains several native-data-type members and a struct definition with various members of type 'matrix', 'float2', and 'float[]' where the last item (in my special case) is an array of 5 numbers.
I grab an ID3DShaderReflectionBuffer pointer from GetConstantBufferByName(...), iterate over the variables (using GetVariableByIndex and GetType), finding out that the struct information has Class = D3D_SVC_STRUCT. For this item, I iterate over the members (GetMemberTypeName and GetMemberTypeByIndex).
The information I get from this approach appears not to have everything I need to know about the memory layout of the cbuffer. My struct has two 'matrix' elements, two 'float2' elements, and an array 'float[5]'. The 'matrix' elements report correct offsets relative to the parent struct (64 and 128), the two 'float2' elements appear to be packed into a single 4-float register, but each array element from the 'float[5]' is mapped to a single register (.x component, but the .yzw components are ignored). I do not believe the shader reflection interface allows me to deduce the packing of the struct. Is this a known deficiency? Or am I missing something about the query process?
If need be, I can post a link to a simple MSVS project that shows what I am doing, what my experiments are, and what information I get from those experiments.
Thanks.
I grab an ID3DShaderReflectionBuffer pointer from GetConstantBufferByName(...), iterate over the variables (using GetVariableByIndex and GetType), finding out that the struct information has Class = D3D_SVC_STRUCT. For this item, I iterate over the members (GetMemberTypeName and GetMemberTypeByIndex).
The information I get from this approach appears not to have everything I need to know about the memory layout of the cbuffer. My struct has two 'matrix' elements, two 'float2' elements, and an array 'float[5]'. The 'matrix' elements report correct offsets relative to the parent struct (64 and 128), the two 'float2' elements appear to be packed into a single 4-float register, but each array element from the 'float[5]' is mapped to a single register (.x component, but the .yzw components are ignored). I do not believe the shader reflection interface allows me to deduce the packing of the struct. Is this a known deficiency? Or am I missing something about the query process?
If need be, I can post a link to a simple MSVS project that shows what I am doing, what my experiments are, and what information I get from those experiments.
Thanks.