Results 1 to 5 of 5

Thread: VBO and compute shader

  1. #1
    Member Contributor
    Join Date
    Mar 2014
    Posts
    59

    VBO and compute shader

    hi!

    I try to access to vertex list and face index.

    glBindBufferBase(GL_ARRAY_BUFFER,10,((ModelGL*)(n->getModel()))->getVertex());
    glBindBufferBase(GL_ARRAY_BUFFER,11,((ModelGL*)(n->getModel()))->getFaces());
    and in my compute :
    layout (std430,binding = 10) readonly buffer Vbuffer
    {
    vec3 vertex[];
    };

    layout (std430,binding = 11) readonly buffer Fbuffer
    {
    face faces[];
    };
    It doesn't work.
    Any idea?

  2. #2
    Member Contributor
    Join Date
    Mar 2014
    Posts
    59
    Solution : bind vbo as GL_SHADER_STORAGE_BUFFER

    Now, i've a second problem, it seems do deal with padding.
    My vertcies are vec3 and my faces are 3 int. I try std140 and std430 without good results...

  3. #3
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674
    My vertcies are vec3 and my faces are 3 int.
    Even in std430 layout, 'vec3's use the base alignment of 'vec4's. So each array element is 4 values.

    Also, the term "VBO" (to the degree that you should use that term) only applies to a buffer object that is bound to GL_ARRAY_BUFFER. Buffers can be bound to many targets, but they're all still just buffer objects, no matter how you use them.

  4. #4
    Member Contributor
    Join Date
    Mar 2014
    Posts
    59
    To avoid thos f***ing padding issues, i tweak my acces to the VBO from
    layout (std430,binding = 10) readonly buffer Vbuffer
    {
    vec3 vertex[];
    };

    layout (std430,binding = 11) readonly buffer Fbuffer
    {
    face faces[];
    };
    to
    layout (std430,binding = 10) readonly buffer Vbuffer
    {
    float vertex[];
    };

    layout (std430,binding = 11) readonly buffer Fbuffer
    {
    int faces[];
    };
    To acces the data, the solution is simple :
    vec3 readVertex(uint index)
    {
    return vec3(vertex[3*index],vertex[3*index+1],vertex[3*index+2]);
    }

    ivec3 readFace(uint index)
    {
    return ivec3(faces[3*index],faces[3*index+1],faces[3*index+2]);
    }
    Thanks!

  5. #5
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674
    It should be noted that the vec3 alignment thing was something specifically put into the API. Probably for a good reason. Which means you probably shouldn't bypass it like this unless you have a good reason to do so. The compiler could easily turn your memory usage into 3 separate memory access operations, rather than a single one in the case of a vec3 (even padded to a vec4).

    So this could be more of a memory/performance tradeoff.

Similar Threads

  1. Replies: 3
    Last Post: 05-03-2018, 03:52 PM
  2. Compute Shader Profiler
    By __bob__ in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-16-2015, 03:26 AM
  3. Compute shader and GL_TEXTURE_2D_ARRAY
    By __bob__ in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 09-16-2014, 05:35 AM
  4. Compute shader and barrier
    By __bob__ in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-21-2014, 07:55 AM
  5. Compute shader unresponsive
    By Mustard in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-04-2013, 12:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean