[Piglit] [PATCH 11/21] arb_internalformat_query2: Check if the resource is supported in max-dimensions

Alejandro PiƱeiro apinheiro at igalia.com
Fri Jan 22 08:05:58 PST 2016


From: Antia Puentes <apuentes at igalia.com>

The ARB_internalformat_query2 specification says about
MAX_WIDTH, MAX_HEIGHT, MAX_DEPTH and MAX_COMBINED_DIMENSIONS <pnames>:

   "If the resource is unsupported, zero is returned."

>From the same specification:
   "In the following descriptions, the term /resource/ is used
    to generically refer to an object of the appropriate type that has
    been created with <internalformat> and <target>."

We check if the /resource/ is supported by trying to create the object,
if an error is raised, we consider the /resource/ as "unsupported".
Before, we were only checking if the <internalformat> was supported
independently of the <target>.

Tested on NVIDIA GeForce GTX 950 - NVIDIA 352.55: after this commit,
all the subtests on this test fails.

Now that a stricter check for unsupported resources are in place, the
test fails on NVIDIA because for some unsupported resources it returns
a value different to zero.
---
 .../arb_internalformat_query2/max-dimensions.c     | 61 ++++++++++++++++++----
 1 file changed, 51 insertions(+), 10 deletions(-)

diff --git a/tests/spec/arb_internalformat_query2/max-dimensions.c b/tests/spec/arb_internalformat_query2/max-dimensions.c
index 720f724..255cdc3 100644
--- a/tests/spec/arb_internalformat_query2/max-dimensions.c
+++ b/tests/spec/arb_internalformat_query2/max-dimensions.c
@@ -223,6 +223,50 @@ num_dimensions(const GLenum target)
 }
 
 static bool
+is_supported_renderbuffer(const GLenum target, const GLenum internalformat)
+{
+        GLuint rb;
+        bool result = true;
+
+        glGenRenderbuffers(1, &rb);
+        glBindRenderbuffer(GL_RENDERBUFFER, rb);
+        glRenderbufferStorage(GL_RENDERBUFFER, internalformat, 16, 16);
+
+        if (!piglit_check_gl_error(GL_NO_ERROR))
+                result = false;
+
+        glDeleteRenderbuffers(1, &rb);
+        return result;
+}
+
+static bool
+is_resource_supported(const test_data *data,
+                      const GLenum pname,
+                      const GLenum target,
+                      const GLenum internalformat)
+{
+        GLuint tex;
+        GLuint buffer;
+
+        if (!check_query2_dependencies(pname, target))
+                return false;
+
+        if (!test_data_check_supported(data, target, internalformat))
+                return false;
+
+        if (target == GL_RENDERBUFFER)
+                return is_supported_renderbuffer(target, internalformat);
+
+        if (!create_texture(target, internalformat, &tex, &buffer))
+                return false;
+
+        glDeleteTextures(1, &tex);
+        glDeleteBuffers(1, &buffer);
+
+        return true;
+}
+
+static bool
 try(const GLenum *targets, unsigned num_targets,
     const GLenum *internalformats, unsigned num_internalformats,
     const GLenum pname,
@@ -239,9 +283,8 @@ try(const GLenum *targets, unsigned num_targets,
                         bool value_test = true;
                         bool supported;
 
-                        supported = check_query2_dependencies(pname, targets[i])
-                                && test_data_check_supported(data, targets[i],
-                                                             internalformats[j]);
+                        supported = is_resource_supported(data, pname,
+                                                          targets[i], internalformats[j]);
 
                         test_data_execute(data, targets[i], internalformats[j],
                                           pname);
@@ -413,9 +456,8 @@ try_max_layers(const GLenum *targets, unsigned num_targets,
                         bool value_test = true;
                         bool supported;
 
-                        supported = check_query2_dependencies(GL_MAX_LAYERS, targets[i])
-                                && test_data_check_supported(data, targets[i],
-                                                             internalformats[j]);
+                        supported = is_resource_supported(data, GL_MAX_LAYERS,
+                                                          targets[i], internalformats[j]);
 
                         test_data_execute(data, targets[i], internalformats[j],
                                           GL_MAX_LAYERS);
@@ -578,10 +620,9 @@ try_max_combined_dimensions(const GLenum *targets, unsigned num_targets,
                         bool value_test = true;
                         bool supported;
 
-                        supported = check_query2_dependencies(GL_MAX_COMBINED_DIMENSIONS,
-                                                              targets[i])
-                                && test_data_check_supported(data, targets[i],
-                                                             internalformats[j]);
+                        supported = is_resource_supported(data, GL_MAX_COMBINED_DIMENSIONS,
+                                                          targets[i],
+                                                          internalformats[j]);
 
                         test_data_execute(data, targets[i], internalformats[j],
                                           GL_MAX_COMBINED_DIMENSIONS);
-- 
2.1.4



More information about the Piglit mailing list