2

currently I am writing a compute shader, which implements marching cubes. But I am still struggeling about some questions about how to get the triangle information or some other dynamic data out of the compute shader.

In my opinion there are two ways:

  1. Create a big enough SSBO (I think, now it is also possible to create one with dynamic size, but I am unsure about that) and use an atomic counter within the shader to write my data into the buffer. But I think, that this is very inefficient because of the atomic counter.
  2. Do the marching cubes stuff in several steps. At first, get the case and save the number of triangles in a texture or some other buffer. Then. use the prefix sum to get the number of triangles. Create a buffer accordingly to that sum and let each shader write its triangle information into the buffer.

I know that the two ways are not described in detail, but it should be enough to understand the idea. My question is now: Are there other good possibilities to get the information out of the compute shader, which I do not know?

DanceIgel
  • 714
  • 8
  • 25
  • SSBOs were created for this purpose, unless you're running into size limitations (16 MiB is the minimum required SSBO size) you probably don't need to do multiple indirect invocations. There's also texture load/store, but that seems rather silly if I'm being honest. So those two options sound reasonable to me, and since I don't know enough about your dataset, the best I can tell you is _profile_ both. If you find one performs better than the other, edit your question with some details and we can help you better understand what's going on. – Andon M. Coleman Aug 12 '15 at 14:39

0 Answers0