Jump to content
  • Advertisement
Sign in to follow this  
Nanook

Shaders, buffers and layouts

This topic is 2476 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

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
I'm reading on the dx docs.. shouldn't the buffer layout always match the shader input?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!