[Piglit] [PATCH 7/8] shader_runner: Factor out open-coded texture target parsing as parser primitive.
Francisco Jerez
currojerez at riseup.net
Tue Oct 18 23:17:45 UTC 2016
This will be re-used later on.
---
tests/shaders/parser_utils.c | 17 +++++++++++++++++
tests/shaders/parser_utils.h | 6 ++++++
tests/shaders/shader_runner.c | 14 +-------------
3 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/tests/shaders/parser_utils.c b/tests/shaders/parser_utils.c
index d180842..ba59671 100644
--- a/tests/shaders/parser_utils.c
+++ b/tests/shaders/parser_utils.c
@@ -222,6 +222,23 @@ parse_enum_tab(const struct string_to_enum *tab,
}
bool
+parse_tex_target(const char *s, unsigned *t, const char **rest)
+{
+ static const struct string_to_enum tab[] = {
+ { "1D", GL_TEXTURE_1D },
+ { "2D", GL_TEXTURE_2D },
+ { "3D", GL_TEXTURE_3D },
+ { "Rect", GL_TEXTURE_RECTANGLE },
+ { "Cube", GL_TEXTURE_CUBE_MAP },
+ { "1DArray", GL_TEXTURE_1D_ARRAY },
+ { "2DArray", GL_TEXTURE_2D_ARRAY },
+ { "CubeArray", GL_TEXTURE_CUBE_MAP_ARRAY },
+ { NULL, 0 }
+ };
+ return parse_enum_tab(tab, s, t, rest);
+}
+
+bool
parse_comparison_op(const char *s, enum comparison *t, const char **rest)
{
if (parse_str(s, "==", rest)) {
diff --git a/tests/shaders/parser_utils.h b/tests/shaders/parser_utils.h
index 6907a69..28e0630 100644
--- a/tests/shaders/parser_utils.h
+++ b/tests/shaders/parser_utils.h
@@ -184,6 +184,12 @@ bool
parse_enum_tab(const struct string_to_enum *tab,
const char *s, unsigned *e, const char **rest);
+/**
+ * Parse a texture target symbolic constant.
+ */
+bool
+parse_tex_target(const char *s, GLenum *t, const char **rest);
+
const char *eat_whitespace(const char *src);
const char *eat_text(const char *src);
bool string_match(const char *string, const char *line);
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 9aa988d..6d2f7f4 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2469,18 +2469,6 @@ decode_drawing_mode(const char *mode_str)
static void
handle_texparameter(const char *line)
{
- static const struct string_to_enum texture_target[] = {
- { "1D", GL_TEXTURE_1D },
- { "2D", GL_TEXTURE_2D },
- { "3D", GL_TEXTURE_3D },
- { "Rect", GL_TEXTURE_RECTANGLE },
- { "Cube", GL_TEXTURE_CUBE_MAP },
- { "1DArray", GL_TEXTURE_1D_ARRAY },
- { "2DArray", GL_TEXTURE_2D_ARRAY },
- { "CubeArray", GL_TEXTURE_CUBE_MAP_ARRAY },
- { NULL, 0 }
- };
-
static const struct string_to_enum compare_funcs[] = {
{ "greater", GL_GREATER },
{ "gequal", GL_GEQUAL },
@@ -2532,7 +2520,7 @@ handle_texparameter(const char *line)
const struct string_to_enum *strings = NULL;
unsigned value;
- REQUIRE(parse_enum_tab(texture_target, line, &value, NULL),
+ REQUIRE(parse_tex_target(line, &target, &line),
"Bad texture target at: %s\n", line);
if (parse_str(line, "compare_func ", &line)) {
--
2.9.0
More information about the Piglit
mailing list