[Piglit] [PATCH 03/31] Remove GLenum primitive string literals.
Fabian Bieler
fabianbieler at fastmail.fm
Thu Dec 28 15:57:29 UTC 2017
Replace GLenum primitive string literals with calls to piglit_get_prim_name.
This commit modifies all tests were the replacement is simple and
straightforward.
---
tests/general/primitive-restart.c | 9 ++---
.../arb_geometry_shader4/execution/vertices-in.c | 14 ++++----
tests/spec/ext_transform_feedback/negative-prims.c | 39 +++++++++++-----------
.../ext_transform_feedback/overflow-edge-cases.c | 5 +--
4 files changed, 30 insertions(+), 37 deletions(-)
diff --git a/tests/general/primitive-restart.c b/tests/general/primitive-restart.c
index abe55c7a8..4219a6c5b 100644
--- a/tests/general/primitive-restart.c
+++ b/tests/general/primitive-restart.c
@@ -176,9 +176,7 @@ test_begin_end(GLenum primMode)
pass = check_rendering();
if (!pass) {
fprintf(stderr, "%s: failure drawing with glBegin(%s) / glEnd()\n",
- TestName,
- (primMode == GL_TRIANGLE_STRIP
- ? "GL_TRIANGLE_STRIP" : "GL_LINE_STRIP"));
+ TestName, piglit_get_prim_name(primMode));
}
piglit_present_results();
@@ -296,7 +294,6 @@ test_draw_by_index(VBO_CFG vbo_cfg, bool one_by_one, GLenum primMode, GLenum ind
GLuint restart_index;
GLuint num_elems;
bool pass = true;
- const char *primStr = NULL;
GLuint vbo1, vbo2;
bool create_vbo1 = false;
bool create_vbo2 = false;
@@ -359,7 +356,6 @@ test_draw_by_index(VBO_CFG vbo_cfg, bool one_by_one, GLenum primMode, GLenum ind
}
num_elems = j;
- primStr = "GL_TRIANGLE_STRIP";
}
else {
const GLfloat y = 0.5 * piglit_height;
@@ -385,7 +381,6 @@ test_draw_by_index(VBO_CFG vbo_cfg, bool one_by_one, GLenum primMode, GLenum ind
}
num_elems = j;
- primStr = "GL_LINE_STRIP";
}
assert(num_elems <= NUM_ELEMS);
@@ -468,7 +463,7 @@ test_draw_by_index(VBO_CFG vbo_cfg, bool one_by_one, GLenum primMode, GLenum ind
fprintf(stderr, "%s: failure drawing with %s(%s, %s), %s\n",
TestName,
one_by_one ? "glArrayElement" : "glDrawElements",
- primStr,
+ piglit_get_prim_name(primMode),
piglit_get_gl_enum_name(indexType),
vbo_cfg_names[vbo_cfg]);
pass = false;
diff --git a/tests/spec/arb_geometry_shader4/execution/vertices-in.c b/tests/spec/arb_geometry_shader4/execution/vertices-in.c
index 22084d7f5..c3f20662a 100644
--- a/tests/spec/arb_geometry_shader4/execution/vertices-in.c
+++ b/tests/spec/arb_geometry_shader4/execution/vertices-in.c
@@ -59,15 +59,14 @@ static const char *gs_text =
static const char *varyings[] = { "vertices_in" };
struct test_vector {
- const char *name;
GLenum prim_type;
GLint vertices_in;
} test_vectors[] = {
- { "GL_POINTS", GL_POINTS, 1},
- { "GL_LINES", GL_LINES, 2},
- { "GL_LINES_ADJACENCY", GL_LINES_ADJACENCY, 4},
- { "GL_TRIANGLES", GL_TRIANGLES, 3},
- { "GL_TRIANGLES_ADJACENCY", GL_TRIANGLES_ADJACENCY, 6}
+ { GL_POINTS, 1},
+ { GL_LINES, 2},
+ { GL_LINES_ADJACENCY, 4},
+ { GL_TRIANGLES, 3},
+ { GL_TRIANGLES_ADJACENCY, 6}
};
void
@@ -112,7 +111,8 @@ piglit_init(int argc, char **argv)
piglit_report_result(PIGLIT_FAIL);
for (i = 0; i < ARRAY_SIZE(test_vectors); i++) {
- printf("Testing %s:\n", test_vectors[i].name);
+ printf("Testing %s:\n",
+ piglit_get_prim_name(test_vectors[i].prim_type));
glProgramParameteriARB(prog, GL_GEOMETRY_INPUT_TYPE_ARB,
test_vectors[i].prim_type);
glLinkProgram(prog);
diff --git a/tests/spec/ext_transform_feedback/negative-prims.c b/tests/spec/ext_transform_feedback/negative-prims.c
index 81ce778c0..7716f61d4 100644
--- a/tests/spec/ext_transform_feedback/negative-prims.c
+++ b/tests/spec/ext_transform_feedback/negative-prims.c
@@ -55,24 +55,25 @@ PIGLIT_GL_TEST_CONFIG_END
struct {
GLenum tf_prim;
GLenum prim;
- const char *name;
} prims[] = {
- { GL_POINTS, GL_POINTS, "GL_POINTS" },
- { GL_LINES, GL_LINES, "GL_LINES" },
- { GL_LINES, GL_LINE_STRIP, "GL_LINE_STRIP" },
- { GL_LINES, GL_LINE_LOOP, "GL_LINE_LOOP" },
- { GL_TRIANGLES, GL_TRIANGLES, "GL_TRIANGLES" },
- { GL_TRIANGLES, GL_TRIANGLE_STRIP, "GL_TRIANGLE_STRIP" },
- { GL_TRIANGLES, GL_TRIANGLE_FAN, "GL_TRIANGLE_FAN" },
- { GL_TRIANGLES, GL_QUADS, "GL_QUADS" },
- { GL_TRIANGLES, GL_QUAD_STRIP, "GL_QUAD_STRIP" },
- { GL_TRIANGLES, GL_POLYGON, "GL_POLYGON" },
+ { GL_POINTS, GL_POINTS },
+ { GL_LINES, GL_LINES },
+ { GL_LINES, GL_LINE_STRIP },
+ { GL_LINES, GL_LINE_LOOP },
+ { GL_TRIANGLES, GL_TRIANGLES },
+ { GL_TRIANGLES, GL_TRIANGLE_STRIP },
+ { GL_TRIANGLES, GL_TRIANGLE_FAN },
+ { GL_TRIANGLES, GL_QUADS },
+ { GL_TRIANGLES, GL_QUAD_STRIP },
+ { GL_TRIANGLES, GL_POLYGON },
};
static bool
-test_one_prim(GLenum tf_prim, const char *tf_name, int i)
+test_one_prim(GLenum tf_prim, int i)
{
GLenum error;
+ const char *prim_name = piglit_get_prim_name(prims[i].prim);
+ const char *tf_name = piglit_get_prim_name(tf_prim);
glDrawArrays(prims[i].prim, 0, 4);
@@ -82,7 +83,7 @@ test_one_prim(GLenum tf_prim, const char *tf_name, int i)
printf("Expected GL error 0x%x, got 0x%x, when "
"rendering %s during %s transform feedback\n",
GL_INVALID_OPERATION, error,
- prims[i].name, tf_name);
+ prim_name, tf_name);
return false;
}
} else {
@@ -90,7 +91,7 @@ test_one_prim(GLenum tf_prim, const char *tf_name, int i)
printf("Unxpected GL error 0x%x when "
"rendering %s during %s transform feedback\n",
error,
- prims[i].name, tf_name);
+ prim_name, tf_name);
return false;
}
}
@@ -98,14 +99,14 @@ test_one_prim(GLenum tf_prim, const char *tf_name, int i)
}
static bool
-test_transform_feedback_prim(GLenum tf_prim, const char *tf_name)
+test_transform_feedback_prim(GLenum tf_prim)
{
bool pass = true;
int i;
glBeginTransformFeedbackEXT(tf_prim);
for (i = 0; i < ARRAY_SIZE(prims); i++) {
- pass = pass && test_one_prim(tf_prim, tf_name, i);
+ pass = pass && test_one_prim(tf_prim, i);
}
glEndTransformFeedbackEXT();
@@ -117,9 +118,9 @@ piglit_display(void)
{
bool pass = true;
- pass = pass && test_transform_feedback_prim(GL_POINTS, "GL_POINTS");
- pass = pass && test_transform_feedback_prim(GL_LINES, "GL_LINES");
- pass = pass && test_transform_feedback_prim(GL_TRIANGLES, "GL_TRIANGLES");
+ pass = pass && test_transform_feedback_prim(GL_POINTS);
+ pass = pass && test_transform_feedback_prim(GL_LINES);
+ pass = pass && test_transform_feedback_prim(GL_TRIANGLES);
piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
diff --git a/tests/spec/ext_transform_feedback/overflow-edge-cases.c b/tests/spec/ext_transform_feedback/overflow-edge-cases.c
index 88ec7d94a..0249c6739 100644
--- a/tests/spec/ext_transform_feedback/overflow-edge-cases.c
+++ b/tests/spec/ext_transform_feedback/overflow-edge-cases.c
@@ -131,9 +131,6 @@ static GLuint query_prims_generated;
static GLuint query_prims_written;
static GLenum modes[] = { GL_POINTS, GL_LINES, GL_TRIANGLES };
-static const char *mode_names[] = {
- "GL_POINTS", "GL_LINES", "GL_TRIANGLES"
-};
static const char *mode_gs_out_primtypes[] = {
"points", "line_strip", "triangle_strip"
};
@@ -213,7 +210,7 @@ test(int bind_size, int num_varyings, int num_primitives, int mode_index)
printf("size=%d, num_varyings=%d, num_primitives=%d, mode=%s: ",
bind_size, num_varyings, num_primitives,
- mode_names[mode_index]);
+ piglit_get_prim_name(modes[mode_index]));
/* Setup program and initial buffer contents */
prog = progs[mode_index][num_varyings - 1];
--
2.15.1
More information about the Piglit
mailing list