Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shaders, buffers and layouts


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
5 replies to this topic

#1 Nanook   Members   -  Reputation: 473

Like
0Likes
Like

Posted 03 March 2012 - 02:39 PM

I'm new with shaders so this might be a wierd question, but does it make sense to make it possible to use the same shader with different buffers and even with differen buffer layouts?

Sponsor:

#2 MJP   Moderators   -  Reputation: 10535

Like
0Likes
Like

Posted 03 March 2012 - 05:08 PM

By "buffer" do you mean vertex buffer? If so then the answer is "yes" for most cases, but the specifics will depend on which API you're using.

#3 Nanook   Members   -  Reputation: 473

Like
0Likes
Like

Posted 03 March 2012 - 06:43 PM

Yes the vertex buffer.. I'm writing a cross API renderer so need to consider both..

#4 Nanook   Members   -  Reputation: 473

Like
0Likes
Like

Posted 03 March 2012 - 08:18 PM

I'm reading on the dx docs.. shouldn't the buffer layout always match the shader input?

#5 Nanook   Members   -  Reputation: 473

Like
0Likes
Like

Posted 03 March 2012 - 08:20 PM

Didn't it use to be a edit button here?

If I want to change the layout of a shader, would I need to keep the compiled ID3D10Blob around? Or is there another way than the CreateInputLayout function on device to change the layout?

#6 MJP   Moderators   -  Reputation: 10535

Like
0Likes
Like

Posted 03 March 2012 - 08:28 PM

In D3D10/D3D11 you're okay as long as the vertex buffer has at least the elements required by the vertex shader, and you always use an input layout created for vertex layout/vertex shader input signature combination. If the vertex buffer doesn't have an element required by the vertex shader, then creating the input layout will fail. So in other words it's okay for a vertex buffer to have too many elements, but not for it to have not enough elements. In D3D9 if you don't have enough elements in your vertex buffer the runtime will just supply 0's for those values, however if you have the debug runtimes enabled it will spew warnings about it.

I'm not sure how it works in OpenGL, so I can't comment on that.




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