Sign in to follow this  

Why won't this D3D11 Shader code work?

This topic is 1794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This code is throwing an exception (D3D invalid parameter) on the last line of the function and I'm not sure why.  It seems to be consistent with what is shown in the SlimDX SimpleTriangle tutorial:

 

public void InitShaders(ShaderBytecode vShader, ShaderBytecode pShader)
        {
            this.vShader = new VertexShader(this.Device, vShader);
            this.pShader = new PixelShader(this.Device, pShader);

            InputElement[] inputElements = 
            { 
                new InputElement("POSITION", 0, Format.R32G32B32_Float, 0), 
                new InputElement("TEXCOORD", 0, Format.R32G32_Float,0),
                new InputElement("NORMAL", 0, Format.R32G32B32_Float, 0) 
            };

            this.Context.InputAssembler.InputLayout = new InputLayout(this.Device, ShaderSignature.GetInputSignature(vShader), inputElements);
        }

 

Any ideas?

Share this post


Link to post
Share on other sites

The most likely explanation is that your vertex shader's input signature requires an input element that isn't specified in the array of InputElement's that you're passing to the InputLayout constructor. If you could post your vertex shader code I could tell you for sure, or you could also check the debugger output stream for the detailed error message.

Edited by MJP

Share this post


Link to post
Share on other sites

The most likely explanation is that your vertex shader's input signature requires an input element that isn't specified in the array of InputElement's that you're passing to the InputLayout constructor. If you could post your vertex shader code I could tell you for sure, or you could also check the debugger output stream for the detailed error message.

Also isn't the Input element for the vertex supposed to have an offset to where each elements are. It seems like in his code above all the input offset are pointing to 0.

Share this post


Link to post
Share on other sites

The most likely explanation is that your vertex shader's input signature requires an input element that isn't specified in the array of InputElement's that you're passing to the InputLayout constructor. If you could post your vertex shader code I could tell you for sure, or you could also check the debugger output stream for the detailed error message.

Also isn't the Input element for the vertex supposed to have an offset to where each elements are. It seems like in his code above all the input offset are pointing to 0.


Well for the native D3D11_INPUT_ELEMENT_DESC structure you do need to either specify either the byte offset or D3D11_APPEND_ALIGNED_ELEMENT to indicate that the element is located immediately after the previous element in the stream. However the constructor he's using for the SlimDX InputElement struct doesn't take a byte offset parameter, so I would assume that internally it's setting it to D3D11_APPEND_ALIGNED_ELEMENT. However I'm not a SlimDX expert, so I'm not sure if that's the actual behavior.

Edited by MJP

Share this post


Link to post
Share on other sites

This topic is 1794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this