8800 Texture Buffer Object Extension

Started by
1 comment, last by TimothyFarrar 16 years, 11 months ago
Anyone know of any examples of EXT_texture_buffer_object usage on the new NVidia 8 series cards? The online spec is good (link below), but I have yet to find a working example, http://developer.download.nvidia.com/opengl/specs/GL_EXT_texture_buffer_object.txt I am trying to use a texture buffer object to do an indexed read-back from a VBO that was written to using transform feedback from a geometry shader. I've managed to get the transform feedback and geometry shader working, however I haven't been able to get the texture buffer object to work. I have included some simplified details from the program, I'm guessing that I am missing something in the setup of the texture (tbo, in the example below), that is to be used as a texture buffer object, or something is wrong in my setup of GL_TEXTURE0 before I start drawing. Anyone have any ideas? // SETUP OF TEXTURE AND VBO glGenTextures(1,&tbo); glGenBuffers(1,&vbo); glBindBuffer(GL_ARRAY_BUFFER,vbo); glBufferData(GL_ARRAY_BUFFER,size,NULL,GL_DYNAMIC_DRAW); // glTransformFeedbackVaryingsNV(... GL_SEPARATE_ATTRIBS_NV) // WAS USED TO SETUP NON-INTERLEAVED VBO OUTPUT FROM TRANSFORM FEEDBACK // THEN LAYER, VBO IS WRITTEN TO AFTER THE FOLLOWING, glBindBufferBaseNV(GL_TRANSFORM_FEEDBACK_BUFFER_NV,0,vbo); glEnable(GL_RASTERIZER_DISCARD_NV); glBeginTransformFeedbackNV(GL_POINTS); glDrawArrays(...); // THEN LATER, WHEN DRAWING glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_BUFFER_EXT, tbo); glTexBufferEXT(GL_TEXTURE_BUFFER_EXT,GL_RGBA32F_ARB, vbo); ... glDrawArrays(...); -- // FRAGMENT PROGRAM DOES SOMETHING LIKE THE FOLLOWING // TO TRY AND READ FROM THE TEXTURE BUFFER OBJECT attribute in int tbo_index; varying out vec4 gathered_output; uniform samplerBuffer tbo; void main() { ... gathered_output = texelFetchBuffer(tbo,tbo_index); ... -- Thanks in advance for any comments or suggestions, - Timothy Farrar
_|imothy Farrar :: www.farrarfocus.com/atom
Advertisement
I think in general G80 tech is too new. How's this, I'll help you figure out GL_EXT_texture_buffer_object if you can help me with GL_EXT_draw_instanced. PM me if you interested.

Found the solution to the problem. I was "double-buffering" two VBOs. I would map then write to one VBO each frame, then in a geometry shader, do an indexed read (using the texture buffer object) from the VBO written to from the CPU on the previous frame.

To setup both VBOs I did this,

glGenBuffers(1,&vbo1);
glBindBuffer(GL_ARRAY_BUFFER,vbo1);
glBufferData(GL_ARRAY_BUFFER,size,0,GL_DYNAMIC_DRAW);
glGenBuffers(1,&vbo2);
glBindBuffer(GL_ARRAY_BUFFER,vbo2);
glBufferData(GL_ARRAY_BUFFER,size,0,GL_DYNAMIC_DRAW);

Thinking that the card would somehow allocate space for the second VBO which actually wouldn't get mapped and written to until the 2nd frame (because of the double buffering).

Turns out mapping and filling vbo2 with dummy data in the setup code fixes the problem,

glGenBuffers(1,&vbo1);
glBindBuffer(GL_ARRAY_BUFFER,vbo1);
glBufferData(GL_ARRAY_BUFFER,size,0,GL_DYNAMIC_DRAW);
glGenBuffers(1,&vbo2);
glBindBuffer(GL_ARRAY_BUFFER,vbo2);
glBufferData(GL_ARRAY_BUFFER,size,0,GL_DYNAMIC_DRAW);
float* z=(float*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
bzero(z,size);
glUnmapBuffer(GL_ARRAY_BUFFER);

I'm guessing that simply glBufferData(,,0,) without writing anything does not actually trigger allocation of the memory on the GPU. Then reading from this VBO which the driver never allocated memory for, caused the driver to put the VBO in some kind of error state in which the map and write on the second frame somehow failed.

Anyway, I hopefully someone will find some use on this follow-up post. It is truly amazing what can be done with the functionality on the 8 series cards!

_|imothy Farrar :: www.farrarfocus.com/atom

This topic is closed to new replies.

Advertisement