[Piglit] [PATCH] texelFetch: Add geometry shader testing.
Paul Berry
stereotype441 at gmail.com
Sun Jun 23 17:35:14 PDT 2013
---
tests/all.tests | 6 ++--
tests/texturing/shaders/common.c | 3 ++
tests/texturing/shaders/texelFetch.c | 69 ++++++++++++++++++++++++++++++++++--
3 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/tests/all.tests b/tests/all.tests
index 9c928a0..3a042a5 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -835,7 +835,7 @@ import_glsl_parser_tests(spec['glsl-1.30'],
spec['glsl-1.30']['execution'] = Group()
textureSize_samplers_130 = ['sampler1D', 'sampler2D', 'sampler3D', 'samplerCube', 'sampler1DShadow', 'sampler2DShadow', 'samplerCubeShadow', 'sampler1DArray', 'sampler2DArray', 'sampler1DArrayShadow', 'sampler2DArrayShadow', 'isampler1D', 'isampler2D', 'isampler3D', 'isamplerCube', 'isampler1DArray', 'isampler2DArray', 'usampler1D', 'usampler2D', 'usampler3D', 'usamplerCube', 'usampler1DArray', 'usampler2DArray']
-for stage in ['vs', 'fs']:
+for stage in ['vs', 'gs', 'fs']:
# textureSize():
for sampler in textureSize_samplers_130:
spec['glsl-1.30/execution/textureSize/' + stage + '-textureSize-' + sampler] = concurrent_test('textureSize ' + stage + ' ' + sampler)
@@ -882,7 +882,7 @@ add_shader_test_dir(spec['glsl-1.40'],
spec['glsl-1.40']['execution']['tf-no-position'] = concurrent_test('glsl-1.40-tf-no-position')
textureSize_samplers_140 = textureSize_samplers_130 + ['sampler2DRect', 'isampler2DRect', 'sampler2DRectShadow', 'samplerBuffer', 'isamplerBuffer', 'usamplerBuffer']
-for stage in ['vs', 'fs']:
+for stage in ['vs', 'gs', 'fs']:
# textureSize():
for sampler in textureSize_samplers_140:
spec['glsl-1.40/execution/textureSize/' + stage + '-textureSize-' + sampler] = concurrent_test('textureSize 140 ' + stage + ' ' + sampler)
@@ -935,7 +935,7 @@ for sample_count in MSAA_SAMPLE_COUNTS:
spec['ARB_texture_multisample/fb-completeness/%d' % (sample_count,)] = \
concurrent_test('arb_texture_multisample-fb-completeness %d' % (sample_count,))
# texel-fetch execution
- for stage in ['vs','fs']:
+ for stage in ['vs', 'gs', 'fs']:
for sampler in samplers_atm:
spec['ARB_texture_multisample/texelFetch/%d-%s-%s' % (
sample_count, stage, sampler)] = \
diff --git a/tests/texturing/shaders/common.c b/tests/texturing/shaders/common.c
index 0b13d47..dba578a 100644
--- a/tests/texturing/shaders/common.c
+++ b/tests/texturing/shaders/common.c
@@ -333,6 +333,9 @@ require_GL_features(enum shader_target test_stage)
piglit_require_GLSL_version(shader_version);
+ if (test_stage == GS)
+ piglit_require_extension("GL_ARB_geometry_shader4");
+
if (swizzling)
piglit_require_extension("GL_EXT_texture_swizzle");
diff --git a/tests/texturing/shaders/texelFetch.c b/tests/texturing/shaders/texelFetch.c
index ebfdfe0..71f2b5e 100644
--- a/tests/texturing/shaders/texelFetch.c
+++ b/tests/texturing/shaders/texelFetch.c
@@ -33,7 +33,7 @@
* ./bin/texelFetch usampler3D vs
*
* The test covers:
- * - All pipeline stages (VS, FS)
+ * - All pipeline stages (VS, GS, FS)
* - Integer and floating point texture formats
* - Sampler dimensionality (1D, 2D, 3D, 1DArray, 2DArray)
* - Mipmapping
@@ -556,9 +556,10 @@ coordinate_size()
int
generate_GLSL(enum shader_target test_stage)
{
- int vs, fs, prog;
+ int vs, gs, fs, prog;
static char *vs_code;
+ static char *gs_code = NULL;
static char *fs_code;
const char *offset_func, *offset_arg;
@@ -621,6 +622,52 @@ generate_GLSL(enum shader_target test_stage)
shader_version,
sampler.return_type);
break;
+ case GS:
+ asprintf(&vs_code,
+ "#version %d\n"
+ "in vec4 pos;\n"
+ "in ivec4 texcoord;\n"
+ "flat out ivec4 texcoord_to_gs;\n"
+ "void main()\n"
+ "{\n"
+ " texcoord_to_gs = texcoord;\n"
+ " gl_Position = pos;\n"
+ "}\n",
+ shader_version);
+ asprintf(&gs_code,
+ "#version %d\n"
+ "#extension GL_ARB_geometry_shader4: require\n"
+ "%s\n"
+ "#define ivec1 int\n"
+ "flat out %s color;\n"
+ "flat in ivec4 texcoord_to_gs[1];\n"
+ "uniform %s tex;\n"
+ "void main()\n"
+ "{\n"
+ " ivec4 texcoord = texcoord_to_gs[0];\n"
+ " color = texelFetch%s(tex, ivec%d(texcoord)%s%s);\n"
+ " gl_Position = gl_PositionIn[0];\n"
+ " EmitVertex();\n"
+ "}\n",
+ shader_version,
+ has_samples() ? "#extension GL_ARB_texture_multisample: require" : "",
+ sampler.return_type, sampler.name,
+ offset_func,
+ coordinate_size(),
+ ((sampler.target == GL_TEXTURE_RECTANGLE) ?
+ "" : ", texcoord.w"),
+ offset_arg);
+ asprintf(&fs_code,
+ "#version %d\n"
+ "flat in %s color;\n"
+ "uniform vec4 divisor;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = vec4(color)/divisor;\n"
+ "}\n",
+ shader_version,
+ sampler.return_type);
+ break;
case FS:
asprintf(&vs_code,
"#version %d\n"
@@ -665,6 +712,13 @@ generate_GLSL(enum shader_target test_stage)
printf("VS code:\n%s", vs_code);
piglit_report_result(PIGLIT_FAIL);
}
+ if (gs_code) {
+ gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gs_code);
+ if (!gs) {
+ printf("GS code:\n%s", gs_code);
+ piglit_report_result(PIGLIT_FAIL);
+ }
+ }
fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_code);
if (!fs) {
printf("FS code:\n%s", fs_code);
@@ -672,6 +726,12 @@ generate_GLSL(enum shader_target test_stage)
}
prog = glCreateProgram();
glAttachShader(prog, vs);
+ if (gs_code) {
+ glAttachShader(prog, gs);
+ glProgramParameteri(prog, GL_GEOMETRY_INPUT_TYPE_ARB, GL_POINTS);
+ glProgramParameteri(prog, GL_GEOMETRY_OUTPUT_TYPE_ARB, GL_POINTS);
+ glProgramParameteri(prog, GL_GEOMETRY_VERTICES_OUT_ARB, 1);
+ }
glAttachShader(prog, fs);
glBindAttribLocation(prog, pos_loc, "pos");
@@ -718,7 +778,7 @@ supported_sampler()
void
fail_and_show_usage()
{
- printf("Usage: texelFetch [140] [offset] <vs|fs> <sampler type> "
+ printf("Usage: texelFetch [140] [offset] <vs|gs|fs> <sampler type> "
"[sample_count] [swizzle] [piglit args...]\n");
piglit_report_result(PIGLIT_FAIL);
}
@@ -738,6 +798,9 @@ piglit_init(int argc, char **argv)
if (strcmp(argv[i], "vs") == 0) {
test_stage = VS;
continue;
+ } else if (strcmp(argv[i], "gs") == 0) {
+ test_stage = GS;
+ continue;
} else if (strcmp(argv[i], "fs") == 0) {
test_stage = FS;
continue;
--
1.8.3.1
More information about the Piglit
mailing list