Fix checks for maximum number of samples
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 12 Jan 2018 09:11:42 +0000 (10:11 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 1 Feb 2018 11:58:35 +0000 (06:58 -0500)
Some tests query MAX_SAMPLES and/or MAX_INTEGER_SAMPLES, then
attempt to create FBOs passing MAX_SAMPLES+1 samples and
expecting an error to be reported.

There are a couple of bugs in these tests:

1. One uses GL_RGB10_A2UI which is an integer format and should
   use MAX_INTEGER_SAMPLES instead of MAX_SAMPLES (this is actually
   what the comment above the call says it is doing).

2. Formats can actually support more samples than
   MAX_SAMPLES. As stated for the SAMPLES internal format query:

   "The maximum value in SAMPLES is guaranteed to be at least
    the lowest of the following:
    (...)
    * The value of MAX_SAMPLES"

   The key aspect here is "at least", which means that the
   maximum number reported in SAMPLES can be larger than any
   of the values in the list, which includes MAX_SAMPLES.

As a consequence of 2), it is possible for these tests to fail
because MAX_SAMPLES+1 is a valid number of samples for the target
internal format and not an invalid number like the test intended.

This patch modifies the affected tests to query SAMPLES for the
internal formats used in the checks so we have the actual maximum
number of sample counts supported for each one, that way we ensure
that SAMPLES+1 is always an invalid number of samples.

Components: OpenGL

Vk-GL-CTS issue: 944

Affects:
KHR-GL45.direct_state_access.renderbuffers_storage_multisample_errors
KHR-GL46.direct_state_access.renderbuffers_storage_multisample_errors
KHR-GL45.direct_state_access.textures_storage_errors
KHR-GL46.direct_state_access.textures_storage_errors

Change-Id: Ic294fe866a3d574fe0321821713d3258027db73b

external/openglcts/modules/gl/gl4cDirectStateAccessFramebuffersAndRenderbuffersTests.cpp
external/openglcts/modules/gl/gl4cDirectStateAccessTexturesTests.cpp

index 843aa74..66148a6 100644 (file)
@@ -9374,7 +9374,7 @@ tcu::TestNode::IterateResult StorageMultisampleErrorsTest::iterate()
 
                /*  Check that INVALID_VALUE is generated by
                 NamedRenderbufferStorageMultisample if samples is greater than
-                MAX_SAMPLES. */
+                the maximum number of SAMPLES reported for GL_RGBA8. */
                gl.namedRenderbufferStorageMultisample(m_rbo_valid, m_max_samples + 1, GL_RGBA8, 1, 1);
 
                is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorageMultisample",
@@ -9393,9 +9393,9 @@ tcu::TestNode::IterateResult StorageMultisampleErrorsTest::iterate()
 
                /*  Check that INVALID_OPERATION is generated by
                 NamedRenderbufferStorageMultisample if internalformat is a signed or
-                unsigned integer format and samples is greater than the value of
-                MAX_INTEGER_SAMPLES. */
-               gl.namedRenderbufferStorageMultisample(m_rbo_valid, m_max_samples + 1, GL_RGB10_A2UI, 1, 1);
+                unsigned integer format and samples is greater than the maximum number
+                of samples reported for GL_RGB10_A2UI */
+               gl.namedRenderbufferStorageMultisample(m_rbo_valid, m_max_integer_samples + 1, GL_RGB10_A2UI, 1, 1);
 
                is_ok &= ExpectError(GL_INVALID_OPERATION, "NamedRenderbufferStorageMultisample",
                                                         "internalformat is a signed or unsigned integer format and samples is greater than the "
@@ -9454,11 +9454,11 @@ void StorageMultisampleErrorsTest::PrepareObjects()
        GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer has failed");
 
        /* Limits. */
-       gl.getIntegerv(GL_MAX_SAMPLES, &m_max_samples);
-       GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
+       gl.getInternalformativ(GL_RENDERBUFFER, GL_RGBA8, GL_SAMPLES, 1, &m_max_samples);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ has failed");
 
-       gl.getIntegerv(GL_MAX_INTEGER_SAMPLES, &m_max_integer_samples);
-       GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
+       gl.getInternalformativ(GL_RENDERBUFFER, GL_RGB10_A2UI, GL_SAMPLES, 1, &m_max_integer_samples);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ has failed");
 
        /* Invalid objects. */
        while (gl.isRenderbuffer(++m_rbo_invalid))
index c86f378..6bc7fe2 100644 (file)
@@ -9158,8 +9158,8 @@ void StorageErrorsTest::Prepare()
        GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
 
        /* Maximum number of samples. */
-       gl.getIntegerv(GL_MAX_SAMPLES, &m_max_samples);
-       GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv has failed");
+       gl.getInternalformativ(GL_RENDERBUFFER, GL_R8, GL_SAMPLES, 1, &m_max_samples);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "glGetInternalformativ has failed");
 
        /* Maximum number of array texture layers. */
        gl.getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_max_array_texture_layers);
@@ -9522,7 +9522,7 @@ bool StorageErrorsTest::Test3DMultisample()
        }
 
        /* Check that INVALID_VALUE is generated by TextureStorage3DMultisample if
-        samples is greater than the value of MAX_SAMPLES. */
+        samples is greater than the maximum number of samples reported for GL_R8 */
        {
                gl.textureStorage3DMultisample(m_to_3D_ms, m_max_samples * 2, GL_R8, 8, 8, 8, false);
                is_ok &= CheckErrorAndLog(m_context, GL_INVALID_OPERATION, "glTextureStorage3DMultisample",