summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/spirv/emit_spirv_control_flow.cpp
blob: b4a6fbb937d678cd775233e841f4cd939b8b40d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// 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"

namespace Shader::Backend::SPIRV {

void EmitBranch(EmitContext& ctx, Id label) {
    ctx.OpBranch(label);
}

void EmitBranchConditional(EmitContext& ctx, Id condition, Id true_label, Id false_label) {
    ctx.OpBranchConditional(condition, true_label, false_label);
}

void EmitLoopMerge(EmitContext& ctx, Id merge_label, Id continue_label) {
    ctx.OpLoopMerge(merge_label, continue_label, spv::LoopControlMask::MaskNone);
}

void EmitSelectionMerge(EmitContext& ctx, Id merge_label) {
    ctx.OpSelectionMerge(merge_label, spv::SelectionControlMask::MaskNone);
}

void EmitReturn(EmitContext& ctx) {
    ctx.OpReturn();
}

void EmitJoin(EmitContext&) {
    throw NotImplementedException("Join shouldn't be emitted");
}

void EmitUnreachable(EmitContext& ctx) {
    ctx.OpUnreachable();
}

void EmitDemoteToHelperInvocation(EmitContext& ctx, Id continue_label) {
    if (ctx.profile.support_demote_to_helper_invocation) {
        ctx.OpDemoteToHelperInvocationEXT();
        ctx.OpBranch(continue_label);
    } else {
        ctx.OpKill();
    }
}

} // namespace Shader::Backend::SPIRV