I've added this with the intention of using it to ease porting the numerous fog tests from glean to the piglit framework, many of which can easily be ported to shader_runner, except for the need for glFog setup.
Signed-off-by: Dylan Baker <dylanx.c.ba...@intel.com> --- tests/shaders/shader_runner.c | 74 ++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 0 deletions(-) diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c index 8e29346..ba193c6 100644 --- a/tests/shaders/shader_runner.c +++ b/tests/shaders/shader_runner.c @@ -2592,6 +2592,78 @@ decode_drawing_mode(const char *mode_str) } static void +handle_fog(const char *line) +{ + static const struct string_to_enum fog_pname[] = { + { "mode", GL_FOG_MODE }, + { "density", GL_FOG_DENSITY }, + { "start", GL_FOG_START }, + { "end", GL_FOG_END }, + { "index", GL_FOG_INDEX }, + { "color", GL_FOG_COLOR }, + { "coord_src", GL_FOG_COORD_SRC }, + { "frag_depth", GL_FRAGMENT_DEPTH_EXT }, + { NULL, 0 } + }; + static const struct string_to_enum modes[] = { + { "linear", GL_LINEAR }, + { "exp", GL_EXP }, + { "exp2", GL_EXP2 }, + { NULL, 0 } + }; +#ifdef PIGLIT_USE_OPENGL + static const struct string_to_enum coord_src[] = { + { "fog_coord", GL_FOG_COORD }, + { "frag_depth", GL_FRAGMENT_DEPTH }, + { NULL, 0 } + }; +#endif + float v[4]; + GLenum target, e; + + // call glFogCoord + if (string_match("coord ", line)) { + line += strlen("coord "); + get_floats(line, v, 1); + glFogCoordf(v[0]); + return; + } + + target = lookup_enum_string(fog_pname, &line, "glFog pname"); + switch (target) { + case GL_FOG_MODE: + e = lookup_enum_string(modes, &line, + "glFog(GL_FOG_MODE, param)"); + glFogi(target, e); + break; + case GL_FOG_COORD_SRC: +#ifdef PIGLIT_USE_OPENGL + e = lookup_enum_string(coord_src, &line, + "glFog(GL_FOG_CCORD_SRC, param)"); + glFogi(target, e); + break; +#else + printf("glFog for GLES doesn't support coord_src\n"); + piglit_report_result(PIGLIT_FAIL); +#endif + case GL_FOG_COLOR: + sscanf(line, "( %f , %f , %f , %f )", + &v[0], &v[1], &v[2], &v[3]); + glFogfv(target, v); + break; + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + get_floats(line, v, 1); + glFogf(target, v[0]); + break; + default: + assert(0); + } +} + +static void handle_texparameter(const char *line) { static const struct string_to_enum texture_target[] = { @@ -3370,6 +3442,8 @@ piglit_display(void) active_uniform(line + strlen("active uniform ")); } else if (string_match("verify program_interface_query ", line)) { active_program_interface(line + strlen("verify program_interface_query ")); + } else if (string_match("fog ", line)) { + handle_fog(line + strlen("fog ")); } else if ((line[0] != '\n') && (line[0] != '\0') && (line[0] != '#')) { printf("unknown command \"%s\"\n", line); -- git-series 0.8.10 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit