diff options
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) { | |||
| 1209 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S)) { | 1209 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S)) { |
| 1210 | const Id id{DefineInput(*this, F32[4], true)}; | 1210 | const Id id{DefineInput(*this, F32[4], true)}; |
| 1211 | Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); | 1211 | Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); |
| 1212 | input_txt_coord = id; | 1212 | input_fixed_fnc_texture = id; |
| 1213 | } | 1213 | } |
| 1214 | if (loads[IR::Attribute::InstanceId]) { | 1214 | if (loads[IR::Attribute::InstanceId]) { |
| 1215 | if (profile.support_vertex_instance_id) { | 1215 | if (profile.support_vertex_instance_id) { |
| @@ -1332,7 +1332,7 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1332 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S)) { | 1332 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S)) { |
| 1333 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1333 | const Id id{DefineOutput(*this, F32[4], invocations)}; |
| 1334 | Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); | 1334 | Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); |
| 1335 | output_txt_coord = id; | 1335 | output_fixed_fnc_texture = id; |
| 1336 | } | 1336 | } |
| 1337 | 1337 | ||
| 1338 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 1338 | 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: | |||
| 269 | 269 | ||
| 270 | Id input_position{}; | 270 | Id input_position{}; |
| 271 | Id input_front_color{}; | 271 | Id input_front_color{}; |
| 272 | Id input_txt_coord{}; | 272 | Id input_fixed_fnc_texture{}; |
| 273 | std::array<Id, 32> input_generics{}; | 273 | std::array<Id, 32> input_generics{}; |
| 274 | 274 | ||
| 275 | Id output_point_size{}; | 275 | Id output_point_size{}; |
| 276 | Id output_position{}; | 276 | Id output_position{}; |
| 277 | Id output_front_color{}; | 277 | Id output_front_color{}; |
| 278 | Id output_txt_coord; | 278 | Id output_fixed_fnc_texture; |
| 279 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; | 279 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; |
| 280 | 280 | ||
| 281 | Id output_tess_level_outer{}; | 281 | 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) { | |||
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { | 77 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { |
| 78 | const u32 index{IR::TxtCoordAttributeIndex(attr)}; | 78 | const u32 index{IR::FixedFncTextureAttributeIndex(attr)}; |
| 79 | const u32 element{IR::TxtCoordAttributeElement(attr)}; | 79 | const u32 element{IR::FixedFncTextureAttributeElement(attr)}; |
| 80 | const Id element_id{ctx.Const(element)}; | 80 | const Id element_id{ctx.Const(element)}; |
| 81 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_txt_coord, element_id); | 81 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_fixed_fnc_texture, element_id); |
| 82 | } | 82 | } |
| 83 | switch (attr) { | 83 | switch (attr) { |
| 84 | case IR::Attribute::PointSize: | 84 | case IR::Attribute::PointSize: |
| @@ -322,8 +322,8 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 322 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; | 322 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; |
| 323 | } | 323 | } |
| 324 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { | 324 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { |
| 325 | const u32 index{IR::TxtCoordAttributeIndex(attr)}; | 325 | const u32 index{IR::FixedFncTextureAttributeIndex(attr)}; |
| 326 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_txt_coord, | 326 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_fixed_fnc_texture, |
| 327 | ctx.Const(element))); | 327 | ctx.Const(element))); |
| 328 | } | 328 | } |
| 329 | switch (attr) { | 329 | 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 @@ | |||
| 9 | 9 | ||
| 10 | namespace Shader::IR { | 10 | namespace Shader::IR { |
| 11 | 11 | ||
| 12 | u32 TxtCoordAttributeIndex(Attribute attribute) { | 12 | bool IsFixedFncTexture(Attribute attribute) { |
| 13 | return attribute >= Attribute::FixedFncTexture0S && attribute <= Attribute::FixedFncTexture9Q; | ||
| 14 | } | ||
| 15 | |||
| 16 | u32 FixedFncTextureAttributeIndex(Attribute attribute) { | ||
| 17 | if (!IsFixedFncTexture(attribute)) { | ||
| 18 | throw InvalidArgument("Attribute is not fixedfnctexture {}", attribute); | ||
| 19 | } | ||
| 13 | return (static_cast<u32>(attribute) - static_cast<u32>(Attribute::FixedFncTexture0S)) / 4u; | 20 | return (static_cast<u32>(attribute) - static_cast<u32>(Attribute::FixedFncTexture0S)) / 4u; |
| 14 | } | 21 | } |
| 15 | 22 | ||
| 16 | u32 TxtCoordAttributeElement(Attribute attribute) { | 23 | u32 FixedFncTextureAttributeElement(Attribute attribute) { |
| 24 | if (!IsFixedFncTexture(attribute)) { | ||
| 25 | throw InvalidArgument("Attribute is not fixedfnctexture {}", attribute); | ||
| 26 | } | ||
| 17 | return static_cast<u32>(attribute) % 4; | 27 | return static_cast<u32>(attribute) % 4; |
| 18 | } | 28 | } |
| 19 | 29 | ||
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 { | |||
| 222 | FrontFace = 255, | 222 | FrontFace = 255, |
| 223 | }; | 223 | }; |
| 224 | 224 | ||
| 225 | constexpr size_t NUM_TXT_COORD = 10; | 225 | constexpr size_t NUM_FIXEDFNCTEXTURE = 10; |
| 226 | constexpr size_t NUM_GENERICS = 32; | 226 | constexpr size_t NUM_GENERICS = 32; |
| 227 | 227 | ||
| 228 | [[nodiscard]] u32 TxtCoordAttributeIndex(Attribute attribute); | 228 | [[nodiscard]] u32 FixedFncTextureAttributeIndex(Attribute attribute); |
| 229 | 229 | ||
| 230 | [[nodiscard]] u32 TxtCoordAttributeElement(Attribute attribute); | 230 | [[nodiscard]] u32 FixedFncTextureAttributeElement(Attribute attribute); |
| 231 | 231 | ||
| 232 | [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; | 232 | [[nodiscard]] bool IsGeneric(Attribute attribute) noexcept; |
| 233 | 233 | ||