diff options
10 files changed, 32 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 | } |
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 c84bf211f..9631a445e 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -96,6 +96,9 @@ void SetAttribute(Info& info, IR::Attribute attribute) { | |||
| 96 | case IR::Attribute::ViewportIndex: | 96 | case IR::Attribute::ViewportIndex: |
| 97 | info.stores_viewport_index = true; | 97 | info.stores_viewport_index = true; |
| 98 | break; | 98 | break; |
| 99 | case IR::Attribute::ViewportMask: | ||
| 100 | info.stores_viewport_mask = true; | ||
| 101 | break; | ||
| 99 | default: | 102 | default: |
| 100 | throw NotImplementedException("Set attribute {}", attribute); | 103 | throw NotImplementedException("Set attribute {}", attribute); |
| 101 | } | 104 | } |
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index 3a04f075e..a2c2948d5 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h | |||
| @@ -75,6 +75,7 @@ struct Profile { | |||
| 75 | bool support_explicit_workgroup_layout{}; | 75 | bool support_explicit_workgroup_layout{}; |
| 76 | bool support_vote{}; | 76 | bool support_vote{}; |
| 77 | bool support_viewport_index_layer_non_geometry{}; | 77 | bool support_viewport_index_layer_non_geometry{}; |
| 78 | bool support_viewport_mask{}; | ||
| 78 | bool support_typeless_image_loads{}; | 79 | bool support_typeless_image_loads{}; |
| 79 | bool warp_size_potentially_larger_than_guest{}; | 80 | bool warp_size_potentially_larger_than_guest{}; |
| 80 | bool support_int64_atomics{}; | 81 | bool support_int64_atomics{}; |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index d6cde1596..d33df8aad 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -124,6 +124,7 @@ struct Info { | |||
| 124 | bool stores_clip_distance{}; | 124 | bool stores_clip_distance{}; |
| 125 | bool stores_layer{}; | 125 | bool stores_layer{}; |
| 126 | bool stores_viewport_index{}; | 126 | bool stores_viewport_index{}; |
| 127 | bool stores_viewport_mask{}; | ||
| 127 | bool stores_tess_level_outer{}; | 128 | bool stores_tess_level_outer{}; |
| 128 | bool stores_tess_level_inner{}; | 129 | bool stores_tess_level_inner{}; |
| 129 | bool stores_indexed_attributes{}; | 130 | bool stores_indexed_attributes{}; |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 0bccc640a..4d0d3ebb7 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -690,6 +690,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::GPU& gpu_, | |||
| 690 | .support_vote = true, | 690 | .support_vote = true, |
| 691 | .support_viewport_index_layer_non_geometry = | 691 | .support_viewport_index_layer_non_geometry = |
| 692 | device.IsExtShaderViewportIndexLayerSupported(), | 692 | device.IsExtShaderViewportIndexLayerSupported(), |
| 693 | .support_viewport_mask = device.IsNvViewportArray2Supported(), | ||
| 693 | .support_typeless_image_loads = device.IsFormatlessImageLoadSupported(), | 694 | .support_typeless_image_loads = device.IsFormatlessImageLoadSupported(), |
| 694 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), | 695 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), |
| 695 | .support_int64_atomics = device.IsExtShaderAtomicInt64Supported(), | 696 | .support_int64_atomics = device.IsExtShaderAtomicInt64Supported(), |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index f0de19ba1..72b83f99a 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -346,6 +346,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 346 | LOG_INFO(Render_Vulkan, "Device doesn't support viewport swizzles"); | 346 | LOG_INFO(Render_Vulkan, "Device doesn't support viewport swizzles"); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | if (!nv_viewport_array2) { | ||
| 350 | LOG_INFO(Render_Vulkan, "Device doesn't support viewport masks"); | ||
| 351 | } | ||
| 352 | |||
| 349 | VkPhysicalDeviceUniformBufferStandardLayoutFeaturesKHR std430_layout; | 353 | VkPhysicalDeviceUniformBufferStandardLayoutFeaturesKHR std430_layout; |
| 350 | if (khr_uniform_buffer_standard_layout) { | 354 | if (khr_uniform_buffer_standard_layout) { |
| 351 | std430_layout = { | 355 | std430_layout = { |
| @@ -724,6 +728,7 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) { | |||
| 724 | } | 728 | } |
| 725 | }; | 729 | }; |
| 726 | test(nv_viewport_swizzle, VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME, true); | 730 | test(nv_viewport_swizzle, VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME, true); |
| 731 | test(nv_viewport_array2, VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME, true); | ||
| 727 | test(khr_uniform_buffer_standard_layout, | 732 | test(khr_uniform_buffer_standard_layout, |
| 728 | VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, true); | 733 | VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, true); |
| 729 | test(khr_spirv_1_4, VK_KHR_SPIRV_1_4_EXTENSION_NAME, true); | 734 | test(khr_spirv_1_4, VK_KHR_SPIRV_1_4_EXTENSION_NAME, true); |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 4e6d13308..4415558bb 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -169,6 +169,11 @@ public: | |||
| 169 | return nv_viewport_swizzle; | 169 | return nv_viewport_swizzle; |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | /// Returns true if the device supports VK_NV_viewport_array2. | ||
| 173 | bool IsNvViewportArray2Supported() const { | ||
| 174 | return nv_viewport_array2; | ||
| 175 | } | ||
| 176 | |||
| 172 | /// Returns true if the device supports VK_KHR_uniform_buffer_standard_layout. | 177 | /// Returns true if the device supports VK_KHR_uniform_buffer_standard_layout. |
| 173 | bool IsKhrUniformBufferStandardLayoutSupported() const { | 178 | bool IsKhrUniformBufferStandardLayoutSupported() const { |
| 174 | return khr_uniform_buffer_standard_layout; | 179 | return khr_uniform_buffer_standard_layout; |
| @@ -312,6 +317,7 @@ private: | |||
| 312 | bool is_shader_storage_image_multisample{}; ///< Support for image operations on MSAA images. | 317 | bool is_shader_storage_image_multisample{}; ///< Support for image operations on MSAA images. |
| 313 | bool is_blit_depth_stencil_supported{}; ///< Support for blitting from and to depth stencil. | 318 | bool is_blit_depth_stencil_supported{}; ///< Support for blitting from and to depth stencil. |
| 314 | bool nv_viewport_swizzle{}; ///< Support for VK_NV_viewport_swizzle. | 319 | bool nv_viewport_swizzle{}; ///< Support for VK_NV_viewport_swizzle. |
| 320 | bool nv_viewport_array2{}; ///< Support for VK_NV_viewport_array2. | ||
| 315 | bool khr_uniform_buffer_standard_layout{}; ///< Support for scalar uniform buffer layouts. | 321 | bool khr_uniform_buffer_standard_layout{}; ///< Support for scalar uniform buffer layouts. |
| 316 | bool khr_spirv_1_4{}; ///< Support for VK_KHR_spirv_1_4. | 322 | bool khr_spirv_1_4{}; ///< Support for VK_KHR_spirv_1_4. |
| 317 | bool khr_workgroup_memory_explicit_layout{}; ///< Support for explicit workgroup layouts. | 323 | bool khr_workgroup_memory_explicit_layout{}; ///< Support for explicit workgroup layouts. |