OpenGL 8800 Texture Buffer Object Extension

Recommended Posts

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

Share on other sites
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.

Share on other sites
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!

Create an account

Register a new account

• Partner Spotlight

• Forum Statistics

• Total Topics
627674
• Total Posts
2978558
• Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 11
• 11
• 10
• 12
• 22