diff options
author | Feng Chen <vonchenplus@gmail.com> | 2021-09-03 17:52:20 +0200 |
---|---|---|
committer | Feng Chen <vonchenplus@gmail.com> | 2021-09-03 17:52:20 +0200 |
commit | a7bbaa489755c9847416c8c96f0eefb9e78a50a0 (patch) | |
tree | 341ab621a49becca148157877d6e57e2a31ba770 | |
parent | Fix create GraphicsPipelines crash (diff) | |
download | yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.gz yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.bz2 yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.lz yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.xz yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.tar.zst yuzu-a7bbaa489755c9847416c8c96f0eefb9e78a50a0.zip |
Diffstat (limited to '')
5 files changed, 24 insertions, 14 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 78ca97d91..3ec5a4570 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp @@ -1209,7 +1209,7 @@ void EmitContext::DefineInputs(const IR::Program& program) { if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S)) { const Id id{DefineInput(*this, F32[4], true)}; Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); - input_txt_coord = id; + input_fixed_fnc_texture = id; } if (loads[IR::Attribute::InstanceId]) { if (profile.support_vertex_instance_id) { @@ -1332,7 +1332,7 @@ void EmitContext::DefineOutputs(const IR::Program& program) { if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S)) { const Id id{DefineOutput(*this, F32[4], invocations)}; Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); - output_txt_coord = id; + output_fixed_fnc_texture = id; } for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index 1023d0ee4..9a76e1ca9 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h @@ -269,13 +269,13 @@ public: Id input_position{}; Id input_front_color{}; - Id input_txt_coord{}; + Id input_fixed_fnc_texture{}; std::array<Id, 32> input_generics{}; Id output_point_size{}; Id output_position{}; Id output_front_color{}; - Id output_txt_coord; + Id output_fixed_fnc_texture; std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; Id output_tess_level_outer{}; diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 0444bbf8f..a546d06a5 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -75,10 +75,10 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { } } if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { - const u32 index{IR::TxtCoordAttributeIndex(attr)}; - const u32 element{IR::TxtCoordAttributeElement(attr)}; + const u32 index{IR::FixedFncTextureAttributeIndex(attr)}; + const u32 element{IR::FixedFncTextureAttributeElement(attr)}; const Id element_id{ctx.Const(element)}; - return OutputAccessChain(ctx, ctx.output_f32, ctx.output_txt_coord, element_id); + return OutputAccessChain(ctx, ctx.output_f32, ctx.output_fixed_fnc_texture, element_id); } switch (attr) { case IR::Attribute::PointSize: @@ -322,8 +322,8 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; } if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { - const u32 index{IR::TxtCoordAttributeIndex(attr)}; - return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_txt_coord, + const u32 index{IR::FixedFncTextureAttributeIndex(attr)}; + return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_fixed_fnc_texture, ctx.Const(element))); } switch (attr) { diff --git a/src/shader_recompiler/frontend/ir/attribute.cpp b/src/shader_recompiler/frontend/ir/attribute.cpp index dc2bec06d..5b3694f65 100644 --- a/src/shader_recompiler/frontend/ir/attribute.cpp +++ b/src/shader_recompiler/frontend/ir/attribute.cpp @@ -9,11 +9,21 @@ namespace Shader::IR { -u32 TxtCoordAttributeIndex(Attribute attribute) { +bool IsFixedFncTexture(Attribute attribute) { + return attribute >= Attribute::FixedFncTexture0S && attribute <= Attribute::FixedFncTexture9Q; +} + +u32 FixedFncTextureAttributeIndex(Attribute attribute) { + if (!IsFixedFncTexture(attribute)) { + throw InvalidArgument("Attribute is not fixedfnctexture {}", attribute); + } return (static_cast<u32>(attribute) - static_cast<u32>(Attribute::FixedFncTexture0S)) / 4u; } -u32 TxtCoordAttributeElement(Attribute attribute) { +u32 FixedFncTextureAttributeElement(Attribute attribute) { + if (!IsFixedFncTexture(attribute)) { + throw InvalidArgument("Attribute is not fixedfnctexture {}", attribute); + } return static_cast<u32>(attribute) % 4; } diff --git a/src/shader_recompiler/frontend/ir/attribute.h b/src/shader_recompiler/frontend/ir/attribute.h index 6957fb43b..3f07fd7ac 100644 --- a/src/shader_recompiler/frontend/ir/attribute.h +++ b/src/shader_recompiler/frontend/ir/attribute.h @@ -222,12 +222,12 @@ enum class Attribute : u64 { FrontFace = 255, }; -constexpr size_t NUM_TXT_COORD = 10; +constexpr size_t NUM_FIXEDFNCTEXTURE = 10; constexpr size_t NUM_GENERICS = 32; -[[nodiscard]] u32 TxtCoordAttributeIndex(Attribute attribute); +[[nodiscard]] u32 FixedFncTextureAttributeIndex(Attribute attribute); -[[nodiscard]] u32 TxtCoordAttributeElement(Attribute attribute); +[[nodiscard]] u32 FixedFncTextureAttributeElement(Attribute attribute); [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; |