Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Hollings <bill.hollings@brenwill.com>2018-07-29 22:22:14 +0300
committerGitHub <noreply@github.com>2018-07-29 22:22:14 +0300
commit162eee632599cd077972ee1d88b341eedbcfdf27 (patch)
treef7efcbcde213f9ea9ef92087ccdb9af9fd945e99 /spirv_msl.cpp
parent439da40b1f8f9dcd9d1cb219bc4b7850c01344b4 (diff)
parentc3d74e1e14586f2d0f81d57b4bd6fc64bf97633d (diff)
Merge pull request #648 from billhollings/master
CompilerMSL disable rasterization on buffer writes in vertex shader.
Diffstat (limited to 'spirv_msl.cpp')
-rw-r--r--spirv_msl.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/spirv_msl.cpp b/spirv_msl.cpp
index 52c8c53d..e9a49e43 100644
--- a/spirv_msl.cpp
+++ b/spirv_msl.cpp
@@ -383,8 +383,8 @@ void CompilerMSL::preprocess_op_codes()
add_pragma_line("#pragma clang diagnostic ignored \"-Wunused-variable\"");
}
- // Metal vertex functions that write to textures must disable rasterization and return void.
- if (preproc.uses_image_write)
+ // Metal vertex functions that write to resources must disable rasterization and return void.
+ if (preproc.uses_resource_write)
is_rasterization_disabled = true;
}
@@ -3141,8 +3141,8 @@ string CompilerMSL::get_argument_address_space(const SPIRVariable &argument)
case StorageClassStorageBuffer:
{
- auto flags = get_buffer_block_flags(argument);
- return flags.get(DecorationNonWritable) ? "const device" : "device";
+ bool readonly = get_buffer_block_flags(argument).get(DecorationNonWritable);
+ return readonly ? "const device" : "device";
}
case StorageClassUniform:
@@ -3151,13 +3151,13 @@ string CompilerMSL::get_argument_address_space(const SPIRVariable &argument)
if (type.basetype == SPIRType::Struct)
{
bool ssbo = has_decoration(type.self, DecorationBufferBlock);
- if (!ssbo)
- return "constant";
- else
+ if (ssbo)
{
bool readonly = get_buffer_block_flags(argument).get(DecorationNonWritable);
return readonly ? "const device" : "device";
}
+ else
+ return "constant";
}
break;
@@ -4039,13 +4039,16 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui
break;
case OpImageWrite:
- uses_image_write = true;
+ uses_resource_write = true;
+ break;
+
+ case OpStore:
+ check_resource_write(args[0]);
break;
case OpAtomicExchange:
case OpAtomicCompareExchange:
case OpAtomicCompareExchangeWeak:
- case OpAtomicLoad:
case OpAtomicIIncrement:
case OpAtomicIDecrement:
case OpAtomicIAdd:
@@ -4058,6 +4061,11 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui
case OpAtomicOr:
case OpAtomicXor:
uses_atomics = true;
+ check_resource_write(args[2]);
+ break;
+
+ case OpAtomicLoad:
+ uses_atomics = true;
break;
default:
@@ -4072,6 +4080,15 @@ bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t *args, ui
return true;
}
+// If the variable is a Uniform or StorageBuffer, mark that a resource has been written to.
+void CompilerMSL::OpCodePreprocessor::check_resource_write(uint32_t var_id)
+{
+ auto *p_var = compiler.maybe_get_backing_variable(var_id);
+ StorageClass sc = p_var ? p_var->storage : StorageClassMax;
+ if (sc == StorageClassUniform || sc == StorageClassStorageBuffer)
+ uses_resource_write = true;
+}
+
// Returns an enumeration of a SPIR-V function that needs to be output for certain Op codes.
CompilerMSL::SPVFuncImpl CompilerMSL::OpCodePreprocessor::get_spv_func_impl(Op opcode, const uint32_t *args)
{