Test readonly and writeonly buffer variables
authorPiotr Byszewski <piotr.byszewski@mobica.com>
Tue, 5 Sep 2017 10:39:13 +0000 (12:39 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 14 Sep 2017 14:16:30 +0000 (10:16 -0400)
It is allowed the both readonly and writeonly qualifiers be used on
buffer variables. It just means it can't be read or written, but can
otherwise be referenced like with .size(), etc.

Components: OpenGL

VK-GL-CTS issue: 639

Affects:
KHR-GL43.shader_storage_buffer_object.basic-readonly-writeonly
KHR-GLES31.core.shader_storage_buffer_object.basic-readonly-writeonly

Change-Id: Id8f68a8687e41cdd42d45c8300f812833312517e

external/openglcts/data/mustpass/gl/khronos_mustpass/4.6.0.x/gl43-master.txt
external/openglcts/data/mustpass/gl/khronos_mustpass/4.6.0.x/gl44-master.txt
external/openglcts/data/mustpass/gl/khronos_mustpass/4.6.0.x/gl45-master.txt
external/openglcts/data/mustpass/gl/khronos_mustpass/4.6.0.x/gl46-master.txt
external/openglcts/data/mustpass/gles/khronos_mustpass/3.2.4.x/gles31-khr-master.txt
external/openglcts/data/mustpass/gles/khronos_mustpass/master/gles31-khr-master.txt
external/openglcts/modules/gl/gl4cShaderStorageBufferObjectTests.cpp
external/openglcts/modules/gles31/es31cShaderStorageBufferObjectTests.cpp

index 1ef15f80ad24893e5a05b2f3d87f79495c805adf..e84a07f424364f11e71a87b649634e1037f3cab3 100644 (file)
@@ -3876,6 +3876,7 @@ KHR-GL43.shader_storage_buffer_object.basic-matrixOperations-case6-cs
 KHR-GL43.shader_storage_buffer_object.basic-matrixOperations-case7-vs
 KHR-GL43.shader_storage_buffer_object.basic-matrixOperations-case7-cs
 KHR-GL43.shader_storage_buffer_object.basic-noBindingLayout
+KHR-GL43.shader_storage_buffer_object.basic-readonly-writeonly
 KHR-GL43.shader_storage_buffer_object.advanced-switchBuffers
 KHR-GL43.shader_storage_buffer_object.advanced-switchBuffers-cs
 KHR-GL43.shader_storage_buffer_object.advanced-switchPrograms
index 3cfe11105174ebcb56f63a670853514a24d5e2db..971a7916b3d070b760114c4af0f8cb619ce647e7 100644 (file)
@@ -3876,6 +3876,7 @@ KHR-GL44.shader_storage_buffer_object.basic-matrixOperations-case6-cs
 KHR-GL44.shader_storage_buffer_object.basic-matrixOperations-case7-vs
 KHR-GL44.shader_storage_buffer_object.basic-matrixOperations-case7-cs
 KHR-GL44.shader_storage_buffer_object.basic-noBindingLayout
+KHR-GL44.shader_storage_buffer_object.basic-readonly-writeonly
 KHR-GL44.shader_storage_buffer_object.advanced-switchBuffers
 KHR-GL44.shader_storage_buffer_object.advanced-switchBuffers-cs
 KHR-GL44.shader_storage_buffer_object.advanced-switchPrograms
index 18a7e3ac2924f59c0182b9a205ed37e77cad5fb7..01fe4d2955d5c7fe8431211b5774398721a0657d 100644 (file)
@@ -3877,6 +3877,7 @@ KHR-GL45.shader_storage_buffer_object.basic-matrixOperations-case6-cs
 KHR-GL45.shader_storage_buffer_object.basic-matrixOperations-case7-vs
 KHR-GL45.shader_storage_buffer_object.basic-matrixOperations-case7-cs
 KHR-GL45.shader_storage_buffer_object.basic-noBindingLayout
+KHR-GL45.shader_storage_buffer_object.basic-readonly-writeonly
 KHR-GL45.shader_storage_buffer_object.advanced-switchBuffers
 KHR-GL45.shader_storage_buffer_object.advanced-switchBuffers-cs
 KHR-GL45.shader_storage_buffer_object.advanced-switchPrograms
index 446572a88539c63b6a81bdceb164cb27461041af..01f1097efcce45af104c82d2e6d7afd2ad227825 100644 (file)
@@ -3877,6 +3877,7 @@ KHR-GL46.shader_storage_buffer_object.basic-matrixOperations-case6-cs
 KHR-GL46.shader_storage_buffer_object.basic-matrixOperations-case7-vs
 KHR-GL46.shader_storage_buffer_object.basic-matrixOperations-case7-cs
 KHR-GL46.shader_storage_buffer_object.basic-noBindingLayout
+KHR-GL46.shader_storage_buffer_object.basic-readonly-writeonly
 KHR-GL46.shader_storage_buffer_object.advanced-switchBuffers
 KHR-GL46.shader_storage_buffer_object.advanced-switchBuffers-cs
 KHR-GL46.shader_storage_buffer_object.advanced-switchPrograms
index 583d2a7e287cbbeaa810bfbf2f5114f1bbc11d24..60c082800dd162052150ea821d5dcea031cf4e7b 100644 (file)
@@ -1900,6 +1900,7 @@ KHR-GLES31.core.shader_storage_buffer_object.basic-matrixOperations-case6-vs
 KHR-GLES31.core.shader_storage_buffer_object.basic-matrixOperations-case6-cs
 KHR-GLES31.core.shader_storage_buffer_object.basic-matrixOperations-case7-vs
 KHR-GLES31.core.shader_storage_buffer_object.basic-matrixOperations-case7-cs
+KHR-GLES31.core.shader_storage_buffer_object.basic-readonly-writeonly
 KHR-GLES31.core.shader_storage_buffer_object.advanced-switchBuffers-vs
 KHR-GLES31.core.shader_storage_buffer_object.advanced-switchBuffers-cs
 KHR-GLES31.core.shader_storage_buffer_object.advanced-switchPrograms-vs
index 583d2a7e287cbbeaa810bfbf2f5114f1bbc11d24..60c082800dd162052150ea821d5dcea031cf4e7b 100644 (file)
@@ -1900,6 +1900,7 @@ KHR-GLES31.core.shader_storage_buffer_object.basic-matrixOperations-case6-vs
 KHR-GLES31.core.shader_storage_buffer_object.basic-matrixOperations-case6-cs
 KHR-GLES31.core.shader_storage_buffer_object.basic-matrixOperations-case7-vs
 KHR-GLES31.core.shader_storage_buffer_object.basic-matrixOperations-case7-cs
+KHR-GLES31.core.shader_storage_buffer_object.basic-readonly-writeonly
 KHR-GLES31.core.shader_storage_buffer_object.advanced-switchBuffers-vs
 KHR-GLES31.core.shader_storage_buffer_object.advanced-switchBuffers-cs
 KHR-GLES31.core.shader_storage_buffer_object.advanced-switchPrograms-vs
index 950df6fa410d10e636f4d4824f912a86dd9d9519..ed7881c250520c574fffbc346bba4aa996eecbd2 100644 (file)
@@ -5136,6 +5136,73 @@ class BasicNoBindingLayout : public ShaderStorageBufferObjectBase
                return NO_ERROR;
        }
 };
+
+//----------------------------------------------------------------------------
+// 1.14 BasicReadonlyWriteonly
+//-----------------------------------------------------------------------------
+class BasicReadonlyWriteonly : public ShaderStorageBufferObjectBase
+{
+       GLuint m_program;
+       GLuint m_storage_buffer[2];
+
+       virtual long Setup()
+       {
+               m_program = 0;
+               memset(m_storage_buffer, 0, sizeof(m_storage_buffer));
+               return NO_ERROR;
+       }
+
+       virtual long Run()
+       {
+               const char* const glsl_cs =
+                       NL "layout(local_size_x = 1) in;" NL "layout(std430, binding = 0) buffer Input {" NL
+                          "  readonly writeonly int g_in[];" NL "};" NL "layout(std430, binding = 1) buffer Output {" NL
+                          "  int count;" NL "} g_output;" NL "void main() {" NL "  g_output.count = g_in.length();" NL "}";
+
+               m_program = CreateProgramCS(glsl_cs);
+               glLinkProgram(m_program);
+               if (!CheckProgram(m_program))
+                       return ERROR;
+
+               glGenBuffers(2, m_storage_buffer);
+
+               /* Input */
+               int input_data[] = { 1, 2, 3 };
+               glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_storage_buffer[0]);
+               glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(input_data), input_data, GL_STATIC_DRAW);
+
+               /* Output */
+               int output_data[] = { 0 };
+               glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_storage_buffer[1]);
+               glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(output_data), output_data, GL_DYNAMIC_COPY);
+
+               glUseProgram(m_program);
+               glDispatchCompute(1, 1, 1);
+               glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
+
+               glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_storage_buffer[1]);
+               int* data = (int*)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 4, GL_MAP_READ_BIT);
+               if (!data)
+                       return ERROR;
+               if (*data != DE_LENGTH_OF_ARRAY(input_data))
+               {
+                       m_context.getTestContext().getLog() << tcu::TestLog::Message << "Buffer data is " << *data << " should be "
+                                                                                               << sizeof(input_data) << tcu::TestLog::EndMessage;
+                       return ERROR;
+               }
+               glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
+               return NO_ERROR;
+       }
+
+       virtual long Cleanup()
+       {
+               glUseProgram(0);
+               glDeleteProgram(m_program);
+               glDeleteBuffers(2, m_storage_buffer);
+               return NO_ERROR;
+       }
+};
+
 //-----------------------------------------------------------------------------
 // 2.1 AdvancedSwitchBuffers
 //-----------------------------------------------------------------------------
@@ -9003,6 +9070,7 @@ void ShaderStorageBufferObjectTests::init()
        addChild(new TestSubcase(m_context, "basic-matrixOperations-case7-cs",
                                                         TestSubcase::Create<BasicMatrixOperationsCase7CS>));
        addChild(new TestSubcase(m_context, "basic-noBindingLayout", TestSubcase::Create<BasicNoBindingLayout>));
+       addChild(new TestSubcase(m_context, "basic-readonly-writeonly", TestSubcase::Create<BasicReadonlyWriteonly>));
        addChild(new TestSubcase(m_context, "advanced-switchBuffers", TestSubcase::Create<AdvancedSwitchBuffers>));
        addChild(new TestSubcase(m_context, "advanced-switchBuffers-cs", TestSubcase::Create<AdvancedSwitchBuffersCS>));
        addChild(new TestSubcase(m_context, "advanced-switchPrograms", TestSubcase::Create<AdvancedSwitchPrograms>));
index cece92ed15fd8b36880a27cf3a2079efb1aa59ac..3e9cfe6d9c286ba201ab06363f5ad1d495f7706a 100644 (file)
@@ -4857,6 +4857,72 @@ class BasicMatrixOperationsCase7CS : public BasicMatrixOperationsBaseCS
        }
 };
 
+//----------------------------------------------------------------------------
+// 1.13 BasicReadonlyWriteonly
+//-----------------------------------------------------------------------------
+class BasicReadonlyWriteonly : public ShaderStorageBufferObjectBase
+{
+       GLuint m_program;
+       GLuint m_storage_buffer[2];
+
+       virtual long Setup()
+       {
+               m_program = 0;
+               memset(m_storage_buffer, 0, sizeof(m_storage_buffer));
+               return NO_ERROR;
+       }
+
+       virtual long Run()
+       {
+               const char* const glsl_cs =
+                       NL "layout(local_size_x = 1) in;" NL "layout(std430, binding = 0) buffer Input {" NL
+                          "  readonly writeonly int g_in[];" NL "};" NL "layout(std430, binding = 1) buffer Output {" NL
+                          "  int count;" NL "} g_output;" NL "void main() {" NL "  g_output.count = g_in.length();" NL "}";
+
+               m_program = CreateProgramCS(glsl_cs);
+               glLinkProgram(m_program);
+               if (!CheckProgram(m_program))
+                       return ERROR;
+
+               glGenBuffers(2, m_storage_buffer);
+
+               /* Input */
+               int input_data[] = { 1, 2, 3 };
+               glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_storage_buffer[0]);
+               glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(input_data), input_data, GL_STATIC_DRAW);
+
+               /* Output */
+               int output_data[] = { 0 };
+               glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_storage_buffer[1]);
+               glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(output_data), output_data, GL_DYNAMIC_COPY);
+
+               glUseProgram(m_program);
+               glDispatchCompute(1, 1, 1);
+               glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
+
+               glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_storage_buffer[1]);
+               int* data = (int*)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 4, GL_MAP_READ_BIT);
+               if (!data)
+                       return ERROR;
+               if (*data != DE_LENGTH_OF_ARRAY(input_data))
+               {
+                       m_context.getTestContext().getLog() << tcu::TestLog::Message << "Buffer data is " << *data << " should be "
+                                                                                               << sizeof(input_data) << tcu::TestLog::EndMessage;
+                       return ERROR;
+               }
+               glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
+               return NO_ERROR;
+       }
+
+       virtual long Cleanup()
+       {
+               glUseProgram(0);
+               glDeleteProgram(m_program);
+               glDeleteBuffers(2, m_storage_buffer);
+               return NO_ERROR;
+       }
+};
+
 //-----------------------------------------------------------------------------
 // 2.1 AdvancedSwitchBuffers
 //-----------------------------------------------------------------------------
@@ -8532,6 +8598,7 @@ void ShaderStorageBufferObjectTests::init()
                                                         TestSubcase::Create<BasicMatrixOperationsCase7VS>));
        addChild(new TestSubcase(m_context, "basic-matrixOperations-case7-cs",
                                                         TestSubcase::Create<BasicMatrixOperationsCase7CS>));
+       addChild(new TestSubcase(m_context, "basic-readonly-writeonly", TestSubcase::Create<BasicReadonlyWriteonly>));
        addChild(new TestSubcase(m_context, "advanced-switchBuffers-vs", TestSubcase::Create<AdvancedSwitchBuffersVS>));
        addChild(new TestSubcase(m_context, "advanced-switchBuffers-cs", TestSubcase::Create<AdvancedSwitchBuffersCS>));
        addChild(new TestSubcase(m_context, "advanced-switchPrograms-vs", TestSubcase::Create<AdvancedSwitchProgramsVS>));