diff options
| author | 2023-01-04 21:20:00 -0500 | |
|---|---|---|
| committer | 2023-01-04 21:20:00 -0500 | |
| commit | b78328f19a54964ef6874281d1a4d6b6ad1c34d9 (patch) | |
| tree | 239947ad53a4a06c3641d58c5d6b8daf5b3dc16a /src/shader_recompiler/backend/spirv | |
| parent | Merge pull request #9518 from gidoly/revert-9504-pg2 (diff) | |
| parent | yuzu-ui: Add setting for disabling macro HLE (diff) | |
| download | yuzu-b78328f19a54964ef6874281d1a4d6b6ad1c34d9.tar.gz yuzu-b78328f19a54964ef6874281d1a4d6b6ad1c34d9.tar.xz yuzu-b78328f19a54964ef6874281d1a4d6b6ad1c34d9.zip | |
Merge pull request #9501 from FernandoS27/yfc-rel-2
Yuzu Fried Chicken Part 1.5: MacroHLE Rework and Dynamic State
Diffstat (limited to 'src/shader_recompiler/backend/spirv')
3 files changed, 26 insertions, 0 deletions
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 73b67f0af..db9c94ce8 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 | |||
| @@ -339,6 +339,12 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 339 | const Id base{ctx.OpLoad(ctx.U32[1], ctx.base_vertex)}; | 339 | const Id base{ctx.OpLoad(ctx.U32[1], ctx.base_vertex)}; |
| 340 | return ctx.OpBitcast(ctx.F32[1], ctx.OpISub(ctx.U32[1], index, base)); | 340 | return ctx.OpBitcast(ctx.F32[1], ctx.OpISub(ctx.U32[1], index, base)); |
| 341 | } | 341 | } |
| 342 | case IR::Attribute::BaseInstance: | ||
| 343 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.base_instance)); | ||
| 344 | case IR::Attribute::BaseVertex: | ||
| 345 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.base_vertex)); | ||
| 346 | case IR::Attribute::DrawID: | ||
| 347 | return ctx.OpBitcast(ctx.F32[1], ctx.OpLoad(ctx.U32[1], ctx.draw_index)); | ||
| 342 | case IR::Attribute::FrontFace: | 348 | case IR::Attribute::FrontFace: |
| 343 | return ctx.OpSelect(ctx.F32[1], ctx.OpLoad(ctx.U1, ctx.front_face), | 349 | return ctx.OpSelect(ctx.F32[1], ctx.OpLoad(ctx.U1, ctx.front_face), |
| 344 | ctx.OpBitcast(ctx.F32[1], ctx.Const(std::numeric_limits<u32>::max())), | 350 | ctx.OpBitcast(ctx.F32[1], ctx.Const(std::numeric_limits<u32>::max())), |
| @@ -380,6 +386,12 @@ Id EmitGetAttributeU32(EmitContext& ctx, IR::Attribute attr, Id) { | |||
| 380 | const Id base{ctx.OpLoad(ctx.U32[1], ctx.base_vertex)}; | 386 | const Id base{ctx.OpLoad(ctx.U32[1], ctx.base_vertex)}; |
| 381 | return ctx.OpISub(ctx.U32[1], index, base); | 387 | return ctx.OpISub(ctx.U32[1], index, base); |
| 382 | } | 388 | } |
| 389 | case IR::Attribute::BaseInstance: | ||
| 390 | return ctx.OpLoad(ctx.U32[1], ctx.base_instance); | ||
| 391 | case IR::Attribute::BaseVertex: | ||
| 392 | return ctx.OpLoad(ctx.U32[1], ctx.base_vertex); | ||
| 393 | case IR::Attribute::DrawID: | ||
| 394 | return ctx.OpLoad(ctx.U32[1], ctx.draw_index); | ||
| 383 | default: | 395 | default: |
| 384 | throw NotImplementedException("Read U32 attribute {}", attr); | 396 | throw NotImplementedException("Read U32 attribute {}", attr); |
| 385 | } | 397 | } |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 41dc6d031..ecb2db494 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -1379,18 +1379,31 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1379 | if (loads[IR::Attribute::InstanceId]) { | 1379 | if (loads[IR::Attribute::InstanceId]) { |
| 1380 | if (profile.support_vertex_instance_id) { | 1380 | if (profile.support_vertex_instance_id) { |
| 1381 | instance_id = DefineInput(*this, U32[1], true, spv::BuiltIn::InstanceId); | 1381 | instance_id = DefineInput(*this, U32[1], true, spv::BuiltIn::InstanceId); |
| 1382 | if (loads[IR::Attribute::BaseInstance]) { | ||
| 1383 | base_instance = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex); | ||
| 1384 | } | ||
| 1382 | } else { | 1385 | } else { |
| 1383 | instance_index = DefineInput(*this, U32[1], true, spv::BuiltIn::InstanceIndex); | 1386 | instance_index = DefineInput(*this, U32[1], true, spv::BuiltIn::InstanceIndex); |
| 1384 | base_instance = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseInstance); | 1387 | base_instance = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseInstance); |
| 1385 | } | 1388 | } |
| 1389 | } else if (loads[IR::Attribute::BaseInstance]) { | ||
| 1390 | base_instance = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseInstance); | ||
| 1386 | } | 1391 | } |
| 1387 | if (loads[IR::Attribute::VertexId]) { | 1392 | if (loads[IR::Attribute::VertexId]) { |
| 1388 | if (profile.support_vertex_instance_id) { | 1393 | if (profile.support_vertex_instance_id) { |
| 1389 | vertex_id = DefineInput(*this, U32[1], true, spv::BuiltIn::VertexId); | 1394 | vertex_id = DefineInput(*this, U32[1], true, spv::BuiltIn::VertexId); |
| 1395 | if (loads[IR::Attribute::BaseVertex]) { | ||
| 1396 | base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex); | ||
| 1397 | } | ||
| 1390 | } else { | 1398 | } else { |
| 1391 | vertex_index = DefineInput(*this, U32[1], true, spv::BuiltIn::VertexIndex); | 1399 | vertex_index = DefineInput(*this, U32[1], true, spv::BuiltIn::VertexIndex); |
| 1392 | base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex); | 1400 | base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex); |
| 1393 | } | 1401 | } |
| 1402 | } else if (loads[IR::Attribute::BaseVertex]) { | ||
| 1403 | base_vertex = DefineInput(*this, U32[1], true, spv::BuiltIn::BaseVertex); | ||
| 1404 | } | ||
| 1405 | if (loads[IR::Attribute::DrawID]) { | ||
| 1406 | draw_index = DefineInput(*this, U32[1], true, spv::BuiltIn::DrawIndex); | ||
| 1394 | } | 1407 | } |
| 1395 | if (loads[IR::Attribute::FrontFace]) { | 1408 | if (loads[IR::Attribute::FrontFace]) { |
| 1396 | front_face = DefineInput(*this, U1, true, spv::BuiltIn::FrontFacing); | 1409 | front_face = DefineInput(*this, U1, true, spv::BuiltIn::FrontFacing); |
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index dde45b4bc..4414a5169 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h | |||
| @@ -218,6 +218,7 @@ public: | |||
| 218 | Id base_instance{}; | 218 | Id base_instance{}; |
| 219 | Id vertex_id{}; | 219 | Id vertex_id{}; |
| 220 | Id vertex_index{}; | 220 | Id vertex_index{}; |
| 221 | Id draw_index{}; | ||
| 221 | Id base_vertex{}; | 222 | Id base_vertex{}; |
| 222 | Id front_face{}; | 223 | Id front_face{}; |
| 223 | Id point_coord{}; | 224 | Id point_coord{}; |