[Piglit] [PATCH 2/3] ARB_ubo/maxuniformblocksize: Add support for GL_ARB_geometry_shader4.
Eric Anholt
eric at anholt.net
Mon Jun 17 13:34:49 PDT 2013
Passes on the i965 driver.
---
tests/all.tests | 2 +
.../maxuniformblocksize.c | 82 ++++++++++++++++++----
2 files changed, 70 insertions(+), 14 deletions(-)
diff --git a/tests/all.tests b/tests/all.tests
index ea18999..1eb752d 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2142,6 +2142,8 @@ arb_uniform_buffer_object['link-mismatch-blocks'] = concurrent_test('arb_uniform
arb_uniform_buffer_object['maxblocks'] = concurrent_test('arb_uniform_buffer_object-maxblocks')
arb_uniform_buffer_object['maxuniformblocksize/vs'] = concurrent_test('arb_uniform_buffer_object-maxuniformblocksize vs')
arb_uniform_buffer_object['maxuniformblocksize/vsexceed'] = concurrent_test('arb_uniform_buffer_object-maxuniformblocksize vsexceed')
+arb_uniform_buffer_object['maxuniformblocksize/gs'] = concurrent_test('arb_uniform_buffer_object-maxuniformblocksize gs')
+arb_uniform_buffer_object['maxuniformblocksize/gsexceed'] = concurrent_test('arb_uniform_buffer_object-maxuniformblocksize gsexceed')
arb_uniform_buffer_object['maxuniformblocksize/fs'] = concurrent_test('arb_uniform_buffer_object-maxuniformblocksize fs')
arb_uniform_buffer_object['maxuniformblocksize/fsexceed'] = concurrent_test('arb_uniform_buffer_object-maxuniformblocksize fsexceed')
arb_uniform_buffer_object['minmax'] = concurrent_test('arb_uniform_buffer_object-minmax')
diff --git a/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c b/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
index 879fa19..6513afd 100644
--- a/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
+++ b/tests/spec/arb_uniform_buffer_object/maxuniformblocksize.c
@@ -21,7 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-/** @file maxblocks.c
+/** @file maxuniformblocksize.c
*
* Tests linking and drawing with uniform buffer objects of size
* MAX_UNIFORM_BLOCK_SIZE and MAX_UNIFORM_BLOCK_SIZE + 4.
@@ -45,6 +45,8 @@ PIGLIT_GL_TEST_CONFIG_END
static enum {
VS,
VS_EXCEED,
+ GS,
+ GS_EXCEED,
FS,
FS_EXCEED,
} mode;
@@ -52,7 +54,8 @@ static enum {
static void
usage(const char *name)
{
- fprintf(stderr, "usage: %s <vs | vs_exceed | fs | fs_exceed>\n",
+ fprintf(stderr, "usage: %s <vs | vs_exceed | gs | gs_exceed | "
+ "fs | fs_exceed>\n",
name);
piglit_report_result(PIGLIT_FAIL);
}
@@ -75,7 +78,7 @@ piglit_display(void)
" vary = v[i];\n"
"}\n";
- const char *fs_template =
+ const char *fs_source =
"#extension GL_ARB_uniform_buffer_object : enable\n"
"\n"
"varying vec4 vary;"
@@ -84,7 +87,7 @@ piglit_display(void)
" gl_FragColor = vary;\n"
"}\n";
- const char *vs_template =
+ const char *vs_source =
"#extension GL_ARB_uniform_buffer_object : enable\n"
"\n"
"void main() {\n"
@@ -103,9 +106,26 @@ piglit_display(void)
" gl_FragColor = v[i];\n"
"}\n";
- char *vs_source, *fs_source;
+ const char *gs_ubo_template =
+ "#extension GL_ARB_uniform_buffer_object : enable\n"
+ "#extension GL_ARB_geometry_shader4 : enable\n"
+ "\n"
+ "layout(std140) uniform ubo {\n"
+ " vec4 v[%d];\n"
+ "};\n"
+ "uniform int i;\n"
+ "varying vec4 vary;"
+ "\n"
+ "void main() {\n"
+ " vary = v[i];\n"
+ " for (int v = 0; v < 3; v++) {\n"
+ " gl_Position = gl_PositionIn[v];\n"
+ " EmitVertex();\n"
+ " }\n"
+ "}\n";
+ char *gen_source = NULL;
GLint max_size, vec4s, i_location;
- GLuint vs, fs, prog, bo;
+ GLuint vs, gs = 0, fs, prog, bo;
GLenum target;
float *data;
size_t size;
@@ -129,6 +149,15 @@ piglit_display(void)
may_link_fail = true;
vec4s++;
break;
+ case GS:
+ target = GL_GEOMETRY_SHADER;
+ may_link_fail = false;
+ break;
+ case GS_EXCEED:
+ target = GL_GEOMETRY_SHADER;
+ may_link_fail = true;
+ vec4s++;
+ break;
case FS:
target = GL_FRAGMENT_SHADER;
may_link_fail = false;
@@ -140,26 +169,47 @@ piglit_display(void)
break;
}
+ if (target == GL_GEOMETRY_SHADER)
+ piglit_require_extension("GL_ARB_geometry_shader4");
+
+ prog = glCreateProgram();
+
switch (target) {
case GL_VERTEX_SHADER:
- asprintf(&vs_source, vs_ubo_template, vec4s);
- asprintf(&fs_source, fs_template);
+ asprintf(&gen_source, vs_ubo_template, vec4s);
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, gen_source);
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
printf("Testing VS with uniform block vec4 v[%d]\n", vec4s);
break;
+ case GL_GEOMETRY_SHADER:
+ asprintf(&gen_source, gs_ubo_template, vec4s);
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
+ gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gen_source);
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
+
+ printf("Testing GS with uniform block vec4 v[%d]\n", vec4s);
+
+ glProgramParameteri(prog,
+ GL_GEOMETRY_INPUT_TYPE_ARB, GL_TRIANGLES);
+ glProgramParameteri(prog,
+ GL_GEOMETRY_OUTPUT_TYPE_ARB,
+ GL_TRIANGLE_STRIP);
+ glProgramParameteri(prog,
+ GL_GEOMETRY_VERTICES_OUT_ARB, 3);
+ break;
case GL_FRAGMENT_SHADER:
- asprintf(&vs_source, vs_template);
- asprintf(&fs_source, fs_ubo_template, vec4s);
+ asprintf(&gen_source, fs_ubo_template, vec4s);
+ vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, gen_source);
printf("Testing FS with uniform block vec4 v[%d]\n", vec4s);
break;
default:
piglit_report_result(PIGLIT_FAIL);
}
- vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
- fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
-
- prog = glCreateProgram();
glAttachShader(prog, vs);
+ if (gs)
+ glAttachShader(prog, gs);
glAttachShader(prog, fs);
glLinkProgram(prog);
@@ -219,6 +269,10 @@ piglit_init(int argc, char **argv)
mode = VS;
else if (strcmp(argv[1], "vsexceed") == 0)
mode = VS_EXCEED;
+ else if (strcmp(argv[1], "gs") == 0)
+ mode = GS;
+ else if (strcmp(argv[1], "gsexceed") == 0)
+ mode = GS_EXCEED;
else if (strcmp(argv[1], "fs") == 0)
mode = FS;
else if (strcmp(argv[1], "fsexceed") == 0)
--
1.8.3.rc0
More information about the Piglit
mailing list