Improve GLSL source program support
authorPyry Haulos <phaulos@google.com>
Thu, 4 May 2017 22:29:08 +0000 (15:29 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Sun, 18 Jun 2017 14:53:35 +0000 (10:53 -0400)
Old GLSL source program support in Vulkan framework was built on top
of glu::ProgramSources. This had two problems:

1) There was no obvious way to extend/annotate sources with SPIR-V
-specific information such as target SPIR-V version.

2) Most of glu::ProgramSources, such as attribute bindings or TF
configuration, was completely ignored.

This change introduces new vk::GlslSource type that replaces
glu::ProgramSources in vk::SourceCollections. vk::GlslSource contains
shader source strings as well as build options (vk::GlslBuildOptions).

vk::GlslBuildOptions doesn't currently contain anything useful but can
be later extended to support selecting target SPIR-V version for
example.

The change is mostly transparent to existing code, except:

 * vkSpirvProgram.hpp was somewhat unnecessarily including
tcuTestLog.hpp and changing that to a forward declaration required
fixing includes in several test code files.

  * vktShaderExecutor.cpp has been extended to allow specifying build
options.

Components: Vulkan

Change-Id: I69a6cd55ea91215585515b9d41860d818cbc97ae
(cherry picked from commit fa7a45c9bcb909be38ffd55549beb6db5115a65b)

35 files changed:
Android.mk
external/vulkancts/framework/vulkan/CMakeLists.txt
external/vulkancts/framework/vulkan/vkBinaryRegistry.cpp
external/vulkancts/framework/vulkan/vkDefs.hpp
external/vulkancts/framework/vulkan/vkGlslProgram.cpp [new file with mode: 0644]
external/vulkancts/framework/vulkan/vkGlslProgram.hpp [new file with mode: 0644]
external/vulkancts/framework/vulkan/vkGlslToSpirV.cpp
external/vulkancts/framework/vulkan/vkGlslToSpirV.hpp
external/vulkancts/framework/vulkan/vkPrograms.cpp
external/vulkancts/framework/vulkan/vkPrograms.hpp
external/vulkancts/framework/vulkan/vkSpirVProgram.hpp
external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp
external/vulkancts/modules/vulkan/clipping/vktClippingTests.cpp
external/vulkancts/modules/vulkan/draw/vktDrawNegativeViewportHeightTests.cpp
external/vulkancts/modules/vulkan/fragment_ops/vktFragmentOperationsEarlyFragmentTests.cpp
external/vulkancts/modules/vulkan/geometry/vktGeometryInstancedRenderingTests.cpp
external/vulkancts/modules/vulkan/geometry/vktGeometryLayeredRenderingTests.cpp
external/vulkancts/modules/vulkan/geometry/vktGeometryTestsUtil.hpp
external/vulkancts/modules/vulkan/image/vktImageMultisampleLoadStoreTests.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineImageSamplingInstance.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleImageTests.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleInterpolationTests.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineMultisampleTests.cpp
external/vulkancts/modules/vulkan/pipeline/vktPipelineRenderToImageTests.cpp
external/vulkancts/modules/vulkan/shaderexecutor/vktShaderExecutor.cpp
external/vulkancts/modules/vulkan/shaderexecutor/vktShaderExecutor.hpp
external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp
external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesBufferTests.cpp
external/vulkancts/modules/vulkan/ssbo/vktSSBOLayoutTests.cpp
external/vulkancts/modules/vulkan/vktBuildPrograms.cpp
external/vulkancts/modules/vulkan/vktShaderLibrary.cpp
external/vulkancts/modules/vulkan/vktTestPackage.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiDisplayTimingTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiIncrementalPresentTests.cpp
external/vulkancts/modules/vulkan/wsi/vktWsiSharedPresentableImageTests.cpp

index d032bb7..0281756 100644 (file)
@@ -701,6 +701,7 @@ LOCAL_SRC_FILES := \
        external/vulkancts/framework/vulkan/vkDebugReportUtil.cpp \
        external/vulkancts/framework/vulkan/vkDefs.cpp \
        external/vulkancts/framework/vulkan/vkDeviceUtil.cpp \
+       external/vulkancts/framework/vulkan/vkGlslProgram.cpp \
        external/vulkancts/framework/vulkan/vkGlslToSpirV.cpp \
        external/vulkancts/framework/vulkan/vkImageUtil.cpp \
        external/vulkancts/framework/vulkan/vkMemUtil.cpp \
index e286154..baef5d7 100644 (file)
@@ -45,6 +45,8 @@ set(VKUTIL_SRCS
        vkWsiUtil.hpp
        vkDebugReportUtil.cpp
        vkDebugReportUtil.hpp
+       vkGlslProgram.cpp
+       vkGlslProgram.hpp
        )
 
 set(VKUTIL_LIBS
index 54a74e8..6ad9d60 100644 (file)
@@ -30,6 +30,7 @@
 #include "deString.h"
 #include "deInt32.h"
 #include "deFile.h"
+#include "deMemory.h"
 
 #include <sstream>
 #include <fstream>
index cb46b0e..20350a9 100644 (file)
@@ -95,6 +95,13 @@ private:
 
 #define VK_CORE_FORMAT_LAST            ((vk::VkFormat)(vk::VK_FORMAT_ASTC_12x12_SRGB_BLOCK+1))
 
+enum SpirvVersion
+{
+       SPIRV_VERSION_1_0       = 0,    //!< SPIR-V 1.0
+
+       SPIRV_VERSION_LAST
+};
+
 namespace wsi
 {
 
diff --git a/external/vulkancts/framework/vulkan/vkGlslProgram.cpp b/external/vulkancts/framework/vulkan/vkGlslProgram.cpp
new file mode 100644 (file)
index 0000000..377f95b
--- /dev/null
@@ -0,0 +1,58 @@
+/*-------------------------------------------------------------------------
+ * Vulkan CTS Framework
+ * --------------------
+ *
+ * Copyright (c) 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief GLSL source program.
+ *//*--------------------------------------------------------------------*/
+
+#include "vkGlslProgram.hpp"
+
+#include "tcuTestLog.hpp"
+
+namespace vk
+{
+
+tcu::TestLog& operator<< (tcu::TestLog& log, const GlslSource& glslSource)
+{
+       log << tcu::TestLog::ShaderProgram(false, "(Source only)");
+
+       try
+       {
+               for (int shaderType = 0; shaderType < glu::SHADERTYPE_LAST; shaderType++)
+               {
+                       for (size_t shaderNdx = 0; shaderNdx < glslSource.sources[shaderType].size(); shaderNdx++)
+                       {
+                               log << tcu::TestLog::Shader(glu::getLogShaderType((glu::ShaderType)shaderType),
+                                                                                       glslSource.sources[shaderType][shaderNdx],
+                                                                                       false, "");
+                       }
+               }
+       }
+       catch (...)
+       {
+               log << tcu::TestLog::EndShaderProgram;
+               throw;
+       }
+
+       log << tcu::TestLog::EndShaderProgram;
+
+       return log;
+}
+
+} // vk
diff --git a/external/vulkancts/framework/vulkan/vkGlslProgram.hpp b/external/vulkancts/framework/vulkan/vkGlslProgram.hpp
new file mode 100644 (file)
index 0000000..1afa5a3
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef _VKGLSLPROGRAM_HPP
+#define _VKGLSLPROGRAM_HPP
+/*-------------------------------------------------------------------------
+ * Vulkan CTS Framework
+ * --------------------
+ *
+ * Copyright (c) 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief GLSL source program.
+ *//*--------------------------------------------------------------------*/
+
+#include "vkDefs.hpp"
+#include "gluShaderProgram.hpp"
+
+#include <string>
+
+namespace tcu
+{
+class TestLog;
+} // tcu
+
+namespace vk
+{
+
+struct GlslBuildOptions
+{
+       SpirvVersion    targetVersion;
+       deUint32                flags;
+
+       GlslBuildOptions (SpirvVersion targetVersion_, deUint32 flags_)
+               : targetVersion (targetVersion_)
+               , flags                 (flags_)
+       {}
+
+       GlslBuildOptions (void)
+               : targetVersion (SPIRV_VERSION_1_0)
+               , flags                 (0u)
+       {}
+};
+
+struct GlslSource
+{
+       std::vector<std::string>        sources[glu::SHADERTYPE_LAST];
+       GlslBuildOptions                        buildOptions;
+
+                                                               GlslSource (void) {}
+
+       GlslSource&                                     operator<<                      (const glu::ShaderSource& shaderSource) { sources[shaderSource.shaderType].push_back(shaderSource.source);      return *this;   }
+       GlslSource&                                     operator<<                      (const GlslBuildOptions& buildOptions_) { buildOptions = buildOptions_;                                                                         return *this;   }
+};
+
+tcu::TestLog&  operator<<              (tcu::TestLog& log, const GlslSource& glslSource);
+
+} // vk
+
+#endif // _VKGLSLPROGRAM_HPP
index 4202ddd..a8f5502 100644 (file)
@@ -191,9 +191,7 @@ void getDefaultBuiltInResources (TBuiltInResource* builtin)
        builtin->maxSamples                                                                     = 4;
 };
 
-} // anonymous
-
-int getNumShaderStages (const glu::ProgramSources& program)
+int getNumShaderStages (const GlslSource& program)
 {
        int numShaderStages = 0;
 
@@ -206,10 +204,23 @@ int getNumShaderStages (const glu::ProgramSources& program)
        return numShaderStages;
 }
 
-bool compileGlslToSpirV (const glu::ProgramSources& program, std::vector<deUint32>* dst, glu::ShaderProgramInfo* buildInfo)
+std::string getShaderStageSource (const GlslSource& program, glu::ShaderType shaderType)
+{
+       if (program.sources[shaderType].size() != 1)
+               TCU_THROW(InternalError, "Linking multiple compilation units is not supported");
+
+       return program.sources[shaderType][0];
+}
+
+} // anonymous
+
+bool compileGlslToSpirV (const GlslSource& program, std::vector<deUint32>* dst, glu::ShaderProgramInfo* buildInfo)
 {
        TBuiltInResource        builtinRes;
 
+       if (program.buildOptions.targetVersion != SPIRV_VERSION_1_0)
+               TCU_THROW(InternalError, "Unsupported SPIR-V target version");
+
        if (getNumShaderStages(program) > 1)
                TCU_THROW(InternalError, "Linking multiple shader stages into a single SPIR-V binary is not supported");
 
@@ -221,7 +232,7 @@ bool compileGlslToSpirV (const glu::ProgramSources& program, std::vector<deUint3
        {
                if (!program.sources[shaderType].empty())
                {
-                       const std::string&              srcText                         = program.sources[shaderType][0];
+                       const std::string&              srcText                         = getShaderStageSource(program, (glu::ShaderType)shaderType);
                        const char*                             srcPtrs[]                       = { srcText.c_str() };
                        const int                               srcLengths[]            = { (int)srcText.size() };
                        const EShLanguage               shaderStage                     = getGlslangStage(glu::ShaderType(shaderType));
@@ -281,7 +292,7 @@ void stripSpirVDebugInfo (const size_t numSrcInstrs, const deUint32* srcInstrs,
 
 #else // defined(DEQP_HAVE_GLSLANG)
 
-bool compileGlslToSpirV (const glu::ProgramSources&, std::vector<deUint32>*, glu::ShaderProgramInfo*)
+bool compileGlslToSpirV (const GlslSource&, std::vector<deUint32>*, glu::ShaderProgramInfo*)
 {
        TCU_THROW(NotSupportedError, "GLSL to SPIR-V compilation not supported (DEQP_HAVE_GLSLANG not defined)");
 }
index a32ace9..1d91712 100644 (file)
@@ -45,7 +45,7 @@ namespace vk
  * \note No linking is currently supported so src may contain source
  *       for only one shader stage.
  *//*--------------------------------------------------------------------*/
-bool   compileGlslToSpirV              (const glu::ProgramSources& src, std::vector<deUint32>* dst, glu::ShaderProgramInfo* buildInfo);
+bool   compileGlslToSpirV              (const GlslSource& src, std::vector<deUint32>* dst, glu::ShaderProgramInfo* buildInfo);
 
 /*--------------------------------------------------------------------*//*!
  * \brief Strip SPIR-V binary
index 007efff..8d398b1 100644 (file)
@@ -26,8 +26,6 @@
 #include "vkSpirVAsm.hpp"
 #include "vkRefUtil.hpp"
 
-#include "tcuTestLog.hpp"
-
 #include "deArrayUtil.hpp"
 #include "deMemory.h"
 #include "deInt32.h"
@@ -37,7 +35,6 @@ namespace vk
 
 using std::string;
 using std::vector;
-using tcu::TestLog;
 
 #if defined(DE_DEBUG) && defined(DEQP_HAVE_SPIRV_TOOLS)
 #      define VALIDATE_BINARIES        true
@@ -102,42 +99,36 @@ ProgramBinary* createProgramBinaryFromSpirV (const vector<deUint32>& binary)
 
 } // anonymous
 
-ProgramBinary* buildProgram (const glu::ProgramSources& program, ProgramFormat binaryFormat, glu::ShaderProgramInfo* buildInfo)
+ProgramBinary* buildProgram (const GlslSource& program, glu::ShaderProgramInfo* buildInfo)
 {
-       const bool      validateBinary  = VALIDATE_BINARIES;
+       const bool                      validateBinary  = VALIDATE_BINARIES;
+       vector<deUint32>        binary;
 
-       if (binaryFormat == PROGRAM_FORMAT_SPIRV)
        {
-               vector<deUint32> binary;
+               vector<deUint32> nonStrippedBinary;
 
-               {
-                       vector<deUint32> nonStrippedBinary;
+               if (!compileGlslToSpirV(program, &nonStrippedBinary, buildInfo))
+                       TCU_THROW(InternalError, "Compiling GLSL to SPIR-V failed");
 
-                       if (!compileGlslToSpirV(program, &nonStrippedBinary, buildInfo))
-                               TCU_THROW(InternalError, "Compiling GLSL to SPIR-V failed");
+               TCU_CHECK_INTERNAL(!nonStrippedBinary.empty());
+               stripSpirVDebugInfo(nonStrippedBinary.size(), &nonStrippedBinary[0], &binary);
+               TCU_CHECK_INTERNAL(!binary.empty());
+       }
 
-                       TCU_CHECK_INTERNAL(!nonStrippedBinary.empty());
-                       stripSpirVDebugInfo(nonStrippedBinary.size(), &nonStrippedBinary[0], &binary);
-                       TCU_CHECK_INTERNAL(!binary.empty());
-               }
+       if (validateBinary)
+       {
+               std::ostringstream validationLog;
 
-               if (validateBinary)
+               if (!validateSpirV(binary.size(), &binary[0], &validationLog))
                {
-                       std::ostringstream validationLog;
-
-                       if (!validateSpirV(binary.size(), &binary[0], &validationLog))
-                       {
-                               buildInfo->program.linkOk        = false;
-                               buildInfo->program.infoLog      += "\n" + validationLog.str();
+                       buildInfo->program.linkOk        = false;
+                       buildInfo->program.infoLog      += "\n" + validationLog.str();
 
-                               TCU_THROW(InternalError, "Validation failed for compiled SPIR-V binary");
-                       }
+                       TCU_THROW(InternalError, "Validation failed for compiled SPIR-V binary");
                }
-
-               return createProgramBinaryFromSpirV(binary);
        }
-       else
-               TCU_THROW(NotSupportedError, "Unsupported program format");
+
+       return createProgramBinaryFromSpirV(binary);
 }
 
 ProgramBinary* assembleProgram (const SpirVAsmSource& program, SpirVProgramInfo* buildInfo)
index 4a2a52d..3e54428 100644 (file)
 #include "vkDefs.hpp"
 #include "vkRef.hpp"
 #include "vkSpirVProgram.hpp"
-#include "gluShaderProgram.hpp"
+#include "vkGlslProgram.hpp"
+
 #include "deUniquePtr.hpp"
 #include "deSTLUtil.hpp"
 
 #include <vector>
 #include <map>
 
-namespace tcu
-{
-class TestLog;
-} // tcu
-
 namespace vk
 {
 
@@ -158,8 +154,8 @@ const Program& ProgramCollection<Program>::get (const std::string& name) const
        return *m_programs.find(name)->second;
 }
 
-typedef vk::ProgramCollection<glu::ProgramSources>     GlslSourceCollection;
-typedef vk::ProgramCollection<vk::SpirVAsmSource>      SpirVAsmCollection;
+typedef ProgramCollection<GlslSource>          GlslSourceCollection;
+typedef ProgramCollection<SpirVAsmSource>      SpirVAsmCollection;
 
 struct SourceCollections
 {
@@ -169,7 +165,7 @@ struct SourceCollections
 
 typedef ProgramCollection<ProgramBinary>               BinaryCollection;
 
-ProgramBinary*                 buildProgram            (const glu::ProgramSources& program, ProgramFormat binaryFormat, glu::ShaderProgramInfo* buildInfo);
+ProgramBinary*                 buildProgram            (const GlslSource& program, glu::ShaderProgramInfo* buildInfo);
 ProgramBinary*                 assembleProgram         (const vk::SpirVAsmSource& program, SpirVProgramInfo* buildInfo);
 void                                   disassembleProgram      (const ProgramBinary& program, std::ostream* dst);
 bool                                   validateProgram         (const ProgramBinary& program, std::ostream* dst);
index 6370a63..5c5244a 100644 (file)
  *//*--------------------------------------------------------------------*/
 
 #include "vkDefs.hpp"
-#include "tcuTestLog.hpp"
 #include "deStringUtil.hpp"
 
 #include <string>
 
+namespace tcu
+{
+class TestLog;
+} // tcu
+
 namespace vk
 {
 
index f17e281..262c8d1 100644 (file)
@@ -32,6 +32,7 @@
 #include "tcuTextureUtil.hpp"
 #include "tcuVectorType.hpp"
 #include "tcuVectorUtil.hpp"
+#include "tcuTestLog.hpp"
 
 #include "vkImageUtil.hpp"
 #include "vkMemUtil.hpp"
index 11d245f..a354198 100644 (file)
@@ -29,6 +29,7 @@
 #include "vkRefUtil.hpp"
 #include "vkTypeUtil.hpp"
 #include "vkImageUtil.hpp"
+#include "tcuTestLog.hpp"
 #include "deUniquePtr.hpp"
 #include "deStringUtil.hpp"
 #include "deRandom.hpp"
index 179cd50..853bb2a 100644 (file)
@@ -33,6 +33,7 @@
 #include "vktTestCase.hpp"
 
 #include "tcuVector.hpp"
+#include "tcuTexture.hpp"
 
 #include "deStringUtil.hpp"
 #include "deUniquePtr.hpp"
index f9b9933..e02fca0 100644 (file)
@@ -32,6 +32,7 @@
 #include "vkRefUtil.hpp"
 #include "tcuTexLookupVerifier.hpp"
 #include "tcuTextureUtil.hpp"
+#include "tcuTestLog.hpp"
 #include "deSTLUtil.hpp"
 
 namespace vkt
index e4a9042..7a0e980 100644 (file)
@@ -37,6 +37,7 @@
 #include "vkRef.hpp"
 #include "vkRefUtil.hpp"
 #include "tcuImageCompare.hpp"
+#include "tcuTestLog.hpp"
 #include "deUniquePtr.hpp"
 #include "deSharedPtr.hpp"
 #include "deStringUtil.hpp"
index 5a4cbef..56b0659 100644 (file)
@@ -1423,9 +1423,9 @@ void VertexShaderExecutor::generateSources (const ShaderSpec& shaderSpec, Source
 {
        const FragmentOutputLayout      outputLayout    (computeFragmentOutputLayout(shaderSpec.outputs));
 
-       programCollection.glslSources.add("vert") << glu::VertexSource(generateVertexShader(shaderSpec, "a_", "vtx_out_"));
+       programCollection.glslSources.add("vert") << glu::VertexSource(generateVertexShader(shaderSpec, "a_", "vtx_out_")) << shaderSpec.buildOptions;
        /* \todo [2015-09-11 hegedusd] set useIntOutputs parameter if needed. */
-       programCollection.glslSources.add("frag") << glu::FragmentSource(generatePassthroughFragmentShader(shaderSpec, false, outputLayout.locationMap, "vtx_out_", "o_"));
+       programCollection.glslSources.add("frag") << glu::FragmentSource(generatePassthroughFragmentShader(shaderSpec, false, outputLayout.locationMap, "vtx_out_", "o_")) << shaderSpec.buildOptions;
 }
 
 // GeometryShaderExecutor
@@ -1457,12 +1457,12 @@ void GeometryShaderExecutor::generateSources (const ShaderSpec& shaderSpec, Sour
 {
        const FragmentOutputLayout      outputLayout    (computeFragmentOutputLayout(shaderSpec.outputs));
 
-       programCollection.glslSources.add("vert") << glu::VertexSource(generatePassthroughVertexShader(shaderSpec.inputs, "a_", "vtx_out_"));
+       programCollection.glslSources.add("vert") << glu::VertexSource(generatePassthroughVertexShader(shaderSpec.inputs, "a_", "vtx_out_")) << shaderSpec.buildOptions;
 
-       programCollection.glslSources.add("geom") << glu::GeometrySource(generateGeometryShader(shaderSpec, "vtx_out_", "geom_out_"));
+       programCollection.glslSources.add("geom") << glu::GeometrySource(generateGeometryShader(shaderSpec, "vtx_out_", "geom_out_")) << shaderSpec.buildOptions;
 
        /* \todo [2015-09-18 rsipka] set useIntOutputs parameter if needed. */
-       programCollection.glslSources.add("frag") << glu::FragmentSource(generatePassthroughFragmentShader(shaderSpec, false, outputLayout.locationMap, "geom_out_", "o_"));
+       programCollection.glslSources.add("frag") << glu::FragmentSource(generatePassthroughFragmentShader(shaderSpec, false, outputLayout.locationMap, "geom_out_", "o_")) << shaderSpec.buildOptions;
 
 }
 
@@ -1491,9 +1491,9 @@ void FragmentShaderExecutor::generateSources (const ShaderSpec& shaderSpec, Sour
 {
        const FragmentOutputLayout      outputLayout    (computeFragmentOutputLayout(shaderSpec.outputs));
 
-       programCollection.glslSources.add("vert") << glu::VertexSource(generatePassthroughVertexShader(shaderSpec.inputs, "a_", "vtx_out_"));
+       programCollection.glslSources.add("vert") << glu::VertexSource(generatePassthroughVertexShader(shaderSpec.inputs, "a_", "vtx_out_")) << shaderSpec.buildOptions;
        /* \todo [2015-09-11 hegedusd] set useIntOutputs parameter if needed. */
-       programCollection.glslSources.add("frag") << glu::FragmentSource(generateFragmentShader(shaderSpec, false, outputLayout.locationMap, "vtx_out_", "o_"));
+       programCollection.glslSources.add("frag") << glu::FragmentSource(generateFragmentShader(shaderSpec, false, outputLayout.locationMap, "vtx_out_", "o_")) << shaderSpec.buildOptions;
 }
 
 // Shared utilities for compute and tess executors
@@ -1897,7 +1897,7 @@ std::string ComputeShaderExecutor::generateComputeShader (const ShaderSpec& spec
 
 void ComputeShaderExecutor::generateSources (const ShaderSpec& shaderSpec, SourceCollections& programCollection)
 {
-       programCollection.glslSources.add("compute") << glu::ComputeSource(generateComputeShader(shaderSpec));
+       programCollection.glslSources.add("compute") << glu::ComputeSource(generateComputeShader(shaderSpec)) << shaderSpec.buildOptions;
 }
 
 void ComputeShaderExecutor::execute (int numValues, const void* const* inputs, void* const* outputs, VkDescriptorSet extraResources)
@@ -2715,10 +2715,10 @@ static std::string generateEmptyTessEvalShader ()
 
 void TessControlExecutor::generateSources (const ShaderSpec& shaderSpec, SourceCollections& programCollection)
 {
-       programCollection.glslSources.add("vert") << glu::VertexSource(generateVertexShaderForTess());
-       programCollection.glslSources.add("tess_control") << glu::TessellationControlSource(generateTessControlShader(shaderSpec));
-       programCollection.glslSources.add("tess_eval") << glu::TessellationEvaluationSource(generateEmptyTessEvalShader());
-       programCollection.glslSources.add("frag") << glu::FragmentSource(generateEmptyFragmentSource());
+       programCollection.glslSources.add("vert") << glu::VertexSource(generateVertexShaderForTess()) << shaderSpec.buildOptions;
+       programCollection.glslSources.add("tess_control") << glu::TessellationControlSource(generateTessControlShader(shaderSpec)) << shaderSpec.buildOptions;
+       programCollection.glslSources.add("tess_eval") << glu::TessellationEvaluationSource(generateEmptyTessEvalShader()) << shaderSpec.buildOptions;
+       programCollection.glslSources.add("frag") << glu::FragmentSource(generateEmptyFragmentSource()) << shaderSpec.buildOptions;
 }
 
 void TessControlExecutor::execute (int numValues, const void* const* inputs, void* const* outputs, VkDescriptorSet extraResources)
@@ -2812,10 +2812,10 @@ std::string TessEvaluationExecutor::generateTessEvalShader (const ShaderSpec& sh
 
 void TessEvaluationExecutor::generateSources (const ShaderSpec& shaderSpec, SourceCollections& programCollection)
 {
-       programCollection.glslSources.add("vert") << glu::VertexSource(generateVertexShaderForTess());
-       programCollection.glslSources.add("tess_control") << glu::TessellationControlSource(generatePassthroughTessControlShader());
-       programCollection.glslSources.add("tess_eval") << glu::TessellationEvaluationSource(generateTessEvalShader(shaderSpec));
-       programCollection.glslSources.add("frag") << glu::FragmentSource(generateEmptyFragmentSource());
+       programCollection.glslSources.add("vert") << glu::VertexSource(generateVertexShaderForTess()) << shaderSpec.buildOptions;
+       programCollection.glslSources.add("tess_control") << glu::TessellationControlSource(generatePassthroughTessControlShader()) << shaderSpec.buildOptions;
+       programCollection.glslSources.add("tess_eval") << glu::TessellationEvaluationSource(generateTessEvalShader(shaderSpec)) << shaderSpec.buildOptions;
+       programCollection.glslSources.add("frag") << glu::FragmentSource(generateEmptyFragmentSource()) << shaderSpec.buildOptions;
 }
 
 void TessEvaluationExecutor::execute (int numValues, const void* const* inputs, void* const* outputs, VkDescriptorSet extraResources)
index 126bb44..454513b 100644 (file)
@@ -27,6 +27,7 @@
 #include "tcuDefs.hpp"
 #include "vktTestCase.hpp"
 #include "gluVarType.hpp"
+#include "vkGlslProgram.hpp"
 
 #include <vector>
 #include <string>
@@ -53,6 +54,7 @@ struct ShaderSpec
        std::vector<Symbol>             outputs;
        std::string                             globalDeclarations;     //!< These are placed into global scope. Can contain uniform declarations for example.
        std::string                             source;                         //!< Source snippet to be executed.
+       vk::GlslBuildOptions    buildOptions;
 
        ShaderSpec (void) {}
 };
index 3a6d8cc..da59993 100644 (file)
@@ -29,6 +29,7 @@
 #include "tcuImageCompare.hpp"
 #include "tcuStringTemplate.hpp"
 #include "tcuTextureUtil.hpp"
+#include "tcuTestLog.hpp"
 
 #include "deMath.h"
 #include "deRandom.hpp"
index 82ce1c1..348e9a1 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "deUniquePtr.hpp"
 #include "tcuCommandLine.hpp"
+#include "tcuTestLog.hpp"
 #include "deRandom.hpp"
 #include "deStringUtil.hpp"
 #include "deString.h"
index 416ec8e..c80ae87 100644 (file)
@@ -240,7 +240,7 @@ class BuildGlslTask : public Task
 {
 public:
 
-       BuildGlslTask (const glu::ProgramSources& source, Program* program)
+       BuildGlslTask (const vk::GlslSource& source, Program* program)
                : m_source      (source)
                , m_program     (program)
        {}
@@ -253,7 +253,7 @@ public:
 
                try
                {
-                       m_program->binary               = ProgramBinarySp(vk::buildProgram(m_source, vk::PROGRAM_FORMAT_SPIRV, &buildInfo));
+                       m_program->binary               = ProgramBinarySp(vk::buildProgram(m_source, &buildInfo));
                        m_program->buildStatus  = Program::STATUS_PASSED;
                }
                catch (const tcu::Exception&)
@@ -269,8 +269,8 @@ public:
        }
 
 private:
-       glu::ProgramSources     m_source;
-       Program*                        m_program;
+       vk::GlslSource  m_source;
+       Program*                m_program;
 };
 
 void writeBuildLogs (const vk::SpirVProgramInfo& buildInfo, std::ostream& dst)
index 15ca3b1..15d4830 100644 (file)
@@ -1757,7 +1757,7 @@ void ShaderCase::initPrograms (SourceCollections& sourceCollection) const
                {
                        if (!specializedSources[progNdx].sources[shaderType].empty())
                        {
-                               glu::ProgramSources& curSrc     = sourceCollection.glslSources.add(getShaderName((glu::ShaderType)shaderType, progNdx));
+                               vk::GlslSource& curSrc  = sourceCollection.glslSources.add(getShaderName((glu::ShaderType)shaderType, progNdx));
                                curSrc.sources[shaderType] = specializedSources[progNdx].sources[shaderType];
                        }
                }
index 2620deb..0dcdc4e 100644 (file)
@@ -83,9 +83,9 @@
 namespace // compilation
 {
 
-vk::ProgramBinary* compileProgram (const glu::ProgramSources& source, glu::ShaderProgramInfo* buildInfo)
+vk::ProgramBinary* compileProgram (const vk::GlslSource& source, glu::ShaderProgramInfo* buildInfo)
 {
-       return vk::buildProgram(source, vk::PROGRAM_FORMAT_SPIRV, buildInfo);
+       return vk::buildProgram(source, buildInfo);
 }
 
 vk::ProgramBinary* compileProgram (const vk::SpirVAsmSource& source, vk::SpirVProgramInfo* buildInfo)
index 7cc45e4..8c2c405 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "tcuPlatform.hpp"
 #include "tcuResultCollector.hpp"
+#include "tcuTestLog.hpp"
 #include "deClock.h"
 
 #include <vector>