diff options
Diffstat (limited to '')
4 files changed, 25 insertions, 19 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 3ec5a4570..81c79e1ed 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -1206,10 +1206,12 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1206 | Decorate(id, spv::Decoration::Location, static_cast<u32>(11)); | 1206 | Decorate(id, spv::Decoration::Location, static_cast<u32>(11)); |
| 1207 | input_front_color = id; | 1207 | input_front_color = id; |
| 1208 | } | 1208 | } |
| 1209 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S)) { | 1209 | for (size_t index = 0; index < IR::NUM_FIXEDFNCTEXTURE; ++index) { |
| 1210 | const Id id{DefineInput(*this, F32[4], true)}; | 1210 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1211 | Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); | 1211 | const Id id{DefineInput(*this, F32[4], true)}; |
| 1212 | input_fixed_fnc_texture = id; | 1212 | Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); |
| 1213 | input_fixed_fnc_textures[index] = id; | ||
| 1214 | } | ||
| 1213 | } | 1215 | } |
| 1214 | if (loads[IR::Attribute::InstanceId]) { | 1216 | if (loads[IR::Attribute::InstanceId]) { |
| 1215 | if (profile.support_vertex_instance_id) { | 1217 | if (profile.support_vertex_instance_id) { |
| @@ -1292,11 +1294,6 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1292 | if (info.stores.AnyComponent(IR::Attribute::PositionX) || stage == Stage::VertexB) { | 1294 | if (info.stores.AnyComponent(IR::Attribute::PositionX) || stage == Stage::VertexB) { |
| 1293 | output_position = DefineOutput(*this, F32[4], invocations, spv::BuiltIn::Position); | 1295 | output_position = DefineOutput(*this, F32[4], invocations, spv::BuiltIn::Position); |
| 1294 | } | 1296 | } |
| 1295 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR) || stage == Stage::VertexB) { | ||
| 1296 | const Id id{DefineOutput(*this, F32[4], invocations)}; | ||
| 1297 | Decorate(id, spv::Decoration::Location, static_cast<u32>(11)); | ||
| 1298 | output_front_color = id; | ||
| 1299 | } | ||
| 1300 | if (info.stores[IR::Attribute::PointSize] || runtime_info.fixed_state_point_size) { | 1297 | if (info.stores[IR::Attribute::PointSize] || runtime_info.fixed_state_point_size) { |
| 1301 | if (stage == Stage::Fragment) { | 1298 | if (stage == Stage::Fragment) { |
| 1302 | throw NotImplementedException("Storing PointSize in fragment stage"); | 1299 | throw NotImplementedException("Storing PointSize in fragment stage"); |
| @@ -1328,13 +1325,18 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1328 | viewport_mask = DefineOutput(*this, TypeArray(U32[1], Const(1u)), std::nullopt, | 1325 | viewport_mask = DefineOutput(*this, TypeArray(U32[1], Const(1u)), std::nullopt, |
| 1329 | spv::BuiltIn::ViewportMaskNV); | 1326 | spv::BuiltIn::ViewportMaskNV); |
| 1330 | } | 1327 | } |
| 1331 | 1328 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR) || stage == Stage::VertexB) { | |
| 1332 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S)) { | ||
| 1333 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1329 | const Id id{DefineOutput(*this, F32[4], invocations)}; |
| 1334 | Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); | 1330 | Decorate(id, spv::Decoration::Location, static_cast<u32>(11)); |
| 1335 | output_fixed_fnc_texture = id; | 1331 | output_front_color = id; |
| 1332 | } | ||
| 1333 | for (size_t index = 0; index < IR::NUM_FIXEDFNCTEXTURE; ++index) { | ||
| 1334 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | ||
| 1335 | const Id id{DefineOutput(*this, F32[4], invocations)}; | ||
| 1336 | Decorate(id, spv::Decoration::Location, static_cast<u32>(12)); | ||
| 1337 | output_fixed_fnc_textures[index] = id; | ||
| 1338 | } | ||
| 1336 | } | 1339 | } |
| 1337 | |||
| 1338 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 1340 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { |
| 1339 | if (info.stores.Generic(index)) { | 1341 | if (info.stores.Generic(index)) { |
| 1340 | DefineGenericOutput(*this, index, invocations); | 1342 | DefineGenericOutput(*this, index, invocations); |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index 9a76e1ca9..847d0c0e6 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_fixed_fnc_texture{}; | 272 | std::array<Id, 10> input_fixed_fnc_textures{}; |
| 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_fixed_fnc_texture; | 278 | std::array<Id, 10> output_fixed_fnc_textures{}; |
| 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 a546d06a5..c3ebd3e6a 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 | |||
| @@ -78,7 +78,8 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 78 | const u32 index{IR::FixedFncTextureAttributeIndex(attr)}; | 78 | const u32 index{IR::FixedFncTextureAttributeIndex(attr)}; |
| 79 | const u32 element{IR::FixedFncTextureAttributeElement(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_fixed_fnc_texture, element_id); | 81 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_fixed_fnc_textures[index], |
| 82 | element_id); | ||
| 82 | } | 83 | } |
| 83 | switch (attr) { | 84 | switch (attr) { |
| 84 | case IR::Attribute::PointSize: | 85 | case IR::Attribute::PointSize: |
| @@ -323,8 +324,9 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 323 | } | 324 | } |
| 324 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { | 325 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { |
| 325 | const u32 index{IR::FixedFncTextureAttributeIndex(attr)}; | 326 | const u32 index{IR::FixedFncTextureAttributeIndex(attr)}; |
| 326 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_fixed_fnc_texture, | 327 | return ctx.OpLoad(ctx.F32[1], |
| 327 | ctx.Const(element))); | 328 | AttrPointer(ctx, ctx.input_f32, vertex, |
| 329 | ctx.input_fixed_fnc_textures[index], ctx.Const(element))); | ||
| 328 | } | 330 | } |
| 329 | switch (attr) { | 331 | switch (attr) { |
| 330 | case IR::Attribute::PrimitiveId: | 332 | case IR::Attribute::PrimitiveId: |
diff --git a/src/shader_recompiler/frontend/ir/attribute.h b/src/shader_recompiler/frontend/ir/attribute.h index 3f07fd7ac..9ca4dd76e 100644 --- a/src/shader_recompiler/frontend/ir/attribute.h +++ b/src/shader_recompiler/frontend/ir/attribute.h | |||
| @@ -225,6 +225,8 @@ enum class Attribute : u64 { | |||
| 225 | constexpr size_t NUM_FIXEDFNCTEXTURE = 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]] bool IsFixedFncTexture(Attribute attribute); | ||
| 229 | |||
| 228 | [[nodiscard]] u32 FixedFncTextureAttributeIndex(Attribute attribute); | 230 | [[nodiscard]] u32 FixedFncTextureAttributeIndex(Attribute attribute); |
| 229 | 231 | ||
| 230 | [[nodiscard]] u32 FixedFncTextureAttributeElement(Attribute attribute); | 232 | [[nodiscard]] u32 FixedFncTextureAttributeElement(Attribute attribute); |