diff options
5 files changed, 36 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index c8ce58254..2e3e3346d 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -176,6 +176,9 @@ void EmitContext::DefineCommonTypes(const Info& info) { | |||
| 176 | AddCapability(spv::Capability::Float64); | 176 | AddCapability(spv::Capability::Float64); |
| 177 | F64.Define(*this, TypeFloat(64), "f64"); | 177 | F64.Define(*this, TypeFloat(64), "f64"); |
| 178 | } | 178 | } |
| 179 | if (info.stores_clip_distance) { | ||
| 180 | Array8F32 = Name(TypeArray(F32[1], Constant(U32[1], 8)), "array_8_f32"); | ||
| 181 | } | ||
| 179 | } | 182 | } |
| 180 | 183 | ||
| 181 | void EmitContext::DefineCommonConstants() { | 184 | void EmitContext::DefineCommonConstants() { |
| @@ -502,6 +505,12 @@ void EmitContext::DefineOutputs(const Info& info) { | |||
| 502 | } | 505 | } |
| 503 | output_point_size = DefineOutput(*this, F32[1], spv::BuiltIn::PointSize); | 506 | output_point_size = DefineOutput(*this, F32[1], spv::BuiltIn::PointSize); |
| 504 | } | 507 | } |
| 508 | if (info.stores_clip_distance) { | ||
| 509 | if (stage == Stage::Fragment) { | ||
| 510 | throw NotImplementedException("Storing PointSize in Fragment stage"); | ||
| 511 | } | ||
| 512 | clip_distances = DefineOutput(*this, Array8F32, spv::BuiltIn::ClipDistance); | ||
| 513 | } | ||
| 505 | for (size_t i = 0; i < info.stores_generics.size(); ++i) { | 514 | for (size_t i = 0; i < info.stores_generics.size(); ++i) { |
| 506 | if (info.stores_generics[i]) { | 515 | if (info.stores_generics[i]) { |
| 507 | output_generics[i] = DefineOutput(*this, F32[4]); | 516 | output_generics[i] = DefineOutput(*this, F32[4]); |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index 3965869f0..bffe1558c 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -67,6 +67,8 @@ public: | |||
| 67 | VectorTypes F16; | 67 | VectorTypes F16; |
| 68 | VectorTypes F64; | 68 | VectorTypes F64; |
| 69 | 69 | ||
| 70 | Id Array8F32{}; | ||
| 71 | |||
| 70 | Id true_value{}; | 72 | Id true_value{}; |
| 71 | Id false_value{}; | 73 | Id false_value{}; |
| 72 | Id u32_zero_value{}; | 74 | Id u32_zero_value{}; |
| @@ -105,6 +107,7 @@ public: | |||
| 105 | Id base_vertex{}; | 107 | Id base_vertex{}; |
| 106 | Id front_face{}; | 108 | Id front_face{}; |
| 107 | Id point_coord{}; | 109 | Id point_coord{}; |
| 110 | Id clip_distances{}; | ||
| 108 | 111 | ||
| 109 | Id fswzadd_lut_a{}; | 112 | Id fswzadd_lut_a{}; |
| 110 | Id fswzadd_lut_b{}; | 113 | Id fswzadd_lut_b{}; |
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 d02761f32..2eaeb29de 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 | |||
| @@ -44,6 +44,19 @@ Id OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 44 | case IR::Attribute::PositionZ: | 44 | case IR::Attribute::PositionZ: |
| 45 | case IR::Attribute::PositionW: | 45 | case IR::Attribute::PositionW: |
| 46 | return ctx.OpAccessChain(ctx.output_f32, ctx.output_position, element_id()); | 46 | return ctx.OpAccessChain(ctx.output_f32, ctx.output_position, element_id()); |
| 47 | case IR::Attribute::ClipDistance0: | ||
| 48 | case IR::Attribute::ClipDistance1: | ||
| 49 | case IR::Attribute::ClipDistance2: | ||
| 50 | case IR::Attribute::ClipDistance3: | ||
| 51 | case IR::Attribute::ClipDistance4: | ||
| 52 | case IR::Attribute::ClipDistance5: | ||
| 53 | case IR::Attribute::ClipDistance6: | ||
| 54 | case IR::Attribute::ClipDistance7: { | ||
| 55 | const u32 base{static_cast<u32>(IR::Attribute::ClipDistance0)}; | ||
| 56 | const u32 index{static_cast<u32>(attr) - base}; | ||
| 57 | const Id clip_num{ctx.Constant(ctx.U32[1], index)}; | ||
| 58 | return ctx.OpAccessChain(ctx.output_f32, ctx.clip_distances, clip_num); | ||
| 59 | } | ||
| 47 | default: | 60 | default: |
| 48 | throw NotImplementedException("Read attribute {}", attr); | 61 | throw NotImplementedException("Read attribute {}", attr); |
| 49 | } | 62 | } |
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp index 730d3e91e..50ffc4c19 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -71,6 +71,16 @@ void SetAttribute(Info& info, IR::Attribute attribute) { | |||
| 71 | case IR::Attribute::PositionW: | 71 | case IR::Attribute::PositionW: |
| 72 | info.stores_position = true; | 72 | info.stores_position = true; |
| 73 | break; | 73 | break; |
| 74 | case IR::Attribute::ClipDistance0: | ||
| 75 | case IR::Attribute::ClipDistance1: | ||
| 76 | case IR::Attribute::ClipDistance2: | ||
| 77 | case IR::Attribute::ClipDistance3: | ||
| 78 | case IR::Attribute::ClipDistance4: | ||
| 79 | case IR::Attribute::ClipDistance5: | ||
| 80 | case IR::Attribute::ClipDistance6: | ||
| 81 | case IR::Attribute::ClipDistance7: | ||
| 82 | info.stores_clip_distance = true; | ||
| 83 | break; | ||
| 74 | default: | 84 | default: |
| 75 | throw NotImplementedException("Set attribute {}", attribute); | 85 | throw NotImplementedException("Set attribute {}", attribute); |
| 76 | } | 86 | } |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index c9f6d9ef7..a62ad1e79 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -81,6 +81,7 @@ struct Info { | |||
| 81 | std::array<bool, 32> stores_generics{}; | 81 | std::array<bool, 32> stores_generics{}; |
| 82 | bool stores_position{}; | 82 | bool stores_position{}; |
| 83 | bool stores_point_size{}; | 83 | bool stores_point_size{}; |
| 84 | bool stores_clip_distance{}; | ||
| 84 | 85 | ||
| 85 | bool uses_fp16{}; | 86 | bool uses_fp16{}; |
| 86 | bool uses_fp64{}; | 87 | bool uses_fp64{}; |