I'm working on a GPU-side particle system in DirectX 11 where the vertex shader uses a vector field encoded into the color channels of a texture to modify the positions of the vertices before drawing them to the screen.

I'm trying to keep the computations on the GPU rather than calculating the updated particle positions on the CPU and send the new vertex data to the GPU every frame, so I've been investigating the possibility of having the vertex shader overwrite the vertex buffer in VRAM with the updated vertex positions each frame. So far, I haven't managed to find anything on the topic.

Would this be possible, and if so, how would I accomplish it?


1 Answer 1


Vertex shaders can't generally do that. They transform geometry, but do not write it back into the source buffers or into buffers at all (that you can access, at least).

You probably want to have a look a geometry shaders and the stream-output stage.

This way you can create a buffer for your data using the stream output bind flag, write yourself a geometry shader that does essentially what you were trying to do in a vertex shader (updates positions, dumps them to the buffer you created above). You can feed that buffer back into the start of the pipeline (input assembly) or later (you can read the buffer from shader code).

  • \$\begingroup\$ stream output is not the easiest way, with dx11, a compute shader have read write capabities over vram, it is way easier to perform your update and write a vertex buffer from it. \$\endgroup\$
    – galop1n
    Commented Jul 22, 2016 at 18:08
  • \$\begingroup\$ @galop1n That's a good point, you should turn that into an answer. \$\endgroup\$
    – user1430
    Commented Jul 22, 2016 at 18:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .