suyu/src/shader_recompiler/backend/spirv/emit_spirv_control_flow.cpp

48 lines
1.3 KiB
C++
Raw Normal View History

2021-02-08 06:54:35 +01:00
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "shader_recompiler/backend/spirv/emit_spirv.h"
#include "shader_recompiler/backend/spirv/emit_spirv_instructions.h"
2021-02-16 08:10:22 +01:00
namespace Shader::Backend::SPIRV {
void EmitBranch(EmitContext& ctx, Id label) {
ctx.OpBranch(label);
2021-02-16 08:10:22 +01:00
}
void EmitBranchConditional(EmitContext& ctx, Id condition, Id true_label, Id false_label) {
ctx.OpBranchConditional(condition, true_label, false_label);
2021-02-16 08:10:22 +01:00
}
void EmitLoopMerge(EmitContext& ctx, Id merge_label, Id continue_label) {
ctx.OpLoopMerge(merge_label, continue_label, spv::LoopControlMask::MaskNone);
2021-02-16 08:10:22 +01:00
}
void EmitSelectionMerge(EmitContext& ctx, Id merge_label) {
ctx.OpSelectionMerge(merge_label, spv::SelectionControlMask::MaskNone);
2021-02-16 08:10:22 +01:00
}
2021-02-17 04:59:28 +01:00
void EmitReturn(EmitContext& ctx) {
2021-02-16 08:10:22 +01:00
ctx.OpReturn();
}
2021-04-19 01:03:38 +02:00
void EmitJoin(EmitContext&) {
throw NotImplementedException("Join shouldn't be emitted");
}
2021-03-27 22:30:24 +01:00
void EmitUnreachable(EmitContext& ctx) {
ctx.OpUnreachable();
}
void EmitDemoteToHelperInvocation(EmitContext& ctx, Id continue_label) {
2021-05-23 09:20:37 +02:00
if (ctx.profile.support_demote_to_helper_invocation) {
ctx.OpDemoteToHelperInvocationEXT();
ctx.OpBranch(continue_label);
} else {
ctx.OpKill();
}
}
2021-02-16 08:10:22 +01:00
} // namespace Shader::Backend::SPIRV