qt - Potential problems using OpenGL buffer object with multiple targets? -


i developing library qt extends it's opengl functionality support modern opengl (3+) features texture buffers, image load-store textures, shader storage buffers, atomic counter buffers, etc.. in order support features transform feedback, allow users bind buffer object different targets @ different times (regardless of data allocated buffer with). consider following scenario use transform feedback advance vertex data once, , bind separate program rendering (used rest of application run time) :

// attach (previously allocated) buffer transform feedback target  // can capture data advanced in shader program.  glbindbuffer(gl_transform_feedback_buffer, somebufferid);  // execute shader program...  // , release buffer transform feedback target. glbindbuffer(gl_transform_feedback_buffer, 0);  // then, bind same buffer containing data advanced via transform feedback  // array buffer target use in separate shader program. glbindbuffer(gl_array_buffer, somebufferid);  // then, render using buffer data source vertex attrib.  // after, release buffer array buffer target. glbindbuffer(gl_array_buffer, 0); 

in scenario, being able bind buffer object multiple targets useful. however, uncertain if there situations in capability cause problems given opengl specification. essentially, should allow single buffer object bound multiple targets or force target (like standard qt buffer wrappers) during instantiation?

edit: have found there problem mixing creation/binding targets texture objects opengl documentation glbindtexture states:

gl_invalid_operation generated if texture created target doesn't match of target.

however, documentation glbindbuffer states no such problem.

well, there can faulty drivers (and if don't have "green" hardware nothing can guaranteed, anyway). rest assured legal bind buffers target want, disregarding target created with.

there might subtleties, targets need used in indexed way using glbindbufferrange/base (like uniform buffers or transform feedback buffers). enforcing buffer used single target only, qt does, rigid useful in modern opengl, common example shows. maybe compromise use either per-class (like qt does) or per-buffer default target (which sufficient in simple situations, when buffer used single target, , can used class-internal binding operations if neccessary), provide option bind else.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -