Unify getShaderStageName helper
authorIlkka Saarelainen <ilkka.saarelainen@siru.fi>
Wed, 22 May 2019 10:25:49 +0000 (13:25 +0300)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 29 May 2019 17:19:38 +0000 (13:19 -0400)
Clean out helper functions used to create shader stage
and precision names.

Note: affects only the test case name generation.

Affects:

dEQP-VK.ycbcr.format.*
dEQP-VK.glsl.builtin.function.*
dEQP-VK.protected_memory.ssbo.ssbo_atomic.*

Components: Vulkan, Framework, OpenGL

VK-GL-CTS issue: 1736

Change-Id: Id326c3c241ecf1a60c0dda3ee8c31b155114fc3c

13 files changed:
external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemStorageBufferTests.cpp
external/vulkancts/modules/vulkan/shaderexecutor/vktShaderCommonFunctionTests.cpp
external/vulkancts/modules/vulkan/shaderexecutor/vktShaderIntegerFunctionTests.cpp
external/vulkancts/modules/vulkan/shaderexecutor/vktShaderPackingFunctionTests.cpp
external/vulkancts/modules/vulkan/ycbcr/vktYCbCrFormatTests.cpp
framework/opengl/gluShaderUtil.cpp
framework/opengl/gluShaderUtil.hpp
modules/gles3/functional/es3fShaderCommonFunctionTests.cpp
modules/gles3/functional/es3fShaderPackingFunctionTests.cpp
modules/gles31/functional/es31fShaderCommonFunctionTests.cpp
modules/gles31/functional/es31fShaderIntegerFunctionTests.cpp
modules/gles31/functional/es31fShaderPackingFunctionTests.cpp
modules/gles31/functional/es31fShaderUniformIntegerFunctionTests.cpp

index a0b93e0..ae944b8 100644 (file)
@@ -96,15 +96,6 @@ const char* getSSBOTypeString (SSBOTestType type)
        }
 }
 
-const char* getShaderTypeString (const glu::ShaderType shaderType)
-{
-       switch (shaderType) {
-               case glu::SHADERTYPE_FRAGMENT:  return "fragment";
-               case glu::SHADERTYPE_COMPUTE:   return "compute";
-               default: DE_FATAL("Invalid shader type"); return "";
-       }
-}
-
 const char* getSSBOAtomicTypeString (SSBOAtomicType type)
 {
        switch (type)
@@ -717,7 +708,7 @@ tcu::TestCaseGroup* createRWStorageBufferTests (tcu::TestContext&                                                   testCtx,
        for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(shaderTypes); ++shaderNdx)
        {
                const glu::ShaderType                           shaderType                      = shaderTypes[shaderNdx];
-               const std::string                                       shaderName                      = getShaderTypeString(shaderType);
+               const std::string                                       shaderName                      = glu::getShaderTypeName(shaderType);
                const std::string                                       shaderGroupDesc         = "Storage buffer tests for shader type: " + shaderName;
                de::MovePtr<tcu::TestCaseGroup>         testShaderGroup         (new tcu::TestCaseGroup(testCtx, shaderName.c_str(), shaderGroupDesc.c_str()));
 
@@ -854,7 +845,7 @@ tcu::TestCaseGroup* createAtomicStorageBufferTests (tcu::TestContext& testctx)
        for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(shaderTypes); ++shaderNdx)
        {
                const glu::ShaderType                           shaderType                      = shaderTypes[shaderNdx];
-               const std::string                                       shaderName                      = getShaderTypeString(shaderType);
+               const std::string                                       shaderName                      = glu::getShaderTypeName(shaderType);
                const std::string                                       shaderDesc                      = "Storage Buffer Atomic Tests for shader type: " + shaderName;
                de::MovePtr<tcu::TestCaseGroup>         atomicShaderGroup       (new tcu::TestCaseGroup(testctx, shaderName.c_str(), shaderDesc.c_str()));
 
index 9961392..7b4724d 100644 (file)
@@ -326,34 +326,6 @@ std::ostream& operator<< (std::ostream& str, const VarValue& varValue)
        return str;
 }
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-       {
-               "_lowp",
-               "_mediump",
-               "_highp"
-       };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-       {
-               "_vertex",
-               "_fragment",
-               "_geometry",
-               "_tess_control",
-               "_tess_eval",
-               "_compute"
-       };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 static std::string getCommonFuncCaseName (glu::DataType baseType, glu::Precision precision, glu::ShaderType shaderType)
 {
        return string(glu::getDataTypeName(baseType)) + getPrecisionPostfix(precision) + getShaderTypePostfix(shaderType);
index c651f54..a7d2956 100644 (file)
@@ -193,34 +193,6 @@ static vector<void*> getInputOutputPointers (const vector<Symbol>& symbols, vect
        return pointers;
 }
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-       {
-               "_lowp",
-               "_mediump",
-               "_highp"
-       };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-       {
-               "_vertex",
-               "_fragment",
-               "_geometry",
-               "_tess_control",
-               "_tess_eval",
-               "_compute"
-       };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 static std::string getIntegerFuncCaseName (glu::DataType baseType, glu::Precision precision, glu::ShaderType shaderType)
 {
        return string(glu::getDataTypeName(baseType)) + getPrecisionPostfix(precision) + getShaderTypePostfix(shaderType);
index ad40f2e..5a1a5d8 100644 (file)
@@ -65,34 +65,6 @@ std::ostream& operator<< (std::ostream& str, const HexFloat& v)
        return str << v.value << " / " << tcu::toHex(tcu::Float32(v.value).bits());
 }
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-       {
-               "_lowp",
-               "_mediump",
-               "_highp"
-       };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-       {
-               "_vertex",
-               "_fragment",
-               "_geometry",
-               "_tess_control",
-               "_tess_eval",
-               "_compute"
-       };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 } // anonymous
 
 // ShaderPackingFunctionCase
index 83acdaa..e6f7c3f 100644 (file)
@@ -550,19 +550,15 @@ void initPrograms (SourceCollections& dst, TestParameters params)
 
 void populatePerFormatGroup (tcu::TestCaseGroup* group, VkFormat format)
 {
-       const UVec2     size    (66, 32);
-       const struct
-       {
-               const char*             name;
-               glu::ShaderType value;
-       } shaderTypes[] =
+       const UVec2                             size                    (66, 32);
+       const glu::ShaderType   shaderTypes[]   =
        {
-               { "vertex",                     glu::SHADERTYPE_VERTEX },
-               { "fragment",           glu::SHADERTYPE_FRAGMENT },
-               { "geometry",           glu::SHADERTYPE_GEOMETRY },
-               { "tess_control",       glu::SHADERTYPE_TESSELLATION_CONTROL },
-               { "tess_eval",          glu::SHADERTYPE_TESSELLATION_EVALUATION },
-               { "compute",            glu::SHADERTYPE_COMPUTE }
+               glu::SHADERTYPE_VERTEX,
+               glu::SHADERTYPE_FRAGMENT,
+               glu::SHADERTYPE_GEOMETRY,
+               glu::SHADERTYPE_TESSELLATION_CONTROL,
+               glu::SHADERTYPE_TESSELLATION_EVALUATION,
+               glu::SHADERTYPE_COMPUTE
        };
        const struct
        {
@@ -574,14 +570,13 @@ void populatePerFormatGroup (tcu::TestCaseGroup* group, VkFormat format)
                { "linear",             VK_IMAGE_TILING_LINEAR }
        };
 
-       for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(shaderTypes); shaderTypeNdx++)
+       for (glu::ShaderType shaderType : shaderTypes)
        for (int tilingNdx = 0; tilingNdx < DE_LENGTH_OF_ARRAY(tilings); tilingNdx++)
        for (int useArrayLayers = 0; useArrayLayers < 2; useArrayLayers++)
        {
                const VkImageTiling             tiling                  = tilings[tilingNdx].value;
                const char* const               tilingName              = tilings[tilingNdx].name;
-               const glu::ShaderType   shaderType              = shaderTypes[shaderTypeNdx].value;
-               const char* const               shaderTypeName  = shaderTypes[shaderTypeNdx].name;
+               const char* const               shaderTypeName  = glu::getShaderTypeName(shaderType);
                const string                    name                    = string(shaderTypeName) + "_" + tilingName + ((useArrayLayers) ? "_array" : "");
 
                addFunctionCaseWithPrograms(group, name, "", checkSupport, initPrograms, testFormat, TestParameters(format, size, 0u, tiling, shaderType, false, useArrayLayers));
index abd7cd9..9881ac9 100644 (file)
@@ -159,6 +159,11 @@ const char* getShaderTypeName (ShaderType shaderType)
        return s_names[(int)shaderType];
 }
 
+std::string getShaderTypePostfix (ShaderType shaderType)
+{
+       return "_" + std::string(getShaderTypeName(shaderType));
+}
+
 // Precision
 
 const char* getPrecisionName (Precision precision)
@@ -175,6 +180,11 @@ const char* getPrecisionName (Precision precision)
        return s_names[(int)precision];
 }
 
+std::string getPrecisionPostfix (Precision precision)
+{
+       return "_" + std::string(getPrecisionName(precision));
+}
+
 // DataType
 
 const char* getDataTypeName (DataType dataType)
index 58d53c4..7d6e749 100644 (file)
@@ -78,7 +78,8 @@ enum ShaderType
        SHADERTYPE_LAST
 };
 
-const char*    getShaderTypeName (ShaderType shaderType);
+const char*            getShaderTypeName               (ShaderType shaderType);
+std::string            getShaderTypePostfix    (ShaderType shaderType);
 
 // Precision
 
@@ -91,7 +92,8 @@ enum Precision
        PRECISION_LAST
 };
 
-const char* getPrecisionName (Precision precision);
+const char* getPrecisionName   (Precision precision);
+std::string getPrecisionPostfix        (Precision precision);
 
 // DataType
 
index edcf245..53b63e7 100644 (file)
@@ -374,30 +374,6 @@ CommonFunctionCase::IterateResult CommonFunctionCase::iterate (void)
        return STOP;
 }
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-       {
-               "_lowp",
-               "_mediump",
-               "_highp"
-       };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-       {
-               "_vertex",
-               "_fragment"
-       };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 static std::string getCommonFuncCaseName (glu::DataType baseType, glu::Precision precision, glu::ShaderType shaderType)
 {
        return string(glu::getDataTypeName(baseType)) + getPrecisionPostfix(precision) + getShaderTypePostfix(shaderType);
index bc5141b..f7f717e 100644 (file)
@@ -117,30 +117,6 @@ void ShaderPackingFunctionCase::deinit (void)
 
 // Test cases
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-       {
-               "_lowp",
-               "_mediump",
-               "_highp"
-       };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-       {
-               "_vertex",
-               "_fragment"
-       };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 class PackSnorm2x16Case : public ShaderPackingFunctionCase
 {
 public:
index 566e183..21ee0f6 100644 (file)
@@ -448,34 +448,6 @@ CommonFunctionCase::IterateResult CommonFunctionCase::iterate (void)
        return STOP;
 }
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-       {
-               "_lowp",
-               "_mediump",
-               "_highp"
-       };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-       {
-               "_vertex",
-               "_fragment",
-               "_geometry",
-               "_tess_control",
-               "_tess_eval",
-               "_compute"
-       };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 static std::string getCommonFuncCaseName (glu::DataType baseType, glu::Precision precision, glu::ShaderType shaderType)
 {
        return string(glu::getDataTypeName(baseType)) + getPrecisionPostfix(precision) + getShaderTypePostfix(shaderType);
index 59ebdfb..19f44be 100644 (file)
@@ -319,34 +319,6 @@ IntegerFunctionCase::IterateResult IntegerFunctionCase::iterate (void)
        return STOP;
 }
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-       {
-               "_lowp",
-               "_mediump",
-               "_highp"
-       };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-       {
-               "_vertex",
-               "_fragment",
-               "_geometry",
-               "_tess_control",
-               "_tess_eval",
-               "_compute"
-       };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 static std::string getIntegerFuncCaseName (glu::DataType baseType, glu::Precision precision, glu::ShaderType shaderType)
 {
        return string(glu::getDataTypeName(baseType)) + getPrecisionPostfix(precision) + getShaderTypePostfix(shaderType);
index ddf3667..6ebdf69 100644 (file)
@@ -117,34 +117,6 @@ void ShaderPackingFunctionCase::deinit (void)
 
 // Test cases
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-       {
-               "_lowp",
-               "_mediump",
-               "_highp"
-       };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-       {
-               "_vertex",
-               "_fragment",
-               "_geometry",
-               "_tess_control",
-               "_tess_eval",
-               "_compute"
-       };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 class PackSnorm2x16Case : public ShaderPackingFunctionCase
 {
 public:
index 466d793..2211546 100644 (file)
@@ -143,37 +143,9 @@ tcu::TestNode::IterateResult UniformIntegerFunctionCase::iterate(void)
        return STOP;
 }
 
-static const char* getPrecisionPostfix (glu::Precision precision)
-{
-       static const char* s_postfix[] =
-               {
-                       "lowp",
-                       "mediump",
-                       "highp"
-               };
-       DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(s_postfix) == glu::PRECISION_LAST);
-       DE_ASSERT(de::inBounds<int>(precision, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[precision];
-}
-
-static const char* getShaderTypePostfix (glu::ShaderType shaderType)
-{
-       static const char* s_postfix[] =
-               {
-                       "_vertex",
-                       "_fragment",
-                       "_geometry",
-                       "_tess_control",
-                       "_tess_eval",
-                       "_compute"
-               };
-       DE_ASSERT(de::inBounds<int>(shaderType, 0, DE_LENGTH_OF_ARRAY(s_postfix)));
-       return s_postfix[shaderType];
-}
-
 static std::string getCaseName (glu::Precision precision, glu::ShaderType shaderType)
 {
-       return string(getPrecisionPostfix(precision)) + getShaderTypePostfix(shaderType);
+       return string(getPrecisionName(precision)) + getShaderTypePostfix(shaderType);
 }
 
 static int findMSB (deInt32 value)