summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.cpp4
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv.cpp19
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_image.cpp11
-rw-r--r--src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp2
4 files changed, 22 insertions, 14 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp
index b738e00cc..0c114402b 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_context.cpp
@@ -4,6 +4,7 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <array> 6#include <array>
7#include <climits>
7#include <string_view> 8#include <string_view>
8 9
9#include <fmt/format.h> 10#include <fmt/format.h>
@@ -116,7 +117,8 @@ void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_vie
116 const std::string_view def_name_view( 117 const std::string_view def_name_view(
117 def_name.data(), 118 def_name.data(),
118 fmt::format_to_n(def_name.data(), def_name.size(), "{}x{}", name, i + 1).size); 119 fmt::format_to_n(def_name.data(), def_name.size(), "{}x{}", name, i + 1).size);
119 defs[i] = sirit_ctx.Name(sirit_ctx.TypeVector(base_type, i + 1), def_name_view); 120 defs[static_cast<size_t>(i)] =
121 sirit_ctx.Name(sirit_ctx.TypeVector(base_type, i + 1), def_name_view);
120 } 122 }
121} 123}
122 124
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp
index 32512a0e5..355cf0ca8 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp
@@ -16,7 +16,7 @@
16namespace Shader::Backend::SPIRV { 16namespace Shader::Backend::SPIRV {
17namespace { 17namespace {
18template <class Func> 18template <class Func>
19struct FuncTraits : FuncTraits<Func> {}; 19struct FuncTraits {};
20 20
21template <class ReturnType_, class... Args> 21template <class ReturnType_, class... Args>
22struct FuncTraits<ReturnType_ (*)(Args...)> { 22struct FuncTraits<ReturnType_ (*)(Args...)> {
@@ -64,17 +64,20 @@ ArgType Arg(EmitContext& ctx, const IR::Value& arg) {
64template <auto func, bool is_first_arg_inst, size_t... I> 64template <auto func, bool is_first_arg_inst, size_t... I>
65void Invoke(EmitContext& ctx, IR::Inst* inst, std::index_sequence<I...>) { 65void Invoke(EmitContext& ctx, IR::Inst* inst, std::index_sequence<I...>) {
66 using Traits = FuncTraits<decltype(func)>; 66 using Traits = FuncTraits<decltype(func)>;
67 if constexpr (std::is_same_v<Traits::ReturnType, Id>) { 67 if constexpr (std::is_same_v<typename Traits::ReturnType, Id>) {
68 if constexpr (is_first_arg_inst) { 68 if constexpr (is_first_arg_inst) {
69 SetDefinition<func>(ctx, inst, inst, Arg<Traits::ArgType<I + 2>>(ctx, inst->Arg(I))...); 69 SetDefinition<func>(
70 ctx, inst, inst,
71 Arg<typename Traits::template ArgType<I + 2>>(ctx, inst->Arg(I))...);
70 } else { 72 } else {
71 SetDefinition<func>(ctx, inst, Arg<Traits::ArgType<I + 1>>(ctx, inst->Arg(I))...); 73 SetDefinition<func>(
74 ctx, inst, Arg<typename Traits::template ArgType<I + 1>>(ctx, inst->Arg(I))...);
72 } 75 }
73 } else { 76 } else {
74 if constexpr (is_first_arg_inst) { 77 if constexpr (is_first_arg_inst) {
75 func(ctx, inst, Arg<Traits::ArgType<I + 2>>(ctx, inst->Arg(I))...); 78 func(ctx, inst, Arg<typename Traits::template ArgType<I + 2>>(ctx, inst->Arg(I))...);
76 } else { 79 } else {
77 func(ctx, Arg<Traits::ArgType<I + 1>>(ctx, inst->Arg(I))...); 80 func(ctx, Arg<typename Traits::template ArgType<I + 1>>(ctx, inst->Arg(I))...);
78 } 81 }
79 } 82 }
80} 83}
@@ -94,14 +97,14 @@ void Invoke(EmitContext& ctx, IR::Inst* inst) {
94} 97}
95 98
96void EmitInst(EmitContext& ctx, IR::Inst* inst) { 99void EmitInst(EmitContext& ctx, IR::Inst* inst) {
97 switch (inst->Opcode()) { 100 switch (inst->GetOpcode()) {
98#define OPCODE(name, result_type, ...) \ 101#define OPCODE(name, result_type, ...) \
99 case IR::Opcode::name: \ 102 case IR::Opcode::name: \
100 return Invoke<&Emit##name>(ctx, inst); 103 return Invoke<&Emit##name>(ctx, inst);
101#include "shader_recompiler/frontend/ir/opcodes.inc" 104#include "shader_recompiler/frontend/ir/opcodes.inc"
102#undef OPCODE 105#undef OPCODE
103 } 106 }
104 throw LogicError("Invalid opcode {}", inst->Opcode()); 107 throw LogicError("Invalid opcode {}", inst->GetOpcode());
105} 108}
106 109
107Id TypeId(const EmitContext& ctx, IR::Type type) { 110Id TypeId(const EmitContext& ctx, IR::Type type) {
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
index f0f8db8c3..815ca6299 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp
@@ -43,11 +43,13 @@ public:
43 // LOG_WARNING("Not all arguments in PTP are immediate, STUBBING"); 43 // LOG_WARNING("Not all arguments in PTP are immediate, STUBBING");
44 return; 44 return;
45 } 45 }
46 const IR::Opcode opcode{values[0]->Opcode()}; 46 const IR::Opcode opcode{values[0]->GetOpcode()};
47 if (opcode != values[1]->Opcode() || opcode != IR::Opcode::CompositeConstructU32x4) { 47 if (opcode != values[1]->GetOpcode() || opcode != IR::Opcode::CompositeConstructU32x4) {
48 throw LogicError("Invalid PTP arguments"); 48 throw LogicError("Invalid PTP arguments");
49 } 49 }
50 auto read{[&](int a, int b) { return ctx.Constant(ctx.U32[1], values[a]->Arg(b).U32()); }}; 50 auto read{[&](unsigned int a, unsigned int b) {
51 return ctx.Constant(ctx.U32[1], values[a]->Arg(b).U32());
52 }};
51 53
52 const Id offsets{ 54 const Id offsets{
53 ctx.ConstantComposite(ctx.TypeArray(ctx.U32[2], ctx.Constant(ctx.U32[1], 4)), 55 ctx.ConstantComposite(ctx.TypeArray(ctx.U32[2], ctx.Constant(ctx.U32[1], 4)),
@@ -297,13 +299,14 @@ Id EmitImageGather(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id
297 299
298Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, 300Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords,
299 const IR::Value& offset, const IR::Value& offset2, Id dref) { 301 const IR::Value& offset, const IR::Value& offset2, Id dref) {
300 const auto info{inst->Flags<IR::TextureInstInfo>()};
301 const ImageOperands operands(ctx, offset, offset2); 302 const ImageOperands operands(ctx, offset, offset2);
302 return Emit(&EmitContext::OpImageSparseDrefGather, &EmitContext::OpImageDrefGather, ctx, inst, 303 return Emit(&EmitContext::OpImageSparseDrefGather, &EmitContext::OpImageDrefGather, ctx, inst,
303 ctx.F32[4], Texture(ctx, index), coords, dref, operands.Mask(), operands.Span()); 304 ctx.F32[4], Texture(ctx, index), coords, dref, operands.Mask(), operands.Span());
304} 305}
305 306
307#ifdef _WIN32
306#pragma optimize("", off) 308#pragma optimize("", off)
309#endif
307 310
308Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, 311Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset,
309 Id lod, Id ms) { 312 Id lod, Id ms) {
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp
index c57bd291d..12a03ed6e 100644
--- a/src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_spirv_warp.cpp
@@ -7,7 +7,7 @@
7namespace Shader::Backend::SPIRV { 7namespace Shader::Backend::SPIRV {
8namespace { 8namespace {
9Id WarpExtract(EmitContext& ctx, Id value) { 9Id WarpExtract(EmitContext& ctx, Id value) {
10 const Id shift{ctx.Constant(ctx.U32[1], 5)}; 10 [[maybe_unused]] const Id shift{ctx.Constant(ctx.U32[1], 5)};
11 const Id local_index{ctx.OpLoad(ctx.U32[1], ctx.subgroup_local_invocation_id)}; 11 const Id local_index{ctx.OpLoad(ctx.U32[1], ctx.subgroup_local_invocation_id)};
12 return ctx.OpVectorExtractDynamic(ctx.U32[1], value, local_index); 12 return ctx.OpVectorExtractDynamic(ctx.U32[1], value, local_index);
13} 13}