diff options
| author | 2021-04-05 22:25:22 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:26 -0400 | |
| commit | 0bb85f6a753c769266c95c4ba146b25b9eaaaffd (patch) | |
| tree | e5d818ae7dc1d0025bb115c7a63235d866e53286 /src/shader_recompiler/backend | |
| parent | shader: Fix FCMP immediate variant (diff) | |
| download | yuzu-0bb85f6a753c769266c95c4ba146b25b9eaaaffd.tar.gz yuzu-0bb85f6a753c769266c95c4ba146b25b9eaaaffd.tar.xz yuzu-0bb85f6a753c769266c95c4ba146b25b9eaaaffd.zip | |
shader_recompiler,video_core: Cleanup some GCC and Clang errors
Mostly fixing unused *, implicit conversion, braced scalar init,
fpermissive, and some others.
Some Clang errors likely remain in video_core, and std::ranges is still
a pertinent issue in shader_recompiler
shader_recompiler: cmake: Force bracket depth to 1024 on Clang
Increases the maximum fold expression depth
thread_worker: Include condition_variable
Don't use list initializers in control flow
Co-authored-by: ReinUsesLisp <reinuseslisp@airmail.cc>
Diffstat (limited to 'src/shader_recompiler/backend')
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 @@ | |||
| 16 | namespace Shader::Backend::SPIRV { | 16 | namespace Shader::Backend::SPIRV { |
| 17 | namespace { | 17 | namespace { |
| 18 | template <class Func> | 18 | template <class Func> |
| 19 | struct FuncTraits : FuncTraits<Func> {}; | 19 | struct FuncTraits {}; |
| 20 | 20 | ||
| 21 | template <class ReturnType_, class... Args> | 21 | template <class ReturnType_, class... Args> |
| 22 | struct FuncTraits<ReturnType_ (*)(Args...)> { | 22 | struct FuncTraits<ReturnType_ (*)(Args...)> { |
| @@ -64,17 +64,20 @@ ArgType Arg(EmitContext& ctx, const IR::Value& arg) { | |||
| 64 | template <auto func, bool is_first_arg_inst, size_t... I> | 64 | template <auto func, bool is_first_arg_inst, size_t... I> |
| 65 | void Invoke(EmitContext& ctx, IR::Inst* inst, std::index_sequence<I...>) { | 65 | void 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 | ||
| 96 | void EmitInst(EmitContext& ctx, IR::Inst* inst) { | 99 | void 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 | ||
| 107 | Id TypeId(const EmitContext& ctx, IR::Type type) { | 110 | Id 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 | ||
| 298 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 300 | Id 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 | ||
| 308 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, | 311 | Id 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 @@ | |||
| 7 | namespace Shader::Backend::SPIRV { | 7 | namespace Shader::Backend::SPIRV { |
| 8 | namespace { | 8 | namespace { |
| 9 | Id WarpExtract(EmitContext& ctx, Id value) { | 9 | Id 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 | } |