aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/spirv/emit_context.h
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-02-16 04:10:22 -0300
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 21:51:22 -0400
commitb5d7279d878211654b4abb165d94af763a365f47 (patch)
tree9b3a7b6e9d7d2b8945fe87d27ff75f1712ef06aa /src/shader_recompiler/backend/spirv/emit_context.h
parentd5d468cf2cbe235ee149dbd37951389d2a7e61da (diff)
spirv: Initial bindings support
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_context.h')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h
new file mode 100644
index 0000000000..c4b84759dc
--- /dev/null
+++ b/src/shader_recompiler/backend/spirv/emit_context.h
@@ -0,0 +1,67 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <array>
+#include <string_view>
+
+#include <sirit/sirit.h>
+
+#include "shader_recompiler/frontend/ir/program.h"
+#include "shader_recompiler/shader_info.h"
+
+namespace Shader::Backend::SPIRV {
+
+using Sirit::Id;
+
+class VectorTypes {
+public:
+ void Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name);
+
+ [[nodiscard]] Id operator[](size_t size) const noexcept {
+ return defs[size - 1];
+ }
+
+private:
+ std::array<Id, 4> defs{};
+};
+
+class EmitContext final : public Sirit::Module {
+public:
+ explicit EmitContext(IR::Program& program);
+ ~EmitContext();
+
+ [[nodiscard]] Id Def(const IR::Value& value);
+
+ Id void_id{};
+ Id U1{};
+ VectorTypes F32;
+ VectorTypes U32;
+ VectorTypes F16;
+ VectorTypes F64;
+
+ Id true_value{};
+ Id false_value{};
+ Id u32_zero_value{};
+
+ Id uniform_u32{};
+ Id storage_u32{};
+
+ std::array<Id, Info::MAX_CBUFS> cbufs{};
+ std::array<Id, Info::MAX_SSBOS> ssbos{};
+
+ Id workgroup_id{};
+ Id local_invocation_id{};
+
+private:
+ void DefineCommonTypes(const Info& info);
+ void DefineCommonConstants();
+ void DefineSpecialVariables(const Info& info);
+ void DefineConstantBuffers(const Info& info);
+ void DefineStorageBuffers(const Info& info);
+ void DefineLabels(IR::Program& program);
+};
+
+} // namespace Shader::Backend::SPIRV