Commit 019feda6 by Sean Risser

Track SPIR-V version in VkConfig.hpp

Multiple places in the codebase use SPV_VERSION_1_1, which makes updating the SPIR-V version a nuissance. Now only VkConfig.hpp tracks that information. Bug: b/172837769 Change-Id: I9ba09b431e48e2205cf0d8b428417b72a3f514cb Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/50128Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarSean Risser <srisser@google.com>
parent 4ed9d349
...@@ -1632,7 +1632,7 @@ SpirvShader::EmitResult SpirvShader::EmitInstruction(InsnIterator insn, EmitStat ...@@ -1632,7 +1632,7 @@ SpirvShader::EmitResult SpirvShader::EmitInstruction(InsnIterator insn, EmitStat
#if SPIRV_SHADER_ENABLE_DBG #if SPIRV_SHADER_ENABLE_DBG
{ {
auto text = spvtools::spvInstructionBinaryToText( auto text = spvtools::spvInstructionBinaryToText(
SPV_ENV_VULKAN_1_1, vk::SPIRV_VERSION,
insn.wordPointer(0), insn.wordPointer(0),
insn.wordCount(), insn.wordCount(),
insns.data(), insns.data(),
......
...@@ -2549,7 +2549,7 @@ void SpirvShader::dbgCreateFile() ...@@ -2549,7 +2549,7 @@ void SpirvShader::dbgCreateFile()
for(auto insn : *this) for(auto insn : *this)
{ {
auto instruction = spvtools::spvInstructionBinaryToText( auto instruction = spvtools::spvInstructionBinaryToText(
SPV_ENV_VULKAN_1_1, vk::SPIRV_VERSION,
insn.wordPointer(0), insn.wordPointer(0),
insn.wordCount(), insn.wordCount(),
insns.data(), insns.data(),
...@@ -2648,7 +2648,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c ...@@ -2648,7 +2648,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c
# if PRINT_EACH_EMITTED_INSTRUCTION # if PRINT_EACH_EMITTED_INSTRUCTION
{ {
auto instruction = spvtools::spvInstructionBinaryToText( auto instruction = spvtools::spvInstructionBinaryToText(
SPV_ENV_VULKAN_1_1, vk::SPIRV_VERSION,
insn.wordPointer(0), insn.wordPointer(0),
insn.wordCount(), insn.wordCount(),
insns.data(), insns.data(),
...@@ -2661,7 +2661,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c ...@@ -2661,7 +2661,7 @@ void SpirvShader::dbgBeginEmitInstruction(InsnIterator insn, EmitState *state) c
# if PRINT_EACH_EXECUTED_INSTRUCTION # if PRINT_EACH_EXECUTED_INSTRUCTION
{ {
auto instruction = spvtools::spvInstructionBinaryToText( auto instruction = spvtools::spvInstructionBinaryToText(
SPV_ENV_VULKAN_1_1, vk::SPIRV_VERSION,
insn.wordPointer(0), insn.wordPointer(0),
insn.wordCount(), insn.wordCount(),
insns.data(), insns.data(),
...@@ -2757,7 +2757,7 @@ void SpirvShader::DefineOpenCLDebugInfo100(const InsnIterator &insn) ...@@ -2757,7 +2757,7 @@ void SpirvShader::DefineOpenCLDebugInfo100(const InsnIterator &insn)
# if PRINT_EACH_DEFINED_DBG_INSTRUCTION # if PRINT_EACH_DEFINED_DBG_INSTRUCTION
{ {
auto instruction = spvtools::spvInstructionBinaryToText( auto instruction = spvtools::spvInstructionBinaryToText(
SPV_ENV_VULKAN_1_1, vk::SPIRV_VERSION,
insn.wordPointer(0), insn.wordPointer(0),
insn.wordCount(), insn.wordCount(),
insns.data(), insns.data(),
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "Version.hpp" #include "Version.hpp"
#include "Vulkan/VulkanPlatform.hpp" #include "Vulkan/VulkanPlatform.hpp"
#include "spirv-tools/libspirv.h"
namespace vk { namespace vk {
...@@ -26,6 +27,8 @@ namespace vk { ...@@ -26,6 +27,8 @@ namespace vk {
#define SWIFTSHADER_DEVICE_NAME "SwiftShader Device" // Max length: VK_MAX_PHYSICAL_DEVICE_NAME_SIZE #define SWIFTSHADER_DEVICE_NAME "SwiftShader Device" // Max length: VK_MAX_PHYSICAL_DEVICE_NAME_SIZE
#define SWIFTSHADER_UUID "SwiftShaderUUID" // Max length: VK_UUID_SIZE (16) #define SWIFTSHADER_UUID "SwiftShaderUUID" // Max length: VK_UUID_SIZE (16)
const spv_target_env SPIRV_VERSION = SPV_ENV_VULKAN_1_1;
enum enum
{ {
API_VERSION = VK_API_VERSION_1_1, API_VERSION = VK_API_VERSION_1_1,
......
...@@ -38,7 +38,7 @@ std::vector<uint32_t> preprocessSpirv( ...@@ -38,7 +38,7 @@ std::vector<uint32_t> preprocessSpirv(
VkSpecializationInfo const *specializationInfo, VkSpecializationInfo const *specializationInfo,
bool optimize) bool optimize)
{ {
spvtools::Optimizer opt{ SPV_ENV_VULKAN_1_1 }; spvtools::Optimizer opt{ vk::SPIRV_VERSION };
opt.SetMessageConsumer([](spv_message_level_t level, const char *source, const spv_position_t &position, const char *message) { opt.SetMessageConsumer([](spv_message_level_t level, const char *source, const spv_position_t &position, const char *message) {
switch(level) switch(level)
...@@ -79,7 +79,7 @@ std::vector<uint32_t> preprocessSpirv( ...@@ -79,7 +79,7 @@ std::vector<uint32_t> preprocessSpirv(
if(false) if(false)
{ {
spvtools::SpirvTools core(SPV_ENV_VULKAN_1_1); spvtools::SpirvTools core(vk::SPIRV_VERSION);
std::string preOpt; std::string preOpt;
core.Disassemble(code, &preOpt, SPV_BINARY_TO_TEXT_OPTION_NONE); core.Disassemble(code, &preOpt, SPV_BINARY_TO_TEXT_OPTION_NONE);
std::string postOpt; std::string postOpt;
......
...@@ -30,7 +30,7 @@ ShaderModule::ShaderModule(const VkShaderModuleCreateInfo *pCreateInfo, void *me ...@@ -30,7 +30,7 @@ ShaderModule::ShaderModule(const VkShaderModuleCreateInfo *pCreateInfo, void *me
wordCount = static_cast<uint32_t>(pCreateInfo->codeSize / sizeof(uint32_t)); wordCount = static_cast<uint32_t>(pCreateInfo->codeSize / sizeof(uint32_t));
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
spvtools::SpirvTools spirvTools(SPV_ENV_VULKAN_1_1); spvtools::SpirvTools spirvTools(SPIRV_VERSION);
ASSERT(spirvTools.Validate(getCode())); // The SPIR-V code passed to vkCreateShaderModule must be valid (b/158228522) ASSERT(spirvTools.Validate(getCode())); // The SPIR-V code passed to vkCreateShaderModule must be valid (b/158228522)
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment