[Piglit] [PATCH v2] gs: Make texelFetch and textureSize tests use GLSL 1.50 for geometry shaders.
Paul Berry
stereotype441 at gmail.com
Wed Aug 7 12:09:30 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.
v2: Use a generic vertex attribute instead of gl_PositionIn.
---
tests/all.tests | 37 ++++++++++---
tests/texturing/shaders/common.c | 3 --
tests/texturing/shaders/texelFetch.c | 98 +++++++++++++++++++++--------------
tests/texturing/shaders/textureSize.c | 50 ++++++++++++------
4 files changed, 123 insertions(+), 65 deletions(-)
diff --git a/tests/all.tests b/tests/all.tests
index 2f32120..cf24db6 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 d374c62..ac85e7a 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 549c105..badaac7 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;
@@ -628,25 +638,28 @@ generate_GLSL(enum shader_target test_stage)
"in vec4 pos;\n"
"in ivec4 texcoord;\n"
"flat out ivec4 texcoord_to_gs;\n"
+ "out vec4 pos_to_gs;\n"
"void main()\n"
"{\n"
" texcoord_to_gs = texcoord;\n"
- " gl_Position = pos;\n"
+ " pos_to_gs = pos;\n"
"}\n",
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"
+ "in vec4 pos_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"
+ " gl_Position = pos_to_gs[0];\n"
" EmitVertex();\n"
"}\n",
shader_version,
@@ -726,12 +739,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 +792,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? */
@@ -823,30 +832,8 @@ piglit_init(int argc, char **argv)
/* Maybe it's the sample count? */
if (sampler_found && has_samples() && !sample_count) {
- if ((sample_count = atoi(argv[i]))) {
- /* check it */
- GLint max_samples;
-
- if (sampler.data_type == GL_INT ||
- sampler.data_type == GL_UNSIGNED_INT) {
- glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &max_samples);
- if (sample_count > max_samples) {
- printf("Sample count of %d not supported,"
- " >MAX_INTEGER_SAMPLES\n",
- sample_count);
- piglit_report_result(PIGLIT_SKIP);
- }
- }
- else {
- 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);
- }
- }
- }
+ sample_count = atoi(argv[i]);
+
continue;
}
@@ -859,6 +846,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);
@@ -866,6 +864,30 @@ piglit_init(int argc, char **argv)
require_GL_features(test_stage);
+ if (sample_count) {
+ /* check it */
+ GLint max_samples;
+
+ if (sampler.data_type == GL_INT ||
+ sampler.data_type == GL_UNSIGNED_INT) {
+ glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &max_samples);
+ if (sample_count > max_samples) {
+ printf("Sample count of %d not supported,"
+ " >MAX_INTEGER_SAMPLES\n",
+ sample_count);
+ piglit_report_result(PIGLIT_SKIP);
+ }
+ } else {
+ 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..f010d9c 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;
@@ -282,24 +292,27 @@ generate_GLSL(enum shader_target test_stage)
asprintf(&vs_code,
"#version %d\n"
"in vec4 vertex;\n"
+ "out vec4 pos_to_gs;\n"
"void main()\n"
"{\n"
- " gl_Position = vertex;\n"
+ " pos_to_gs = vertex;\n"
"}\n",
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"
+ "in vec4 pos_to_gs[3];\n"
"flat out ivec%d size;\n"
"void main()\n"
"{\n"
" for (int i = 0; i < 3; i++) {\n"
" size = textureSize(tex%s);\n"
- " gl_Position = gl_PositionIn[i];\n"
+ " gl_Position = pos_to_gs[i];\n"
" EmitVertex();\n"
" }\n"
"}\n",
@@ -354,14 +367,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 +384,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 +420,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