diff options
Diffstat (limited to 'src/shader_recompiler')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index ed023fcfe..bb9ccc0ac 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp | |||
| @@ -811,10 +811,14 @@ void EmitContext::DefineAttributeMemAccess(const Info& info) { | |||
| 811 | labels.push_back(OpLabel()); | 811 | labels.push_back(OpLabel()); |
| 812 | } | 812 | } |
| 813 | if (info.stores.ClipDistances()) { | 813 | if (info.stores.ClipDistances()) { |
| 814 | literals.push_back(static_cast<u32>(IR::Attribute::ClipDistance0) >> 2); | 814 | if (profile.max_user_clip_distances >= 4) { |
| 815 | labels.push_back(OpLabel()); | 815 | literals.push_back(static_cast<u32>(IR::Attribute::ClipDistance0) >> 2); |
| 816 | literals.push_back(static_cast<u32>(IR::Attribute::ClipDistance4) >> 2); | 816 | labels.push_back(OpLabel()); |
| 817 | labels.push_back(OpLabel()); | 817 | } |
| 818 | if (profile.max_user_clip_distances >= 8) { | ||
| 819 | literals.push_back(static_cast<u32>(IR::Attribute::ClipDistance4) >> 2); | ||
| 820 | labels.push_back(OpLabel()); | ||
| 821 | } | ||
| 818 | } | 822 | } |
| 819 | OpSelectionMerge(end_block, spv::SelectionControlMask::MaskNone); | 823 | OpSelectionMerge(end_block, spv::SelectionControlMask::MaskNone); |
| 820 | OpSwitch(compare_index, default_label, literals, labels); | 824 | OpSwitch(compare_index, default_label, literals, labels); |
| @@ -843,17 +847,21 @@ void EmitContext::DefineAttributeMemAccess(const Info& info) { | |||
| 843 | ++label_index; | 847 | ++label_index; |
| 844 | } | 848 | } |
| 845 | if (info.stores.ClipDistances()) { | 849 | if (info.stores.ClipDistances()) { |
| 846 | AddLabel(labels[label_index]); | 850 | if (profile.max_user_clip_distances >= 4) { |
| 847 | const Id pointer{OpAccessChain(output_f32, clip_distances, masked_index)}; | 851 | AddLabel(labels[label_index]); |
| 848 | OpStore(pointer, store_value); | 852 | const Id pointer{OpAccessChain(output_f32, clip_distances, masked_index)}; |
| 849 | OpReturn(); | 853 | OpStore(pointer, store_value); |
| 850 | ++label_index; | 854 | OpReturn(); |
| 851 | AddLabel(labels[label_index]); | 855 | ++label_index; |
| 852 | const Id fixed_index{OpIAdd(U32[1], masked_index, Const(4U))}; | 856 | } |
| 853 | const Id pointer2{OpAccessChain(output_f32, clip_distances, fixed_index)}; | 857 | if (profile.max_user_clip_distances >= 8) { |
| 854 | OpStore(pointer2, store_value); | 858 | AddLabel(labels[label_index]); |
| 855 | OpReturn(); | 859 | const Id fixed_index{OpIAdd(U32[1], masked_index, Const(4U))}; |
| 856 | ++label_index; | 860 | const Id pointer{OpAccessChain(output_f32, clip_distances, fixed_index)}; |
| 861 | OpStore(pointer, store_value); | ||
| 862 | OpReturn(); | ||
| 863 | ++label_index; | ||
| 864 | } | ||
| 857 | } | 865 | } |
| 858 | AddLabel(end_block); | 866 | AddLabel(end_block); |
| 859 | OpUnreachable(); | 867 | OpUnreachable(); |
| @@ -1532,9 +1540,11 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1532 | if (stage == Stage::Fragment) { | 1540 | if (stage == Stage::Fragment) { |
| 1533 | throw NotImplementedException("Storing ClipDistance in fragment stage"); | 1541 | throw NotImplementedException("Storing ClipDistance in fragment stage"); |
| 1534 | } | 1542 | } |
| 1535 | const Id type{TypeArray( | 1543 | if (profile.max_user_clip_distances > 0) { |
| 1536 | F32[1], Const(std::min(info.used_clip_distances, profile.max_user_clip_distances)))}; | 1544 | const Id type{TypeArray(F32[1], Const(std::min(info.used_clip_distances, |
| 1537 | clip_distances = DefineOutput(*this, type, invocations, spv::BuiltIn::ClipDistance); | 1545 | profile.max_user_clip_distances)))}; |
| 1546 | clip_distances = DefineOutput(*this, type, invocations, spv::BuiltIn::ClipDistance); | ||
| 1547 | } | ||
| 1538 | } | 1548 | } |
| 1539 | if (info.stores[IR::Attribute::Layer] && | 1549 | if (info.stores[IR::Attribute::Layer] && |
| 1540 | (profile.support_viewport_index_layer_non_geometry || stage == Stage::Geometry)) { | 1550 | (profile.support_viewport_index_layer_non_geometry || stage == Stage::Geometry)) { |