[Piglit] [PATCH 6/6] gs: Make texelFetch and textureSize tests use GLSL 1.50 for geometry shaders.

Paul Berry stereotype441 at gmail.com
Sat Jul 27 06:10:07 PDT 2013


Previously, these tests used ARB_geometry_shader4.  However, the
initial implementation of geometry shaders in Mesa isn't going to
support ARB_geometry_shader4.  So test this functionality using GLSL
1.50 geometry shaders instead.
---
 tests/all.tests                       | 37 ++++++++++++++----
 tests/texturing/shaders/common.c      |  3 --
 tests/texturing/shaders/texelFetch.c  | 73 ++++++++++++++++++++++-------------
 tests/texturing/shaders/textureSize.c | 44 ++++++++++++++-------
 4 files changed, 106 insertions(+), 51 deletions(-)

diff --git a/tests/all.tests b/tests/all.tests
index bc5c284..d61820a 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -838,16 +838,29 @@ 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', 'gs', 'fs']:
+        if stage == 'gs':
+                version = '1.50'
+        else:
+                version = '1.30'
 	# textureSize():
 	for sampler in textureSize_samplers_130:
-		spec['glsl-1.30/execution/textureSize/' + stage + '-textureSize-' + sampler] = concurrent_test('textureSize ' + stage + ' ' + sampler)
+                spec['glsl-{0}/execution/textureSize/{1}-textureSize-{2}'.format(
+                        version, stage, sampler)] = concurrent_test(
+                        'textureSize {0} {1}'.format(stage, sampler))
 	# texelFetch():
 	for sampler in ['sampler1D', 'sampler2D', 'sampler3D', 'sampler1DArray', 'sampler2DArray', 'isampler1D', 'isampler2D', 'isampler3D', 'isampler1DArray', 'isampler2DArray', 'usampler1D', 'usampler2D', 'usampler3D', 'usampler1DArray', 'usampler2DArray']:
-		spec['glsl-1.30/execution/texelFetch/' + stage + '-texelFetch-' + sampler] = concurrent_test('texelFetch ' + stage + ' ' + sampler)
-		spec['glsl-1.30/execution/texelFetchOffset/' + stage + '-' + sampler] = concurrent_test('texelFetch offset ' + stage + ' ' + sampler)
+                spec['glsl-{0}/execution/texelFetch/{1}-texelFetch-{2}'.format(
+                        version, stage, sampler)] = concurrent_test(
+                        'texelFetch {0} {1}'.format(stage, sampler))
+                spec['glsl-{0}/execution/texelFetchOffset/{1}-texelFetch-{2}'.format(
+                        version, stage, sampler)] = concurrent_test(
+                        'texelFetch offset {0} {1}'.format(stage, sampler))
 	# texelFetch() with EXT_texture_swizzle mode "b0r1":
 	for type in ['i', 'u', '']:
-		spec['glsl-1.30/execution/texelFetch/' + stage + '-texelFetch-' + type + 'sampler2DArray-swizzle'] = concurrent_test('texelFetch ' + stage + ' ' + type + 'sampler2DArray b0r1')
+                spec['glsl-{0}/execution/texelFetch/{1}-texelFetch-{2}sampler2Darray-swizzle'.format(
+                        version, stage, type)] = concurrent_test(
+                        'texelFetch {0} {1}sampler2DArray b0r1'.format(
+                                stage, type))
 
 add_plain_test(spec['glsl-1.30']['execution'], 'fs-texelFetch-2D')
 add_plain_test(spec['glsl-1.30']['execution'], 'fs-texelFetchOffset-2D')
@@ -885,13 +898,23 @@ spec['glsl-1.40']['execution']['tf-no-position'] = concurrent_test('glsl-1.40-tf
 
 textureSize_samplers_140 = textureSize_samplers_130 + ['sampler2DRect', 'isampler2DRect', 'sampler2DRectShadow', 'samplerBuffer', 'isamplerBuffer', 'usamplerBuffer']
 for stage in ['vs', 'gs', 'fs']:
+        if stage == 'gs':
+                version = '1.50'
+        else:
+                version = '1.40'
 	# textureSize():
 	for sampler in textureSize_samplers_140:
-		spec['glsl-1.40/execution/textureSize/' + stage + '-textureSize-' + sampler] = concurrent_test('textureSize 140 ' + stage + ' ' + sampler)
+                spec['glsl-{0}/execution/textureSize/{1}-textureSize-{2}'.format(
+                        version, stage, sampler)] = concurrent_test(
+                        'textureSize 140 {0} {1}'.format(stage, sampler))
 	# texelFetch():
 	for sampler in ['sampler2DRect', 'usampler2DRect', 'isampler2DRect']:
-		spec['glsl-1.40/execution/texelFetch/' + stage + '-texelFetch-' + sampler] = concurrent_test('texelFetch 140 ' + stage + ' ' + sampler)
-		spec['glsl-1.40/execution/texelFetchOffset/' + stage + '-' + sampler] = concurrent_test('texelFetch offset 140 ' + stage + ' ' + sampler)
+                spec['glsl-{0}/execution/texelFetch/{1}-texelFetch-{2}'.format(
+                        version, stage, sampler)] = concurrent_test(
+                        'texelFetch 140 {0} {1}'.format(stage, sampler))
+                spec['glsl-{0}/execution/texelFetchOffset/{1}-{2}'.format(
+                        version, stage, sampler)] = concurrent_test(
+                        'texelFetch offset 140 {0} {1}'.format(stage, sampler))
 
 spec['glsl-1.50'] = Group()
 import_glsl_parser_tests(spec['glsl-1.50'],
diff --git a/tests/texturing/shaders/common.c b/tests/texturing/shaders/common.c
index dba578a..0b13d47 100644
--- a/tests/texturing/shaders/common.c
+++ b/tests/texturing/shaders/common.c
@@ -333,9 +333,6 @@ 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 71f2b5e..f499237 100644
--- a/tests/texturing/shaders/texelFetch.c
+++ b/tests/texturing/shaders/texelFetch.c
@@ -78,10 +78,20 @@
  */
 #include "common.h"
 
+void
+parse_args(int argc, char **argv);
+static enum shader_target test_stage = UNKNOWN;
+
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
-	config.supports_gl_compat_version = 10;
-	config.supports_gl_core_version = 31;
+	parse_args(argc, argv);
+	if (test_stage == GS) {
+		config.supports_gl_compat_version = 32;
+		config.supports_gl_core_version = 32;
+	} else {
+		config.supports_gl_compat_version = 10;
+		config.supports_gl_core_version = 31;
+	}
 
 	config.window_width = 355;
 	config.window_height = 350;
@@ -636,9 +646,10 @@ generate_GLSL(enum shader_target test_stage)
 			 shader_version);
 		asprintf(&gs_code,
 			 "#version %d\n"
-			 "#extension GL_ARB_geometry_shader4: require\n"
 			 "%s\n"
 			 "#define ivec1 int\n"
+			 "layout(points) in;\n"
+			 "layout(points, max_vertices = 1) out;\n"
 			 "flat out %s color;\n"
 			 "flat in ivec4 texcoord_to_gs[1];\n"
 			 "uniform %s tex;\n"
@@ -726,12 +737,8 @@ generate_GLSL(enum shader_target test_stage)
 	}
 	prog = glCreateProgram();
 	glAttachShader(prog, vs);
-	if (gs_code) {
+	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");
@@ -783,15 +790,15 @@ fail_and_show_usage()
 	piglit_report_result(PIGLIT_FAIL);
 }
 
+
 void
-piglit_init(int argc, char **argv)
+parse_args(int argc, char **argv)
 {
-	int prog;
-	int tex_location;
 	int i;
-	enum shader_target test_stage = UNKNOWN;
 	bool sampler_found = false;
 
+	sample_count = 0;
+
 	for (i = 1; i < argc; i++) {
 		if (test_stage == UNKNOWN) {
 			/* Maybe it's the shader stage? */
@@ -821,20 +828,12 @@ piglit_init(int argc, char **argv)
 		if (!sampler_found && (sampler_found = select_sampler(argv[i])))
 			continue;
 
-        /* Maybe it's the sample count? */
-        if (sampler_found && has_samples() && !sample_count) {
-            if ((sample_count = atoi(argv[i]))) {
-                /* check it */
-                GLint max_samples;
-                glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
-                if (sample_count > max_samples) {
-                    printf("Sample count of %d not supported, >MAX_SAMPLES\n",
-                            sample_count);
-                    piglit_report_result(PIGLIT_SKIP);
-                }
-            }
-            continue;
-        }
+		/* Maybe it's the sample count? */
+		if (sampler_found && has_samples() && !sample_count) {
+			sample_count = atoi(argv[i]);
+
+			continue;
+		}
 
 		if (!swizzling && (swizzling = parse_swizzle(argv[i])))
 			continue;
@@ -845,6 +844,17 @@ piglit_init(int argc, char **argv)
 	if (test_stage == UNKNOWN || !sampler_found)
 		fail_and_show_usage();
 
+	if (test_stage == GS && shader_version < 150)
+		shader_version = 150;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	int prog;
+	int tex_location;
+
 	if (!supported_sampler()) {
 		printf("%s unsupported\n", sampler.name);
 		piglit_report_result(PIGLIT_FAIL);
@@ -852,6 +862,17 @@ piglit_init(int argc, char **argv)
 
 	require_GL_features(test_stage);
 
+	if (sample_count) {
+                /* check it */
+                GLint max_samples;
+                glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
+                if (sample_count > max_samples) {
+			printf("Sample count of %d not supported, >MAX_SAMPLES\n",
+			       sample_count);
+			piglit_report_result(PIGLIT_SKIP);
+                }
+	}
+
 	prog = generate_GLSL(test_stage);
 
 	tex_location = glGetUniformLocation(prog, "tex");
diff --git a/tests/texturing/shaders/textureSize.c b/tests/texturing/shaders/textureSize.c
index 05187a3..fda15c4 100644
--- a/tests/texturing/shaders/textureSize.c
+++ b/tests/texturing/shaders/textureSize.c
@@ -46,10 +46,20 @@
  */
 #include "common.h"
 
+void
+parse_args(int argc, char **argv);
+static enum shader_target test_stage = UNKNOWN;
+
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
-	config.supports_gl_compat_version = 10;
-	config.supports_gl_core_version = 31;
+	parse_args(argc, argv);
+	if (test_stage == GS) {
+		config.supports_gl_compat_version = 32;
+		config.supports_gl_core_version = 32;
+	} else {
+		config.supports_gl_compat_version = 10;
+		config.supports_gl_core_version = 31;
+	}
 
 	config.window_width = 150;
 	config.window_height = 30;
@@ -289,9 +299,10 @@ generate_GLSL(enum shader_target test_stage)
 			 shader_version);
 		asprintf(&gs_code,
 			 "#version %d\n"
-			 "#extension GL_ARB_geometry_shader4: require\n"
 			 "%s\n"
 			 "#define ivec1 int\n"
+			 "layout(triangles) in;\n"
+			 "layout(triangle_strip, max_vertices = 3) out;\n"
 			 "uniform int lod;\n"
 			 "uniform %s tex;\n"
 			 "flat out ivec%d size;\n"
@@ -354,14 +365,8 @@ generate_GLSL(enum shader_target test_stage)
 
 	prog = glCreateProgram();
 	glAttachShader(prog, vs);
-	if (gs_code) {
+	if (gs_code)
 		glAttachShader(prog, gs);
-		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);
-	}
 	glAttachShader(prog, fs);
 	glLinkProgram(prog);
 	if (!piglit_link_check_status(prog))
@@ -377,13 +382,11 @@ fail_and_show_usage()
 	piglit_report_result(PIGLIT_SKIP);
 }
 
+
 void
-piglit_init(int argc, char **argv)
+parse_args(int argc, char **argv)
 {
-	int prog;
-	int tex_location;
 	int i;
-	enum shader_target test_stage = UNKNOWN;
 	bool sampler_found = false;
 
 	for (i = 1; i < argc; i++) {
@@ -415,7 +418,18 @@ piglit_init(int argc, char **argv)
 
 	if (test_stage == UNKNOWN || !sampler_found)
 		fail_and_show_usage();
-		
+
+	if (test_stage == GS && shader_version < 150)
+		shader_version = 150;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	int prog;
+	int tex_location;
+
 	require_GL_features(test_stage);
 
 	if (sampler.target == GL_TEXTURE_CUBE_MAP_ARRAY)
-- 
1.8.3.4



More information about the Piglit mailing list