<div dir="ltr">On 26 August 2013 11:37, 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">


From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
<br>
This will be used in future commits.<br>
<br>
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>><br>
Cc: Matt Turner <<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>
---<br>
 tests/util/piglit-util-gl-common.c | 86 ++++++++++++++++++++++++--------------<br>
 tests/util/piglit-util-gl-common.h |  3 +-<br>
 2 files changed, 56 insertions(+), 33 deletions(-)<br>
<br>
diff --git a/tests/util/piglit-util-gl-common.c b/tests/util/piglit-util-gl-common.c<br>
index b5e87bf..c097d8f 100644<br>
--- a/tests/util/piglit-util-gl-common.c<br>
+++ b/tests/util/piglit-util-gl-common.c<br>
@@ -599,46 +599,68 @@ required_gl_version_from_glsl_version(unsigned glsl_version)<br>
  *   float tex[4][2];<br>
  *<br>
  * if not NULL.<br>
+ *<br>
+ * \param fixed_function_attribute  Should fixed-function attributes (e.g.,<br>
+ *                                  \c glVertexPointer) be used?  In an OpenGL<br>
+ *                                  core profile this must be \c true.  In<br>
+ *                                  OpenGL ES the value is ignored.<br>
  */<br>
 void<br>
-piglit_draw_rect_from_arrays(const void *verts, const void *tex)<br>
+piglit_draw_rect_from_arrays(const void *verts, const void *tex,<br>
+                             bool fixed_function_attributes)<br>
 {<br>
+#if defined(PIGLIT_USE_OPENGL_ES1)<br>
+#define USE_FF(x) true<br>
+#elif defined(PIGLIT_USE_OPENGL_ES2) ||  defined(PIGLIT_USE_OPENGL_ES3)<br>
+#define USE_FF(x) false<br>
+#elif defined(PIGLIT_USE_OPENGL)<br>
+#define USE_FF(x) x<br>
+#else<br>
+#error "don't know how to draw arrays"<br>
+#endif<br></blockquote><div><br></div><div>The use of defines seems weird here.  Why not just:<br><br></div><div>#if defined(PIGLIT_USE_OPENGL_ES1)<br></div><div>   const bool use_ff = true;<br></div><div>#elif defined(PIGLIT_USE_OPENGL_ES2) || defined(PIGLIT_USE_OPENGL_ES3)<br>


</div><div>   const bool use_ff = false;<br></div><div>#elif defined(PIGLIT_USE_OPENGL)<br></div><div>   const bool use_ff = fixed_function_attributes;<br></div><div>#else<br></div><div>#error "don't know how to draw arrays"<br>


</div><div>#endif<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+<br>
 #if defined(PIGLIT_USE_OPENGL_ES1) || defined(PIGLIT_USE_OPENGL)<br>
-       if (verts) {<br>
-               glVertexPointer(4, GL_FLOAT, 0, verts);<br>
-               glEnableClientState(GL_VERTEX_ARRAY);<br>
-       }<br>
+       if (USE_FF(fixed_function_attributes)) {<br>
+               if (verts) {<br>
+                       glVertexPointer(4, GL_FLOAT, 0, verts);<br>
+                       glEnableClientState(GL_VERTEX_ARRAY);<br>
+               }<br>
<br>
-       if (tex) {<br>
-               glTexCoordPointer(2, GL_FLOAT, 0, tex);<br>
-               glEnableClientState(GL_TEXTURE_COORD_ARRAY);<br>
-       }<br>
+               if (tex) {<br>
+                       glTexCoordPointer(2, GL_FLOAT, 0, tex);<br>
+                       glEnableClientState(GL_TEXTURE_COORD_ARRAY);<br>
+               }<br>
<br>
-       glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);<br>
+               glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);<br>
<br>
-       if (verts)<br>
-               glDisableClientState(GL_VERTEX_ARRAY);<br>
-       if (tex)<br>
-               glDisableClientState(GL_TEXTURE_COORD_ARRAY);<br>
-#elif defined(PIGLIT_USE_OPENGL_ES2) ||defined(PIGLIT_USE_OPENGL_ES3)<br>
-       if (verts) {<br>
-               glVertexAttribPointer(PIGLIT_ATTRIB_POS, 4, GL_FLOAT, GL_FALSE, 0, verts);<br>
-               glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);<br>
+               if (verts)<br>
+                       glDisableClientState(GL_VERTEX_ARRAY);<br>
+               if (tex)<br>
+                       glDisableClientState(GL_TEXTURE_COORD_ARRAY);<br>
        }<br>
+#endif<br>
+#if defined(PIGLIT_USE_OPENGL_ES2) || defined(PIGLIT_USE_OPENGL_ES3) \<br>
+       || defined(PIGLIT_USE_OPENGL)<br>
+       if (!USE_FF(fixed_function_attributes)) {<br>
+               if (verts) {<br>
+                       glVertexAttribPointer(PIGLIT_ATTRIB_POS, 4, GL_FLOAT,<br>
+                                             GL_FALSE, 0, verts);<br>
+                       glEnableVertexAttribArray(PIGLIT_ATTRIB_POS);<br>
+               }<br>
<br>
-       if (tex) {<br>
-               glVertexAttribPointer(PIGLIT_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, tex);<br>
-               glEnableVertexAttribArray(PIGLIT_ATTRIB_TEX);<br>
-       }<br>
+               if (tex) {<br>
+                       glVertexAttribPointer(PIGLIT_ATTRIB_TEX, 2, GL_FLOAT,<br>
+                                             GL_FALSE, 0, tex);<br>
+                       glEnableVertexAttribArray(PIGLIT_ATTRIB_TEX);<br>
+               }<br>
<br>
-       glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);<br>
+               glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);<br>
<br>
-       if (verts)<br>
-               glDisableVertexAttribArray(PIGLIT_ATTRIB_POS);<br>
-       if (tex)<br>
-               glDisableVertexAttribArray(PIGLIT_ATTRIB_TEX);<br>
-#else<br>
-#      error "don't know how to draw arrays"<br>
+               if (verts)<br>
+                       glDisableVertexAttribArray(PIGLIT_ATTRIB_POS);<br>
+               if (tex)<br>
+                       glDisableVertexAttribArray(PIGLIT_ATTRIB_TEX);<br>
+       }<br>
 #endif<br>
 }<br>
<br>
@@ -667,7 +689,7 @@ piglit_draw_rect(float x, float y, float w, float h)<br>
        verts[3][2] = 0.0;<br>
        verts[3][3] = 1.0;<br>
<br>
-       piglit_draw_rect_from_arrays(verts, NULL);<br>
+       piglit_draw_rect_from_arrays(verts, NULL, true);<br>
 }<br>
<br>
 /**<br>
@@ -695,7 +717,7 @@ piglit_draw_rect_z(float z, float x, float y, float w, float h)<br>
        verts[3][2] = z;<br>
        verts[3][3] = 1.0;<br>
<br>
-       piglit_draw_rect_from_arrays(verts, NULL);<br>
+       piglit_draw_rect_from_arrays(verts, NULL, true);<br>
 }<br>
<br>
 /**<br>
@@ -734,5 +756,5 @@ piglit_draw_rect_tex(float x, float y, float w, float h,<br>
        tex[3][0] = tx + tw;<br>
        tex[3][1] = ty + th;<br>
<br>
-       piglit_draw_rect_from_arrays(verts, tex);<br>
+       piglit_draw_rect_from_arrays(verts, tex, true);<br>
 }<br>
diff --git a/tests/util/piglit-util-gl-common.h b/tests/util/piglit-util-gl-common.h<br>
index ef87514..44e46ac 100644<br>
--- a/tests/util/piglit-util-gl-common.h<br>
+++ b/tests/util/piglit-util-gl-common.h<br>
@@ -162,7 +162,8 @@ GLvoid piglit_draw_rect_z(float z, float x, float y, float w, float h);<br>
 GLvoid piglit_draw_rect_tex(float x, float y, float w, float h,<br>
                             float tx, float ty, float tw, float th);<br>
 GLvoid piglit_draw_rect_back(float x, float y, float w, float h);<br>
-void piglit_draw_rect_from_arrays(const void *verts, const void *tex);<br>
+void piglit_draw_rect_from_arrays(const void *verts, const void *tex,<br>
+                                  bool fixed_function_attributes);<br>
<br>
 unsigned short piglit_half_from_float(float val);<br>
<span><font color="#888888"><br>
--<br>
1.8.1.4<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org" target="_blank">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>