On 11/03/2016 06:01 PM, Ilia Mirkin wrote:
The RGB -> RGBA thing is probably because GLES is a lot pickier about
formats matching and not having to do conversion. I had to do that all
over the place when GLES-ifying piglits. Fixing this at the util level
would be nice, but I couldn't think of a reliable way to do so.

Yeah, I thought about this but when I removed the changes related to alpha this test was working just fine on gles2 so maybe there is already something enough happening at util level (?) .. TBH not sure


On Thu, Nov 3, 2016 at 3:00 AM, Tapani Pälli <[email protected]> wrote:
going from RGB ro RGBA (adding of alpha channel) seems like an unnecessary
change but harmless ...

Reviewed-by: Tapani Pälli <[email protected]>


On 10/11/2016 12:25 AM, Kevin Strasser wrote:

Add ES2 implementation to the test to provide coverage for
GL_OES_vertex_half_float extension. The tests will continue to pass on
mesa
for desktop GL as well as ES2 once supported is added.

Signed-off-by: Kevin Strasser <[email protected]>
---
 tests/all.py                             |  6 ++
 tests/general/CMakeLists.gles2.txt       |  4 ++
 tests/general/draw-vertices-half-float.c | 99
+++++++++++++++++++++++---------
 3 files changed, 82 insertions(+), 27 deletions(-)
 create mode 100644 tests/general/CMakeLists.gles2.txt

diff --git a/tests/all.py b/tests/all.py
index 2382054..7855116 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4163,6 +4163,12 @@ with profile.group_manager(
       run_concurrent=False)

 with profile.group_manager(
+        PiglitGLTest, grouptools.join('spec', 'oes_vertex_half_float'))
as g:
+    g(['draw-vertices-half-float_gles2'], run_concurrent=False)
+    g(['draw-vertices-half-float_gles2', 'user'],
'draw-vertices-half-float-user_gles2',
+      run_concurrent=False)
+
+with profile.group_manager(
         PiglitGLTest,
         grouptools.join('spec', 'arb_vertex_type_2_10_10_10_rev')) as g:
     g(['draw-vertices-2101010'], run_concurrent=False)
diff --git a/tests/general/CMakeLists.gles2.txt
b/tests/general/CMakeLists.gles2.txt
new file mode 100644
index 0000000..c3db943
--- /dev/null
+++ b/tests/general/CMakeLists.gles2.txt
@@ -0,0 +1,4 @@
+link_libraries(piglitutil_${piglit_target_api})
+
+piglit_add_executable(draw-vertices-half-float_gles2
draw-vertices-half-float.c)
+
diff --git a/tests/general/draw-vertices-half-float.c
b/tests/general/draw-vertices-half-float.c
index dfd2da8..2489c99 100644
--- a/tests/general/draw-vertices-half-float.c
+++ b/tests/general/draw-vertices-half-float.c
@@ -34,15 +34,33 @@
 PIGLIT_GL_TEST_CONFIG_BEGIN

        config.supports_gl_compat_version = 10;
+       config.supports_gl_es_version = 20;

        config.window_width = 320;
        config.window_height = 60;
-       config.window_visual = PIGLIT_GL_VISUAL_RGB |
PIGLIT_GL_VISUAL_DOUBLE;
+       config.window_visual = PIGLIT_GL_VISUAL_RGBA |
PIGLIT_GL_VISUAL_DOUBLE;

 PIGLIT_GL_TEST_CONFIG_END

 GLboolean user_va = GL_FALSE;

+static GLenum vertex_array_type;
+
+#ifndef PIGLIT_USE_OPENGL
+static const char *vs_text =
+    "attribute vec4 position;\n"
+    "uniform mat4 projection;\n"
+    "void main() { gl_Position = projection * position; }\n";
+
+static const char *fs_text =
+    "precision mediump float;\n"
+    "void main() { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); }\n";
+
+static GLuint prog;
+static GLint projection_loc;
+static GLint position_loc;
+#endif
+
 void piglit_init(int argc, char **argv)
 {
     unsigned i;
@@ -54,12 +72,27 @@ void piglit_init(int argc, char **argv)
         }
     }

+#ifdef PIGLIT_USE_OPENGL
     piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

     piglit_require_gl_version(15);
     piglit_require_extension("GL_ARB_half_float_vertex");

     glShadeModel(GL_FLAT);
+
+    vertex_array_type = GL_HALF_FLOAT_ARB;
+#else
+    piglit_require_extension("GL_OES_vertex_half_float");
+
+    prog = piglit_build_simple_program(vs_text, fs_text);
+    glUseProgram(prog);
+    position_loc = glGetAttribLocation(prog, "position");
+    projection_loc = glGetUniformLocation(prog, "projection");
+
+    piglit_ortho_uniform(projection_loc, piglit_width, piglit_height);
+
+    vertex_array_type = GL_HALF_FLOAT_OES;
+#endif
     glClearColor(0.2, 0.2, 0.2, 1.0);
 }

@@ -68,13 +101,23 @@ static GLuint vboVertexPointer(GLint size, GLenum
type, GLsizei stride,
 {
     GLuint id;
     if (user_va) {
+#ifdef PIGLIT_USE_OPENGL
         glVertexPointer(size, type, stride, (char*)buf + bufOffset);
+#else
+        glEnableVertexAttribArray(position_loc);
+        glVertexAttribPointer(position_loc, size, type, GL_FALSE, stride,
(char*)buf + bufOffset);
+#endif
         return 0;
     }
     glGenBuffers(1, &id);
     glBindBuffer(GL_ARRAY_BUFFER, id);
     glBufferData(GL_ARRAY_BUFFER, bufSize, buf, GL_STATIC_DRAW);
+#ifdef PIGLIT_USE_OPENGL
     glVertexPointer(size, type, stride, (void*)bufOffset);
+#else
+    glEnableVertexAttribArray(position_loc);
+    glVertexAttribPointer(position_loc, size, type, GL_FALSE, stride,
(void*)bufOffset);
+#endif
     return id;
 }

@@ -118,23 +161,23 @@ static void test_half_vertices_wrapped(unsigned
short x1, unsigned short y1,
     GLuint vbo;

     switch (index) {
-        case 0: vbo = vboVertexPointer(2, GL_HALF_FLOAT_ARB, 4, v2,
sizeof(v2), 0); break;
+        case 0: vbo = vboVertexPointer(2, vertex_array_type, 4, v2,
sizeof(v2), 0); break;

-        case 1: vbo = vboVertexPointer(2, GL_HALF_FLOAT_ARB, 6, v3,
sizeof(v3), 0); break;
-        case 2: vbo = vboVertexPointer(3, GL_HALF_FLOAT_ARB, 6, v3,
sizeof(v3), 0); break;
+        case 1: vbo = vboVertexPointer(2, vertex_array_type, 6, v3,
sizeof(v3), 0); break;
+        case 2: vbo = vboVertexPointer(3, vertex_array_type, 6, v3,
sizeof(v3), 0); break;

-        case 3: vbo = vboVertexPointer(2, GL_HALF_FLOAT_ARB, 8, v4,
sizeof(v4), 0); break;
-        case 4: vbo = vboVertexPointer(3, GL_HALF_FLOAT_ARB, 8, v4,
sizeof(v4), 0); break;
-        case 5: vbo = vboVertexPointer(4, GL_HALF_FLOAT_ARB, 8, v4,
sizeof(v4), 0); break;
+        case 3: vbo = vboVertexPointer(2, vertex_array_type, 8, v4,
sizeof(v4), 0); break;
+        case 4: vbo = vboVertexPointer(3, vertex_array_type, 8, v4,
sizeof(v4), 0); break;
+        case 5: vbo = vboVertexPointer(4, vertex_array_type, 8, v4,
sizeof(v4), 0); break;

-        case 6: vbo = vboVertexPointer(2, GL_HALF_FLOAT_ARB, 4, v2o,
sizeof(v2o), 2); break;
+        case 6: vbo = vboVertexPointer(2, vertex_array_type, 4, v2o,
sizeof(v2o), 2); break;

-        case 7: vbo = vboVertexPointer(2, GL_HALF_FLOAT_ARB, 6, v3o,
sizeof(v3o), 2); break;
-        case 8: vbo = vboVertexPointer(3, GL_HALF_FLOAT_ARB, 6, v3o,
sizeof(v3o), 2); break;
+        case 7: vbo = vboVertexPointer(2, vertex_array_type, 6, v3o,
sizeof(v3o), 2); break;
+        case 8: vbo = vboVertexPointer(3, vertex_array_type, 6, v3o,
sizeof(v3o), 2); break;

-        case 9: vbo = vboVertexPointer(2, GL_HALF_FLOAT_ARB, 8, v4o,
sizeof(v4o), 2); break;
-        case 10:vbo = vboVertexPointer(3, GL_HALF_FLOAT_ARB, 8, v4o,
sizeof(v4o), 2); break;
-        case 11:vbo = vboVertexPointer(4, GL_HALF_FLOAT_ARB, 8, v4o,
sizeof(v4o), 2); break;
+        case 9: vbo = vboVertexPointer(2, vertex_array_type, 8, v4o,
sizeof(v4o), 2); break;
+        case 10:vbo = vboVertexPointer(3, vertex_array_type, 8, v4o,
sizeof(v4o), 2); break;
+        case 11:vbo = vboVertexPointer(4, vertex_array_type, 8, v4o,
sizeof(v4o), 2); break;

         default:vbo = 0; assert(0); break;
     }
@@ -160,23 +203,23 @@ static void test_half_vertices(float fx1, float fy1,
float fx2, float fy2, int i
 struct test {
     void (*test)(float x1, float y1, float x2, float y2, int index);
     int index;
-    float expected_color[3];
+    float expected_color[4];
     const char *name;
 };

 struct test tests[] = {
-    {test_half_vertices, 0, {1, 1, 1}, "Half vertices - components: 2,
stride: 4, offset: 0"},
-    {test_half_vertices, 1, {1, 1, 1}, "Half vertices - components: 2,
stride: 6, offset: 0"},
-    {test_half_vertices, 2, {1, 1, 1}, "Half vertices - components: 3,
stride: 6, offset: 0"},
-    {test_half_vertices, 3, {1, 1, 1}, "Half vertices - components: 2,
stride: 8, offset: 0"},
-    {test_half_vertices, 4, {1, 1, 1}, "Half vertices - components: 3,
stride: 8, offset: 0"},
-    {test_half_vertices, 5, {1, 1, 1}, "Half vertices - components: 4,
stride: 8, offset: 0"},
-    {test_half_vertices, 6, {1, 1, 1}, "Half vertices - components: 2,
stride: 4, offset: 2"},
-    {test_half_vertices, 7, {1, 1, 1}, "Half vertices - components: 2,
stride: 6, offset: 2"},
-    {test_half_vertices, 8, {1, 1, 1}, "Half vertices - components: 3,
stride: 6, offset: 2"},
-    {test_half_vertices, 9, {1, 1, 1}, "Half vertices - components: 2,
stride: 8, offset: 2"},
-    {test_half_vertices, 10, {1, 1, 1}, "Half vertices - components: 3,
stride: 8, offset: 2"},
-    {test_half_vertices, 11, {1, 1, 1}, "Half vertices - components: 4,
stride: 8, offset: 2"},
+    {test_half_vertices, 0, {1, 1, 1, 1}, "Half vertices - components: 2,
stride: 4, offset: 0"},
+    {test_half_vertices, 1, {1, 1, 1, 1}, "Half vertices - components: 2,
stride: 6, offset: 0"},
+    {test_half_vertices, 2, {1, 1, 1, 1}, "Half vertices - components: 3,
stride: 6, offset: 0"},
+    {test_half_vertices, 3, {1, 1, 1, 1}, "Half vertices - components: 2,
stride: 8, offset: 0"},
+    {test_half_vertices, 4, {1, 1, 1, 1}, "Half vertices - components: 3,
stride: 8, offset: 0"},
+    {test_half_vertices, 5, {1, 1, 1, 1}, "Half vertices - components: 4,
stride: 8, offset: 0"},
+    {test_half_vertices, 6, {1, 1, 1, 1}, "Half vertices - components: 2,
stride: 4, offset: 2"},
+    {test_half_vertices, 7, {1, 1, 1, 1}, "Half vertices - components: 2,
stride: 6, offset: 2"},
+    {test_half_vertices, 8, {1, 1, 1, 1}, "Half vertices - components: 3,
stride: 6, offset: 2"},
+    {test_half_vertices, 9, {1, 1, 1, 1}, "Half vertices - components: 2,
stride: 8, offset: 2"},
+    {test_half_vertices, 10, {1, 1, 1, 1}, "Half vertices - components:
3, stride: 8, offset: 2"},
+    {test_half_vertices, 11, {1, 1, 1, 1}, "Half vertices - components:
4, stride: 8, offset: 2"},

     {0}
 };
@@ -189,7 +232,9 @@ piglit_display(void)
     float x = 0, y = 0;

     glClear(GL_COLOR_BUFFER_BIT);
+#ifdef PIGLIT_USE_OPENGL
     glEnableClientState(GL_VERTEX_ARRAY);
+#endif

     for (i = 0; tests[i].test; i++) {
         glBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -198,7 +243,7 @@ piglit_display(void)
         tests[i].test(x, y, x+20, y+20, tests[i].index);
         if (!piglit_check_gl_error(GL_NO_ERROR))
                 piglit_report_result(PIGLIT_FAIL);
-        pass = piglit_probe_pixel_rgb(x+5, y+5, tests[i].expected_color)
&& pass;
+        pass = piglit_probe_pixel_rgba(x+5, y+5, tests[i].expected_color)
&& pass;

         x += 20;
         if (x > 300) {

_______________________________________________
Piglit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/piglit
_______________________________________________
Piglit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to