Jump to content

  • Log In with Google      Sign In   
  • Create Account


Clear ID3D11Buffer ?


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

#1 melak47   Members   -  Reputation: 112

Like
0Likes
Like

Posted 02 March 2012 - 02:29 AM

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?

Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 7574

Like
0Likes
Like

Posted 02 March 2012 - 04:12 AM

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

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 melak47   Members   -  Reputation: 112

Like
0Likes
Like

Posted 02 March 2012 - 04:29 AM

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!




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