[Piglit] [PATCH] arb_fb_no_attach: Test with an odd sample count

Neil Roberts neil at linux.intel.com
Wed Feb 3 19:04:49 CET 2016


Adds a test that creates a framebuffer with no attachments and sets
the default sample count to 3. It then verifies that GL_SAMPLES for
the fbo is at least 3. It also checks the value of gl_NumSamples in
the shader by doing an image store with the value to verify that it
has the same value.

Currently using multisampling with no attachments seems to break the
i965 driver in Mesa.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93957
Cc: Ilia Mirkin <imirkin at alum.mit.edu>
---
 tests/all.py                                       |   1 +
 .../CMakeLists.gl.txt                              |   1 +
 .../roundup-samples.c                              | 173 +++++++++++++++++++++
 3 files changed, 175 insertions(+)
 create mode 100644 tests/spec/arb_framebuffer_no_attachments/roundup-samples.c

diff --git a/tests/all.py b/tests/all.py
index 59f20fa..2912d1f 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2425,6 +2425,7 @@ with profile.group_manager(
     g(['arb_framebuffer_no_attachments-params'])
     g(['arb_framebuffer_no_attachments-atomic'])
     g(['arb_framebuffer_no_attachments-query'])
+    g(['arb_framebuffer_no_attachments-roundup-samples'])
 
 # Group ARB_explicit_uniform_location
 with profile.group_manager(
diff --git a/tests/spec/arb_framebuffer_no_attachments/CMakeLists.gl.txt b/tests/spec/arb_framebuffer_no_attachments/CMakeLists.gl.txt
index bbc3177..38fc9e1 100755
--- a/tests/spec/arb_framebuffer_no_attachments/CMakeLists.gl.txt
+++ b/tests/spec/arb_framebuffer_no_attachments/CMakeLists.gl.txt
@@ -12,3 +12,4 @@ piglit_add_executable (arb_framebuffer_no_attachments-minmax minmax.c)
 piglit_add_executable (arb_framebuffer_no_attachments-params params.c)
 piglit_add_executable (arb_framebuffer_no_attachments-atomic atomic.c)
 piglit_add_executable (arb_framebuffer_no_attachments-query query.c)
+piglit_add_executable (arb_framebuffer_no_attachments-roundup-samples roundup-samples.c)
diff --git a/tests/spec/arb_framebuffer_no_attachments/roundup-samples.c b/tests/spec/arb_framebuffer_no_attachments/roundup-samples.c
new file mode 100644
index 0000000..8fecc9c
--- /dev/null
+++ b/tests/spec/arb_framebuffer_no_attachments/roundup-samples.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * \file roundup-samples.c
+ *
+ * Tests that requesting an odd number of samples doesn't break
+ * anything. The implementation should round this up to the next
+ * supported value. Technically the implementation is probably allowed
+ * to support the odd number of samples so it doesn't report this as a
+ * failure.
+ *
+ * Bug #93957
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 31;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+#define REQUEST_N_SAMPLES 3
+
+const char *vs_source =
+	"#version 140\n"
+	"\n"
+	"in vec4 piglit_vertex;\n"
+	"\n"
+	"void\n"
+	"main()\n"
+	"{\n"
+	"        gl_Position = piglit_vertex;\n"
+	"}\n";
+
+const char *fs_source =
+	"#version 140\n"
+	"#extension GL_ARB_sample_shading : require\n"
+	"#extension GL_ARB_shader_image_load_store : require\n"
+	"\n"
+	"writeonly uniform uimage2D img;\n"
+	"\n"
+	"void\n"
+	"main()\n"
+	"{\n"
+	"        imageStore(img,\n"
+	"                   ivec2(gl_FragCoord.xy),\n"
+	"                   uvec4(gl_NumSamples));\n"
+	"}\n";
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint fbo;
+	GLint prog;
+	GLuint tex;
+	bool pass = true;
+	uint32_t *tex_data;
+	GLint actual_n_samples;
+
+	piglit_require_gl_version(31);
+	piglit_require_extension("GL_ARB_framebuffer_no_attachments");
+	piglit_require_extension("GL_ARB_shader_image_load_store");
+	piglit_require_extension("GL_ARB_sample_shading");
+
+	/* Create fbo with no attachments. */
+	glGenFramebuffers(1, &fbo);
+	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+	/* Setup default width, height and number of samples */
+	glFramebufferParameteri(GL_FRAMEBUFFER,
+				GL_FRAMEBUFFER_DEFAULT_WIDTH,
+				piglit_width);
+	glFramebufferParameteri(GL_FRAMEBUFFER,
+				GL_FRAMEBUFFER_DEFAULT_HEIGHT,
+				piglit_height);
+	glFramebufferParameteri(GL_FRAMEBUFFER,
+				GL_FRAMEBUFFER_DEFAULT_SAMPLES,
+				REQUEST_N_SAMPLES);
+
+	/* Check that fbo is marked complete. */
+	if (glCheckFramebufferStatus(GL_FRAMEBUFFER) !=
+	    GL_FRAMEBUFFER_COMPLETE)
+		piglit_report_result(PIGLIT_SKIP);
+
+	glGenTextures(1, &tex);
+	glBindTexture(GL_TEXTURE_2D, tex);
+	glTexImage2D(GL_TEXTURE_2D,
+		     0, /* level */
+		     GL_R32UI,
+		     piglit_width, piglit_height,
+		     0, /* border */
+		     GL_RGBA_INTEGER, GL_UNSIGNED_INT,
+		     NULL /* data */);
+	glBindImageTexture(0, /* unit */
+			   tex,
+			   0, /* level */
+			   GL_FALSE, /* layered */
+			   0, /* layer */
+			   GL_WRITE_ONLY,
+			   GL_R32UI);
+
+	prog = piglit_build_simple_program(vs_source, fs_source);
+
+	glUseProgram(prog);
+
+	piglit_draw_rect(-1, -1, 2, 2);
+
+	glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
+
+	tex_data = malloc(sizeof (*tex_data) * piglit_width * piglit_height);
+	memset(tex_data, 0, sizeof (*tex_data) * piglit_width * piglit_height);
+
+	glGetIntegerv(GL_SAMPLES, &actual_n_samples);
+
+	printf("Requested samples = %i\n"
+	       "glGetIntegerv(GL_SAMPLES) == %i\n",
+	       REQUEST_N_SAMPLES,
+	       actual_n_samples);
+
+	if (actual_n_samples < REQUEST_N_SAMPLES) {
+		printf("FAIL: GL_SAMPLES is too small\n");
+		pass = false;
+	}
+
+	glGetTexImage(GL_TEXTURE_2D,
+		      0, /* level */
+		      GL_RED_INTEGER, GL_UNSIGNED_INT,
+		      tex_data);
+
+	printf("gl_NumSamples from shader == %u\n",
+	       *tex_data);
+
+	if (*tex_data != actual_n_samples) {
+		printf("FAIL: GL_SAMPLES does not match gl_NumSamples\n");
+		pass = false;
+	}
+
+	free(tex_data);
+
+	glDeleteTextures(1, &tex);
+	glDeleteFramebuffers(1, &fbo);
+	glDeleteProgram(prog);
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
2.5.0



More information about the Piglit mailing list