[Piglit] [PATCH 1/3] arb_texture_multisample: don't use hard-coded sample counts

Brian Paul brianp at vmware.com
Tue Dec 5 16:43:35 UTC 2017


Instead of using a fixed number of samples, query the
GL_MAX_COLOR_TEXTURE_SAMPLES or GL_MAX_DEPTH_TEXTURE_SAMPLES value
and use those.

Fixes failures with llvmpipe and VMware driver when MSAA is disabled.
---
 tests/spec/arb_texture_multisample/errors.c        | 10 +++++++++-
 tests/spec/arb_texture_multisample/sample-depth.c  | 12 +++++++----
 tests/spec/arb_texture_multisample/stencil-clear.c | 23 +++++++++++++---------
 .../teximage-2d-multisample.c                      | 13 ++++++++----
 .../teximage-3d-multisample.c                      | 13 ++++++++----
 5 files changed, 49 insertions(+), 22 deletions(-)

diff --git a/tests/spec/arb_texture_multisample/errors.c b/tests/spec/arb_texture_multisample/errors.c
index 42cc2c1..08e1696 100644
--- a/tests/spec/arb_texture_multisample/errors.c
+++ b/tests/spec/arb_texture_multisample/errors.c
@@ -44,6 +44,14 @@ piglit_init(int argc, char **argv)
 
     GLuint fbo;
     GLuint tex[2];
+    GLint max_samples;
+
+    glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &max_samples);
+    if (max_samples < 1) {
+       printf("GL_MAX_COLOR_TEXTURE_SAMPLES must be at least one\n");
+       piglit_report_result(PIGLIT_FAIL);
+    }
+
     glGenFramebuffers(1, &fbo);
 
     glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@@ -51,7 +59,7 @@ piglit_init(int argc, char **argv)
     glGenTextures(2, tex);
     glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, tex[0]);
     glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY,
-            4, GL_RGBA, 64, 64, 2, GL_TRUE);
+            max_samples, GL_RGBA, 64, 64, 2, GL_TRUE);
 
     if (!piglit_check_gl_error(GL_NO_ERROR)) {
         printf("should be no error so far\n");
diff --git a/tests/spec/arb_texture_multisample/sample-depth.c b/tests/spec/arb_texture_multisample/sample-depth.c
index ef2be19..94bc63d 100644
--- a/tests/spec/arb_texture_multisample/sample-depth.c
+++ b/tests/spec/arb_texture_multisample/sample-depth.c
@@ -38,7 +38,6 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 PIGLIT_GL_TEST_CONFIG_END
 
-#define NUM_SAMPLES 4
 #define TEX_WIDTH 64
 #define TEX_HEIGHT 64
 
@@ -93,16 +92,21 @@ void
 piglit_init(int argc, char **argv)
 {
 	GLuint tex;
+	int num_samples;
+
 	piglit_require_extension("GL_ARB_texture_multisample");
 
+	/* Use the max number of samples for testing */
+	glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &num_samples);
+
 	/* setup an fbo with multisample depth texture */
 
 	glGenTextures(1, &tex);
 	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
 	glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE,
-			NUM_SAMPLES, GL_DEPTH_COMPONENT24,
-			TEX_WIDTH, TEX_HEIGHT,
-			GL_TRUE);
+				num_samples, GL_DEPTH_COMPONENT24,
+				TEX_WIDTH, TEX_HEIGHT,
+				GL_TRUE);
 
 	glGenFramebuffers(1, &fbo);
 	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
diff --git a/tests/spec/arb_texture_multisample/stencil-clear.c b/tests/spec/arb_texture_multisample/stencil-clear.c
index ca0fd81..413aa41 100644
--- a/tests/spec/arb_texture_multisample/stencil-clear.c
+++ b/tests/spec/arb_texture_multisample/stencil-clear.c
@@ -108,7 +108,7 @@ piglit_display(void)
 	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
 }
 
-GLuint create_fbo(unsigned num_samples)
+GLuint create_fbo(unsigned num_color_samples, unsigned num_depth_samples)
 {
 	GLenum tex_target;
 	GLuint texColor;
@@ -119,17 +119,17 @@ GLuint create_fbo(unsigned num_samples)
 	glGenTextures(1, &texColor);
 	glGenTextures(1, &texZS);
 
-	if (num_samples != 0) {
+	if (num_color_samples != 0) {
 		tex_target = GL_TEXTURE_2D_MULTISAMPLE;
 
 		glBindTexture(tex_target, texZS);
 		glTexImage2DMultisample(
-			tex_target, num_samples, GL_DEPTH32F_STENCIL8,
+			tex_target, num_depth_samples, GL_DEPTH32F_STENCIL8,
 			TEX_WIDTH, TEX_HEIGHT, GL_TRUE);
 
 		glBindTexture(tex_target, texColor);
 		glTexImage2DMultisample(
-			tex_target, num_samples, GL_RGBA8,
+			tex_target, num_color_samples, GL_RGBA8,
 			TEX_WIDTH, TEX_HEIGHT, GL_TRUE);
 	} else {
 		tex_target = GL_TEXTURE_2D;
@@ -167,22 +167,27 @@ GLuint create_fbo(unsigned num_samples)
 void
 piglit_init(int argc, char **argv)
 {
-	unsigned num_samples = 4;
+	GLint num_color_samples, num_depth_samples;
 
 	piglit_require_extension("GL_ARB_texture_multisample");
 
+	/* By default, se the max number of samples for testing */
+	glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &num_color_samples);
+	glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &num_depth_samples);
+
 	for (int i = 1; i < argc; ++i) {
 		if (!strcmp(argv[i], "samples")) {
 			++i;
 			if (i >= argc)
 				usage();
-			num_samples = atoi(argv[i]);
+			num_color_samples = num_depth_samples = atoi(argv[i]);
 		} else
 			usage();
 	}
 
-	printf("Number of samples: %u\n", num_samples);
+	printf("Number of color samples: %u  depth samples: %d\n",
+	       num_color_samples, num_depth_samples);
 
-	fbo = create_fbo(num_samples);
-	fbo_copy = create_fbo(0);
+	fbo = create_fbo(num_color_samples, num_depth_samples);
+	fbo_copy = create_fbo(0, 0);
 }
diff --git a/tests/spec/arb_texture_multisample/teximage-2d-multisample.c b/tests/spec/arb_texture_multisample/teximage-2d-multisample.c
index 8063a78..0f6cb4c 100644
--- a/tests/spec/arb_texture_multisample/teximage-2d-multisample.c
+++ b/tests/spec/arb_texture_multisample/teximage-2d-multisample.c
@@ -40,28 +40,33 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 PIGLIT_GL_TEST_CONFIG_END
 
+
 void
 piglit_init(int argc, char **argv)
 {
 	bool pass = true;
 	GLuint textures[3];
+	GLint num_samples;
 
 	if(piglit_get_gl_version() < 32) {
 		piglit_require_extension("GL_ARB_texture_multisample");
 	}
 
+	/* Use the max number of samples for testing */
+	glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &num_samples);
+
 	glGenTextures(3, textures);
 
 	/* Pass a Texture 2D Multisample */
 	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures[0]);
-	glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGB,
-				1024, 1024, GL_FALSE);
+	glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, num_samples,
+				GL_RGB, 1024, 1024, GL_FALSE);
 	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
 
 	/* Pass a Proxy Texture 2d Multisample */
 	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textures[1]);
-	glTexImage2DMultisample(GL_PROXY_TEXTURE_2D_MULTISAMPLE, 4, GL_RGB,
-				1024, 1024, GL_FALSE);
+	glTexImage2DMultisample(GL_PROXY_TEXTURE_2D_MULTISAMPLE, num_samples,
+				GL_RGB, 1024, 1024, GL_FALSE);
 	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
 
 	/* Pass an Invalid Enum */
diff --git a/tests/spec/arb_texture_multisample/teximage-3d-multisample.c b/tests/spec/arb_texture_multisample/teximage-3d-multisample.c
index 4e6e476..3b60c32 100644
--- a/tests/spec/arb_texture_multisample/teximage-3d-multisample.c
+++ b/tests/spec/arb_texture_multisample/teximage-3d-multisample.c
@@ -45,29 +45,34 @@ piglit_init(int argc, char **argv)
 {
 	bool pass = true;
 	GLuint textures[3];
+	GLint num_samples;
 
 	if(piglit_get_gl_version() < 32) {
 		piglit_require_extension("GL_ARB_texture_multisample");
 	}
 
+	/* Use the max number of samples for testing */
+	glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &num_samples);
+
 	glGenTextures(3, textures);
 
 	/* Pass a Texture Multisample 3D Array */
 	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures[0]);
-	glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 4, GL_RGB,
-				1024, 1024, 4, GL_FALSE);
+	glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, num_samples,
+				GL_RGB, 1024, 1024, 4, GL_FALSE);
 	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
 
 	/* Pass a Proxy Texture 3D Multisample Array */
 	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, textures[1]);
-	glTexImage3DMultisample(GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY, 4, GL_RGB,
+	glTexImage3DMultisample(GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY,
+				num_samples, GL_RGB,
 				1024, 1024, 4, GL_FALSE);
 	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
 
 	/* Pass an Invalid Enum */
 	if (!piglit_khr_no_error) {
 		glBindTexture(GL_TEXTURE_2D, textures[2]);
-		glTexImage3DMultisample(GL_TEXTURE_2D, 4, GL_RGB,
+		glTexImage3DMultisample(GL_TEXTURE_2D, num_samples, GL_RGB,
 					1024, 1024, 4, GL_FALSE);
 		pass = piglit_check_gl_error(GL_INVALID_ENUM) && pass;
 	}
-- 
1.9.1



More information about the Piglit mailing list