<div dir="ltr">On 27 August 2013 07:56, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On 08/27/2013 07:50 AM, Paul Berry wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
On 26 August 2013 11:37, Ian Romanick <<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a><br></div><div>
<mailto:<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>>> wrote:<br>
<br>
    From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a><br></div>
    <mailto:<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.<u></u>com</a>>><div><br>
<br>
    This will allow users of piglit_draw_rect_from_arrays to function in<br>
    desktop OpenGL core profile.<br>
<br>
    Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a><br></div>
    <mailto:<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.<u></u>com</a>>><br>
    Cc: Matt Turner <<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a> <mailto:<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>>><br>
    Cc: Paul Berry <<a href="mailto:stereoytpe441@gmail.com" target="_blank">stereoytpe441@gmail.com</a><br>
    <mailto:<a href="mailto:stereoytpe441@gmail.com" target="_blank">stereoytpe441@gmail.<u></u>com</a>>><div><div><br>
    ---<br>
      tests/util/piglit-util-gl-<u></u>common.c | 53<br>
    ++++++++++++++++++++++++++++++<u></u>++++++--<br>
      1 file changed, 51 insertions(+), 2 deletions(-)<br>
<br>
    diff --git a/tests/util/piglit-util-gl-<u></u>common.c<br>
    b/tests/util/piglit-util-gl-<u></u>common.c<br>
    index d95eeac..79edd76 100644<br>
    --- a/tests/util/piglit-util-gl-<u></u>common.c<br>
    +++ b/tests/util/piglit-util-gl-<u></u>common.c<br>
    @@ -24,6 +24,7 @@<br>
      #include "piglit-util-gl-common.h"<br>
      #include <ctype.h><br>
<br>
    +#define BUFFER_OFFSET(i) ((char *)NULL + (i))<br>
<br>
      /**<br>
       * An array of pointers to extension strings.<br>
    @@ -642,15 +643,55 @@ piglit_draw_rect_from_arrays(<u></u>const void<br>
    *verts, const void *tex,<br>
      #if defined(PIGLIT_USE_OPENGL_ES2) || defined(PIGLIT_USE_OPENGL_ES3) \<br>
             || defined(PIGLIT_USE_OPENGL)<br>
             if (!USE_FF(fixed_function_<u></u>attributes)) {<br>
    +               GLuint buf = 0;<br>
    +               GLuint old_buf = 0;<br>
    +               GLuint vao = 0;<br>
    +               GLuint old_vao = 0;<br>
    +<br>
    +               /* Vertex array objects were added in both OpenGL<br>
    3.0 and<br>
    +                * OpenGL ES 3.0.  The use of VAOs is required in<br>
    desktop<br>
    +                * OpenGL 3.1 (without GL_ARB_compatibility) and all<br>
    desktop<br>
    +                * OpenGL core profiles.  If the functionality is<br>
    supported,<br>
    +                * just use it.<br>
    +                */<br>
    +               if (piglit_get_gl_version() >= 30<br>
    +                   ||<br>
    piglit_is_extension_supported(<u></u>"GL_OES_vertex_array_object")<br>
    +                   ||<br>
    piglit_is_extension_supported(<u></u>"GL_ARB_vertex_array_object")) {<br>
    +                       glGetIntegerv(GL_VERTEX_ARRAY_<u></u>BINDING,<br>
    +                                     (GLint *) &old_vao);<br>
    +                       glGenVertexArrays(1, &vao);<br>
    +                       glBindVertexArray(vao);<br>
    +               }<br>
    +<br>
    +               glGetIntegerv(GL_ARRAY_BUFFER_<u></u>BINDING,<br>
    +                             (GLint *) &old_buf);<br>
    +               glGenBuffers(1, &buf);<br>
    +               glBindBuffer(GL_ARRAY_BUFFER, buf);<br>
    +               glBufferData(GL_ARRAY_BUFFER,<br>
    +                            (sizeof(GLfloat) * 4 * 4)<br>
    +                            + (sizeof(GLfloat) * 4 * 2),<br>
    +                       NULL,<br>
    +                       GL_STATIC_DRAW);<br>
<br>
<br>
Shouldn't we also condition this code on the presence of<br>
ARB_vertex_buffer_object?  Or has that extension been around long enough<br>
that we don't care to test systems that don't support it?<br>
</div></div></blockquote>
<br>
I guess I'm assuming that any implementation that can do shaders can also do VBOs.  Since VBOs predate shaders by several years, this is probably a reasonable assumption.  Not checking also made it easier to transparently support the ES2 case.</blockquote>

<div><br></div><div>Ah, ok.  I failed to think about the fact that this code is inside the if(!USE_FF(...)) block, and therefore won't get executed when testing really old OpenGL functionality.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    +<br>
                     if (verts) {<br>
    +                       glBufferSubData(GL_ARRAY_<u></u>BUFFER,<br>
    +                                       0,<br>
    +                                       sizeof(GLfloat) * 4 * 4,<br>
    +                                       verts);<br>
                             glVertexAttribPointer(PIGLIT_<u></u>ATTRIB_POS, 4,<br>
    GL_FLOAT,<br>
    -                                             GL_FALSE, 0, verts);<br>
    +                                             GL_FALSE, 0,<br>
    +                                             BUFFER_OFFSET(0));<br>
                             glEnableVertexAttribArray(<u></u>PIGLIT_ATTRIB_POS);<br>
                     }<br>
<br>
                     if (tex) {<br>
    +                       glBufferSubData(GL_ARRAY_<u></u>BUFFER,<br>
    +                                       sizeof(GLfloat) * 4 * 4,<br>
    +                                       sizeof(GLfloat) * 4 * 2,<br>
    +                                       tex);<br>
                             glVertexAttribPointer(PIGLIT_<u></u>ATTRIB_TEX, 2,<br>
    GL_FLOAT,<br>
    -                                             GL_FALSE, 0, tex);<br>
    +                                             GL_FALSE, 0,<br>
    +<br>
    BUFFER_OFFSET(sizeof(GLfloat) * 4 * 4));<br>
                             glEnableVertexAttribArray(<u></u>PIGLIT_ATTRIB_TEX);<br>
                     }<br>
<br>
    @@ -660,6 +701,14 @@ piglit_draw_rect_from_arrays(<u></u>const void *verts,<br>
    const void *tex,<br>
                             glDisableVertexAttribArray(<u></u>PIGLIT_ATTRIB_POS);<br>
                     if (tex)<br>
                             glDisableVertexAttribArray(<u></u>PIGLIT_ATTRIB_TEX);<br>
    +<br>
    +               glBindBuffer(GL_ARRAY_BUFFER, old_buf);<br>
    +               glDeleteBuffers(1, &buf);<br>
    +<br>
    +               if (vao != 0) {<br>
    +                       glBindVertexArray(old_vao);<br>
    +                       glDeleteVertexArrays(1, &vao);<br>
    +               }<br>
<br>
<br>
I don't think this does what you want in the case where the<br>
implementation supports vao's, but there was no vao bound before the<br>
call to piglit_draw_rect_from_arrays()<u></u>.  (What it does is: generate a<br>
vao, bind it, use it, and then leave it bound.  What I think you want<br>
is: generate a vao, bind it, use it, unbind it, and delete it).<br>
</blockquote>
<br></div></div>
No, I think it does the right thing.  If it calls glGenVertexArrays, vao will not be zero.  Right?  The if-test checks vao, not old_vao.<br></blockquote><div><br></div><div>Oops, you're right. Patch is:<br><br></div>
<div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
I think you need to do something like this instead:<br>
<br>
bool use_vaos = piglit_get_gl_version() >= 30 || ...;<br>
if (use_vaos) {<br>
    glGetIntegerv(GL_VERTEX_ARRAY_<u></u>BINDING...);<br>
    ...<br>
}<br>
<br>
...<br>
<br>
if (use_vaos) {<br>
    glBindVertexArray(old_vao);<br>
    glDeleteVertexArrays(1, &vao);<br>
}<br>
<br>
With that fixed, this patch is:<br>
<br>
Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a><br></div>
<mailto:<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.<u></u>com</a>>><div><br>
<br>
             }<br>
      #endif<br>
      }<br>
    --<br>
    1.8.1.4<br>
<br>
    ______________________________<u></u>_________________<br>
    Piglit mailing list<br></div>
    <a href="mailto:Piglit@lists.freedesktop.org" target="_blank">Piglit@lists.freedesktop.org</a> <mailto:<a href="mailto:Piglit@lists.freedesktop.org" target="_blank">Piglit@lists.<u></u>freedesktop.org</a>><br>
    <a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/piglit</a><br>
</blockquote>
<br>
</blockquote></div><br></div></div>