GL_ARB_enhanced_layouts: use proper max size value
authorAndres Gomez <agomez@igalia.com>
Thu, 22 Jun 2017 21:31:44 +0000 (00:31 +0300)
committerAndres Gomez <agomez@igalia.com>
Sun, 2 Jul 2017 14:26:39 +0000 (17:26 +0300)
When checking for invalid offset alignment in uniform blocks we have
to take into account the MAX_UNIFORM_BLOCK_SIZE limit but, when trying
to do the same for Shader Storage Blocks, the limit to have into
account is MAX_SHADER_STORAGE_BLOCK_SIZE.

From page 52 (page 65 of the PDF) of the OpenGL 3.1 spec:

  "2.11.4 Uniform Variables

   ...

   The total amount of buffer object storage available for any given
   uniform block is subject to an implementation-dependent limit. The
   maximum amount of available space, in basic machine units, can be
   queried by calling GetIntegerv with the constant
   MAX_UNIFORM_BLOCK_SIZE . If the amount of storage required for a
   uniform block exceeds this limit, a program may fail to link."

From page 128 (page 129 of the PDF) of the OpenGL 4.3 spec:

  "7.8 Shader Buffer Variables and Shader Storage Blocks

   ...

   The total amount of buffer object storage that can be accessed in
   any shader storage block is subject to an implementation-dependent
   limit. The maximum amount of available space, in basic machine
   units, can be queried by calling GetIntegerv with the constant
   MAX_SHADER_STORAGE_BLOCK_SIZE . If the amount of storage required
   for any shader storage block exceeds this limit, a program will
   fail to link."

Affects:

GL44-CTS.enhanced_layouts.uniform_block_member_invalid_offset_alignment
GL44-CTS.enhanced_layouts.ssb_member_invalid_offset_alignment

Components: OpenGL

VK-GL-CTS issue: 527

Change-Id: I9185f32a6a90643aa1d3fca0e27a70dbd80d6e16

external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.cpp
external/openglcts/modules/gl/gl4cEnhancedLayoutsTests.hpp

index be9d946..7f5679b 100644 (file)
@@ -9299,6 +9299,21 @@ GLuint UniformBlockMemberInvalidOffsetAlignmentTest::getTestCaseNumber()
        return static_cast<GLuint>(m_test_cases.size());
 }
 
+/** Get the maximum size for an uniform block
+ *
+ * @return The maximum size in basic machine units of a uniform block.
+ **/
+GLint UniformBlockMemberInvalidOffsetAlignmentTest::getMaxBlockSize()
+{
+       const Functions& gl               = m_context.getRenderContext().getFunctions();
+       GLint                    max_size = 0;
+
+       gl.getIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &max_size);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
+
+       return max_size;
+}
+
 /** Selects if "compute" stage is relevant for test
  *
  * @param test_case_index Index of test case
@@ -9337,25 +9352,20 @@ bool UniformBlockMemberInvalidOffsetAlignmentTest::isStageSupported(Utils::Shade
  **/
 void UniformBlockMemberInvalidOffsetAlignmentTest::testInit()
 {
-       const Functions& gl               = m_context.getRenderContext().getFunctions();
-       GLint                    max_size = 0;
-       const GLuint     n_types  = getTypesNumber();
-       bool                     stage_support[Utils::Shader::STAGE_MAX];
+       const GLuint n_types = getTypesNumber();
+       bool             stage_support[Utils::Shader::STAGE_MAX];
 
        for (GLuint stage = 0; stage < Utils::Shader::STAGE_MAX; ++stage)
        {
                stage_support[stage] = isStageSupported((Utils::Shader::STAGES)stage);
        }
 
-       gl.getIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &max_size);
-       GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
-
        for (GLuint i = 0; i < n_types; ++i)
        {
                const Utils::Type& type           = getType(i);
                const GLuint       alignment  = type.GetBaseAlignment(false);
                const GLuint       type_size  = type.GetSize(true);
-               const GLuint       sec_to_end = max_size - 2 * type_size;
+               const GLuint       sec_to_end = getMaxBlockSize() - 2 * type_size;
 
                for (GLuint stage = 0; stage < Utils::Shader::STAGE_MAX; ++stage)
                {
@@ -10999,6 +11009,21 @@ SSBMemberInvalidOffsetAlignmentTest::SSBMemberInvalidOffsetAlignmentTest(deqp::C
        /* Nothing to be done here */
 }
 
+/** Get the maximum size for a shader storage block
+ *
+ * @return The maximum size in basic machine units of a shader storage block.
+ **/
+GLint SSBMemberInvalidOffsetAlignmentTest::getMaxBlockSize()
+{
+       const Functions& gl               = m_context.getRenderContext().getFunctions();
+       GLint                    max_size = 0;
+
+       gl.getIntegerv(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_size);
+       GLU_EXPECT_NO_ERROR(gl.getError(), "GetIntegerv");
+
+       return max_size;
+}
+
 /** Source for given test case and stage
  *
  * @param test_case_index Index of test case
index 5e87d73..ff9d606 100644 (file)
@@ -1610,6 +1610,7 @@ protected:
 
        virtual std::string getTestCaseName(glw::GLuint test_case_index);
        virtual glw::GLuint getTestCaseNumber();
+       virtual glw::GLint  getMaxBlockSize();
        virtual bool isComputeRelevant(glw::GLuint test_case_index);
        virtual bool isFailureExpected(glw::GLuint test_case_index);
        virtual bool isStageSupported(Utils::Shader::STAGES stage);
@@ -1902,8 +1903,9 @@ private:
  *
  * Test verifies that offset alignment rules are enforced.
  *
- * Modify UniformBlockMemberInvalidOffsetAlignment to test shader storage block
- * instead of uniform block
+ * Modify UniformBlockMemberInvalidOffsetAlignment to test shader
+ * storage block against MAX_SHADER_STORAGE_BLOCK_SIZE instead of
+ * uniform block
  **/
 class SSBMemberInvalidOffsetAlignmentTest : public UniformBlockMemberInvalidOffsetAlignmentTest
 {
@@ -1917,6 +1919,7 @@ public:
 
 protected:
        /* Methods to be implemented by child class */
+       virtual glw::GLint  getMaxBlockSize();
        virtual std::string getShaderSource(glw::GLuint test_case_index, Utils::Shader::STAGES stage);
 
        virtual bool isStageSupported(Utils::Shader::STAGES stage);