diff options
author | Roland Scheidegger <sroland@vmware.com> | 2018-01-01 02:39:54 +0100 |
---|---|---|
committer | Roland Scheidegger <sroland@vmware.com> | 2018-01-04 04:30:41 +0100 |
commit | 119cf8df354c6cca60d6c5a36493ec650dc2e07f (patch) | |
tree | 23be1afd738ee31207e32b4c9bdf257cb25889dd | |
parent | 03887bf7d2dafd1a81a41e702399b7c7ef575e7f (diff) |
textureSize: add ability to test tess eval stage
This is a problem of all texturing tests, they cannot exercise the tesselation
stages. (But I'm too lazy to fix the others, and too lazy to hack something up
for tcs stage, I only need it to verify a bug/fix with r600 buffer textures.)
v2: add to all.py so it is actually run (all in all there's about 40
addtional tests run)
Reviewed-by: Fabian Bieler <fabianbieler@fastmail.fm>
-rw-r--r-- | tests/all.py | 13 | ||||
-rw-r--r-- | tests/texturing/shaders/common.c | 3 | ||||
-rw-r--r-- | tests/texturing/shaders/common.h | 3 | ||||
-rw-r--r-- | tests/texturing/shaders/textureSize.c | 76 |
4 files changed, 84 insertions, 11 deletions
diff --git a/tests/all.py b/tests/all.py index a9a0528cd..ac1947ca4 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1491,8 +1491,8 @@ with profile.test_list.group_manager( textureSize_samplers_140 = textureSize_samplers_130 + [ 'sampler2DRect', 'isampler2DRect', 'sampler2DRectShadow', 'samplerBuffer', 'isamplerBuffer', 'usamplerBuffer'] -for stage in ['vs', 'gs', 'fs']: - if stage == 'gs': +for stage in ['vs', 'gs', 'fs', 'tes']: + if stage == 'gs' or stage == 'tes': version = '1.50' else: version = '1.40' @@ -1502,6 +1502,11 @@ for stage in ['vs', 'gs', 'fs']: 'spec', 'glsl-{}'.format(version), 'execution', 'textureSize', '{}-textureSize-{}'.format(stage, sampler))] = PiglitGLTest( ['textureSize', '140', stage, sampler]) +for stage in ['vs', 'gs', 'fs']: + if stage == 'gs': + version = '1.50' + else: + version = '1.40' # texelFetch(): for sampler in ['sampler2DRect', 'usampler2DRect', 'isampler2DRect']: profile.test_list[grouptools.join( @@ -1711,7 +1716,7 @@ with profile.test_list.group_manager( grouptools.join('spec', 'ARB_texture_multisample', 'textureSize')) as g: - stages = ['vs', 'gs', 'fs'] + stages = ['vs', 'gs', 'fs', 'tes'] for stage, sampler in itertools.product(stages, samplers_atm): g(['textureSize', stage, sampler], '{}-textureSize-{}'.format(stage, sampler)) @@ -3199,7 +3204,7 @@ with profile.test_list.group_manager( g(['fbo-generatemipmap-cubemap', 'array', 'S3TC_DXT1']) g(['texsubimage', 'cube_map_array']) - for stage in ['vs', 'gs', 'fs']: + for stage in ['vs', 'gs', 'fs', 'tes']: # textureSize(): for sampler in['samplerCubeArray', 'isamplerCubeArray', 'usamplerCubeArray', 'samplerCubeArrayShadow']: diff --git a/tests/texturing/shaders/common.c b/tests/texturing/shaders/common.c index b377bbcae..bda149971 100644 --- a/tests/texturing/shaders/common.c +++ b/tests/texturing/shaders/common.c @@ -378,6 +378,9 @@ require_GL_features(enum shader_target test_stage) glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &tex_units); if (test_stage == VS && tex_units <= 0) piglit_report_result(PIGLIT_SKIP); + + if (test_stage == TES) + piglit_require_extension("GL_ARB_tessellation_shader"); } /** diff --git a/tests/texturing/shaders/common.h b/tests/texturing/shaders/common.h index 49f38e8b5..3edc68bff 100644 --- a/tests/texturing/shaders/common.h +++ b/tests/texturing/shaders/common.h @@ -91,7 +91,8 @@ enum shader_target { UNKNOWN, VS, FS, - GS + GS, + TES, }; float max2(float x, float y); diff --git a/tests/texturing/shaders/textureSize.c b/tests/texturing/shaders/textureSize.c index 2693633fb..3035e0505 100644 --- a/tests/texturing/shaders/textureSize.c +++ b/tests/texturing/shaders/textureSize.c @@ -60,7 +60,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN piglit_gl_process_args(&argc, argv, &config); parse_args(argc, argv); - if (test_stage == GS) { + if (test_stage == GS || test_stage == TES) { config.supports_gl_compat_version = 32; config.supports_gl_core_version = 32; } else { @@ -154,7 +154,7 @@ piglit_display() glUniform1i(lod_location, l); glViewport(x, 10, 10, 10); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glDrawArrays(test_stage == TES ? GL_PATCHES : GL_TRIANGLE_FAN, 0, 4); pass &= piglit_probe_rect_rgba(x, 10, 10, 10, expected_color); } @@ -248,12 +248,14 @@ has_lod(void) int generate_GLSL(enum shader_target test_stage) { - int vs, gs = 0, fs; + int vs, gs = 0, tes = 0, tcs = 0, fs; int prog; static char *vs_code; static char *gs_code = NULL; static char *fs_code; + static char *tes_code = NULL; + static char *tcs_code = NULL; char *lod_arg; static const char *zeroes[3] = { "", "0, ", "0, 0, " }; @@ -357,6 +359,55 @@ generate_GLSL(enum shader_target test_stage) shader_version, extension, sampler.name, size, lod_arg, zeroes[3 - size]); break; + case TES: + (void)!asprintf(&vs_code, + "#version %d\n" + "in vec4 vertex;\n" + "void main()\n" + "{\n" + " gl_Position = vertex;\n" + "}\n", + shader_version); + (void)!asprintf(&tes_code, + "#version %d\n%s" + "#extension GL_ARB_tessellation_shader: require\n" + "#define ivec1 int\n" + "uniform int lod;\n" + "uniform %s tex;\n" + "layout(quads) in;\n" + "flat out ivec%d size;\n" + "void main()\n" + "{\n" + " gl_Position = vec4(gl_TessCoord.x * 2 - 1, gl_TessCoord.y * 2 - 1, 0, 1);\n" + " size = textureSize(tex%s);\n" + "}\n", + shader_version, extension, sampler.name, size, lod_arg); + (void)!asprintf(&tcs_code, + "#version %d\n" + "#extension GL_ARB_tessellation_shader: require\n" + "layout(vertices = 4) out;\n" + "void main()\n" + "{\n" + " gl_TessLevelInner[0] = 1.0;\n" + " gl_TessLevelInner[1] = 1.0;\n" + " gl_TessLevelOuter[0] = 1.0;\n" + " gl_TessLevelOuter[1] = 1.0;\n" + " gl_TessLevelOuter[2] = 1.0;\n" + " gl_TessLevelOuter[3] = 1.0;\n" + "}\n", + shader_version); + (void)!asprintf(&fs_code, + "#version %d\n" + "#define ivec1 int\n" + "#define vec1 float\n" + "flat in ivec%d size;\n" + "out vec4 fragColor;\n" + "void main()\n" + "{\n" + " fragColor = vec4(0.01 * size,%s 1);\n" + "}\n", + shader_version, size, zeroes[3 - size]); + break; default: assert(!"Should not get here."); break; @@ -366,9 +417,15 @@ generate_GLSL(enum shader_target test_stage) if (gs_code) { gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gs_code); } + if (tes_code) { + tes = piglit_compile_shader_text(GL_TESS_EVALUATION_SHADER, tes_code); + } + if (tcs_code) { + tcs = piglit_compile_shader_text(GL_TESS_CONTROL_SHADER, tcs_code); + } fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_code); - if (!vs || (gs_code && !gs) || !fs) + if (!vs || (gs_code && !gs) || (tes_code && !tes) || !fs) return 0; prog = glCreateProgram(); @@ -376,6 +433,10 @@ generate_GLSL(enum shader_target test_stage) if (gs_code) glAttachShader(prog, gs); glAttachShader(prog, fs); + if (tes_code) + glAttachShader(prog, tes); + if (tcs_code) + glAttachShader(prog, tcs); glLinkProgram(prog); if (!piglit_link_check_status(prog)) piglit_report_result(PIGLIT_FAIL); @@ -386,7 +447,7 @@ generate_GLSL(enum shader_target test_stage) void fail_and_show_usage() { - printf("Usage: textureSize [140] <vs|gs|fs> <sampler type> [piglit args...]\n"); + printf("Usage: textureSize [140] <vs|gs|fs|tes> <sampler type> [piglit args...]\n"); piglit_report_result(PIGLIT_SKIP); } @@ -409,6 +470,9 @@ parse_args(int argc, char **argv) } else if (strcmp(argv[i], "fs") == 0) { test_stage = FS; continue; + } else if (strcmp(argv[i], "tes") == 0) { + test_stage = TES; + continue; } } @@ -427,7 +491,7 @@ parse_args(int argc, char **argv) if (test_stage == UNKNOWN || !sampler_found) fail_and_show_usage(); - if (test_stage == GS && shader_version < 150) + if ((test_stage == GS || test_stage == TES) && shader_version < 150) shader_version = 150; } |