[1/2] shader_runner: add commands to set wrap modes and border color

Submitted by Marek Olšák on Oct. 4, 2016, 11:52 p.m.

Details

Message ID 1475625143-17617-1-git-send-email-maraeo@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Marek Olšák Oct. 4, 2016, 11:52 p.m.
From: Marek Olšák <marek.olsak@amd.com>

Everybody loves border colors!
---
 tests/shaders/shader_runner.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Patch hide | download patch | download mbox

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index fc0de88..1070998 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -2684,20 +2684,26 @@  handle_texparameter(const char *line)
 		{ "linear_mipmap_linear",   GL_LINEAR_MIPMAP_LINEAR   },
 		{ "nearest",                GL_NEAREST                },
 		{ "linear",                 GL_LINEAR                 },
 		{ NULL, 0 }
 	};
 	static const struct string_to_enum mag_filter_modes[] = {
 		{ "nearest",                GL_NEAREST                },
 		{ "linear",                 GL_LINEAR                 },
 		{ NULL, 0 }
 	};
+	static const struct string_to_enum wrap_modes[] = {
+		{ "repeat",                 GL_REPEAT                },
+		{ "clamp_to_edge",          GL_CLAMP_TO_EDGE         },
+		{ "clamp_to_border",        GL_CLAMP_TO_BORDER       },
+		{ NULL, 0 }
+	};
 	static const struct string_to_enum swizzle_modes[] = {
 		{ "red", GL_RED },
 		{ "green", GL_GREEN },
 		{ "blue", GL_BLUE },
 		{ "alpha", GL_ALPHA },
 		{ NULL, 0 }
 	};
 	GLenum target = 0;
 	GLenum parameter = GL_NONE;
 	const char *parameter_name = NULL;
@@ -2719,40 +2725,61 @@  handle_texparameter(const char *line)
 	} else if (string_match("min ", line)) {
 		parameter = GL_TEXTURE_MIN_FILTER;
 		parameter_name = "min";
 		line += strlen("min ");
 		strings = min_filter_modes;
 	} else if (string_match("mag ", line)) {
 		parameter = GL_TEXTURE_MAG_FILTER;
 		parameter_name = "mag";
 		line += strlen("mag ");
 		strings = mag_filter_modes;
+	} else if (string_match("wrap_s ", line)) {
+		parameter = GL_TEXTURE_WRAP_S;
+		parameter_name = "wrap_s";
+		line += strlen("wrap_s ");
+		strings = wrap_modes;
+	} else if (string_match("wrap_t ", line)) {
+		parameter = GL_TEXTURE_WRAP_T;
+		parameter_name = "wrap_t";
+		line += strlen("wrap_t ");
+		strings = wrap_modes;
+	} else if (string_match("wrap_r ", line)) {
+		parameter = GL_TEXTURE_WRAP_R;
+		parameter_name = "wrap_r";
+		line += strlen("wrap_r ");
+		strings = wrap_modes;
 	} else if (string_match("lod_bias ", line)) {
 #ifdef PIGLIT_USE_OPENGL
 		line += strlen("lod_bias ");
 		glTexParameterf(target, GL_TEXTURE_LOD_BIAS,
 				strtod(line, NULL));
 		return;
 #else
 		printf("lod_bias feature is only available in desktop GL\n");
 		piglit_report_result(PIGLIT_SKIP);
 #endif
 	} else if (string_match("max_level ", line)) {
 		line += strlen("max_level ");
 		glTexParameteri(target, GL_TEXTURE_MAX_LEVEL,
 				strtol(line, NULL, 10));
 		return;
 	} else if (string_match("base_level ", line)) {
 		line += strlen("base_level ");
 		glTexParameteri(target, GL_TEXTURE_BASE_LEVEL,
 				strtol(line, NULL, 10));
 		return;
+	} else if (string_match("border_color ", line)) {
+		float bc[4];
+		line += strlen("border_color ");
+		sscanf(line, "%f %f %f %f", &bc[0], &bc[1], &bc[2], &bc[3]);
+		glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, bc);
+		return;
 	} else if (string_match("swizzle_r ", line)) {
 		parameter = GL_TEXTURE_SWIZZLE_R;
 		parameter_name = "swizzle_r";
 		line += strlen("swizzle_r ");
 		strings = swizzle_modes;
 	} else {
 		fprintf(stderr, "unknown texture parameter in `%s'\n", line);
 		piglit_report_result(PIGLIT_FAIL);
 	}