Additional OpenGL ES fixes
authorDaniel Koch <dkoch@nvidia.com>
Wed, 8 May 2019 22:36:07 +0000 (18:36 -0400)
committerDaniel Koch <dkoch@nvidia.com>
Wed, 8 May 2019 22:36:07 +0000 (18:36 -0400)
- use highp int precision in fragment shaders (defaults to mediump)
- check for image uniform support in VTG stages
- get rid of extraneous image declaration
- use fewer SSBOs in the subgroup.basic.graphics tests
  and add in an explicit check for the number required (14)

Component: OpenGL
VK-GL-CTS Issue: 1698

Affects:
- KHR-Single-GL*.subgroups.*

Change-Id: I5c6aaa23be5fdd2eec82d567ae18310fc0054faa

14 files changed:
external/openglcts/modules/common/subgroups/glcSubgroupsArithmeticTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsBallotBroadcastTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsBallotOtherTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsBallotTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsBasicTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsBuiltinMaskVarTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsBuiltinVarTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsClusteredTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsPartitionedTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsQuadTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsShapeTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsShuffleTests.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsTestsUtils.cpp
external/openglcts/modules/common/subgroups/glcSubgroupsTestsUtils.hpp

index b4e0cbf..156b16b 100755 (executable)
@@ -777,6 +777,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                "${VERSION_DECL}\n"
                                "#extension GL_KHR_shader_subgroup_arithmetic: enable\n"
                                "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                               "precision highp int;\n"
                                "precision highp float;\n"
                                "layout(location = 0) out uint result;\n"
                                "layout(binding = 4, std430) readonly buffer Buffer4\n"
index 164a11b..0bb5561 100755 (executable)
@@ -378,6 +378,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                const string fragment =
                        "${VERSION_DECL}\n"
                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                       "precision highp int;\n"
                        "precision highp float;\n"
                        "layout(location = 0) out uint result;\n"
                        "layout(binding = 4, std430) readonly buffer Buffer4\n"
index cd74fce..acf97b3 100755 (executable)
@@ -438,6 +438,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                const string fragment =
                        "${VERSION_DECL}\n"
                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                       "precision highp int;\n"
                        "layout(location = 0) out uint result;\n"
                        "void main (void)\n"
                        "{\n"
index c6300d7..728910f 100755 (executable)
@@ -329,6 +329,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                const string fragment =
                        "${VERSION_DECL}\n"
                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                       "precision highp int;\n"
                        "layout(location = 0) out uint result;\n"
                        "layout(binding = 4, std430) readonly buffer Buffer4\n"
                        "{\n"
index 2e5b60b..acdc764 100755 (executable)
@@ -135,7 +135,7 @@ static bool checkVertexPipelineStagesSubgroupBarriers(std::vector<const void*> d
        const deUint32* const resultData = reinterpret_cast<const deUint32*>(datas[0]);
 
        // We used this SSBO to generate our unique value!
-       const deUint32 ref = *reinterpret_cast<const deUint32*>(datas[3]);
+       const deUint32 ref = *reinterpret_cast<const deUint32*>(datas[1]);
 
        for (deUint32 x = 0; x < width; ++x)
        {
@@ -197,7 +197,7 @@ static bool checkComputeSubgroupBarriers(std::vector<const void*> datas,
                deUint32)
 {
        // We used this SSBO to generate our unique value!
-       const deUint32 ref = *reinterpret_cast<const deUint32*>(datas[2]);
+       const deUint32 ref = *reinterpret_cast<const deUint32*>(datas[1]);
        return glc::subgroups::checkCompute(datas, numWorkgroups, localSize, ref);
 }
 
@@ -473,6 +473,7 @@ void initFrameBufferPrograms(SourceCollections& programCollection, CaseDefinitio
                        fragment        << "${VERSION_DECL}\n"
                                << "#extension GL_KHR_shader_subgroup_basic: enable\n"
                                << "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                               << "precision highp int;\n"
                                << "layout(location = 0) out highp vec4 out_color;\n"
                                << "\n"
                                << "layout(binding = 0, std140) uniform Buffer1\n"
@@ -878,6 +879,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                std::ostringstream fragment;
                                fragment        << "${VERSION_DECL}\n"
                                                        << "#extension GL_KHR_shader_subgroup_basic: enable\n"
+                                                       << "precision highp int;\n"
                                                        << "layout(location = 0) out uint data;\n"
                                                        << "layout(binding = 8, std430) buffer Buffer8\n"
                                                        << "{\n"
@@ -915,7 +917,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        case OPTYPE_SUBGROUP_MEMORY_BARRIER_BUFFER:
                                bdy << "  if (subgroupElect())\n"
                                        << "  {\n"
-                                       << "    b${SSBO1}.tempBuffer[id] = b${SSBO2}.value;\n"
+                                       << "    b${SSBO1}.tempBuffer[id] = b${SSBO1}.value;\n"
                                        << "  }\n"
                                        << "  " << getOpTypeName(caseDef.opType) << "();\n"
                                        << "  tempResult = b${SSBO1}.tempBuffer[id];\n";
@@ -923,7 +925,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        case OPTYPE_SUBGROUP_MEMORY_BARRIER_SHARED:
                                bdy << "  if (subgroupElect())\n"
                                        << "  {\n"
-                                       << "    tempShared[localId] = b${SSBO2}.value;\n"
+                                       << "    tempShared[localId] = b${SSBO1}.value;\n"
                                        << "  }\n"
                                        << "  subgroupMemoryBarrierShared();\n"
                                        << "  tempResult = tempShared[localId];\n";
@@ -931,7 +933,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        case OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE:
                                bdy << "  if (subgroupElect())\n"
                                        << "  {\n"
-                                       << "    imageStore(tempImage${IMG1}, ivec2(id, 0), uvec4(b${SSBO2}.value));\n"
+                                       << "    imageStore(tempImage${IMG1}, ivec2(id, 0), uvec4(b${SSBO1}.value));\n"
                                        << "  }\n"
                                        << "  subgroupMemoryBarrierImage();\n"
                                        << "  tempResult = imageLoad(tempImage${IMG1}, ivec2(id, 0)).x;\n";
@@ -945,7 +947,6 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        std::ostringstream src;
                        map<string, string> bufferNameMapping;
                        bufferNameMapping.insert(pair<string, string>("SSBO1", "1"));
-                       bufferNameMapping.insert(pair<string, string>("SSBO2", "2"));
                        bufferNameMapping.insert(pair<string, string>("IMG1", "0"));
 
                        src << "${VERSION_DECL}\n"
@@ -957,25 +958,22 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                << "} b0;\n"
                                << "layout(binding = 1, std430) buffer Buffer1\n"
                                << "{\n"
+                               << "  uint value;\n"
                                << "  uint tempBuffer[];\n"
                                << "} b1;\n"
-                               << "layout(binding = 2, std430) buffer Buffer2\n"
-                               << "{\n"
-                               << "  uint value;\n"
-                               << "} b2;\n"
-                               << "layout(binding = 0, r32ui) uniform highp uimage2D tempImage0;\n"
+                               << (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType ? "layout(binding = 0, r32ui) uniform highp uimage2D tempImage0;\n" : "\n")
                                << "shared uint tempShared[gl_WorkGroupSize.x * gl_WorkGroupSize.y * gl_WorkGroupSize.z];\n"
                                << "\n"
                                << "void main (void)\n"
                                << "{\n"
                                << "  uvec3 globalSize = gl_NumWorkGroups * gl_WorkGroupSize;\n"
                                << "  highp uint offset = globalSize.x * ((globalSize.y * "
-                               "gl_GlobalInvocationID.z) + gl_GlobalInvocationID.y) + "
-                               "gl_GlobalInvocationID.x;\n"
+                                               "gl_GlobalInvocationID.z) + gl_GlobalInvocationID.y) + "
+                                               "gl_GlobalInvocationID.x;\n"
                                << "  uint localId = gl_SubgroupID;\n"
                                << "  uint id = globalSize.x * ((globalSize.y * "
-                               "gl_WorkGroupID.z) + gl_WorkGroupID.y) + "
-                               "gl_WorkGroupID.x + localId;\n"
+                                               "gl_WorkGroupID.z) + gl_WorkGroupID.y) + "
+                                               "gl_WorkGroupID.x + localId;\n"
                                << "  uint tempResult = 0u;\n"
                                << bdyTemplate.specialize(bufferNameMapping)
                                << "  b0.result[offset] = tempResult;\n"
@@ -988,10 +986,10 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        {
                                map<string, string> bufferNameMapping;
                                bufferNameMapping.insert(pair<string, string>("SSBO1", "4"));
-                               bufferNameMapping.insert(pair<string, string>("SSBO2", "6"));
                                bufferNameMapping.insert(pair<string, string>("IMG1", "0"));
 
-                               const string vertex =
+                               std::ostringstream vertex;
+                               vertex <<
                                        "${VERSION_DECL}\n"
                                        "#extension GL_KHR_shader_subgroup_basic: enable\n"
                                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
@@ -1001,18 +999,15 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        "} b0;\n"
                                        "layout(binding = 4, std430) buffer Buffer4\n"
                                        "{\n"
+                                       "  uint value;\n"
                                        "  uint tempBuffer[];\n"
                                        "} b4;\n"
                                        "layout(binding = 5, std430) buffer Buffer5\n"
                                        "{\n"
                                        "  uint subgroupID;\n"
                                        "} b5;\n"
-                                       "layout(binding = 6, std430) buffer Buffer6\n"
-                                       "{\n"
-                                       "  uint value;\n"
-                                       "} b6;\n"
-                                       "layout(binding = 0, r32ui) uniform highp uimage2D tempImage0;\n"
-                                       "void main (void)\n"
+                               <<      (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType ? "layout(binding = 0, r32ui) uniform highp uimage2D tempImage0;\n" : "")
+                               <<      "void main (void)\n"
                                        "{\n"
                                        "  uint id = 0u;\n"
                                        "  if (subgroupElect())\n"
@@ -1029,16 +1024,16 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        "  gl_Position = vec4(float(gl_VertexID) * pixelSize + pixelPosition, 0.0f, 0.0f, 1.0f);\n"
                                        "  gl_PointSize = 1.0f;\n"
                                        "}\n";
-                               programCollection.add("vert") << glu::VertexSource(vertex);
+                               programCollection.add("vert") << glu::VertexSource(vertex.str());
                        }
 
                        {
                                map<string, string> bufferNameMapping;
-                               bufferNameMapping.insert(pair<string, string>("SSBO1", "7"));
-                               bufferNameMapping.insert(pair<string, string>("SSBO2", "9"));
+                               bufferNameMapping.insert(pair<string, string>("SSBO1", "6"));
                                bufferNameMapping.insert(pair<string, string>("IMG1", "1"));
 
-                               const string tesc =
+                               std::ostringstream tesc;
+                               tesc <<
                                        "${VERSION_DECL}\n"
                                        "#extension GL_KHR_shader_subgroup_basic: enable\n"
                                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
@@ -1047,25 +1042,22 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        "{\n"
                                        "  uint result[];\n"
                                        "} b1;\n"
-                                       "layout(binding = 7, std430) buffer Buffer7\n"
+                                       "layout(binding = 6, std430) buffer Buffer6\n"
                                        "{\n"
+                                       "  uint value;\n"
                                        "  uint tempBuffer[];\n"
-                                       "} b7;\n"
-                                       "layout(binding = 8, std430) buffer Buffer8\n"
+                                       "} b6;\n"
+                                       "layout(binding = 7, std430) buffer Buffer7\n"
                                        "{\n"
                                        "  uint subgroupID;\n"
-                                       "} b8;\n"
-                                       "layout(binding = 9, std430) buffer Buffer9\n"
-                                       "{\n"
-                                       "  uint value;\n"
-                                       "} b9;\n"
-                                       "layout(binding = 1, r32ui) uniform highp uimage2D tempImage1;\n"
-                                       "void main (void)\n"
+                                       "} b7;\n"
+                               <<      (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType ? "layout(binding = 1, r32ui) uniform highp uimage2D tempImage1;\n" : "")
+                               <<      "void main (void)\n"
                                        "{\n"
                                        "  uint id = 0u;\n"
                                        "  if (subgroupElect())\n"
                                        "  {\n"
-                                       "    id = atomicAdd(b8.subgroupID, 1u);\n"
+                                       "    id = atomicAdd(b7.subgroupID, 1u);\n"
                                        "  }\n"
                                        "  id = subgroupBroadcastFirst(id);\n"
                                        "  uint localId = id;\n"
@@ -1079,16 +1071,16 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        "  }\n"
                                        "  gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
                                        "}\n";
-                               programCollection.add("tesc") << glu::TessellationControlSource(tesc);
+                               programCollection.add("tesc") << glu::TessellationControlSource(tesc.str());
                        }
 
                        {
                                map<string, string> bufferNameMapping;
-                               bufferNameMapping.insert(pair<string, string>("SSBO1", "10"));
-                               bufferNameMapping.insert(pair<string, string>("SSBO2", "12"));
+                               bufferNameMapping.insert(pair<string, string>("SSBO1", "8"));
                                bufferNameMapping.insert(pair<string, string>("IMG1", "2"));
 
-                               const string tese =
+                               std::ostringstream tese;
+                               tese <<
                                        "${VERSION_DECL}\n"
                                        "#extension GL_KHR_shader_subgroup_basic: enable\n"
                                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
@@ -1097,25 +1089,22 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        "{\n"
                                        "  uint result[];\n"
                                        "} b2;\n"
-                                       "layout(binding = 10, std430) buffer Buffer10\n"
+                                       "layout(binding = 8, std430) buffer Buffer8\n"
                                        "{\n"
+                                       "  uint value;\n"
                                        "  uint tempBuffer[];\n"
-                                       "} b10;\n"
-                                       "layout(binding = 11, std430) buffer Buffer11\n"
+                                       "} b8;\n"
+                                       "layout(binding = 9, std430) buffer Buffer9\n"
                                        "{\n"
                                        "  uint subgroupID;\n"
-                                       "} b11;\n"
-                                       "layout(binding = 12, std430) buffer Buffer12\n"
-                                       "{\n"
-                                       "  uint value;\n"
-                                       "} b12;\n"
-                                       "layout(binding = 2, r32ui) uniform highp uimage2D tempImage2;\n"
-                                       "void main (void)\n"
+                                       "} b9;\n"
+                               <<      (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType ? "layout(binding = 2, r32ui) uniform highp uimage2D tempImage2;\n" : "")
+                               <<      "void main (void)\n"
                                        "{\n"
                                        "  uint id = 0u;\n"
                                        "  if (subgroupElect())\n"
                                        "  {\n"
-                                       "    id = atomicAdd(b11.subgroupID, 1u);\n"
+                                       "    id = atomicAdd(b9.subgroupID, 1u);\n"
                                        "  }\n"
                                        "  id = subgroupBroadcastFirst(id);\n"
                                        "  uint localId = id;\n"
@@ -1124,15 +1113,15 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        "  b2.result[gl_PrimitiveID * 2 + int(gl_TessCoord.x + 0.5)] = tempResult;\n"
                                        "  float pixelSize = 2.0f/1024.0f;\n""  gl_Position = gl_in[0].gl_Position + gl_TessCoord.x * pixelSize / 2.0f;\n"
                                        "}\n";
-                               programCollection.add("tese") << glu::TessellationEvaluationSource(tese);
+                               programCollection.add("tese") << glu::TessellationEvaluationSource(tese.str());
                        }
                        {
                                map<string, string> bufferNameMapping;
-                               bufferNameMapping.insert(pair<string, string>("SSBO1", "13"));
-                               bufferNameMapping.insert(pair<string, string>("SSBO2", "15"));
+                               bufferNameMapping.insert(pair<string, string>("SSBO1", "10"));
                                bufferNameMapping.insert(pair<string, string>("IMG1", "3"));
 
-                               const string geometry =
+                               std::ostringstream geometry;
+                               geometry <<
                                        "#extension GL_KHR_shader_subgroup_basic: enable\n"
                                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
                                        "layout(${TOPOLOGY}) in;\n"
@@ -1141,25 +1130,22 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        "{\n"
                                        "  uint result[];\n"
                                        "} b3;\n"
-                                       "layout(binding = 13, std430) buffer Buffer13\n"
+                                       "layout(binding = 10, std430) buffer Buffer10\n"
                                        "{\n"
+                                       "  uint value;\n"
                                        "  uint tempBuffer[];\n"
-                                       "} b13;\n"
-                                       "layout(binding = 14, std430) buffer Buffer14\n"
+                                       "} b10;\n"
+                                       "layout(binding = 11, std430) buffer Buffer11\n"
                                        "{\n"
                                        "  uint subgroupID;\n"
-                                       "} b14;\n"
-                                       "layout(binding = 15, std430) buffer Buffer15\n"
-                                       "{\n"
-                                       "  uint value;\n"
-                                       "} b15;\n"
-                                       "layout(binding = 3, r32ui) uniform highp uimage2D tempImage3;\n"
-                                       "void main (void)\n"
+                                       "} b11;\n"
+                               <<      (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType ? "layout(binding = 3, r32ui) uniform highp uimage2D tempImage3;\n" : "")
+                               <<      "void main (void)\n"
                                        "{\n"
                                        "  uint id = 0u;\n"
                                        "  if (subgroupElect())\n"
                                        "  {\n"
-                                       "    id = atomicAdd(b14.subgroupID, 1u);\n"
+                                       "    id = atomicAdd(b11.subgroupID, 1u);\n"
                                        "  }\n"
                                        "  id = subgroupBroadcastFirst(id);\n"
                                        "  uint localId = id;\n"
@@ -1170,40 +1156,38 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        "  EmitVertex();\n"
                                        "  EndPrimitive();\n"
                                        "}\n";
-                               subgroups::addGeometryShadersFromTemplate(geometry, programCollection);
+                               subgroups::addGeometryShadersFromTemplate(geometry.str(), programCollection);
                        }
 
                        {
                                map<string, string> bufferNameMapping;
-                               bufferNameMapping.insert(pair<string, string>("SSBO1", "16"));
-                               bufferNameMapping.insert(pair<string, string>("SSBO2", "18"));
+                               bufferNameMapping.insert(pair<string, string>("SSBO1", "12"));
                                bufferNameMapping.insert(pair<string, string>("IMG1", "4"));
 
-                               const string fragment =
+                               std::ostringstream fragment;
+                               fragment <<
                                        "${VERSION_DECL}\n"
                                        "#extension GL_KHR_shader_subgroup_basic: enable\n"
                                        "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                                       "precision highp int;\n"
                                        "layout(location = 0) out uint result;\n"
-                                       "layout(binding = 16, std430) buffer Buffer16\n"
+                                       "layout(binding = 12, std430) buffer Buffer12\n"
                                        "{\n"
+                                       "  uint value;\n"
                                        "  uint tempBuffer[];\n"
-                                       "} b16;\n"
-                                       "layout(binding = 17, std430) buffer Buffer17\n"
+                                       "} b12;\n"
+                                       "layout(binding = 13, std430) buffer Buffer13\n"
                                        "{\n"
                                        "  uint subgroupID;\n"
-                                       "} b17;\n"
-                                       "layout(binding = 18, std430) buffer Buffer18\n"
-                                       "{\n"
-                                       "  uint value;\n"
-                                       "} b18;\n"
-                                       "layout(binding = 4, r32ui) uniform highp uimage2D tempImage4;\n"
-                                       "void main (void)\n"
+                                       "} b13;\n"
+                               <<      (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType ? "layout(binding = 4, r32ui) uniform highp uimage2D tempImage4;\n" : "")
+                               <<      "void main (void)\n"
                                        "{\n"
                                        "  if (gl_HelperInvocation) return;\n"
                                        "  uint id = 0u;\n"
                                        "  if (subgroupElect())\n"
                                        "  {\n"
-                                       "    id = atomicAdd(b17.subgroupID, 1u);\n"
+                                       "    id = atomicAdd(b13.subgroupID, 1u);\n"
                                        "  }\n"
                                        "  id = subgroupBroadcastFirst(id);\n"
                                        "  uint localId = id;\n"
@@ -1211,7 +1195,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                        + bdyTemplate.specialize(bufferNameMapping) +
                                        "  result = tempResult;\n"
                                        "}\n";
-                               programCollection.add("fragment") << glu::FragmentSource(fragment);
+                               programCollection.add("fragment") << glu::FragmentSource(fragment.str());
                        }
 
                subgroups::addNoSubgroupShader(programCollection);
@@ -1261,6 +1245,16 @@ tcu::TestStatus noSSBOtest (Context& context, const CaseDefinition caseDef)
                }
        }
 
+       if (OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType)
+       {
+               if (!subgroups::isImageSupportedForStageOnDevice(context, caseDef.shaderStage))
+               {
+                       TCU_THROW(NotSupportedError, "Subgroup basic memory barrier image test for " +
+                                                                                subgroups::getShaderStageName(caseDef.shaderStage) +
+                                                                                " stage requires that image uniforms be supported on this stage");
+               }
+       }
+
        const deUint32                                          inputDatasCount = OPTYPE_SUBGROUP_MEMORY_BARRIER_IMAGE == caseDef.opType ? 3u : 2u;
        std::vector<subgroups::SSBOData>        inputDatas              (inputDatasCount);
 
@@ -1346,26 +1340,20 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef)
                }
                else
                {
-                       const deUint32 inputDatasCount = 3;
+                       const deUint32 inputDatasCount = 2;
                        subgroups::SSBOData inputDatas[inputDatasCount];
                        inputDatas[0].format = subgroups::FORMAT_R32_UINT;
                        inputDatas[0].layout = subgroups::SSBOData::LayoutStd430;
-                       inputDatas[0].numElements = SHADER_BUFFER_SIZE;
-                       inputDatas[0].initializeType = subgroups::SSBOData::InitializeNone;
+                       inputDatas[0].numElements = 1 + SHADER_BUFFER_SIZE;
+                       inputDatas[0].initializeType = subgroups::SSBOData::InitializeNonZero;
                        inputDatas[0].binding = 1u;
 
                        inputDatas[1].format = subgroups::FORMAT_R32_UINT;
-                       inputDatas[1].layout = subgroups::SSBOData::LayoutStd430;
-                       inputDatas[1].numElements = 1;
-                       inputDatas[1].initializeType = subgroups::SSBOData::InitializeNonZero;
-                       inputDatas[1].binding = 2u;
-
-                       inputDatas[2].format = subgroups::FORMAT_R32_UINT;
-                       inputDatas[2].layout = subgroups::SSBOData::LayoutPacked;
-                       inputDatas[2].numElements = SHADER_BUFFER_SIZE;
-                       inputDatas[2].initializeType = subgroups::SSBOData::InitializeNone;
-                       inputDatas[2].isImage = true;
-                       inputDatas[2].binding = 0u;
+                       inputDatas[1].layout = subgroups::SSBOData::LayoutPacked;
+                       inputDatas[1].numElements = SHADER_BUFFER_SIZE;
+                       inputDatas[1].initializeType = subgroups::SSBOData::InitializeNone;
+                       inputDatas[1].isImage = true;
+                       inputDatas[1].binding = 0u;
 
                        return subgroups::makeComputeTest(context, subgroups::FORMAT_R32_UINT, inputDatas, inputDatasCount, checkComputeSubgroupBarriers);
                }
@@ -1378,6 +1366,7 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef)
                }
 
                int supportedStages = context.getDeqpContext().getContextInfo().getInt(GL_SUBGROUP_SUPPORTED_STAGES_KHR);
+               int combinedSSBOs = context.getDeqpContext().getContextInfo().getInt(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS);
 
                subgroups::ShaderStageFlags stages = (subgroups::ShaderStageFlags)(caseDef.shaderStage & supportedStages);
 
@@ -1392,6 +1381,13 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef)
                if ((subgroups::ShaderStageFlags)0u == stages)
                        TCU_THROW(NotSupportedError, "Subgroup operations are not supported for any graphic shader");
 
+               // with sufficient effort we could dynamically assign the binding points
+               // based on the number of stages actually supported, etc, but we already
+               // have the framebuffer tests which cover those cases, so there doesn't seem
+               // to be much benefit in doing that right now.
+               if (combinedSSBOs < 14)
+                       TCU_THROW(NotSupportedError, "Device does not support enough combined SSBOs for this test (14)");
+
                if (OPTYPE_ELECT == caseDef.opType)
                {
                        const deUint32 inputCount = 5u;
@@ -1445,17 +1441,17 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef)
                                subgroups::SHADER_STAGE_FRAGMENT_BIT,
                        };
 
-                       const deUint32 inputDatasCount = DE_LENGTH_OF_ARRAY(stagesBits) * 4u;
+                       const deUint32 inputDatasCount = DE_LENGTH_OF_ARRAY(stagesBits) * 3u;
                        subgroups::SSBOData inputDatas[inputDatasCount];
 
                        for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stagesBits); ++ndx)
                        {
-                               const deUint32 index = ndx*4;
-                               const deUint32 ssboIndex = ndx*3;
+                               const deUint32 index = ndx*3;
+                               const deUint32 ssboIndex = ndx*2;
                                const deUint32 imgIndex = ndx;
                                inputDatas[index].format                                = subgroups::FORMAT_R32_UINT;
                                inputDatas[index].layout                                = subgroups::SSBOData::LayoutStd430;
-                               inputDatas[index].numElements                   = SHADER_BUFFER_SIZE;
+                               inputDatas[index].numElements                   = 1 + SHADER_BUFFER_SIZE;
                                inputDatas[index].initializeType                = subgroups::SSBOData::InitializeNonZero;
                                inputDatas[index].binding                               = ssboIndex + 4u;
                                inputDatas[index].stages                                = stagesBits[ndx];
@@ -1468,19 +1464,12 @@ tcu::TestStatus test(Context& context, const CaseDefinition caseDef)
                                inputDatas[index + 1].stages                    = stagesBits[ndx];
 
                                inputDatas[index + 2].format                    = subgroups::FORMAT_R32_UINT;
-                               inputDatas[index + 2].layout                    = subgroups::SSBOData::LayoutStd430;
-                               inputDatas[index + 2].numElements               = 1;
-                               inputDatas[index + 2].initializeType    = subgroups::SSBOData::InitializeNonZero;
-                               inputDatas[index + 2].binding                   = ssboIndex + 6u;
+                               inputDatas[index + 2].layout                    = subgroups::SSBOData::LayoutPacked;
+                               inputDatas[index + 2].numElements               = SHADER_BUFFER_SIZE;
+                               inputDatas[index + 2].initializeType    = subgroups::SSBOData::InitializeNone;
+                               inputDatas[index + 2].isImage                   = true;
+                               inputDatas[index + 2].binding                   = imgIndex;
                                inputDatas[index + 2].stages                    = stagesBits[ndx];
-
-                               inputDatas[index + 3].format                    = subgroups::FORMAT_R32_UINT;
-                               inputDatas[index + 3].layout                    = subgroups::SSBOData::LayoutPacked;
-                               inputDatas[index + 3].numElements               = SHADER_BUFFER_SIZE;
-                               inputDatas[index + 3].initializeType    = subgroups::SSBOData::InitializeNone;
-                               inputDatas[index + 3].isImage                   = true;
-                               inputDatas[index + 3].binding                   = imgIndex;
-                               inputDatas[index + 3].stages                    = stagesBits[ndx];
                        }
 
                        return subgroups::allStages(context, subgroups::FORMAT_R32_UINT, inputDatas, inputDatasCount, checkVertexPipelineStagesSubgroupBarriers, stages);
index ae9be21..d4aa9e7 100755 (executable)
@@ -351,6 +351,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        const string fragment =
                                "${VERSION_DECL}\n"
                                "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                               "precision highp int;\n"
                                "layout(location = 0) out uint result;\n"
                                "void main (void)\n"
                                "{\n"
index 0a32b95..65541ba 100755 (executable)
@@ -323,7 +323,8 @@ void initFrameBufferPrograms (SourceCollections& programCollection, CaseDefiniti
 {
        {
                const string fragmentGLSL =
-                 "${VERSION_DECL}\n"
+                       "${VERSION_DECL}\n"
+                       "precision highp int;\n"
                        "layout(location = 0) in highp vec4 in_color;\n"
                        "layout(location = 0) out uvec4 out_color;\n"
                        "void main()\n"
@@ -558,6 +559,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        const string fragmentGLSL =
                                "${VERSION_DECL}\n"
                                "#extension GL_KHR_shader_subgroup_basic: enable\n"
+                               "precision highp int;\n"
                                "layout(location = 0) out uvec4 data;\n"
                                "void main (void)\n"
                                "{\n"
index 33ba6d6..e460591 100755 (executable)
@@ -625,6 +625,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                "${VERSION_DECL}\n"
                                "#extension GL_KHR_shader_subgroup_clustered: enable\n"
                                "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                               "precision highp int;\n"
                                "precision highp float;\n"
                                "layout(location = 0) out uint result;\n"
                                "layout(binding = 4, std430) readonly buffer Buffer4\n"
index b3409bd..412ae03 100755 (executable)
@@ -713,6 +713,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                "#extension GL_NV_shader_subgroup_partitioned: enable\n"
                            "#extension GL_KHR_shader_subgroup_arithmetic: enable\n"
                                "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                               "precision highp int;\n"
                                "precision highp float;\n"
                                "layout(location = 0) out uint result;\n"
                                "layout(binding = 4, std430) readonly buffer Buffer4\n"
index ef4a6f8..7919df7 100755 (executable)
@@ -518,6 +518,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                                "${VERSION_DECL}\n"
                                "#extension GL_KHR_shader_subgroup_quad: enable\n"
                                "#extension GL_KHR_shader_subgroup_ballot: enable\n"
+                               "precision highp int;\n"
                                "precision highp float;\n"
                                "layout(location = 0) out uint result;\n"
                                "layout(binding = 4, std430) readonly buffer Buffer4\n"
index c35bea4..25b884a 100755 (executable)
@@ -410,6 +410,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                        const string fragment =
                                "${VERSION_DECL}\n"
                                + extension +
+                               "precision highp int;\n"
                                "layout(location = 0) out uint result;\n"
                                "void main (void)\n"
                                "{\n"
index cc6de0f..89f6d3b 100755 (executable)
@@ -404,6 +404,7 @@ void initPrograms(SourceCollections& programCollection, CaseDefinition caseDef)
                {
                        const string fragment =
                                versionSource + extSource +
+                               "precision highp int;\n"
                                "precision highp float;\n"
                                "layout(location = 0) out uint result;\n"
                                + declSource +
index 03493bc..9d1c30a 100755 (executable)
@@ -785,6 +785,37 @@ bool glc::subgroups::isVertexSSBOSupportedForDevice(Context& context)
        return (numVertexSSBOs > 0) ? true : false;
 }
 
+bool glc::subgroups::isImageSupportedForStageOnDevice(Context& context, const ShaderStageFlags stage)
+{
+       glw::GLint stageQuery;
+       DE_ASSERT(stage & SHADER_STAGE_ALL_VALID);
+
+       // image uniforms are optional in VTG stages
+       switch (stage)
+       {
+               case SHADER_STAGE_FRAGMENT_BIT:
+               case SHADER_STAGE_COMPUTE_BIT:
+               default:
+                       return true;
+               case SHADER_STAGE_VERTEX_BIT:
+                       stageQuery = GL_MAX_VERTEX_IMAGE_UNIFORMS;
+                       break;
+               case SHADER_STAGE_TESS_CONTROL_BIT:
+                       stageQuery = GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS;
+                       break;
+               case SHADER_STAGE_TESS_EVALUATION_BIT:
+                       stageQuery = GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS;
+                       break;
+               case SHADER_STAGE_GEOMETRY_BIT:
+                       stageQuery = GL_MAX_GEOMETRY_IMAGE_UNIFORMS;
+                       break;
+       }
+
+       int numImages = context.getDeqpContext().getContextInfo().getInt(stageQuery);
+
+       return (numImages > 0) ? true : false;
+}
+
 bool glc::subgroups::isDoubleSupportedForDevice(Context& context)
 {
        glu::ContextType contextType = context.getDeqpContext().getRenderContext().getType();
@@ -871,6 +902,7 @@ void glc::subgroups::setFragmentShaderFrameBuffer (SourceCollections& programCol
 {
        programCollection.add("fragment") << glu::FragmentSource(
                "${VERSION_DECL}\n"
+               "precision highp int;\n"
                "layout(location = 0) in highp float in_color;\n"
                "layout(location = 0) out uint out_color;\n"
                "void main()\n"
@@ -1470,7 +1502,8 @@ tcu::TestStatus glc::subgroups::allStages(
                inputBuffers[ndx] = de::SharedPtr<BufferOrImage>(new Buffer(context, size));
 
                log << tcu::TestLog::Message
-                       << "binding inputBuffers[" << ndx << "](" << inputBuffers[ndx]->getType() << ", " << inputBuffers[ndx]->getId() << " ), "
+                       << "binding inputBuffers[" << ndx << "](" << inputBuffers[ndx]->getType() << ", "
+                       << inputBuffers[ndx]->getId() << ", " << size << "), "
                        << "inputstage[" << ndx << "] = " << stagesVector[ndx] << " binding = " << getResultBinding(stagesVector[ndx])
                        << tcu::TestLog::EndMessage;
 
@@ -1499,7 +1532,8 @@ tcu::TestStatus glc::subgroups::allStages(
                }
 
                log << tcu::TestLog::Message
-                       << "binding inputBuffers[" << ndx << "](" << inputBuffers[ndx]->getType() << ", " << inputBuffers[ndx]->getId() << " ), "
+                       << "binding inputBuffers[" << ndx << "](" << inputBuffers[ndx]->getType() << ", "
+                       << inputBuffers[ndx]->getId() << ", " << extraDatas[datasNdx].numElements << " els), "
                        << "extrastage[" << datasNdx << "] = " << extraDatas[datasNdx].stages << " binding = " << extraDatas[datasNdx].binding
                        << tcu::TestLog::EndMessage;
 
@@ -1606,7 +1640,6 @@ tcu::TestStatus glc::subgroups::allStages(
                                        {
                                                glw::GLvoid * resultData = inputBuffers[index]->getAsBuffer()->mapBufferPtr();
                                                buffersToUnmap.push_back(inputBuffers[index]->getAsBuffer());
-                                               // we always have our result data first
                                                datas.push_back(resultData);
                                        }
                                }
index d20a935..0143233 100644 (file)
@@ -424,6 +424,8 @@ bool isFragmentSSBOSupportedForDevice(Context& context);
 
 bool isVertexSSBOSupportedForDevice(Context& context);
 
+bool isImageSupportedForStageOnDevice(Context& context, const ShaderStageFlags stage);
+
 bool isDoubleSupportedForDevice(Context& context);
 
 bool isDoubleFormat(Format format);