diff options
| author | 2021-04-16 01:55:06 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:27 -0400 | |
| commit | b0f1255c8cb800e9f336be66b3f16c3d958673d2 (patch) | |
| tree | d5c63390c37b32b8ef188b6ce2db9111a9585661 /src | |
| parent | shader: Implement tessellation shaders, polygon mode and invocation id (diff) | |
| download | yuzu-b0f1255c8cb800e9f336be66b3f16c3d958673d2.tar.gz yuzu-b0f1255c8cb800e9f336be66b3f16c3d958673d2.tar.xz yuzu-b0f1255c8cb800e9f336be66b3f16c3d958673d2.zip | |
shader: Implement PrimitiveId
Diffstat (limited to '')
5 files changed, 10 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 067f61613..3946dab14 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -1021,6 +1021,9 @@ void EmitContext::DefineInputs(const Info& info) { | |||
| 1021 | fswzadd_lut_b = | 1021 | fswzadd_lut_b = |
| 1022 | ConstantComposite(F32[4], f32_minus_one, f32_minus_one, f32_one, f32_minus_one); | 1022 | ConstantComposite(F32[4], f32_minus_one, f32_minus_one, f32_one, f32_minus_one); |
| 1023 | } | 1023 | } |
| 1024 | if (info.loads_primitive_id) { | ||
| 1025 | primitive_id = DefineInput(*this, U32[1], false, spv::BuiltIn::PrimitiveId); | ||
| 1026 | } | ||
| 1024 | if (info.loads_position) { | 1027 | if (info.loads_position) { |
| 1025 | const bool is_fragment{stage != Stage::Fragment}; | 1028 | const bool is_fragment{stage != Stage::Fragment}; |
| 1026 | const spv::BuiltIn built_in{is_fragment ? spv::BuiltIn::Position : spv::BuiltIn::FragCoord}; | 1029 | const spv::BuiltIn built_in{is_fragment ? spv::BuiltIn::Position : spv::BuiltIn::FragCoord}; |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index ba0a253b3..c7d6f8a38 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -167,6 +167,7 @@ public: | |||
| 167 | Id clip_distances{}; | 167 | Id clip_distances{}; |
| 168 | Id layer{}; | 168 | Id layer{}; |
| 169 | Id viewport_index{}; | 169 | Id viewport_index{}; |
| 170 | Id primitive_id{}; | ||
| 170 | 171 | ||
| 171 | Id fswzadd_lut_a{}; | 172 | Id fswzadd_lut_a{}; |
| 172 | Id fswzadd_lut_b{}; | 173 | 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 4a1aeece5..23a74f966 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 | |||
| @@ -210,6 +210,8 @@ Id EmitGetAttribute(EmitContext& ctx, IR::Attribute attr, Id vertex) { | |||
| 210 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; | 210 | return type->needs_cast ? ctx.OpBitcast(ctx.F32[1], value) : value; |
| 211 | } | 211 | } |
| 212 | switch (attr) { | 212 | switch (attr) { |
| 213 | case IR::Attribute::PrimitiveId: | ||
| 214 | return ctx.OpLoad(ctx.U32[1], ctx.primitive_id); | ||
| 213 | case IR::Attribute::PositionX: | 215 | case IR::Attribute::PositionX: |
| 214 | case IR::Attribute::PositionY: | 216 | case IR::Attribute::PositionY: |
| 215 | case IR::Attribute::PositionZ: | 217 | case IR::Attribute::PositionZ: |
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 aadcf7999..c84bf211f 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -34,6 +34,9 @@ void GetAttribute(Info& info, IR::Attribute attribute) { | |||
| 34 | return; | 34 | return; |
| 35 | } | 35 | } |
| 36 | switch (attribute) { | 36 | switch (attribute) { |
| 37 | case IR::Attribute::PrimitiveId: | ||
| 38 | info.loads_primitive_id = true; | ||
| 39 | break; | ||
| 37 | case IR::Attribute::PositionX: | 40 | case IR::Attribute::PositionX: |
| 38 | case IR::Attribute::PositionY: | 41 | case IR::Attribute::PositionY: |
| 39 | case IR::Attribute::PositionZ: | 42 | case IR::Attribute::PositionZ: |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index 4dbf9ed12..d6cde1596 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -107,6 +107,7 @@ struct Info { | |||
| 107 | std::array<bool, 30> uses_patches{}; | 107 | std::array<bool, 30> uses_patches{}; |
| 108 | 108 | ||
| 109 | std::array<InputVarying, 32> input_generics{}; | 109 | std::array<InputVarying, 32> input_generics{}; |
| 110 | bool loads_primitive_id{}; | ||
| 110 | bool loads_position{}; | 111 | bool loads_position{}; |
| 111 | bool loads_instance_id{}; | 112 | bool loads_instance_id{}; |
| 112 | bool loads_vertex_id{}; | 113 | bool loads_vertex_id{}; |