diff options
| author | 2021-03-27 02:55:37 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | f0031babeb3ed04aef2468840aa37f4da13b2524 (patch) | |
| tree | a92a4009b4405325d78731fd31abb9ca626ba5ef /src | |
| parent | shader: Fix structured control flow on KIL instructions (diff) | |
| download | yuzu-f0031babeb3ed04aef2468840aa37f4da13b2524.tar.gz yuzu-f0031babeb3ed04aef2468840aa37f4da13b2524.tar.xz yuzu-f0031babeb3ed04aef2468840aa37f4da13b2524.zip | |
shader: Implement front face
Diffstat (limited to 'src')
5 files changed, 12 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index c2d13f97c..4d5dabcbf 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -302,6 +302,9 @@ void EmitContext::DefineInputs(const Info& info) { | |||
| 302 | base_vertex = DefineInput(*this, U32[1], spv::BuiltIn::BaseVertex); | 302 | base_vertex = DefineInput(*this, U32[1], spv::BuiltIn::BaseVertex); |
| 303 | } | 303 | } |
| 304 | } | 304 | } |
| 305 | if (info.loads_front_face) { | ||
| 306 | front_face = DefineInput(*this, U1, spv::BuiltIn::FrontFacing); | ||
| 307 | } | ||
| 305 | for (size_t index = 0; index < info.loads_generics.size(); ++index) { | 308 | for (size_t index = 0; index < info.loads_generics.size(); ++index) { |
| 306 | if (!info.loads_generics[index]) { | 309 | if (!info.loads_generics[index]) { |
| 307 | continue; | 310 | continue; |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index 0cb411a0e..01b7b665d 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -94,6 +94,7 @@ public: | |||
| 94 | Id vertex_id{}; | 94 | Id vertex_id{}; |
| 95 | Id vertex_index{}; | 95 | Id vertex_index{}; |
| 96 | Id base_vertex{}; | 96 | Id base_vertex{}; |
| 97 | Id front_face{}; | ||
| 97 | 98 | ||
| 98 | Id input_position{}; | 99 | Id input_position{}; |
| 99 | std::array<Id, 32> input_generics{}; | 100 | std::array<Id, 32> input_generics{}; |
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 8fc040f8b..6fa16eb80 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 | |||
| @@ -156,6 +156,10 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr) { | |||
| 156 | return ctx.OpISub(ctx.U32[1], ctx.OpLoad(ctx.U32[1], ctx.vertex_index), | 156 | return ctx.OpISub(ctx.U32[1], ctx.OpLoad(ctx.U32[1], ctx.vertex_index), |
| 157 | ctx.OpLoad(ctx.U32[1], ctx.base_vertex)); | 157 | ctx.OpLoad(ctx.U32[1], ctx.base_vertex)); |
| 158 | } | 158 | } |
| 159 | case IR::Attribute::FrontFace: | ||
| 160 | return ctx.OpSelect(ctx.U32[1], ctx.OpLoad(ctx.U1, ctx.front_face), | ||
| 161 | ctx.Constant(ctx.U32[1], std::numeric_limits<u32>::max()), | ||
| 162 | ctx.u32_zero_value); | ||
| 159 | default: | 163 | default: |
| 160 | throw NotImplementedException("Read attribute {}", attr); | 164 | throw NotImplementedException("Read attribute {}", attr); |
| 161 | } | 165 | } |
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 80ca8db26..0ec0d4c01 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -44,6 +44,9 @@ void GetAttribute(Info& info, IR::Attribute attribute) { | |||
| 44 | case IR::Attribute::VertexId: | 44 | case IR::Attribute::VertexId: |
| 45 | info.loads_vertex_id = true; | 45 | info.loads_vertex_id = true; |
| 46 | break; | 46 | break; |
| 47 | case IR::Attribute::FrontFace: | ||
| 48 | info.loads_front_face = true; | ||
| 49 | break; | ||
| 47 | default: | 50 | default: |
| 48 | throw NotImplementedException("Get attribute {}", attribute); | 51 | throw NotImplementedException("Get attribute {}", attribute); |
| 49 | } | 52 | } |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index 27e61a5f9..8ab66bb2a 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -62,6 +62,7 @@ struct Info { | |||
| 62 | bool loads_position{}; | 62 | bool loads_position{}; |
| 63 | bool loads_instance_id{}; | 63 | bool loads_instance_id{}; |
| 64 | bool loads_vertex_id{}; | 64 | bool loads_vertex_id{}; |
| 65 | bool loads_front_face{}; | ||
| 65 | 66 | ||
| 66 | std::array<bool, 8> stores_frag_color{}; | 67 | std::array<bool, 8> stores_frag_color{}; |
| 67 | bool stores_frag_depth{}; | 68 | bool stores_frag_depth{}; |