[Piglit] [PATCH 3/4] Add a fast clear test for non-MSRT surfaces

Neil Roberts neil at linux.intel.com
Wed Nov 25 09:11:52 PST 2015


ext_framebuffer_multisample-fast-clear can now take a parameter on the
command line to make it test a single-sample buffer instead. This is
worth testing at least on i965 because fast clears are handled
differently when multisampling is not used.
---
 tests/all.py                                       |  15 +++
 .../spec/ext_framebuffer_multisample/fast-clear.c  | 138 +++++++++++++--------
 2 files changed, 102 insertions(+), 51 deletions(-)

diff --git a/tests/all.py b/tests/all.py
index fd07adb..ab9f181 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -135,6 +135,10 @@ def add_fbo_formats_tests(adder, extension, suffix=''):
               'fbo-alphatest-formats{}'.format(suffix))
         adder(['fbo-colormask-formats', extension],
               'fbo-colormask-formats{}'.format(suffix))
+        adder(['ext_framebuffer_multisample-fast-clear',
+               extension,
+               'single-sample'],
+              'fbo-fast-clear{}'.format(suffix))
 
 
 def add_msaa_formats_tests(adder, extension):
@@ -2043,6 +2047,11 @@ with profile.group_manager(
        'GL_EXT_texture_sRGB',
        'enable-fb-srgb'],
       'msaa-fast-clear')
+    g(['ext_framebuffer_multisample-fast-clear',
+       'GL_EXT_texture_sRGB',
+       'enable-fb-srgb',
+       'single-sample'],
+      'fbo-fast-clear')
 
 with profile.group_manager(
         PiglitGLTest,
@@ -2937,6 +2946,8 @@ with profile.group_manager(
     g(['fbo-storage-completeness'])
     g(['fbo-storage-formats'])
     g(['getteximage-formats', 'init-by-rendering'])
+    g(['ext_framebuffer_multisample-fast-clear', 'single-sample'],
+      'fbo-fast-clear')
     add_fbo_stencil_tests(g, 'GL_STENCIL_INDEX1')
     add_fbo_stencil_tests(g, 'GL_STENCIL_INDEX4')
     add_fbo_stencil_tests(g, 'GL_STENCIL_INDEX8')
@@ -3241,6 +3252,10 @@ with profile.group_manager(
     #   'fbo-blending-formats')
     g(['fbo-alphatest-formats', 'GL_EXT_texture_sRGB'],
       'fbo-alphatest-formats')
+    g(['ext_framebuffer_multisample-fast-clear',
+       'GL_EXT_texture_sRGB',
+       'single-sample'],
+      'fbo-fast-clear')
     add_msaa_formats_tests(g, 'GL_EXT_texture_sRGB')
     add_texwrap_format_tests(g, 'GL_EXT_texture_sRGB')
     add_texwrap_format_tests(g, 'GL_EXT_texture_sRGB-s3tc', '-s3tc')
diff --git a/tests/spec/ext_framebuffer_multisample/fast-clear.c b/tests/spec/ext_framebuffer_multisample/fast-clear.c
index 5935b2f..fc745da 100644
--- a/tests/spec/ext_framebuffer_multisample/fast-clear.c
+++ b/tests/spec/ext_framebuffer_multisample/fast-clear.c
@@ -40,6 +40,7 @@
  *    before clearing the buffer so that it can test that the color
  *    gets correctly converted to SRGB before being stored in the
  *    color buffer.
+ *  single-sample: A single sample texture will be created instead.
  */
 
 #include "piglit-util-gl.h"
@@ -64,9 +65,10 @@ vertex_source[] =
 
 static const char
 fragment_source_float[] =
-	"#extension GL_ARB_texture_multisample : require\n"
+	"#version 130\n"
+	"%s\n"
 	"\n"
-	"uniform sampler2DMS tex;\n"
+	"uniform %s tex;\n"
 	"\n"
 	"void\n"
 	"main()\n"
@@ -77,9 +79,9 @@ fragment_source_float[] =
 static const char
 fragment_source_int[] =
 	"#version 130\n"
-	"#extension GL_ARB_texture_multisample : require\n"
+	"%s\n"
 	"\n"
-	"uniform isampler2DMS tex;\n"
+	"uniform i%s tex;\n"
 	"\n"
 	"void\n"
 	"main()\n"
@@ -90,9 +92,9 @@ fragment_source_int[] =
 static const char
 fragment_source_uint[] =
 	"#version 130\n"
-	"#extension GL_ARB_texture_multisample : require\n"
+	"%s\n"
 	"\n"
-	"uniform usampler2DMS tex;\n"
+	"uniform u%s tex;\n"
 	"\n"
 	"void\n"
 	"main()\n"
@@ -129,6 +131,7 @@ struct component_sizes {
 static GLuint prog_float, prog_int, prog_uint;
 static GLuint result_fbo;
 static bool enable_fb_srgb = false;
+static bool single_sample = false;
 
 static void
 convert_srgb_color(const struct format_desc *format,
@@ -318,6 +321,7 @@ test_format(const struct format_desc *format)
 	enum piglit_result color_result;
 	struct component_sizes sizes;
 	GLenum type_param;
+	GLenum tex_target;
 	GLenum tex_error;
 	GLint type;
 	GLuint tex;
@@ -333,47 +337,71 @@ test_format(const struct format_desc *format)
 
 	printf("Testing %s\n", format->name);
 
-	glGenTextures(1, &tex);
-	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
-
-	piglit_reset_gl_error();
-
-	glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE,
-				1, /* samples */
-				format->internalformat,
-				1, 1, /* width/height */
-				GL_FALSE /* fixed sample locations */);
-
-	tex_error = glGetError();
+	if (single_sample)
+		tex_target = GL_TEXTURE_2D;
+	else
+		tex_target = GL_TEXTURE_2D_MULTISAMPLE;
 
-	if (tex_error != GL_NO_ERROR) {
-		glDeleteTextures(1, &tex);
-
-		if (tex_error == GL_INVALID_ENUM) {
-			/* You're only supposed to pass color renderable
-			 * formats to glTexImage2DMultisample.
-			 */
-			printf("Format is not color renderable\n");
-			return PIGLIT_SKIP;
-		} else {
-			printf("Unexpected GL error: %s 0x%x\n",
-			       piglit_get_gl_error_name(tex_error),
-			       tex_error);
-			return PIGLIT_FAIL;
+	glGenTextures(1, &tex);
+	glBindTexture(tex_target, tex);
+
+	if (single_sample) {
+		glTexParameteri(tex_target,
+				GL_TEXTURE_MAG_FILTER,
+				GL_NEAREST);
+		glTexParameteri(tex_target,
+				GL_TEXTURE_MIN_FILTER,
+				GL_NEAREST);
+		glTexParameteri(tex_target,
+				GL_TEXTURE_MAX_LEVEL,
+				0);
+		glTexImage2D(tex_target,
+			     0, /* level */
+			     format->internalformat,
+			     128, 128, /* width/height */
+			     0, /* border */
+			     GL_RGBA, GL_UNSIGNED_BYTE,
+			     NULL);
+	} else {
+		piglit_reset_gl_error();
+
+		glTexImage2DMultisample(tex_target,
+					2, /* samples */
+					format->internalformat,
+					128, 128, /* width/height */
+					GL_FALSE /* fixed sample locations */);
+		tex_error = glGetError();
+
+		if (tex_error != GL_NO_ERROR) {
+			glDeleteTextures(1, &tex);
+
+			if (tex_error == GL_INVALID_ENUM) {
+				/* You're only supposed to pass color
+				 * renderable formats to
+				 * glTexImage2DMultisample.
+				 */
+				printf("Format is not color renderable\n");
+				return PIGLIT_SKIP;
+			} else {
+				printf("Unexpected GL error: %s 0x%x\n",
+				       piglit_get_gl_error_name(tex_error),
+				       tex_error);
+				return PIGLIT_FAIL;
+			}
 		}
 	}
 
-	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0,
+	glGetTexLevelParameteriv(tex_target, 0,
 				 GL_TEXTURE_LUMINANCE_SIZE, &sizes.l);
-	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0,
+	glGetTexLevelParameteriv(tex_target, 0,
 				 GL_TEXTURE_ALPHA_SIZE, &sizes.a);
-	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0,
+	glGetTexLevelParameteriv(tex_target, 0,
 				 GL_TEXTURE_INTENSITY_SIZE, &sizes.i);
-	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0,
+	glGetTexLevelParameteriv(tex_target, 0,
 				 GL_TEXTURE_RED_SIZE, &sizes.r);
-	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0,
+	glGetTexLevelParameteriv(tex_target, 0,
 				 GL_TEXTURE_GREEN_SIZE, &sizes.g);
-	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0,
+	glGetTexLevelParameteriv(tex_target, 0,
 				 GL_TEXTURE_BLUE_SIZE, &sizes.b);
 
 	if (sizes.l > 0)
@@ -388,7 +416,7 @@ test_format(const struct format_desc *format)
 		assert(0);
 		type_param = GL_NONE;
 	}
-	glGetTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE,
+	glGetTexLevelParameteriv(tex_target,
 				 0, /* level */
 				 type_param,
 				 &type);
@@ -424,7 +452,7 @@ test_format(const struct format_desc *format)
 	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
 	glFramebufferTexture2D(GL_FRAMEBUFFER,
 			       GL_COLOR_ATTACHMENT0,
-			       GL_TEXTURE_2D_MULTISAMPLE,
+			       tex_target,
 			       tex,
 			       0);
 	if (glCheckFramebufferStatus(GL_FRAMEBUFFER) ==
@@ -462,8 +490,19 @@ build_program(const char *fragment_source)
 {
 	GLint tex_location;
 	GLuint prog;
+	char *source;
+
+	asprintf(&source,
+		 fragment_source,
+		 single_sample ?
+		 "" :
+		 "#extension GL_ARB_texture_multisample : require\n",
+		 single_sample ? "sampler2D" : "sampler2DMS");
+
+	prog = piglit_build_simple_program(vertex_source, source);
+
+	free(source);
 
-	prog = piglit_build_simple_program(vertex_source, fragment_source);
 	glUseProgram(prog);
 	tex_location = glGetUniformLocation(prog, "tex");
 	glUniform1i(tex_location, 0);
@@ -475,22 +514,24 @@ void
 piglit_init(int argc, char **argv)
 {
 	int test_set_index = 0;
-	int glsl_major, glsl_minor;
 	GLuint rb;
-	bool es;
 	int i;
 
 	for (i = 1; i < argc; i++) {
 		if (!strcmp(argv[i], "enable-fb-srgb")) {
 			enable_fb_srgb = true;
 			piglit_require_extension("GL_ARB_framebuffer_sRGB");
+		} else if (!strcmp(argv[i], "single-sample")) {
+			single_sample = true;
 		} else {
 			test_set_index = fbo_lookup_test_set(argv[i]);
 		}
 	}
 
-	piglit_require_extension("GL_ARB_texture_multisample");
+	if (!single_sample)
+		piglit_require_extension("GL_ARB_texture_multisample");
 	piglit_require_extension("GL_ARB_texture_float");
+	piglit_require_GLSL_version(130);
 
 	test_set = test_set + test_set_index;
 
@@ -519,11 +560,6 @@ piglit_init(int argc, char **argv)
 	glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo);
 
 	prog_float = build_program(fragment_source_float);
-
-	piglit_get_glsl_version(&es, &glsl_major, &glsl_minor);
-
-	if (!es && (glsl_major > 1 || (glsl_major == 1 && glsl_minor >= 3))) {
-		prog_int = build_program(fragment_source_int);
-		prog_uint = build_program(fragment_source_uint);
-	}
+	prog_int = build_program(fragment_source_int);
+	prog_uint = build_program(fragment_source_uint);
 }
-- 
1.9.3



More information about the Piglit mailing list