ShaderRenderCase: Add some basic predefined uniforms which can be used by test cases
authorPeter Gal <pgal.u-szeged@partner.samsung.com>
Tue, 1 Sep 2015 12:21:35 +0000 (14:21 +0200)
committerPeter Gal <pgal.u-szeged@partner.samsung.com>
Thu, 12 Nov 2015 18:52:42 +0000 (19:52 +0100)
external/vulkancts/modules/vulkan/shaderrendercase/vktShaderRenderCase.cpp
external/vulkancts/modules/vulkan/shaderrendercase/vktShaderRenderCase.hpp
external/vulkancts/modules/vulkan/shaderrendercase/vktShaderRenderCaseTests.cpp

index a37875e..85479f8 100644 (file)
@@ -488,6 +488,119 @@ void ShaderRenderCaseInstance::setupUniforms (const Vec4& constCoords)
        m_uniformFunc(*this);
 }
 
+void ShaderRenderCaseInstance::useUniform (deUint32 bindingLocation, BaseUniformType type)
+{
+       #define CASE(type, value) case type: addUniform(bindingLocation, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, value); break
+
+       switch(type)
+       {
+               // Bool
+               // TODO: size correction might be needed
+               CASE(UB_FALSE,  0);
+               CASE(UB_TRUE,   1);
+
+               // BVec4
+               CASE(UB4_FALSE, Vec4(0));
+               CASE(UB4_TRUE,  Vec4(1));
+
+               // Integer
+               CASE(UI_ZERO,   0);
+               CASE(UI_ONE,    1);
+               CASE(UI_TWO,    2);
+               CASE(UI_THREE,  3);
+               CASE(UI_FOUR,   4);
+               CASE(UI_FIVE,   5);
+               CASE(UI_SIX,    6);
+               CASE(UI_SEVEN,  7);
+               CASE(UI_EIGTH,  8);
+               CASE(UI_ONEHUNDREDONE, 101);
+
+               // IVec2
+               CASE(UI2_MINUS_ONE, IVec2(-1));
+               CASE(UI2_ZERO,          IVec2(0));
+               CASE(UI2_ONE,           IVec2(1));
+               CASE(UI2_TWO,           IVec2(2));
+               CASE(UI2_THREE,         IVec2(3));
+               CASE(UI2_FOUR,          IVec2(4));
+               CASE(UI2_FIVE,          IVec2(5));
+
+               // IVec3
+               CASE(UI3_MINUS_ONE,     IVec3(-1));
+               CASE(UI3_ZERO,          IVec3(0));
+               CASE(UI3_ONE,           IVec3(1));
+               CASE(UI3_TWO,           IVec3(2));
+               CASE(UI3_THREE,         IVec3(3));
+               CASE(UI3_FOUR,          IVec3(4));
+               CASE(UI3_FIVE,          IVec3(5));
+
+               // IVec4
+               CASE(UI4_MINUS_ONE, IVec4(-1));
+               CASE(UI4_ZERO,          IVec4(0));
+               CASE(UI4_ONE,           IVec4(1));
+               CASE(UI4_TWO,           IVec4(2));
+               CASE(UI4_THREE,         IVec4(3));
+               CASE(UI4_FOUR,          IVec4(4));
+               CASE(UI4_FIVE,          IVec4(5));
+
+               // Float
+               CASE(UF_ZERO,           0.0f);
+               CASE(UF_ONE,            1.0f);
+               CASE(UF_TWO,            2.0f);
+               CASE(UF_THREE,          3.0f);
+               CASE(UF_FOUR,           4.0f);
+               CASE(UF_FIVE,           5.0f);
+               CASE(UF_SIX,            6.0f);
+               CASE(UF_SEVEN,          7.0f);
+               CASE(UF_EIGTH,          8.0f);
+
+               CASE(UF_HALF,           1.0f / 2.0f);
+               CASE(UF_THIRD,          1.0f / 3.0f);
+               CASE(UF_FOURTH,         1.0f / 4.0f);
+               CASE(UF_FIFTH,          1.0f / 5.0f);
+               CASE(UF_SIXTH,          1.0f / 6.0f);
+               CASE(UF_SEVENTH,        1.0f / 7.0f);
+               CASE(UF_EIGHTH,         1.0f / 8.0f);
+
+               // Vec2
+               CASE(UV2_MINUS_ONE,     Vec2(-1.0f));
+               CASE(UV2_ZERO,          Vec2(0.0f));
+               CASE(UV2_ONE,           Vec2(1.0f));
+               CASE(UV2_TWO,           Vec2(2.0f));
+               CASE(UV2_THREE,         Vec2(3.0f));
+
+               CASE(UV2_HALF,          Vec2(1.0f / 2.0f));
+
+               // Vec3
+               CASE(UV3_MINUS_ONE,     Vec3(-1.0f));
+               CASE(UV3_ZERO,          Vec3(0.0f));
+               CASE(UV3_ONE,           Vec3(1.0f));
+               CASE(UV3_TWO,           Vec3(2.0f));
+               CASE(UV3_THREE,         Vec3(3.0f));
+
+               CASE(UV3_HALF,          Vec3(1.0f / 2.0f));
+
+               // Vec4
+               CASE(UV4_MINUS_ONE,     Vec4(-1.0f));
+               CASE(UV4_ZERO,          Vec4(0.0f));
+               CASE(UV4_ONE,           Vec4(1.0f));
+               CASE(UV4_TWO,           Vec4(2.0f));
+               CASE(UV4_THREE,         Vec4(3.0f));
+
+               CASE(UV4_HALF,          Vec4(1.0f / 2.0f));
+
+               CASE(UV4_BLACK,         Vec4(0.0f, 0.0f, 0.0f, 1.0f));
+               CASE(UV4_GRAY,          Vec4(0.5f, 0.5f, 0.5f, 1.0f));
+               CASE(UV4_WHITE,         Vec4(1.0f, 1.0f, 1.0f, 1.0f));
+
+               default:
+                       m_context.getTestContext().getLog() << TestLog::Message << "Unknown Uniform type: " << type << TestLog::EndMessage;
+                       break;
+       }
+
+       #undef CASE
+}
+
+
 tcu::IVec2 ShaderRenderCaseInstance::getViewportSize (void) const
 {
        return tcu::IVec2(de::min(m_renderSize.x(), MAX_RENDER_WIDTH),
index 364d19f..0a762a7 100644 (file)
@@ -198,6 +198,105 @@ private:
 };
 
 
+enum BaseUniformType
+{
+// Bool
+       UB_FALSE,
+       UB_TRUE,
+
+// BVec4
+       UB4_FALSE,
+       UB4_TRUE,
+
+// Integers
+       UI_ZERO,
+       UI_ONE,
+       UI_TWO,
+       UI_THREE,
+       UI_FOUR,
+       UI_FIVE,
+       UI_SIX,
+       UI_SEVEN,
+       UI_EIGTH,
+       UI_ONEHUNDREDONE,
+
+// IVec2
+       UI2_MINUS_ONE,
+       UI2_ZERO,
+       UI2_ONE,
+       UI2_TWO,
+       UI2_THREE,
+       UI2_FOUR,
+       UI2_FIVE,
+
+// IVec3
+       UI3_MINUS_ONE,
+       UI3_ZERO,
+       UI3_ONE,
+       UI3_TWO,
+       UI3_THREE,
+       UI3_FOUR,
+       UI3_FIVE,
+
+// IVec4
+       UI4_MINUS_ONE,
+       UI4_ZERO,
+       UI4_ONE,
+       UI4_TWO,
+       UI4_THREE,
+       UI4_FOUR,
+       UI4_FIVE,
+
+// Float
+       UF_ZERO,
+       UF_ONE,
+       UF_TWO,
+       UF_THREE,
+       UF_FOUR,
+       UF_FIVE,
+       UF_SIX,
+       UF_SEVEN,
+       UF_EIGTH,
+
+       UF_HALF,
+       UF_THIRD,
+       UF_FOURTH,
+       UF_FIFTH,
+       UF_SIXTH,
+       UF_SEVENTH,
+       UF_EIGHTH,
+
+// Vec2
+       UV2_MINUS_ONE,
+       UV2_ZERO,
+       UV2_ONE,
+       UV2_TWO,
+       UV2_THREE,
+
+       UV2_HALF,
+
+// Vec3
+       UV3_MINUS_ONE,
+       UV3_ZERO,
+       UV3_ONE,
+       UV3_TWO,
+       UV3_THREE,
+
+       UV3_HALF,
+
+// Vec4
+       UV4_MINUS_ONE,
+       UV4_ZERO,
+       UV4_ONE,
+       UV4_TWO,
+       UV4_THREE,
+
+       UV4_HALF,
+
+       UV4_BLACK,
+       UV4_GRAY,
+       UV4_WHITE
+};
 
 // ShaderRenderCaseInstance.
 
@@ -223,6 +322,8 @@ public:
        void                                                                                            addUniform                                      (deUint32 bindingLocation,
                                                                                                                                                                        vk::VkDescriptorType descriptorType,
                                                                                                                                                                        const T data);
+       void                                                                                            useUniform                                      (deUint32 bindingLocation,
+                                                                                                                                                                       BaseUniformType type);
 
 protected:
        virtual void                                                                            setupShaderData                         (void);
index d5158bd..4da1c18 100644 (file)
@@ -56,8 +56,11 @@ struct  test_struct {
 
 void dummy_uniforms (ShaderRenderCaseInstance& instance)
 {
-       instance.addUniform(0u, vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1.0f);
-       instance.addUniform(1u, vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0.5f);
+       instance.useUniform(0u, UI_ZERO);
+       instance.useUniform(1u, UI_ONE);
+       instance.useUniform(5u, UV4_WHITE);
+       //instance.addUniform(1u, vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1.0f);
+       //instance.addUniform(0u, vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0.5f);
        instance.addUniform(2u, vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, tcu::Vec4(1, 0.5f, 1.0f, 0.5f));
 
        test_struct data =
@@ -116,11 +119,11 @@ tcu::TestCaseGroup* createTests (tcu::TestContext& testCtx)
                "layout(location = 4) in mediump float a_in1;\n"
 
                "layout (set=0, binding=0) uniform buf {\n"
-               "       float item;\n"
+               "       bool item;\n"
                "};\n"
 
                "layout (set=0, binding=1) uniform buf2 {\n"
-               "       float item2;\n"
+               "       int item2;\n"
                "};\n"
 
                "layout (set=0, binding=2) uniform buf3 {\n"
@@ -135,7 +138,7 @@ tcu::TestCaseGroup* createTests (tcu::TestContext& testCtx)
                "};\n"
 
                "out mediump vec4 v_color;\n"
-        "void main (void) { gl_Position = a_position; v_color = vec4(a_coords.xyz, f_1.a + f_2.a + f_3[0].x + f_3[1].x); }\n";
+        "void main (void) { gl_Position = a_position; v_color = vec4(a_coords.xyz, f_1.a + f_2.a + f_3[0].x + f_3[1].x - (item ? item2 : 0)); }\n";
 
        std::string base_fragment = "#version 300 es\n"
         "layout(location = 0) out lowp vec4 o_color;\n"