Jump to content
  • Advertisement
Sign in to follow this  
Quat

Screen Quad VertexID trick

This topic is 2633 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 am working on my deferred renderer implementation and was writing a "ScreenQuad" class. I was hardcoding the vertex format to position and tex-coords. If I needed extra data per vertex, I was going to use the vertex ID to index the data in the constant buffers. But then I remembered reading some trick where you index the entire vertex data from the constant buffers using the vertex ID. This would mean I wouldn't even need a "ScreenQuad" class.

So how does that work: Bind null vertex/index buffers, but still draw 6 vertices (3 per triangle), then use vertex ID to index constant buffer data that defines the vertex data?

Although for drawing a quad it doesn't matter, but is one way faster than the other (indexing cbuffers or binding quad VB/IB/Input layout)?

Share this post


Link to post
Share on other sites
Advertisement
Nevermind, I found this thread:

http://www.gamedev.net/topic/609917-full-screen-quad-without-vertex-buffer/

Share this post


Link to post
Share on other sites
The rendering of the particle system in the Hieroglyph 3 ParticleStorm demo uses this technique - except that it gets the data from a shader resource view instead of a constant buffer. The way you described it is correct though - you basically unbind the vertex / index buffers, bind an empty input layout, and then perform an appropriate draw call for the number of vertices that you want to render. Then in the vertex shader, you declare the SV_VertexID attribute as an input, and then gather the needed data to assemble your desired output vertex.

As far as using it for a screen sized quad, I would test it out both ways to see if one or the other is faster...

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!