[Piglit] [PATCH 03/15] shader_runner: Add tessellation support.
Fabian Bieler
fabianbieler at fastmail.fm
Mon Mar 24 15:02:42 PDT 2014
Add support for tessellation control and tessellation evaluation shaders.
Signed-off-by: Fabian Bieler <fabianbieler at fastmail.fm>
---
tests/shaders/shader_runner.c | 77 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index dd506e8..7b9ec97 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -98,6 +98,10 @@ const char *test_start = NULL;
GLuint vertex_shaders[256];
unsigned num_vertex_shaders = 0;
+GLuint tess_ctrl_shaders[256];
+unsigned num_tess_ctrl_shaders = 0;
+GLuint tess_eval_shaders[256];
+unsigned num_tess_eval_shaders = 0;
GLuint geometry_shaders[256];
unsigned num_geometry_shaders = 0;
GLuint fragment_shaders[256];
@@ -128,6 +132,10 @@ enum states {
vertex_shader_file,
vertex_shader_passthrough,
vertex_program,
+ tess_ctrl_shader,
+ tess_ctrl_shader_file,
+ tess_eval_shader,
+ tess_eval_shader_file,
geometry_shader,
geometry_shader_file,
geometry_layout,
@@ -237,6 +245,10 @@ target_to_short_name(GLenum target)
return "VS";
case GL_FRAGMENT_SHADER:
return "FS";
+ case GL_TESS_CONTROL_SHADER:
+ return "TCS";
+ case GL_TESS_EVALUATION_SHADER:
+ return "TES";
case GL_GEOMETRY_SHADER:
return "GS";
case GL_COMPUTE_SHADER:
@@ -260,6 +272,11 @@ compile_glsl(GLenum target, bool release_text)
case GL_FRAGMENT_SHADER:
piglit_require_fragment_shader();
break;
+ case GL_TESS_CONTROL_SHADER:
+ case GL_TESS_EVALUATION_SHADER:
+ if (gl_version.num < 40)
+ piglit_require_extension("GL_ARB_tessellation_shader");
+ break;
case GL_GEOMETRY_SHADER:
if (gl_version.num < 32)
piglit_require_extension("GL_ARB_geometry_shader4");
@@ -331,6 +348,14 @@ compile_glsl(GLenum target, bool release_text)
vertex_shaders[num_vertex_shaders] = shader;
num_vertex_shaders++;
break;
+ case GL_TESS_CONTROL_SHADER:
+ tess_ctrl_shaders[num_tess_ctrl_shaders] = shader;
+ num_tess_ctrl_shaders++;
+ break;
+ case GL_TESS_EVALUATION_SHADER:
+ tess_eval_shaders[num_tess_eval_shaders] = shader;
+ num_tess_eval_shaders++;
+ break;
case GL_GEOMETRY_SHADER:
geometry_shaders[num_geometry_shaders] = shader;
num_geometry_shaders++;
@@ -710,6 +735,24 @@ leave_state(enum states state, const char *line)
line - shader_string);
break;
+ case tess_ctrl_shader:
+ shader_string_size = line - shader_string;
+ compile_glsl(GL_TESS_CONTROL_SHADER, false);
+ break;
+
+ case tess_ctrl_shader_file:
+ compile_glsl(GL_TESS_CONTROL_SHADER, true);
+ break;
+
+ case tess_eval_shader:
+ shader_string_size = line - shader_string;
+ compile_glsl(GL_TESS_EVALUATION_SHADER, false);
+ break;
+
+ case tess_eval_shader_file:
+ compile_glsl(GL_TESS_EVALUATION_SHADER, true);
+ break;
+
case geometry_shader:
shader_string_size = line - shader_string;
compile_glsl(GL_GEOMETRY_SHADER, false);
@@ -768,6 +811,8 @@ link_and_use_shaders(void)
if ((num_vertex_shaders == 0)
&& (num_fragment_shaders == 0)
+ && (num_tess_ctrl_shaders == 0)
+ && (num_tess_eval_shaders == 0)
&& (num_geometry_shaders == 0)
&& (num_compute_shaders == 0))
return;
@@ -778,6 +823,14 @@ link_and_use_shaders(void)
glAttachShader(prog, vertex_shaders[i]);
}
+ for (i = 0; i < num_tess_ctrl_shaders; i++) {
+ glAttachShader(prog, tess_ctrl_shaders[i]);
+ }
+
+ for (i = 0; i < num_tess_eval_shaders; i++) {
+ glAttachShader(prog, tess_eval_shaders[i]);
+ }
+
for (i = 0; i < num_geometry_shaders; i++) {
glAttachShader(prog, geometry_shaders[i]);
}
@@ -818,6 +871,14 @@ link_and_use_shaders(void)
glDeleteShader(vertex_shaders[i]);
}
+ for (i = 0; i < num_tess_ctrl_shaders; i++) {
+ glDeleteShader(tess_ctrl_shaders[i]);
+ }
+
+ for (i = 0; i < num_tess_eval_shaders; i++) {
+ glDeleteShader(tess_eval_shaders[i]);
+ }
+
for (i = 0; i < num_geometry_shaders; i++) {
glDeleteShader(geometry_shaders[i]);
}
@@ -893,6 +954,18 @@ process_test_script(const char *script_name)
} else if (string_match("[vertex shader file]", line)) {
state = vertex_shader_file;
shader_string = NULL;
+ } else if (string_match("[tessellation control shader]", line)) {
+ state = tess_ctrl_shader;
+ shader_string = NULL;
+ } else if (string_match("[tessellation control shader file]", line)) {
+ state = tess_ctrl_shader_file;
+ shader_string = NULL;
+ } else if (string_match("[tessellation evaluation shader]", line)) {
+ state = tess_eval_shader;
+ shader_string = NULL;
+ } else if (string_match("[tessellation evaluation shader file]", line)) {
+ state = tess_eval_shader_file;
+ shader_string = NULL;
} else if (string_match("[geometry shader]", line)) {
state = geometry_shader;
shader_string = NULL;
@@ -942,6 +1015,8 @@ process_test_script(const char *script_name)
case vertex_shader:
case vertex_program:
+ case tess_ctrl_shader:
+ case tess_eval_shader:
case geometry_shader:
case fragment_shader:
case fragment_program:
@@ -951,6 +1026,8 @@ process_test_script(const char *script_name)
break;
case vertex_shader_file:
+ case tess_ctrl_shader_file:
+ case tess_eval_shader_file:
case geometry_shader_file:
case fragment_shader_file:
case compute_shader_file:
--
1.8.3.2
More information about the Piglit
mailing list