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 \
vkWsiUtil.hpp
vkDebugReportUtil.cpp
vkDebugReportUtil.hpp
+ vkGlslProgram.cpp
+ vkGlslProgram.hpp
)
set(VKUTIL_LIBS
#include "deString.h"
#include "deInt32.h"
#include "deFile.h"
+#include "deMemory.h"
#include <sstream>
#include <fstream>
#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
{
--- /dev/null
+/*-------------------------------------------------------------------------
+ * 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
--- /dev/null
+#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
builtin->maxSamples = 4;
};
-} // anonymous
-
-int getNumShaderStages (const glu::ProgramSources& program)
+int getNumShaderStages (const GlslSource& program)
{
int numShaderStages = 0;
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");
{
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));
#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)");
}
* \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
#include "vkSpirVAsm.hpp"
#include "vkRefUtil.hpp"
-#include "tcuTestLog.hpp"
-
#include "deArrayUtil.hpp"
#include "deMemory.h"
#include "deInt32.h"
using std::string;
using std::vector;
-using tcu::TestLog;
#if defined(DE_DEBUG) && defined(DEQP_HAVE_SPIRV_TOOLS)
# define VALIDATE_BINARIES true
} // 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)
#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
{
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
{
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);
*//*--------------------------------------------------------------------*/
#include "vkDefs.hpp"
-#include "tcuTestLog.hpp"
#include "deStringUtil.hpp"
#include <string>
+namespace tcu
+{
+class TestLog;
+} // tcu
+
namespace vk
{
#include "tcuTextureUtil.hpp"
#include "tcuVectorType.hpp"
#include "tcuVectorUtil.hpp"
+#include "tcuTestLog.hpp"
#include "vkImageUtil.hpp"
#include "vkMemUtil.hpp"
#include "vkRefUtil.hpp"
#include "vkTypeUtil.hpp"
#include "vkImageUtil.hpp"
+#include "tcuTestLog.hpp"
#include "deUniquePtr.hpp"
#include "deStringUtil.hpp"
#include "deRandom.hpp"
#include "tcuVector.hpp"
#include "tcuTextureUtil.hpp"
#include "tcuImageCompare.hpp"
+#include "tcuTestLog.hpp"
#include "deSharedPtr.hpp"
#include "vkQueryUtil.hpp"
#include "vkImageUtil.hpp"
+#include "tcuTestLog.hpp"
+
#include "deUniquePtr.hpp"
#include "deStringUtil.hpp"
#include "tcuTextureUtil.hpp"
#include "tcuImageCompare.hpp"
+#include "tcuTestLog.hpp"
#include "deRandom.hpp"
#include "deMath.h"
#include "tcuTextureUtil.hpp"
#include "tcuVectorUtil.hpp"
+#include "tcuTestLog.hpp"
namespace vkt
{
#include "vktTestCase.hpp"
#include "tcuVector.hpp"
+#include "tcuTexture.hpp"
#include "deStringUtil.hpp"
#include "deUniquePtr.hpp"
#include "deUniquePtr.hpp"
#include "tcuTextureUtil.hpp"
+#include "tcuTestLog.hpp"
#include <string>
#include <vector>
#include "vkRefUtil.hpp"
#include "tcuTexLookupVerifier.hpp"
#include "tcuTextureUtil.hpp"
+#include "tcuTestLog.hpp"
#include "deSTLUtil.hpp"
namespace vkt
#include "vkImageUtil.hpp"
#include "tcuTextureUtil.hpp"
+#include "tcuTestLog.hpp"
#include "deUniquePtr.hpp"
#include "deSharedPtr.hpp"
#include "vktPipelineMultisampleTestsUtil.hpp"
#include "vktPipelineMakeUtil.hpp"
#include "vkQueryUtil.hpp"
+#include "tcuTestLog.hpp"
#include <set>
#include "vkRef.hpp"
#include "vkRefUtil.hpp"
#include "tcuImageCompare.hpp"
+#include "tcuTestLog.hpp"
#include "deUniquePtr.hpp"
#include "deSharedPtr.hpp"
#include "deStringUtil.hpp"
#include "tcuTextureUtil.hpp"
#include "tcuImageCompare.hpp"
+#include "tcuTestLog.hpp"
#include "deUniquePtr.hpp"
#include "deSharedPtr.hpp"
{
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
{
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;
}
{
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
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)
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)
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)
#include "tcuDefs.hpp"
#include "vktTestCase.hpp"
#include "gluVarType.hpp"
+#include "vkGlslProgram.hpp"
#include <vector>
#include <string>
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) {}
};
#include "tcuImageCompare.hpp"
#include "tcuStringTemplate.hpp"
#include "tcuTextureUtil.hpp"
+#include "tcuTestLog.hpp"
#include "deMath.h"
#include "deRandom.hpp"
#include "vkQueryUtil.hpp"
#include "vkTypeUtil.hpp"
+#include "tcuTestLog.hpp"
+
#include "deUniquePtr.hpp"
#include "deSharedPtr.hpp"
#include "deMath.h"
#include "deUniquePtr.hpp"
#include "tcuCommandLine.hpp"
+#include "tcuTestLog.hpp"
#include "deRandom.hpp"
#include "deStringUtil.hpp"
#include "deString.h"
{
public:
- BuildGlslTask (const glu::ProgramSources& source, Program* program)
+ BuildGlslTask (const vk::GlslSource& source, Program* program)
: m_source (source)
, m_program (program)
{}
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&)
}
private:
- glu::ProgramSources m_source;
- Program* m_program;
+ vk::GlslSource m_source;
+ Program* m_program;
};
void writeBuildLogs (const vk::SpirVProgramInfo& buildInfo, std::ostream& dst)
{
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];
}
}
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)
#include "tcuPlatform.hpp"
#include "tcuResultCollector.hpp"
+#include "tcuTestLog.hpp"
#include "deClock.h"
#include <vector>
#include "tcuPlatform.hpp"
#include "tcuResultCollector.hpp"
+#include "tcuTestLog.hpp"
#include <vector>
#include <string>
#include "tcuPlatform.hpp"
#include "tcuResultCollector.hpp"
+#include "tcuTestLog.hpp"
#include <vector>
#include <string>