I want to write a little command line tool to generate C++ structs in .h files that match HLSL cbuffers.. I want to use the reflection interfaces to get the cbuffer member types and alignments and all that. Eg:
struct Cows {
int i3;
float2 f2;
};
cbuffer Foo {
float3 one;
float2 two;
Cows cows;
};
I could append some trivial shader like float4 PS() : SV_Target { return float4(0.0, 0.0, 0.0, 0.0); } and use D3DX10CompileFrom* and pass the blob to D3D10ReflectShader/D3DReflect. Unfortunately, reflection info seems only to be preserved in compiled shaders for shaders that actually reference that cbuffer. That is, ID3D10ShaderReflection::GetConstantBufferByName returns E_FAIL when I ask for "Foo" in this case. I don't know how to create a shader that references the cbuffer without first parsing the hlsl, which of course I really would rather avoid. Anyone know how to preserve the reflection info for an unreferenced cbuffer or otherwise involve with the shader in some trivial way that requires no parsing?
Thanks,
.sean