Author Topic: Texture buffer object?  (Read 4998 times)

0 Members and 1 Guest are viewing this topic.

Groove

  • Soldier
  • **
  • Posts: 51
    • http://www.g-truc.net
Texture buffer object?
« on: November 26, 2007, 11:04:01 PM »
I tryed to use the texture buffer object extension but unsuccessfully...

It seams to be a great opportunity for massing instancing. Even if a uniform array could be large it remains limited but I also very interested on efficiency between texture buffer object and uniform buffer.

Have you succesfully used this extension? The specification for this extension isn't an example of good one to me. Part of this feature is defined in GL_EXT_gpu_shader4... I can't feature out any reason.

What I currently have is something like that:
In my vertex shader:
#extension GL_EXT_texture_buffer_object : enable
...
uniform samplerBuffer SamplerBuffer;
...
vec4 Displacement = texelFetchBuffer(SamplerBuffer, gl_InstanceID);

Compiled just fine.

In the C++ side I have :
float InstancePosition[InstanceMax];
...
glActiveTexture(GL_TEXTURE0 + 1);
glGenBuffers(1, &TextureBufferObject);
glBindBuffer(GL_TEXTURE_BUFFER_EXT, TextureBufferObject);
glBufferData(GL_TEXTURE_BUFFER_EXT, sizeof(InstancePosition), InstancePosition, GL_STATIC_DRAW);

glGenTextures(1, &_TextureBufferInstances);
glBindTexture(GL_TEXTURE_BUFFER_EXT, TextureBufferInstances);
glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA, TextureBufferObject);

And finally my draw call function is:
glDrawArraysInstancedEXT(GL_TRIANGLES, 0, 6, InstanceMax);

(I just saw thank to an error that I have a warning: (6) : warning C7508: extension GL_EXT_texture_buffer_object not supported. I tryed it on both vertex and fragment shader and I have the same warning...)

Groove

  • Soldier
  • **
  • Posts: 51
    • http://www.g-truc.net
Re: Texture buffer object?
« Reply #1 on: November 26, 2007, 11:27:51 PM »
glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, TextureBufferObject);

That's it...

JeGX

  • Global Moderator
  • Capo Crimine
  • *****
  • Posts: 2357
    • oZone3D.Net
Re: Texture buffer object?
« Reply #2 on: November 27, 2007, 09:18:19 AM »
Not got it, works or does not work ?

Texture Buffer Object IS the solution for massive geometry instancing but the lack of SERIOUS documentation and sample from NVIDIA prevents to use them easily. Regular geometry instancing is limited by the size of the uniform arrays: I did a test with about 500 instances with position and rotation.  500 was the max. Not tried yet the TBO. I'll do it asap.

Groove

  • Soldier
  • **
  • Posts: 51
    • http://www.g-truc.net
Re: Texture buffer object?
« Reply #3 on: November 27, 2007, 01:59:28 PM »
It works with this last code update.

I also tryed gemetry shader (other way for instancing, mostly for particle I guest but maybe not exclusively) but I still haven't get something working... No OpenGL error, shaders compilation are just fine but nothing on the screen XD. I still have thing to understand on the API I guest.

I haven't performance test on instancing with uniform array vs TBO, I'm not sure which one will be the more efficient. I think for a large number of instances a good idea would be the use of bindable uniforms. With create first several buffer objects and then we for on them and performe a instanced draw call for each buffer object. The size of bindable uniforms is quiet limited (65536 bytes) but their number isn't. Actually I thing it depend of the texture look up latency on TBO.

Well, it's time to test all these stuffs. When I see all those good features and some other like texture array, I rely feel like the whole geometry shader stuff is really usefull for advertisment stuff but the good feature are behong this.