summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/glasm/emit_context.h
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-05-07 11:31:30 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:30 +0200
commitc1ba685d9c9b9ca9e8c479c52097adf943e804eb (patch)
tree015e58378db727b8df4089570ad224e7439b281a /src/shader_recompiler/backend/glasm/emit_context.h
parentvk_scheduler: Use locks instead of SPSC a queue (diff)
downloadyuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.gz
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.bz2
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.lz
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.xz
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.tar.zst
yuzu-c1ba685d9c9b9ca9e8c479c52097adf943e804eb.zip
Diffstat (limited to 'src/shader_recompiler/backend/glasm/emit_context.h')
-rw-r--r--src/shader_recompiler/backend/glasm/emit_context.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/shader_recompiler/backend/glasm/emit_context.h b/src/shader_recompiler/backend/glasm/emit_context.h
index ae91069c8..cf66619de 100644
--- a/src/shader_recompiler/backend/glasm/emit_context.h
+++ b/src/shader_recompiler/backend/glasm/emit_context.h
@@ -5,17 +5,38 @@
#pragma once
#include <string>
+#include <utility>
+
+#include <fmt/format.h>
#include "shader_recompiler/backend/glasm/reg_alloc.h"
+namespace Shader::IR {
+class Inst;
+}
+
namespace Shader::Backend::GLASM {
class EmitContext {
public:
- std::string code;
- RegAlloc reg_alloc;
+ explicit EmitContext();
-private:
+ template <typename... Args>
+ void Add(const char* fmt, IR::Inst& inst, Args&&... args) {
+ code += fmt::format(fmt, reg_alloc.Define(inst), std::forward<Args>(args)...);
+ // TODO: Remove this
+ code += '\n';
+ }
+
+ template <typename... Args>
+ void Add(const char* fmt, Args&&... args) {
+ code += fmt::format(fmt, std::forward<Args>(args)...);
+ // TODO: Remove this
+ code += '\n';
+ }
+
+ std::string code;
+ RegAlloc reg_alloc{*this};
};
} // namespace Shader::Backend::GLASM