diff options
Diffstat (limited to 'src/shader_recompiler/backend')
3 files changed, 44 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 2d29d8c14..89c75c52d 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -1201,6 +1201,12 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1201 | } | 1201 | } |
| 1202 | } | 1202 | } |
| 1203 | } | 1203 | } |
| 1204 | if (loads.AllComponents(IR::Attribute::ColorFrontDiffuseR)) { | ||
| 1205 | input_front_color = DefineInput(*this, F32[4], true); | ||
| 1206 | } | ||
| 1207 | if (loads.AllComponents(IR::Attribute::FixedFncTexture0S)) { | ||
| 1208 | input_txt_coord = DefineInput(*this, F32[4], true); | ||
| 1209 | } | ||
| 1204 | if (loads[IR::Attribute::InstanceId]) { | 1210 | if (loads[IR::Attribute::InstanceId]) { |
| 1205 | if (profile.support_vertex_instance_id) { | 1211 | if (profile.support_vertex_instance_id) { |
| 1206 | instance_id = DefineInput(*this, U32[1], true, spv::BuiltIn::InstanceId); | 1212 | instance_id = DefineInput(*this, U32[1], true, spv::BuiltIn::InstanceId); |
| @@ -1282,6 +1288,9 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1282 | if (info.stores.AnyComponent(IR::Attribute::PositionX) || stage == Stage::VertexB) { | 1288 | if (info.stores.AnyComponent(IR::Attribute::PositionX) || stage == Stage::VertexB) { |
| 1283 | output_position = DefineOutput(*this, F32[4], invocations, spv::BuiltIn::Position); | 1289 | output_position = DefineOutput(*this, F32[4], invocations, spv::BuiltIn::Position); |
| 1284 | } | 1290 | } |
| 1291 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR) || stage == Stage::VertexB) { | ||
| 1292 | output_front_color = DefineOutput(*this, F32[4], invocations); | ||
| 1293 | } | ||
| 1285 | if (info.stores[IR::Attribute::PointSize] || runtime_info.fixed_state_point_size) { | 1294 | if (info.stores[IR::Attribute::PointSize] || runtime_info.fixed_state_point_size) { |
| 1286 | if (stage == Stage::Fragment) { | 1295 | if (stage == Stage::Fragment) { |
| 1287 | throw NotImplementedException("Storing PointSize in fragment stage"); | 1296 | throw NotImplementedException("Storing PointSize in fragment stage"); |
| @@ -1313,6 +1322,11 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1313 | viewport_mask = DefineOutput(*this, TypeArray(U32[1], Const(1u)), std::nullopt, | 1322 | viewport_mask = DefineOutput(*this, TypeArray(U32[1], Const(1u)), std::nullopt, |
| 1314 | spv::BuiltIn::ViewportMaskNV); | 1323 | spv::BuiltIn::ViewportMaskNV); |
| 1315 | } | 1324 | } |
| 1325 | |||
| 1326 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S)) { | ||
| 1327 | output_txt_coord = DefineOutput(*this, F32[4], invocations); | ||
| 1328 | } | ||
| 1329 | |||
| 1316 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 1330 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { |
| 1317 | if (info.stores.Generic(index)) { | 1331 | if (info.stores.Generic(index)) { |
| 1318 | DefineGenericOutput(*this, index, invocations); | 1332 | 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 e277bc358..1023d0ee4 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -268,10 +268,14 @@ public: | |||
| 268 | Id write_global_func_u32x4{}; | 268 | Id write_global_func_u32x4{}; |
| 269 | 269 | ||
| 270 | Id input_position{}; | 270 | Id input_position{}; |
| 271 | Id input_front_color{}; | ||
| 272 | Id input_txt_coord{}; | ||
| 271 | std::array<Id, 32> input_generics{}; | 273 | std::array<Id, 32> input_generics{}; |
| 272 | 274 | ||
| 273 | Id output_point_size{}; | 275 | Id output_point_size{}; |
| 274 | Id output_position{}; | 276 | Id output_position{}; |
| 277 | Id output_front_color{}; | ||
| 278 | Id output_txt_coord; | ||
| 275 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; | 279 | std::array<std::array<GenericElementInfo, 4>, 32> output_generics{}; |
| 276 | 280 | ||
| 277 | 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 14c77f162..0444bbf8f 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 | |||
| @@ -74,6 +74,12 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 74 | return OutputAccessChain(ctx, ctx.output_f32, info.id, index_id); | 74 | return OutputAccessChain(ctx, ctx.output_f32, info.id, index_id); |
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { | ||
| 78 | const u32 index{IR::TxtCoordAttributeIndex(attr)}; | ||
| 79 | const u32 element{IR::TxtCoordAttributeElement(attr)}; | ||
| 80 | const Id element_id{ctx.Const(element)}; | ||
| 81 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_txt_coord, element_id); | ||
| 82 | } | ||
| 77 | switch (attr) { | 83 | switch (attr) { |
| 78 | case IR::Attribute::PointSize: | 84 | case IR::Attribute::PointSize: |
| 79 | return ctx.output_point_size; | 85 | return ctx.output_point_size; |
| @@ -85,6 +91,14 @@ std::optional<OutAttr> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 85 | const Id element_id{ctx.Const(element)}; | 91 | const Id element_id{ctx.Const(element)}; |
| 86 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_position, element_id); | 92 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_position, element_id); |
| 87 | } | 93 | } |
| 94 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 95 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 96 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 97 | case IR::Attribute::ColorFrontDiffuseA: { | ||
| 98 | const u32 element{static_cast<u32>(attr) % 4}; | ||
| 99 | const Id element_id{ctx.Const(element)}; | ||
| 100 | return OutputAccessChain(ctx, ctx.output_f32, ctx.output_front_color, element_id); | ||
| 101 | } | ||
| 88 | case IR::Attribute::ClipDistance0: | 102 | case IR::Attribute::ClipDistance0: |
| 89 | case IR::Attribute::ClipDistance1: | 103 | case IR::Attribute::ClipDistance1: |
| 90 | case IR::Attribute::ClipDistance2: | 104 | case IR::Attribute::ClipDistance2: |
| @@ -307,6 +321,11 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 307 | const Id value{ctx.OpLoad(type->id, pointer)}; | 321 | const Id value{ctx.OpLoad(type->id, pointer)}; |
| 308 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; | 322 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; |
| 309 | } | 323 | } |
| 324 | if (attr >= IR::Attribute::FixedFncTexture0S && attr <= IR::Attribute::FixedFncTexture9Q) { | ||
| 325 | const u32 index{IR::TxtCoordAttributeIndex(attr)}; | ||
| 326 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_txt_coord, | ||
| 327 | ctx.Const(element))); | ||
| 328 | } | ||
| 310 | switch (attr) { | 329 | switch (attr) { |
| 311 | case IR::Attribute::PrimitiveId: | 330 | case IR::Attribute::PrimitiveId: |
| 312 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.primitive_id)); | 331 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.primitive_id)); |
| @@ -316,6 +335,13 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 316 | case IR::Attribute::PositionW: | 335 | case IR::Attribute::PositionW: |
| 317 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_position, | 336 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_position, |
| 318 | ctx.Const(element))); | 337 | ctx.Const(element))); |
| 338 | case IR::Attribute::ColorFrontDiffuseR: | ||
| 339 | case IR::Attribute::ColorFrontDiffuseG: | ||
| 340 | case IR::Attribute::ColorFrontDiffuseB: | ||
| 341 | case IR::Attribute::ColorFrontDiffuseA: { | ||
| 342 | return ctx.OpLoad(ctx.F32[1], AttrPointer(ctx, ctx.input_f32, vertex, ctx.input_front_color, | ||
| 343 | ctx.Const(element))); | ||
| 344 | } | ||
| 319 | case IR::Attribute::InstanceId: | 345 | case IR::Attribute::InstanceId: |
| 320 | if (ctx.profile.support_vertex_instance_id) { | 346 | if (ctx.profile.support_vertex_instance_id) { |
| 321 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.instance_id)); | 347 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.instance_id)); |