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>2021-09-12 23:28:21 +0300
committerBill Hollings <bill.hollings@brenwill.com>2021-09-12 23:28:21 +0300
commit35e92e6ffb1a762700190fbf1ca55bc2b1debaff (patch)
tree11187f3fe77173df40182dde8f664ce8c25dc82b /spirv_msl.cpp
parentc2500e504d2b823d73d2f129e4f4f050e9618ecb (diff)
MSL: Return fragment function value even when last SPIR-V Op is discard (OpKill).
Add test shader for new functionality. Add legacy test reference shader for unrelated buffer-bitcast test, that doesn't seem to have been added previously.
Diffstat (limited to 'spirv_msl.cpp')
-rw-r--r--spirv_msl.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/spirv_msl.cpp b/spirv_msl.cpp
index d20f1643..06e27e59 100644
--- a/spirv_msl.cpp
+++ b/spirv_msl.cpp
@@ -3467,6 +3467,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
// Add the output interface struct as a local variable to the entry function.
// If the entry point should return the output struct, set the entry function
// to return the output interface struct, otherwise to return nothing.
+ // Watch out for the rare case where the terminator of the last entry point block is a Kill, instead of a Return.
// Indicate the output var requires early initialization.
bool ep_should_return_output = !get_is_rasterization_disabled();
uint32_t rtn_id = ep_should_return_output ? ib_var_id : 0;
@@ -3476,7 +3477,7 @@ uint32_t CompilerMSL::add_interface_block(StorageClass storage, bool patch)
for (auto &blk_id : entry_func.blocks)
{
auto &blk = get<SPIRBlock>(blk_id);
- if (blk.terminator == SPIRBlock::Return)
+ if (blk.terminator == SPIRBlock::Return || (blk.terminator == SPIRBlock::Kill && blk_id == entry_func.blocks.back()))
blk.return_value = rtn_id;
}
vars_needing_early_declaration.push_back(ib_var_id);