[Piglit] [PATCH 4/4] arb_texture_multisample: multisample texture on fbo color attachment; sample locations V2: updated for new piglit config block

Chris Forbes chrisf at ijw.co.nz
Sat Oct 13 19:55:08 PDT 2012


Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 tests/all.tests                                    |  1 +
 .../spec/arb_texture_multisample/CMakeLists.gl.txt |  1 +
 tests/spec/arb_texture_multisample/queries.c       | 82 ++++++++++++++++++++++
 3 files changed, 84 insertions(+)
 create mode 100644 tests/spec/arb_texture_multisample/queries.c

diff --git a/tests/all.tests b/tests/all.tests
index c6a1004..2ad52cf 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1092,6 +1092,7 @@ arb_texture_multisample = Group()
 spec['ARB_texture_multisample'] = arb_texture_multisample
 add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-binding-2d')
 add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-binding-2d-depth')
+add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-queries')
 
 # Group AMD_shader_stencil_export
 spec['AMD_shader_stencil_export'] = Group()
diff --git a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
index c259403..2fb9741 100644
--- a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
@@ -10,6 +10,7 @@ link_libraries (
 	${OPENGL_glu_LIBRARY}
 )
 
+piglit_add_executable (arb_texture_multisample-queries queries.c)
 piglit_add_executable (arb_texture_multisample-binding-2d binding-2d.c)
 piglit_add_executable (arb_texture_multisample-binding-2d-depth binding-2d-depth.c)
 
diff --git a/tests/spec/arb_texture_multisample/queries.c b/tests/spec/arb_texture_multisample/queries.c
new file mode 100644
index 0000000..8be0ca7
--- /dev/null
+++ b/tests/spec/arb_texture_multisample/queries.c
@@ -0,0 +1,82 @@
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 30;
+
+	config.window_width = 10;
+	config.window_height = 10;
+	config.window_visual = PIGLIT_GL_VISUAL_RGB;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+    return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+    GLint maxSamples;
+    GLuint fb;
+    GLuint color_tex;
+    GLint numSamples, i;
+
+    piglit_require_extension("GL_ARB_texture_multisample");
+
+    glGetIntegerv( GL_MAX_SAMPLES, &maxSamples );
+
+    /* create fbo */
+    glGenFramebuffers(1, &fb);
+    glBindFramebuffer(GL_FRAMEBUFFER, fb);
+
+    /* allocate multisample texture surface --
+        first special thing in this ext */
+    glGenTextures(1, &color_tex);
+    glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, color_tex);
+    glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE,
+        maxSamples, GL_RGBA, 64, 64, GL_TRUE);
+
+    piglit_check_gl_error(GL_NO_ERROR);
+
+    /* verify texture can be attached to fbo */
+    glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, color_tex, 0);
+
+    piglit_check_gl_error(GL_NO_ERROR);
+
+    /* check framebuffer is complete */
+    if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER)) {
+        printf( "Framebuffer not complete\n" );
+        piglit_report_result(PIGLIT_FAIL);
+    }
+
+    /* test getting sample locations */
+    glGetIntegerv( GL_SAMPLES, &numSamples );
+    piglit_check_gl_error(GL_NO_ERROR);
+
+    /* verify that we got the number of samples we expected */
+    if (numSamples != maxSamples) {
+        printf( "Given different number of samples than expected.\n"
+                "Should have errored.\n" );
+        piglit_report_result(PIGLIT_FAIL);
+    }
+
+    /* verify that we can get the sample positions */
+    for(i = 0; i < numSamples; i++) {
+        float samplePos[2];
+        glGetMultisamplefv( GL_SAMPLE_POSITION, i, samplePos );
+        piglit_check_gl_error(GL_NO_ERROR);
+        printf( "Sample %d position %2.2f %2.2f\n",
+            i, samplePos[0], samplePos[1] );
+
+        if (samplePos[0] < 0 || samplePos[0] > 1 ||
+            samplePos[1] < 0 || samplePos[1] > 1) {
+            printf( "Sample %d out of range\n", i );
+            piglit_report_result(PIGLIT_FAIL);
+        }
+    }
+
+    piglit_report_result(PIGLIT_PASS);
+}
-- 
1.7.12.3



More information about the Piglit mailing list