On 03/15/2013 02:13 AM, Chris Forbes wrote:
This covers the sample count limits for both renderbuffers and
multisample textures, when ARB_texture_multisample is supported.

Skips if ARB_internalformat_query is supported, since that extension
allows the overall sample count limits to be exceeded on a
per-internalformat basis.

V2: - Emit a useful message when skipping.

Signed-off-by: Chris Forbes <chr...@ijw.co.nz>
---
  tests/all.tests                                    |   1 +
  .../spec/arb_texture_multisample/CMakeLists.gl.txt |   1 +
  .../arb_texture_multisample/negative-max-samples.c | 130 +++++++++++++++++++++
  3 files changed, 132 insertions(+)
  create mode 100644 tests/spec/arb_texture_multisample/negative-max-samples.c

diff --git a/tests/all.tests b/tests/all.tests
index 20120d1..451aef7 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -898,6 +898,7 @@ add_concurrent_test(arb_texture_multisample, 
'arb_texture_multisample-sample-mas
  add_concurrent_test(arb_texture_multisample, 
'arb_texture_multisample-sample-mask-value')
  add_concurrent_test(arb_texture_multisample, 
'arb_texture_multisample-sample-mask-execution')
  add_concurrent_test(arb_texture_multisample, 
'arb_texture_multisample-sample-mask-execution -tex')
+add_concurrent_test(arb_texture_multisample, 
'arb_texture_multisample-negative-max-samples')
  for stage in ['vs', 'fs']:
        # textureSize():
        for sampler in samplers_atm:
diff --git a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt 
b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
index ce9cb82..1339d62 100644
--- a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
+++ b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
@@ -17,5 +17,6 @@ piglit_add_executable (arb_texture_multisample-texstate 
texstate.c)
  piglit_add_executable (arb_texture_multisample-sample-mask sample-mask.c)
  piglit_add_executable (arb_texture_multisample-sample-mask-value 
sample-mask-value.c)
  piglit_add_executable (arb_texture_multisample-sample-mask-execution 
sample-mask-execution.c)
+piglit_add_executable (arb_texture_multisample-negative-max-samples 
negative-max-samples.c)

  # vim: ft=cmake:
diff --git a/tests/spec/arb_texture_multisample/negative-max-samples.c 
b/tests/spec/arb_texture_multisample/negative-max-samples.c
new file mode 100644
index 0000000..250c89b
--- /dev/null
+++ b/tests/spec/arb_texture_multisample/negative-max-samples.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright © 2013 Chris Forbes
+ *
+ * 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.
+ */
+
+#include "piglit-util-gl-common.h"
+
+/**
+ * @file negative-max-samples.c
+ *
+ * Tests that asking for more than the appropriate sample count limit fails,
+ * with the correct errors.
+ *
+ * See also EXT_framebuffer_multisample/negative-max-samples for the simpler
+ * case prior to ARB_texture_multisample.
+ *
+ * Skips if ARB_internalformat_query is supported -- ARB_internalformat_query 
allows
+ * the limit to be higher for particular internalformats.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+    config.supports_gl_compat_version = 10;
+
+    config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+    /* UNREACHED */
+    return PIGLIT_FAIL;
+}
+
+struct subtest
+{
+    const char *name;
+    int use_texture;
+    GLenum internalformat;
+    GLenum limit;
+    GLenum error;
+} subtests[] =
+{
+    /* multisample textures have separate limits for each of 
color/depth/integer,
+     * all of which must be <= MAX_SAMPLES; GL_INVALID_OPERATION is generated 
if the
+     * limit is exceeded. */
+    { "tex_color", GL_TRUE, GL_RGBA,
+        GL_MAX_COLOR_TEXTURE_SAMPLES, GL_INVALID_OPERATION },
+    { "tex_depth", GL_TRUE, GL_DEPTH_COMPONENT,
+        GL_MAX_DEPTH_TEXTURE_SAMPLES, GL_INVALID_OPERATION },
+    { "tex_integer", GL_TRUE, GL_RGBA16I,
+        GL_MAX_INTEGER_SAMPLES, GL_INVALID_OPERATION },
+
+    /* non-integer formats for renderbuffers are still only checked against
+     * MAX_SAMPLES, and generate GL_INVALID_VALUE if exceeded. */
+    { "rb_color", GL_FALSE, GL_RGBA,
+        GL_MAX_SAMPLES, GL_INVALID_VALUE },
+    { "rb_depth", GL_FALSE, GL_DEPTH_COMPONENT,
+        GL_MAX_SAMPLES, GL_INVALID_VALUE },
+    /* integer formats for renderbuffers are checked against 
MAX_INTEGER_SAMPLES */
+    { "rb_integer", GL_FALSE, GL_RGBA16I,
+        GL_MAX_INTEGER_SAMPLES, GL_INVALID_OPERATION },
+
+    /* sentinel */
+    { 0 },
+};
+
+static void
+check_subtest(struct subtest *t)
+{
+    int limit;
+    glGetIntegerv(t->limit, &limit);
+
+    if (t->use_texture) {
+        GLuint texture;
+        glGenTextures(1, &texture);
+        glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
+        glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, limit+1,
+                t->internalformat, 64, 64, GL_TRUE);
+    }
+    else {

Piglit coding style is } else {

+        GLuint rb;
+        glGenRenderbuffers(1, &rb);
+        glBindRenderbuffer(GL_RENDERBUFFER, rb);
+        glRenderbufferStorageMultisample(GL_RENDERBUFFER,
+                limit + 1, t->internalformat, 64, 64);
+    }
+
+    piglit_report_subtest_result(
+            piglit_check_gl_error(t->error) ? PIGLIT_PASS : PIGLIT_FAIL,
+            t->name);
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+    struct subtest *t = subtests;
+
+    piglit_require_extension("GL_ARB_texture_multisample");
+
+    if (piglit_is_extension_supported("GL_ARB_internalformat_query")) {
+        printf("ARB_internalformat_query is supported and "
+               "redefines this behavior; skipping\n");
+        piglit_report_result(PIGLIT_SKIP);
+    }
+
+    for (; t->name; t++)

I might just initialize t here rather than above, i.e.
for (t = subtests; t->name; t++)

But aside from those silly nits, this looks like a good test.  Thanks Chris!

Reviewed-by: Kenneth Graunke <kenn...@whitecape.org>

+        check_subtest(t);
+
+    piglit_report_result(PIGLIT_PASS);
+}

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to