Read back data from ssbo to cpu

Hey there, how can I read back data from an ssbo which stores a float array back to an cpu float array?

Just like you would for any other buffer object, save for the fact that you must first use a barrier to make the data visible to your read. You can map it for reading (or persistently map it from the start), or use glGetBufferSubData.

1 Like

Thanks, got it to work with glGetBufferSubData. I just didn’t know that I had to bind the buffer first.

However, I am not quite sure how to get glGetNamedBufferSubData to work. I don’t understand what the first parameter stands for. Is it the buffer ID that I get when I call glGenBuffers(); or is it the binding index which I gave the buffer in the shader? Or is it something completely different?

No, it’s the buffer name you got back when you called glCreateBuffers. If you’re using DSA-style functions, you shouldn’t be using glGen* to generate object names.

Hmm, I found the error, I was using a version of opengl that didn’t support the glGetNamedBufferSubData function.

however, I tried it now with the right function and it did work after giving it the id that I generated using glGenBuffers();

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.