diff options
| author | 2023-01-06 10:06:45 -0500 | |
|---|---|---|
| committer | 2023-01-06 10:06:45 -0500 | |
| commit | 8b251fc3f60330f1b1311af2d17cdb1ae9874683 (patch) | |
| tree | 9c9eca32c58912170c07097d885fc08672cb40a8 /src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |
| parent | Merge pull request #9561 from liamwhite/update-dynarmic (diff) | |
| parent | Run clang-format (diff) | |
| download | yuzu-8b251fc3f60330f1b1311af2d17cdb1ae9874683.tar.gz yuzu-8b251fc3f60330f1b1311af2d17cdb1ae9874683.tar.xz yuzu-8b251fc3f60330f1b1311af2d17cdb1ae9874683.zip | |
Merge pull request #9535 from bylaws/master
Port over several shader-compiler fixes from skyline
Diffstat (limited to 'src/shader_recompiler/backend/spirv/spirv_emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index ecb2db494..a0c155fdb 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -544,7 +544,7 @@ void EmitContext::DefineCommonTypes(const Info& info) { | |||
| 544 | U16 = Name(TypeInt(16, false), "u16"); | 544 | U16 = Name(TypeInt(16, false), "u16"); |
| 545 | S16 = Name(TypeInt(16, true), "s16"); | 545 | S16 = Name(TypeInt(16, true), "s16"); |
| 546 | } | 546 | } |
| 547 | if (info.uses_int64) { | 547 | if (info.uses_int64 && profile.support_int64) { |
| 548 | AddCapability(spv::Capability::Int64); | 548 | AddCapability(spv::Capability::Int64); |
| 549 | U64 = Name(TypeInt(64, false), "u64"); | 549 | U64 = Name(TypeInt(64, false), "u64"); |
| 550 | } | 550 | } |
| @@ -721,9 +721,21 @@ void EmitContext::DefineAttributeMemAccess(const Info& info) { | |||
| 721 | size_t label_index{0}; | 721 | size_t label_index{0}; |
| 722 | if (info.loads.AnyComponent(IR::Attribute::PositionX)) { | 722 | if (info.loads.AnyComponent(IR::Attribute::PositionX)) { |
| 723 | AddLabel(labels[label_index]); | 723 | AddLabel(labels[label_index]); |
| 724 | const Id pointer{is_array | 724 | const Id pointer{[&]() { |
| 725 | ? OpAccessChain(input_f32, input_position, vertex, masked_index) | 725 | if (need_input_position_indirect) { |
| 726 | : OpAccessChain(input_f32, input_position, masked_index)}; | 726 | if (is_array) |
| 727 | return OpAccessChain(input_f32, input_position, vertex, u32_zero_value, | ||
| 728 | masked_index); | ||
| 729 | else | ||
| 730 | return OpAccessChain(input_f32, input_position, u32_zero_value, | ||
| 731 | masked_index); | ||
| 732 | } else { | ||
| 733 | if (is_array) | ||
| 734 | return OpAccessChain(input_f32, input_position, vertex, masked_index); | ||
| 735 | else | ||
| 736 | return OpAccessChain(input_f32, input_position, masked_index); | ||
| 737 | } | ||
| 738 | }()}; | ||
| 727 | const Id result{OpLoad(F32[1], pointer)}; | 739 | const Id result{OpLoad(F32[1], pointer)}; |
| 728 | OpReturnValue(result); | 740 | OpReturnValue(result); |
| 729 | ++label_index; | 741 | ++label_index; |
| @@ -1367,12 +1379,25 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1367 | Decorate(layer, spv::Decoration::Flat); | 1379 | Decorate(layer, spv::Decoration::Flat); |
| 1368 | } | 1380 | } |
| 1369 | if (loads.AnyComponent(IR::Attribute::PositionX)) { | 1381 | if (loads.AnyComponent(IR::Attribute::PositionX)) { |
| 1370 | const bool is_fragment{stage != Stage::Fragment}; | 1382 | const bool is_fragment{stage == Stage::Fragment}; |
| 1371 | const spv::BuiltIn built_in{is_fragment ? spv::BuiltIn::Position : spv::BuiltIn::FragCoord}; | 1383 | if (!is_fragment && profile.has_broken_spirv_position_input) { |
| 1372 | input_position = DefineInput(*this, F32[4], true, built_in); | 1384 | need_input_position_indirect = true; |
| 1373 | if (profile.support_geometry_shader_passthrough) { | 1385 | |
| 1374 | if (info.passthrough.AnyComponent(IR::Attribute::PositionX)) { | 1386 | const Id input_position_struct = TypeStruct(F32[4]); |
| 1375 | Decorate(input_position, spv::Decoration::PassthroughNV); | 1387 | input_position = DefineInput(*this, input_position_struct, true); |
| 1388 | |||
| 1389 | MemberDecorate(input_position_struct, 0, spv::Decoration::BuiltIn, | ||
| 1390 | static_cast<unsigned>(spv::BuiltIn::Position)); | ||
| 1391 | Decorate(input_position_struct, spv::Decoration::Block); | ||
| 1392 | } else { | ||
| 1393 | const spv::BuiltIn built_in{is_fragment ? spv::BuiltIn::FragCoord | ||
| 1394 | : spv::BuiltIn::Position}; | ||
| 1395 | input_position = DefineInput(*this, F32[4], true, built_in); | ||
| 1396 | |||
| 1397 | if (profile.support_geometry_shader_passthrough) { | ||
| 1398 | if (info.passthrough.AnyComponent(IR::Attribute::PositionX)) { | ||
| 1399 | Decorate(input_position, spv::Decoration::PassthroughNV); | ||
| 1400 | } | ||
| 1376 | } | 1401 | } |
| 1377 | } | 1402 | } |
| 1378 | } | 1403 | } |