diff options
8 files changed, 52 insertions, 7 deletions
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 01f6ec9b5..73b67f0af 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 | |||
| @@ -461,7 +461,7 @@ void EmitSetSampleMask(EmitContext& ctx, Id value) { | |||
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | void EmitSetFragDepth(EmitContext& ctx, Id value) { | 463 | void EmitSetFragDepth(EmitContext& ctx, Id value) { |
| 464 | if (!ctx.runtime_info.convert_depth_mode) { | 464 | if (!ctx.runtime_info.convert_depth_mode || ctx.profile.support_native_ndc) { |
| 465 | ctx.OpStore(ctx.frag_depth, value); | 465 | ctx.OpStore(ctx.frag_depth, value); |
| 466 | return; | 466 | return; |
| 467 | } | 467 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp index 00be1f127..9f7b6bb4b 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_special.cpp | |||
| @@ -116,7 +116,8 @@ void EmitPrologue(EmitContext& ctx) { | |||
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | void EmitEpilogue(EmitContext& ctx) { | 118 | void EmitEpilogue(EmitContext& ctx) { |
| 119 | if (ctx.stage == Stage::VertexB && ctx.runtime_info.convert_depth_mode) { | 119 | if (ctx.stage == Stage::VertexB && ctx.runtime_info.convert_depth_mode && |
| 120 | !ctx.profile.support_native_ndc) { | ||
| 120 | ConvertDepthMode(ctx); | 121 | ConvertDepthMode(ctx); |
| 121 | } | 122 | } |
| 122 | if (ctx.stage == Stage::Fragment) { | 123 | if (ctx.stage == Stage::Fragment) { |
| @@ -125,7 +126,7 @@ void EmitEpilogue(EmitContext& ctx) { | |||
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { | 128 | void EmitEmitVertex(EmitContext& ctx, const IR::Value& stream) { |
| 128 | if (ctx.runtime_info.convert_depth_mode) { | 129 | if (ctx.runtime_info.convert_depth_mode && !ctx.profile.support_native_ndc) { |
| 129 | ConvertDepthMode(ctx); | 130 | ConvertDepthMode(ctx); |
| 130 | } | 131 | } |
| 131 | if (stream.IsImmediate()) { | 132 | if (stream.IsImmediate()) { |
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h index 21d3d236b..b8841a536 100644 --- a/src/shader_recompiler/profile.h +++ b/src/shader_recompiler/profile.h | |||
| @@ -35,6 +35,7 @@ struct Profile { | |||
| 35 | bool support_int64_atomics{}; | 35 | bool support_int64_atomics{}; |
| 36 | bool support_derivative_control{}; | 36 | bool support_derivative_control{}; |
| 37 | bool support_geometry_shader_passthrough{}; | 37 | bool support_geometry_shader_passthrough{}; |
| 38 | bool support_native_ndc{}; | ||
| 38 | bool support_gl_nv_gpu_shader_5{}; | 39 | bool support_gl_nv_gpu_shader_5{}; |
| 39 | bool support_gl_amd_gpu_shader_half_float{}; | 40 | bool support_gl_amd_gpu_shader_half_float{}; |
| 40 | bool support_gl_texture_shadow_lod{}; | 41 | bool support_gl_texture_shadow_lod{}; |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index fff55d585..f8868a012 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -204,6 +204,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo | |||
| 204 | .support_int64_atomics = false, | 204 | .support_int64_atomics = false, |
| 205 | .support_derivative_control = device.HasDerivativeControl(), | 205 | .support_derivative_control = device.HasDerivativeControl(), |
| 206 | .support_geometry_shader_passthrough = device.HasGeometryShaderPassthrough(), | 206 | .support_geometry_shader_passthrough = device.HasGeometryShaderPassthrough(), |
| 207 | .support_native_ndc = true, | ||
| 207 | .support_gl_nv_gpu_shader_5 = device.HasNvGpuShader5(), | 208 | .support_gl_nv_gpu_shader_5 = device.HasNvGpuShader5(), |
| 208 | .support_gl_amd_gpu_shader_half_float = device.HasAmdShaderHalfFloat(), | 209 | .support_gl_amd_gpu_shader_half_float = device.HasAmdShaderHalfFloat(), |
| 209 | .support_gl_texture_shadow_lod = device.HasTextureShadowLod(), | 210 | .support_gl_texture_shadow_lod = device.HasTextureShadowLod(), |
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 4b10fe7bc..515d8d869 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -640,23 +640,33 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 640 | }; | 640 | }; |
| 641 | std::array<VkViewportSwizzleNV, Maxwell::NumViewports> swizzles; | 641 | std::array<VkViewportSwizzleNV, Maxwell::NumViewports> swizzles; |
| 642 | std::ranges::transform(key.state.viewport_swizzles, swizzles.begin(), UnpackViewportSwizzle); | 642 | std::ranges::transform(key.state.viewport_swizzles, swizzles.begin(), UnpackViewportSwizzle); |
| 643 | const VkPipelineViewportSwizzleStateCreateInfoNV swizzle_ci{ | 643 | VkPipelineViewportSwizzleStateCreateInfoNV swizzle_ci{ |
| 644 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, | 644 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
| 645 | .pNext = nullptr, | 645 | .pNext = nullptr, |
| 646 | .flags = 0, | 646 | .flags = 0, |
| 647 | .viewportCount = Maxwell::NumViewports, | 647 | .viewportCount = Maxwell::NumViewports, |
| 648 | .pViewportSwizzles = swizzles.data(), | 648 | .pViewportSwizzles = swizzles.data(), |
| 649 | }; | 649 | }; |
| 650 | const VkPipelineViewportStateCreateInfo viewport_ci{ | 650 | VkPipelineViewportDepthClipControlCreateInfoEXT ndc_info{ |
| 651 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT, | ||
| 652 | .pNext = nullptr, | ||
| 653 | .negativeOneToOne = key.state.ndc_minus_one_to_one.Value() != 0 ? VK_TRUE : VK_FALSE, | ||
| 654 | }; | ||
| 655 | VkPipelineViewportStateCreateInfo viewport_ci{ | ||
| 651 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, | 656 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, |
| 652 | .pNext = device.IsNvViewportSwizzleSupported() ? &swizzle_ci : nullptr, | 657 | .pNext = nullptr, |
| 653 | .flags = 0, | 658 | .flags = 0, |
| 654 | .viewportCount = Maxwell::NumViewports, | 659 | .viewportCount = Maxwell::NumViewports, |
| 655 | .pViewports = nullptr, | 660 | .pViewports = nullptr, |
| 656 | .scissorCount = Maxwell::NumViewports, | 661 | .scissorCount = Maxwell::NumViewports, |
| 657 | .pScissors = nullptr, | 662 | .pScissors = nullptr, |
| 658 | }; | 663 | }; |
| 659 | 664 | if (device.IsNvViewportSwizzleSupported()) { | |
| 665 | swizzle_ci.pNext = std::exchange(viewport_ci.pNext, &swizzle_ci); | ||
| 666 | } | ||
| 667 | if (device.IsExtDepthClipControlSupported()) { | ||
| 668 | ndc_info.pNext = std::exchange(viewport_ci.pNext, &ndc_info); | ||
| 669 | } | ||
| 660 | VkPipelineRasterizationStateCreateInfo rasterization_ci{ | 670 | VkPipelineRasterizationStateCreateInfo rasterization_ci{ |
| 661 | .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, | 671 | .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, |
| 662 | .pNext = nullptr, | 672 | .pNext = nullptr, |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 86fdde014..e7262420c 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -321,6 +321,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device | |||
| 321 | .support_int64_atomics = device.IsExtShaderAtomicInt64Supported(), | 321 | .support_int64_atomics = device.IsExtShaderAtomicInt64Supported(), |
| 322 | .support_derivative_control = true, | 322 | .support_derivative_control = true, |
| 323 | .support_geometry_shader_passthrough = device.IsNvGeometryShaderPassthroughSupported(), | 323 | .support_geometry_shader_passthrough = device.IsNvGeometryShaderPassthroughSupported(), |
| 324 | .support_native_ndc = device.IsExtDepthClipControlSupported(), | ||
| 324 | 325 | ||
| 325 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), | 326 | .warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(), |
| 326 | 327 | ||
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index f45030311..c4d31681a 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -660,6 +660,16 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 660 | LOG_INFO(Render_Vulkan, "Device doesn't support depth range unrestricted"); | 660 | LOG_INFO(Render_Vulkan, "Device doesn't support depth range unrestricted"); |
| 661 | } | 661 | } |
| 662 | 662 | ||
| 663 | VkPhysicalDeviceDepthClipControlFeaturesEXT depth_clip_control_features; | ||
| 664 | if (ext_depth_clip_control) { | ||
| 665 | depth_clip_control_features = { | ||
| 666 | .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT, | ||
| 667 | .pNext = nullptr, | ||
| 668 | .depthClipControl = VK_TRUE, | ||
| 669 | }; | ||
| 670 | SetNext(next, depth_clip_control_features); | ||
| 671 | } | ||
| 672 | |||
| 663 | VkDeviceDiagnosticsConfigCreateInfoNV diagnostics_nv; | 673 | VkDeviceDiagnosticsConfigCreateInfoNV diagnostics_nv; |
| 664 | if (Settings::values.enable_nsight_aftermath && nv_device_diagnostics_config) { | 674 | if (Settings::values.enable_nsight_aftermath && nv_device_diagnostics_config) { |
| 665 | nsight_aftermath_tracker = std::make_unique<NsightAftermathTracker>(); | 675 | nsight_aftermath_tracker = std::make_unique<NsightAftermathTracker>(); |
| @@ -1084,6 +1094,7 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) { | |||
| 1084 | bool has_ext_vertex_input_dynamic_state{}; | 1094 | bool has_ext_vertex_input_dynamic_state{}; |
| 1085 | bool has_ext_line_rasterization{}; | 1095 | bool has_ext_line_rasterization{}; |
| 1086 | bool has_ext_primitive_topology_list_restart{}; | 1096 | bool has_ext_primitive_topology_list_restart{}; |
| 1097 | bool has_ext_depth_clip_control{}; | ||
| 1087 | for (const std::string& extension : supported_extensions) { | 1098 | for (const std::string& extension : supported_extensions) { |
| 1088 | const auto test = [&](std::optional<std::reference_wrapper<bool>> status, const char* name, | 1099 | const auto test = [&](std::optional<std::reference_wrapper<bool>> status, const char* name, |
| 1089 | bool push) { | 1100 | bool push) { |
| @@ -1117,6 +1128,7 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) { | |||
| 1117 | test(ext_shader_stencil_export, VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME, true); | 1128 | test(ext_shader_stencil_export, VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME, true); |
| 1118 | test(ext_conservative_rasterization, VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME, | 1129 | test(ext_conservative_rasterization, VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME, |
| 1119 | true); | 1130 | true); |
| 1131 | test(has_ext_depth_clip_control, VK_EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME, false); | ||
| 1120 | test(has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, false); | 1132 | test(has_ext_transform_feedback, VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME, false); |
| 1121 | test(has_ext_custom_border_color, VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME, false); | 1133 | test(has_ext_custom_border_color, VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME, false); |
| 1122 | test(has_ext_extended_dynamic_state, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME, false); | 1134 | test(has_ext_extended_dynamic_state, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME, false); |
| @@ -1280,6 +1292,19 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) { | |||
| 1280 | ext_line_rasterization = true; | 1292 | ext_line_rasterization = true; |
| 1281 | } | 1293 | } |
| 1282 | } | 1294 | } |
| 1295 | if (has_ext_depth_clip_control) { | ||
| 1296 | VkPhysicalDeviceDepthClipControlFeaturesEXT depth_clip_control_features; | ||
| 1297 | depth_clip_control_features.sType = | ||
| 1298 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT; | ||
| 1299 | depth_clip_control_features.pNext = nullptr; | ||
| 1300 | features.pNext = &depth_clip_control_features; | ||
| 1301 | physical.GetFeatures2(features); | ||
| 1302 | |||
| 1303 | if (depth_clip_control_features.depthClipControl) { | ||
| 1304 | extensions.push_back(VK_EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME); | ||
| 1305 | ext_depth_clip_control = true; | ||
| 1306 | } | ||
| 1307 | } | ||
| 1283 | if (has_khr_workgroup_memory_explicit_layout) { | 1308 | if (has_khr_workgroup_memory_explicit_layout) { |
| 1284 | VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR layout; | 1309 | VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR layout; |
| 1285 | layout.sType = | 1310 | layout.sType = |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index 391b7604c..6a26c4e6e 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -256,6 +256,11 @@ public: | |||
| 256 | return ext_depth_range_unrestricted; | 256 | return ext_depth_range_unrestricted; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | /// Returns true if the device supports VK_EXT_depth_clip_control. | ||
| 260 | bool IsExtDepthClipControlSupported() const { | ||
| 261 | return ext_depth_clip_control; | ||
| 262 | } | ||
| 263 | |||
| 259 | /// Returns true if the device supports VK_EXT_shader_viewport_index_layer. | 264 | /// Returns true if the device supports VK_EXT_shader_viewport_index_layer. |
| 260 | bool IsExtShaderViewportIndexLayerSupported() const { | 265 | bool IsExtShaderViewportIndexLayerSupported() const { |
| 261 | return ext_shader_viewport_index_layer; | 266 | return ext_shader_viewport_index_layer; |
| @@ -454,6 +459,7 @@ private: | |||
| 454 | bool khr_swapchain_mutable_format{}; ///< Support for VK_KHR_swapchain_mutable_format. | 459 | bool khr_swapchain_mutable_format{}; ///< Support for VK_KHR_swapchain_mutable_format. |
| 455 | bool ext_index_type_uint8{}; ///< Support for VK_EXT_index_type_uint8. | 460 | bool ext_index_type_uint8{}; ///< Support for VK_EXT_index_type_uint8. |
| 456 | bool ext_sampler_filter_minmax{}; ///< Support for VK_EXT_sampler_filter_minmax. | 461 | bool ext_sampler_filter_minmax{}; ///< Support for VK_EXT_sampler_filter_minmax. |
| 462 | bool ext_depth_clip_control{}; ///< Support for VK_EXT_depth_clip_control | ||
| 457 | bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted. | 463 | bool ext_depth_range_unrestricted{}; ///< Support for VK_EXT_depth_range_unrestricted. |
| 458 | bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer. | 464 | bool ext_shader_viewport_index_layer{}; ///< Support for VK_EXT_shader_viewport_index_layer. |
| 459 | bool ext_tooling_info{}; ///< Support for VK_EXT_tooling_info. | 465 | bool ext_tooling_info{}; ///< Support for VK_EXT_tooling_info. |