Advertisement

Only AppendStructuredBuffer no ConsumeBuffer

Started by July 23, 2018 04:23 PM
4 comments, last by MJP 6 years, 6 months ago

Anybody know is it necessary to clear AppendStructuredBuffer if I don't have a consume buffer ?

What's the max size of AppendStructuredBuffer ? 

Now, my code doesn't clear the AppendStructuredBuffer, and the structured buffer i've created is very big,

I append instances in compute shader every frame, then render, the instances flick everywhere.

Personally, I never used appendstructurebuffer, but I have an idea how they work. The maximum size is the size you create your buffer with. The append part is essentially an atomic counter that is incremented on append, and the appended element is written onto the position of the buffer that the counter's previous value points to. A clear should be the operation that resets the counter to zero. So if you never clear the buffer, than you will be appending until you reach the buffer limit. After the buffer is full, the writes will be discarded I imagine.

Advertisement

 

3 minutes ago, turanszkij said:

Personally, I never used appendstructurebuffer, but I have an idea how they work. The maximum size is the size you create your buffer with. The append part is essentially an atomic counter that is incremented on append, and the appended element is written onto the position of the buffer that the counter's previous value points to. A clear should be the operation that resets the counter to zero. So if you never clear the buffer, than you will be appending until you reach the buffer limit. After the buffer is full, the writes will be discarded I imagine.

Sure, now I don't know how to clear the append buffer in dx11, lol.

Oh ! I've found that it can be done in CSSetUnorderedAccessViews  !

You're right, the last parameter of CSSetUnorderedAccessViews should set the buffer counter. Also, the same for OMSetRenderTargetsAndUnorderedAccessViews, if you want to bind the UAV to graphics shaders, like pixel shader.

The counter is 32-bits, so you will easily overflow that if you never clear it. But of course you'll be limited by the actual size of your structured buffer resource long before you hit a count of 0xFFFFFFFF, at which points writes will be discarded like turanszki already explained.

This topic is closed to new replies.

Advertisement