sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.69k stars 641 forks source link

ShaderReflection: cant get ConstantBuffers #1006

Closed montify closed 6 years ago

montify commented 6 years ago

Hello Guys, i cant receive ConstantBuffer information, i do it like

CompilationResult vertexShaderByteCode = ShaderBytecode.CompileFromFile(path, "VSMain", "vs_5_0", ShaderFlags.Debug);

            ShaderReflection shaderReflection = new ShaderReflection(vertexShaderByteCode);

            Console.WriteLine(shaderReflection.Description.ConstantBuffers);

the VertexShader look like:

cbuffer cbPerObject
{
    float4x4 WVP;
};

struct VSInput
{
    float3 Pos : POSITION;
    float4 Color : COLOR;
};
struct VSOutput
{
    float4 Pos : SV_Position;
    float4 Color: COLOR;
};

VSOutput VSMain(VSInput In)
{
    VSOutput Out;

    Out.Pos = float4(In.Pos.x, In.Pos.y, In.Pos.z, 1);
    Out.Color = In.Color;

    return Out;
}

but the result of shaderReflection.Description.ConstantBuffers is 0...

montify commented 6 years ago

Argh, for everyone who have the same issue: Please note that is a Constant Buffer is not used, it will be stripped off the bytecode.