summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/frontend/maxwell/translate/impl/barrier_operations.cpp
blob: 933af572c463272245bf51bbde491167744968f4 (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
47
48
49
50
51
52
53
54
55
56
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#include "common/bit_field.h"
#include "common/common_types.h"
#include "shader_recompiler/frontend/ir/modifiers.h"
#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
#include "shader_recompiler/frontend/maxwell/opcodes.h"

namespace Shader::Maxwell {
namespace {
// Seems to be in CUDA terminology.
enum class LocalScope : u64 {
    CTG = 0,
    GL = 1,
    SYS = 2,
    VC = 3,
};

IR::MemoryScope LocalScopeToMemoryScope(LocalScope scope) {
    switch (scope) {
    case LocalScope::CTG:
        return IR::MemoryScope::Warp;
    case LocalScope::GL:
        return IR::MemoryScope::Device;
    case LocalScope::SYS:
        return IR::MemoryScope::System;
    case LocalScope::VC:
        return IR::MemoryScope::Workgroup; // or should be device?
    default:
        throw NotImplementedException("Unimplemented Local Scope {}", scope);
    }
}

} // namespace

void TranslatorVisitor::MEMBAR(u64 inst) {
    union {
        u64 raw;
        BitField<8, 2, LocalScope> scope;
    } membar{inst};
    IR::BarrierInstInfo info{};
    info.scope.Assign(LocalScopeToMemoryScope(membar.scope));
    ir.MemoryBarrier(info);
}

void TranslatorVisitor::DEPBAR() {
    // DEPBAR is a no-op
}

void TranslatorVisitor::BAR(u64) {
    throw NotImplementedException("Instruction {} is not implemented", Opcode::BAR);
}

} // namespace Shader::Maxwell