summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/glsl/reg_alloc.h
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-05-20 03:58:32 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:35 +0200
commiteaff1030de07f3739794207403ea833ee91c0034 (patch)
treec2e6650ba13f55854b5cba9a79d9afc01528eb96 /src/shader_recompiler/backend/glsl/reg_alloc.h
parentspirv: Reduce log severity of mismatching denorm rules (diff)
downloadyuzu-eaff1030de07f3739794207403ea833ee91c0034.tar
yuzu-eaff1030de07f3739794207403ea833ee91c0034.tar.gz
yuzu-eaff1030de07f3739794207403ea833ee91c0034.tar.bz2
yuzu-eaff1030de07f3739794207403ea833ee91c0034.tar.lz
yuzu-eaff1030de07f3739794207403ea833ee91c0034.tar.xz
yuzu-eaff1030de07f3739794207403ea833ee91c0034.tar.zst
yuzu-eaff1030de07f3739794207403ea833ee91c0034.zip
Diffstat (limited to 'src/shader_recompiler/backend/glsl/reg_alloc.h')
-rw-r--r--src/shader_recompiler/backend/glsl/reg_alloc.h46
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 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <bitset>
+
+#include "common/common_types.h"
+
+namespace Shader::IR {
+class Inst;
+class Value;
+} // namespace Shader::IR
+
+namespace Shader::Backend::GLSL {
+
+struct Id {
+ u32 base_element : 2;
+ u32 num_elements_minus_one : 2;
+ u32 index : 26;
+ u32 is_spill : 1;
+ u32 is_condition_code : 1;
+};
+
+class RegAlloc {
+public:
+ std::string Define(IR::Inst& inst, u32 num_elements = 1, u32 alignment = 1);
+
+ std::string Consume(const IR::Value& value);
+
+private:
+ static constexpr size_t NUM_REGS = 4096;
+ static constexpr size_t NUM_ELEMENTS = 4;
+
+ std::string Consume(IR::Inst& inst);
+
+ Id Alloc(u32 num_elements, u32 alignment);
+
+ void Free(Id id);
+
+ size_t num_used_registers{};
+ std::bitset<NUM_REGS> register_use{};
+};
+
+} // namespace Shader::Backend::GLSL