diff options
| author | 2021-04-16 16:31:15 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:28 -0400 | |
| commit | e3514bcd6b09f623da14c4f3c4ffd988e75577ed (patch) | |
| tree | 8c7e375472cb6b654b9d462ae4a9b51575c38b93 /src/shader_recompiler/backend/spirv | |
| parent | spirv: Bitcast non-F32 attributes to F32 (diff) | |
| download | yuzu-e3514bcd6b09f623da14c4f3c4ffd988e75577ed.tar.gz yuzu-e3514bcd6b09f623da14c4f3c4ffd988e75577ed.tar.xz yuzu-e3514bcd6b09f623da14c4f3c4ffd988e75577ed.zip | |
spirv: Implement ViewportMask with NV_viewport_array2
Diffstat (limited to 'src/shader_recompiler/backend/spirv')
4 files changed, 15 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 3946dab14..2f8678b4e 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -457,6 +457,7 @@ void EmitContext::DefineCommonTypes(const Info& info) { | |||
| 457 | input_s32 = Name(TypePointer(spv::StorageClass::Input, TypeInt(32, true)), "input_s32"); | 457 | input_s32 = Name(TypePointer(spv::StorageClass::Input, TypeInt(32, true)), "input_s32"); |
| 458 | 458 | ||
| 459 | output_f32 = Name(TypePointer(spv::StorageClass::Output, F32[1]), "output_f32"); | 459 | output_f32 = Name(TypePointer(spv::StorageClass::Output, F32[1]), "output_f32"); |
| 460 | output_u32 = Name(TypePointer(spv::StorageClass::Output, U32[1]), "output_u32"); | ||
| 460 | 461 | ||
| 461 | if (info.uses_int8) { | 462 | if (info.uses_int8) { |
| 462 | AddCapability(spv::Capability::Int8); | 463 | AddCapability(spv::Capability::Int8); |
| @@ -1131,6 +1132,9 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1131 | } | 1132 | } |
| 1132 | viewport_index = DefineOutput(*this, U32[1], invocations, spv::BuiltIn::ViewportIndex); | 1133 | viewport_index = DefineOutput(*this, U32[1], invocations, spv::BuiltIn::ViewportIndex); |
| 1133 | } | 1134 | } |
| 1135 | if (info.stores_viewport_mask && profile.support_viewport_mask) { | ||
| 1136 | viewport_mask = DefineOutput(*this, TypeArray(U32[1], Constant(U32[1], 1u)), std::nullopt); | ||
| 1137 | } | ||
| 1134 | for (size_t index = 0; index < info.stores_generics.size(); ++index) { | 1138 | for (size_t index = 0; index < info.stores_generics.size(); ++index) { |
| 1135 | if (info.stores_generics[index]) { | 1139 | if (info.stores_generics[index]) { |
| 1136 | DefineGenericOutput(*this, index, invocations); | 1140 | DefineGenericOutput(*this, index, invocations); |
diff --git a/src/shader_recompiler/backend/spirv/emit_context.h b/src/shader_recompiler/backend/spirv/emit_context.h index c7d6f8a38..c41cad098 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.h +++ b/src/shader_recompiler/backend/spirv/emit_context.h | |||
| @@ -134,6 +134,7 @@ public: | |||
| 134 | Id input_s32{}; | 134 | Id input_s32{}; |
| 135 | 135 | ||
| 136 | Id output_f32{}; | 136 | Id output_f32{}; |
| 137 | Id output_u32{}; | ||
| 137 | 138 | ||
| 138 | Id image_buffer_type{}; | 139 | Id image_buffer_type{}; |
| 139 | Id sampled_texture_buffer_type{}; | 140 | Id sampled_texture_buffer_type{}; |
| @@ -167,6 +168,7 @@ public: | |||
| 167 | Id clip_distances{}; | 168 | Id clip_distances{}; |
| 168 | Id layer{}; | 169 | Id layer{}; |
| 169 | Id viewport_index{}; | 170 | Id viewport_index{}; |
| 171 | Id viewport_mask{}; | ||
| 170 | Id primitive_id{}; | 172 | Id primitive_id{}; |
| 171 | 173 | ||
| 172 | Id fswzadd_lut_a{}; | 174 | Id fswzadd_lut_a{}; |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.cpp b/src/shader_recompiler/backend/spirv/emit_spirv.cpp index 105602ccf..90c4833a8 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv.cpp | |||
| @@ -303,6 +303,10 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct | |||
| 303 | if (info.stores_viewport_index) { | 303 | if (info.stores_viewport_index) { |
| 304 | ctx.AddCapability(spv::Capability::MultiViewport); | 304 | ctx.AddCapability(spv::Capability::MultiViewport); |
| 305 | } | 305 | } |
| 306 | if (info.stores_viewport_mask && profile.support_viewport_mask) { | ||
| 307 | ctx.AddExtension("SPV_NV_viewport_array2"); | ||
| 308 | ctx.AddCapability(spv::Capability::ShaderViewportMaskNV); | ||
| 309 | } | ||
| 306 | if (info.stores_layer || info.stores_viewport_index) { | 310 | if (info.stores_layer || info.stores_viewport_index) { |
| 307 | if (profile.support_viewport_index_layer_non_geometry && ctx.stage != Stage::Geometry) { | 311 | if (profile.support_viewport_index_layer_non_geometry && ctx.stage != Stage::Geometry) { |
| 308 | ctx.AddExtension("SPV_EXT_shader_viewport_index_layer"); | 312 | ctx.AddExtension("SPV_EXT_shader_viewport_index_layer"); |
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 f3de577f6..ca067f1c4 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 | |||
| @@ -99,6 +99,11 @@ std::optional<Id> OutputAttrPointer(EmitContext& ctx, IR::Attribute attr) { | |||
| 99 | ctx.stage == Shader::Stage::Geometry | 99 | ctx.stage == Shader::Stage::Geometry |
| 100 | ? std::optional<Id>{ctx.viewport_index} | 100 | ? std::optional<Id>{ctx.viewport_index} |
| 101 | : std::nullopt; | 101 | : std::nullopt; |
| 102 | case IR::Attribute::ViewportMask: | ||
| 103 | if (!ctx.profile.support_viewport_mask) { | ||
| 104 | return std::nullopt; | ||
| 105 | } | ||
| 106 | return ctx.OpAccessChain(ctx.output_u32, ctx.viewport_mask, ctx.u32_zero_value); | ||
| 102 | default: | 107 | default: |
| 103 | throw NotImplementedException("Read attribute {}", attr); | 108 | throw NotImplementedException("Read attribute {}", attr); |
| 104 | } | 109 | } |