Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: can textureBufferObjects be flattened?

  1. #1
    Intern Newbie
    Join Date
    Feb 2011
    Location
    New Zealand
    Posts
    38

    can textureBufferObjects be flattened?

    I have organized the vbo data to be loaded into a textureBufferObject according to an internal indexing system... [0] is number of lights, [1] is index into first light data, [2] is index into next light data if there is a next light; index into the first light data points to position.x, index into the first light data + 1 points to position.y etc. The tbo is working fine thanks to Dark Photon http://www.opengl.org/discussion_boa...example-needed. But I find the tbo requires to be indexes as an array of vec4 (floats in my case) rather than a flat single array as the tbo specs suggest. That is, to access tbo[4] I have to use
    Code :
    float f=texelFetch(tbo, 1)[0];
    . I do not see any setting in the initialization that might flatten the tbo:

    Code :
    int size=dat.length * GL_FLOAT.sizeof;
    glGenBuffers(1, &tbo); assert(tbo>0);
    glBindBuffer(GL_TEXTURE_BUFFER, tbo);
    glBufferData(GL_TEXTURE_BUFFER, size, null, GL_STATIC_DRAW);
    glBufferSubData(GL_TEXTURE_BUFFER, 0, size, dat.ptr);
     
    glGenTextures(1, &lMap); assert(lMap > 0);
    glActiveTexture(GL_TEXTURE6);
    glBindTexture(GL_TEXTURE_BUFFER, lMap);
    glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, tbo);
    //D

    Does anyone have any thoughts on how best to proceed in the situation?

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,939
    *ahem*

    Code :
    glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, tbo);

    This format tells it that every texel is 4 floating-point values. If you want every texel to be 1 floating point value, then you need to use GL_R32F for the internal format.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    612
    As a side note, GL3-generation hardware supports 1,2 and 4 component TBOs (i.e. R, RG, RGBA) but as a rule of thumb, GL4 hardware is needed for 3-component TBO's (i.e. RGB).

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    989
    Note that no matter what format you use, you'll still get back a gvec4 from the texelFetch function, even if you use GL_R32F, but you should not care about the other components besides the first, they're just there for transparency, i.e. the shader doesn't have to actually know what format you wanted the hardware to interpret your buffer.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  5. #5
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,939
    As a side note, GL3-generation hardware supports 1,2 and 4 component TBOs (i.e. R, RG, RGBA) but as a rule of thumb, GL4 hardware is needed for 3-component TBO's (i.e. RGB).
    Only half of GL 3.x hardware doesn't support 3-component buffer textures. The NVIDIA half. This is easily testable via the ARB_texture_buffer_object_rgb32 extension.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    612
    Only half of GL 3.x hardware doesn't support 3-component buffer textures. The NVIDIA half. This is easily testable via the ARB_texture_buffer_object_rgb32 extension.
    Thanks for the heads up, I did not know that AMD's GL3 generation hardware supported ARB_texture_buffer_object_rgb32 [the test boxes I have are heavily NVIDIA biased, and the AMD box I have is GL4 generation].



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •