diff options
| author | 2021-05-19 21:58:32 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:35 -0400 | |
| commit | eaff1030de07f3739794207403ea833ee91c0034 (patch) | |
| tree | c2e6650ba13f55854b5cba9a79d9afc01528eb96 /src/shader_recompiler/backend/glsl/reg_alloc.h | |
| parent | spirv: Reduce log severity of mismatching denorm rules (diff) | |
| download | yuzu-eaff1030de07f3739794207403ea833ee91c0034.tar.gz yuzu-eaff1030de07f3739794207403ea833ee91c0034.tar.xz yuzu-eaff1030de07f3739794207403ea833ee91c0034.zip | |
glsl: Initial backend
Diffstat (limited to 'src/shader_recompiler/backend/glsl/reg_alloc.h')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/reg_alloc.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glsl/reg_alloc.h b/src/shader_recompiler/backend/glsl/reg_alloc.h new file mode 100644 index 000000000..850a93d6a --- /dev/null +++ b/src/shader_recompiler/backend/glsl/reg_alloc.h | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <bitset> | ||
| 8 | |||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | namespace Shader::IR { | ||
| 12 | class Inst; | ||
| 13 | class Value; | ||
| 14 | } // namespace Shader::IR | ||
| 15 | |||
| 16 | namespace Shader::Backend::GLSL { | ||
| 17 | |||
| 18 | struct Id { | ||
| 19 | u32 base_element : 2; | ||
| 20 | u32 num_elements_minus_one : 2; | ||
| 21 | u32 index : 26; | ||
| 22 | u32 is_spill : 1; | ||
| 23 | u32 is_condition_code : 1; | ||
| 24 | }; | ||
| 25 | |||
| 26 | class RegAlloc { | ||
| 27 | public: | ||
| 28 | std::string Define(IR::Inst& inst, u32 num_elements = 1, u32 alignment = 1); | ||
| 29 | |||
| 30 | std::string Consume(const IR::Value& value); | ||
| 31 | |||
| 32 | private: | ||
| 33 | static constexpr size_t NUM_REGS = 4096; | ||
| 34 | static constexpr size_t NUM_ELEMENTS = 4; | ||
| 35 | |||
| 36 | std::string Consume(IR::Inst& inst); | ||
| 37 | |||
| 38 | Id Alloc(u32 num_elements, u32 alignment); | ||
| 39 | |||
| 40 | void Free(Id id); | ||
| 41 | |||
| 42 | size_t num_used_registers{}; | ||
| 43 | std::bitset<NUM_REGS> register_use{}; | ||
| 44 | }; | ||
| 45 | |||
| 46 | } // namespace Shader::Backend::GLSL | ||