summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-09-23 02:15:09 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-05 00:52:54 +0200
commit100a4bd98856cf16c1fe16b6c1f1ab2863916c37 (patch)
treee4af4d5809a332affdee90a33441fae7924e4355
parentgl_shader_decompiler: Refactor and address feedback. (diff)
downloadyuzu-100a4bd98856cf16c1fe16b6c1f1ab2863916c37.tar
yuzu-100a4bd98856cf16c1fe16b6c1f1ab2863916c37.tar.gz
yuzu-100a4bd98856cf16c1fe16b6c1f1ab2863916c37.tar.bz2
yuzu-100a4bd98856cf16c1fe16b6c1f1ab2863916c37.tar.lz
yuzu-100a4bd98856cf16c1fe16b6c1f1ab2863916c37.tar.xz
yuzu-100a4bd98856cf16c1fe16b6c1f1ab2863916c37.tar.zst
yuzu-100a4bd98856cf16c1fe16b6c1f1ab2863916c37.zip
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 4527e9261..11effe4a1 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -646,7 +646,9 @@ private:
Emit(OpBranchConditional(condition, true_label, skip_label));
Emit(true_label);
+ ++conditional_nest_count;
VisitBasicBlock(conditional->GetCode());
+ --conditional_nest_count;
Emit(OpBranch(skip_label));
Emit(skip_label);
@@ -1011,7 +1013,10 @@ private:
UNIMPLEMENTED_IF(!target);
Emit(OpStore(jmp_to, Constant(t_uint, target->GetValue())));
- BranchingOp([&]() { Emit(OpBranch(continue_label)); });
+ Emit(OpBranch(continue_label));
+ if (conditional_nest_count == 0) {
+ Emit(OpLabel());
+ }
return {};
}
@@ -1019,7 +1024,10 @@ private:
const Id op_a = VisitOperand<Type::Uint>(operation, 0);
Emit(OpStore(jmp_to, op_a));
- BranchingOp([&]() { Emit(OpBranch(continue_label)); });
+ Emit(OpBranch(continue_label));
+ if (conditional_nest_count == 0) {
+ Emit(OpLabel());
+ }
return {};
}
@@ -1046,7 +1054,10 @@ private:
Emit(OpStore(flow_stack_top, previous));
Emit(OpStore(jmp_to, target));
- BranchingOp([&]() { Emit(OpBranch(continue_label)); });
+ Emit(OpBranch(continue_label));
+ if (conditional_nest_count == 0) {
+ Emit(OpLabel());
+ }
return {};
}
@@ -1103,12 +1114,28 @@ private:
Id Exit(Operation operation) {
PreExit();
- BranchingOp([&]() { Emit(OpReturn()); });
+ if (conditional_nest_count > 0) {
+ Emit(OpReturn());
+ } else {
+ const Id dummy = OpLabel();
+ Emit(OpBranch(dummy));
+ Emit(dummy);
+ Emit(OpReturn());
+ Emit(OpLabel());
+ }
return {};
}
Id Discard(Operation operation) {
- BranchingOp([&]() { Emit(OpKill()); });
+ if (conditional_nest_count > 0) {
+ Emit(OpKill());
+ } else {
+ const Id dummy = OpLabel();
+ Emit(OpBranch(dummy));
+ Emit(dummy);
+ Emit(OpKill());
+ Emit(OpLabel());
+ }
return {};
}
@@ -1303,17 +1330,6 @@ private:
return {};
}
- void BranchingOp(std::function<void()> call) {
- const Id true_label = OpLabel();
- const Id skip_label = OpLabel();
- Emit(OpSelectionMerge(skip_label, spv::SelectionControlMask::Flatten));
- Emit(OpBranchConditional(v_true, true_label, skip_label, 1, 0));
- Emit(true_label);
- call();
-
- Emit(skip_label);
- }
-
std::tuple<Id, Id> CreateFlowStack() {
// TODO(Rodrigo): Figure out the actual depth of the flow stack, for now it seems unlikely
// that shaders will use 20 nested SSYs and PBKs.
@@ -1519,6 +1535,7 @@ private:
const ShaderIR& ir;
const ShaderStage stage;
const Tegra::Shader::Header header;
+ u64 conditional_nest_count{};
const Id t_void = Name(TypeVoid(), "void");