ChuckFork / slimdx

Automatically exported from code.google.com/p/slimdx
MIT License
0 stars 0 forks source link

Unable to create InputLayout from valid ShaderBytecode #645

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
All of this is taken from a post I made on GameDev a while back:
http://www.gamedev.net/community/forums/topic.asp?topic_id=564300

I seem unable to create an InputLayout using the
ShaderSignature.GetInputSignature(...) method, when the bytecode comes from
the ShaderBytecode.CompileFromFile(...) method.

I've tried this with numerous shaders, and it's the same everytime. The
shader used below is the simplest example I have available.

Note that using Effect.GetTechnique(0).GetPass(0).Description.Signature
when compiling with the effect framework allows me to create an InputLayout.

The following code causes this error:
D3D11: ERROR: ID3D11Device::CreateInputLayout: Encoded Signature size
doesn't match specified size. [ STATE_CREATION ERROR #161:
CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE ]

D3D11.InputElement[] inputElements = new SlimDX.Direct3D11.InputElement[]
                        {
                                new
D3D11.InputElement("POSITION",0,DXGI.Format.R32G32B32A32_Float,0,0),
                                new
D3D11.InputElement("COLOR",0,DXGI.Format.R8G8B8A8_UNorm,16,0)
                        };

string errors;
using (D3D11.ShaderBytecode vsShaderByte =
D3D11.ShaderBytecode.CompileFromFile("MiniTri.fx", "VS", "vs_4_0",
SlimDX.Direct3D11.ShaderFlags.None, SlimDX.Direct3D11.EffectFlags.None,
null, null, out errors))
{
    VertexShader = new SlimDX.Direct3D11.VertexShader(Device, vsShaderByte);
    D3D11.ShaderSignature s =
D3D11.ShaderSignature.GetInputSignature(vsShaderByte);
    Layout = new D3D11.InputLayout(Device, s, inputElements);
}

The shader in question:
struct VS_IN
{
    float4 pos : POSITION;
    float4 col : COLOR;
};

struct PS_IN
{
    float4 pos : SV_POSITION;
    float4 col : COLOR;
};

PS_IN VS( VS_IN input )
{
    PS_IN output = (PS_IN)0;

    output.pos = input.pos;
    output.col = input.col;

    return output;
}

float4 PS( PS_IN input ) : SV_Target
{
    return input.col;
}

technique10 Render
{
    pass P0
    {
        SetGeometryShader( 0 );
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
    }
}

Original issue reported on code.google.com by adtenn...@gmail.com on 1 Apr 2010 at 3:46

GoogleCodeExporter commented 9 years ago
I'm going to add a constructor overload to take a full shaderbytecode. The
documentation makes it sounds like it wants the whole thing.

Original comment by Mike.Popoloski on 2 Apr 2010 at 7:28

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1490.

Original comment by Mike.Popoloski on 2 Apr 2010 at 7:31