Jump to content

  • Log In with Google      Sign In   
  • Create Account


Why won't this D3D11 Shader code work?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 jdub   Members   -  Reputation: 415

Like
0Likes
Like

Posted 17 February 2013 - 04:12 PM

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?


J.W.

Sponsor:

#2 MJP   Moderators   -  Reputation: 10223

Like
1Likes
Like

Posted 17 February 2013 - 04:31 PM

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, 17 February 2013 - 04:31 PM.


#3 BornToCode   Members   -  Reputation: 900

Like
0Likes
Like

Posted 17 February 2013 - 05:30 PM

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.



#4 MJP   Moderators   -  Reputation: 10223

Like
1Likes
Like

Posted 17 February 2013 - 07:37 PM

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, 17 February 2013 - 07:38 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS