Jump to content
  • Advertisement
Sign in to follow this  
melak47

Clear ID3D11Buffer ?

This topic is 2481 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 using two vertex buffers in my app, one is bound to the input assembler / vertex shader, the other is bound as a streamout target to the geometry shader.

What I want to do is save the new vertices to the buffer, then flip the buffers each frame.

The problem is, the geometry shader can only append new vertices at the end, so I need some way to clear the new streamout target before each frame.

I tried to use ID3D11DeviceContext::UpdateSubresource(..) with a NULL'ed array the size of the buffer as a source, and that does clear the buffer, but no new vertices are saved to it.
Maybe the geometry shader keeps track of how many vertices it has generated in total and tries to append new vertices to the buffer after that point. (which it can't since the buffer has only room for one set of vertices)

I tried to use CopyResource(..) to copy the contents of an empty buffer to the buffer I want to clear, same result.

I even tried releasing and recreating the buffer each frame (which is incredibly inefficient), but even that does not really work.

The only time it has worked somewhat is when I create a new buffer and bind that as the SO target, without deleting the old one, so of course I run out of memory in a matter of seconds.

I'm running out of ideas here, it has to be possible to clear a generic buffer?

Share this post


Link to post
Share on other sites
Advertisement
Have a look at the documentation for SOSetTargets - this is controlled by the offset param.

Share this post


Link to post
Share on other sites

Have a look at the documentation for SOSetTargets - this is controlled by the offset param.

Doh! This whole time I've been passing a nullpointer for the offset array, thinking that would be enough.
Passing a pointer to an offset of 0 works like a charm! Thanks!

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!