Fix race condition in shader_image_load_store.multiple-uniforms
authorSlawomir Cygan <slawomir.cygan@intel.com>
Mon, 20 Mar 2017 17:28:03 +0000 (18:28 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 24 Mar 2017 16:03:42 +0000 (12:03 -0400)
There is a race condition in this tests, where 4 TCS invocation read-modify-write
same image load-store locations. This may lead to indeterminate results data.

As a fix a predicate is used in TCS, limiting image-load-store accessed to only one shader
invocation

Components: OpenGL
VK-GL-CTS issue: 262

Affects test:
GL44-CTS.shader_image_load_store.multiple-uniforms

Change-Id: I7b14ef4e291cf382c4d0c2766dea4b4955c76f5b

external/openglcts/modules/gl/gl4cShaderImageLoadStoreTests.cpp

index c7c55aa..c211739 100644 (file)
@@ -9249,6 +9249,7 @@ private:
        {
                GLint                     max_image_uniforms    = getMaximumImageUniformsForStage(stage);
                const char*               stage_specific_layout = "";
+               const char*               stage_specific_predicate = "true";
                std::stringstream stream;
 
                if (m_min_required_image_uniforms > max_image_uniforms)
@@ -9296,6 +9297,7 @@ private:
                case tesselationControlShaderStage:
                        stage_specific_layout = "layout(vertices = 4) out;\n"
                                                                        "\n";
+                       stage_specific_predicate = "gl_InvocationID == 0";
                        break;
 
                case tesselationEvalutaionShaderStage:
@@ -9329,16 +9331,19 @@ private:
                                  "void main()\n"
                                  "{\n";
 
+               stream << "    if (" << stage_specific_predicate << ")\n";
+               stream << "    {\n";
+
                /* imageLoad and imageStores for each uniform */
                for (GLint i = 0; i < max_image_uniforms; ++i)
                {
-                       stream << "    " << coordinatesVariableDeclaration(i, 0) << "\n"
-                                  << "    " << coordinatesVariableDeclaration(i, 1) << "\n"
+                       stream << "        " << coordinatesVariableDeclaration(i, 0) << "\n"
+                                  << "        " << coordinatesVariableDeclaration(i, 1) << "\n"
                                   << "\n"
-                                  << "    " << imageLoadCall(i) << "\n"
+                                  << "        " << imageLoadCall(i) << "\n"
                                   << "\n"
-                                  << "    " << imageStoreCall(i, 0) << "\n"
-                                  << "    " << imageStoreCall(i, 1) << "\n";
+                                  << "        " << imageStoreCall(i, 0) << "\n"
+                                  << "        " << imageStoreCall(i, 1) << "\n";
 
                        if (max_image_uniforms > i + 1)
                        {
@@ -9346,6 +9351,8 @@ private:
                        }
                }
 
+               stream << "    }\n";
+
                /* Main closing */
                stream << "}\n\n";