Sign up ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using a geometry shader to generate polygons for my voxel terrain (marching cubes). The data is output into a buffer using the method shown in the article I link to below.

Is there any way to somehow extract the vertex data from the buffer, sort of like the inverse operation of this?

struct Vertex
    float x, y, z;
    float tu, tv;

Vertex[] data = new[] // this is what I want to get

DataStream stream = new DataStream(bufferSize, true, true);
stream.Position = 0;
buffer = new Buffer(device, stream, description);
share|improve this question
To clarify, you want to get access to the generated vertex data on the CPU? – Nathan Reed Jul 16 '12 at 16:51
Yes, because I want to extract the positions so that I can generate a collision mesh. – Boreal Jul 16 '12 at 17:35

1 Answer 1

up vote 1 down vote accepted

You should be able to get CPU access to the data by using MapSubresource on the buffer (don't forget to unmap it when you're done). Be aware that this will cause a CPU/GPU sync, though: the CPU has to sit and wait for the GPU to finish all previous rendering before it can access the data. This is bad for performance if you're trying to do stuff in real-time.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.