diff options
Diffstat (limited to 'src')
5 files changed, 65 insertions, 5 deletions
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index 7563dc462..d089da8a4 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | |||
| @@ -88,6 +88,7 @@ void FixedPipelineState::Refresh(Tegra::Engines::Maxwell3D& maxwell3d, | |||
| 88 | y_negate.Assign(regs.screen_y_control.y_negate != 0 ? 1 : 0); | 88 | y_negate.Assign(regs.screen_y_control.y_negate != 0 ? 1 : 0); |
| 89 | provoking_vertex_last.Assign(regs.provoking_vertex_last != 0 ? 1 : 0); | 89 | provoking_vertex_last.Assign(regs.provoking_vertex_last != 0 ? 1 : 0); |
| 90 | conservative_raster_enable.Assign(regs.conservative_raster_enable != 0 ? 1 : 0); | 90 | conservative_raster_enable.Assign(regs.conservative_raster_enable != 0 ? 1 : 0); |
| 91 | smooth_lines.Assign(regs.line_smooth_enable != 0 ? 1 : 0); | ||
| 91 | 92 | ||
| 92 | for (size_t i = 0; i < regs.rt.size(); ++i) { | 93 | for (size_t i = 0; i < regs.rt.size(); ++i) { |
| 93 | color_formats[i] = static_cast<u8>(regs.rt[i].format); | 94 | color_formats[i] = static_cast<u8>(regs.rt[i].format); |
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h index 66b57b636..c9be37935 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h | |||
| @@ -195,6 +195,7 @@ struct FixedPipelineState { | |||
| 195 | BitField<11, 1, u32> y_negate; | 195 | BitField<11, 1, u32> y_negate; |
| 196 | BitField<12, 1, u32> provoking_vertex_last; | 196 | BitField<12, 1, u32> provoking_vertex_last; |
| 197 | BitField<13, 1, u32> conservative_raster_enable; | 197 | BitField<13, 1, u32> conservative_raster_enable; |
| 198 | BitField<14, 1, u32> smooth_lines; | ||
| 198 | }; | 199 | }; |
| 199 | std::array<u8, Maxwell::NumRenderTargets> color_formats; | 200 | std::array<u8, Maxwell::NumRenderTargets> color_formats; |
| 200 | 201 | ||
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 3363a6877..f0ae0b0d6 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -80,6 +80,14 @@ bool SupportsPrimitiveRestart(VkPrimitiveTopology topology) { | |||
| 80 | return std::ranges::find(unsupported_topologies, topology) == unsupported_topologies.end(); | 80 | return std::ranges::find(unsupported_topologies, topology) == unsupported_topologies.end(); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | bool IsLine(VkPrimitiveTopology topology) { | ||
| 84 | static constexpr std::array line_topologies{ | ||
| 85 | VK_PRIMITIVE_TOPOLOGY_LINE_LIST, VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, | ||
| 86 | // VK_PRIMITIVE_TOPOLOGY_LINE_LOOP_EXT, | ||
| 87 | }; | ||
| 88 | return std::ranges::find(line_topologies, topology) == line_topologies.end(); | ||
| 89 | } | ||
| 90 | |||
| 83 | VkViewportSwizzleNV UnpackViewportSwizzle(u16 swizzle) { | 91 | VkViewportSwizzleNV UnpackViewportSwizzle(u16 swizzle) { |
| 84 | union Swizzle { | 92 | union Swizzle { |
| 85 | u32 raw; | 93 | u32 raw; |
| @@ -616,6 +624,16 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 616 | .depthBiasSlopeFactor = 0.0f, | 624 | .depthBiasSlopeFactor = 0.0f, |
| 617 | .lineWidth = 1.0f, | 625 | .lineWidth = 1.0f, |
| 618 | }; | 626 | }; |
| 627 | VkPipelineRasterizationLineStateCreateInfoEXT line_state{ | ||
| 628 | .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT, | ||
| 629 | .pNext = nullptr, | ||
| 630 | .lineRasterizationMode = key.state.smooth_lines != 0 | ||
| 631 | ? VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT | ||
| 632 | : VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT, | ||
| 633 | .stippledLineEnable = VK_FALSE, // TODO | ||
| 634 | .lineStippleFactor = 0, | ||
| 635 | .lineStipplePattern = 0, | ||
| 636 | }; | ||
| 619 | VkPipelineRasterizationConservativeStateCreateInfoEXT conservative_raster{ | 637 | VkPipelineRasterizationConservativeStateCreateInfoEXT conservative_raster{ |
| 620 | .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT, | 638 | .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT, |
| 621 | .pNext = nullptr, | 639 | .pNext = nullptr, |
| @@ -632,6 +650,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 632 | ? VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT | 650 | ? VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT |
| 633 | : VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, | 651 | : VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT, |
| 634 | }; | 652 | }; |
| 653 | if (IsLine(input_assembly_topology) && device.IsExtLineRasterizationSupported()) { | ||
| 654 | line_state.pNext = std::exchange(rasterization_ci.pNext, &line_state); | ||
| 655 | } | ||
| 635 | if (device.IsExtConservativeRasterizationSupported()) { | 656 | if (device.IsExtConservativeRasterizationSupported()) { |
| 636 | conservative_raster.pNext = std::exchange(rasterization_ci.pNext, &conservative_raster); | 657 | conservative_raster.pNext = std::exchange(rasterization_ci.pNext, &conservative_raster); |
| 637 | } | 658 | } |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 912e03c5c..4fa1470e8 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -416,6 +416,23 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 416 | LOG_INFO(Render_Vulkan, "Device doesn't support extended dynamic state"); | 416 | LOG_INFO(Render_Vulkan, "Device doesn't support extended dynamic state"); |
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | VkPhysicalDeviceLineRasterizationFeaturesEXT line_raster; | ||
| 420 | if (ext_line_rasterization) { | ||
| 421 | line_raster = { | ||
| 422 | .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT, | ||
| 423 | .pNext = nullptr, | ||
| 424 | .rectangularLines = VK_TRUE, | ||
| 425 | .bresenhamLines = VK_FALSE, | ||
| 426 | .smoothLines = VK_TRUE, | ||
| 427 | .stippledRectangularLines = VK_FALSE, | ||
| 428 | .stippledBresenhamLines = VK_FALSE, | ||
| 429 | .stippledSmoothLines = VK_FALSE, | ||
| 430 | }; | ||
| 431 | SetNext(next, line_raster); | ||
| 432 | } else { | ||
| 433 | LOG_INFO(Render_Vulkan, "Device doesn't support smooth lines"); | ||
| 434 | } | ||
| 435 | |||
| 419 | if (!ext_conservative_rasterization) { | 436 | if (!ext_conservative_rasterization) { |
| 420 | LOG_INFO(Render_Vulkan, "Device doesn't support conservative rasterization"); | 437 | LOG_INFO(Render_Vulkan, "Device doesn't support conservative rasterization"); |
| 421 | } | 438 | } |
| @@ -757,6 +774,7 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) { | |||
| 757 | bool has_ext_shader_atomic_int64{}; | 774 | bool has_ext_shader_atomic_int64{}; |
| 758 | bool has_ext_provoking_vertex{}; | 775 | bool has_ext_provoking_vertex{}; |
| 759 | bool has_ext_vertex_input_dynamic_state{}; | 776 | bool has_ext_vertex_input_dynamic_state{}; |
| 777 | bool has_ext_line_rasterization{}; | ||
| 760 | for (const VkExtensionProperties& extension : physical.EnumerateDeviceExtensionProperties()) { | 778 | for (const VkExtensionProperties& extension : physical.EnumerateDeviceExtensionProperties()) { |
| 761 | const auto test = [&](std::optional<std::reference_wrapper<bool>> status, const char* name, | 779 | const auto test = [&](std::optional<std::reference_wrapper<bool>> status, const char* name, |
| 762 | bool push) { | 780 | bool push) { |
| @@ -798,6 +816,7 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) { | |||
| 798 | test(has_ext_shader_atomic_int64, VK_KHR_SHADER_ATOMIC_INT64_EXTENSION_NAME, false); | 816 | test(has_ext_shader_atomic_int64, VK_KHR_SHADER_ATOMIC_INT64_EXTENSION_NAME, false); |
| 799 | test(has_khr_workgroup_memory_explicit_layout, | 817 | test(has_khr_workgroup_memory_explicit_layout, |
| 800 | VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME, false); | 818 | VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME, false); |
| 819 | test(has_ext_line_rasterization, VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME, false); | ||
| 801 | if (Settings::values.enable_nsight_aftermath) { | 820 | if (Settings::values.enable_nsight_aftermath) { |
| 802 | test(nv_device_diagnostics_config, VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, | 821 | test(nv_device_diagnostics_config, VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME, |
| 803 | true); | 822 | true); |
| @@ -918,17 +937,29 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) { | |||
| 918 | } | 937 | } |
| 919 | } | 938 | } |
| 920 | if (has_ext_extended_dynamic_state) { | 939 | if (has_ext_extended_dynamic_state) { |
| 921 | VkPhysicalDeviceExtendedDynamicStateFeaturesEXT dynamic_state; | 940 | VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extended_dynamic_state; |
| 922 | dynamic_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT; | 941 | extended_dynamic_state.sType = |
| 923 | dynamic_state.pNext = nullptr; | 942 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT; |
| 924 | features.pNext = &dynamic_state; | 943 | extended_dynamic_state.pNext = nullptr; |
| 944 | features.pNext = &extended_dynamic_state; | ||
| 925 | physical.GetFeatures2KHR(features); | 945 | physical.GetFeatures2KHR(features); |
| 926 | 946 | ||
| 927 | if (dynamic_state.extendedDynamicState) { | 947 | if (extended_dynamic_state.extendedDynamicState) { |
| 928 | extensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); | 948 | extensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME); |
| 929 | ext_extended_dynamic_state = true; | 949 | ext_extended_dynamic_state = true; |
| 930 | } | 950 | } |
| 931 | } | 951 | } |
| 952 | if (has_ext_line_rasterization) { | ||
| 953 | VkPhysicalDeviceLineRasterizationFeaturesEXT line_raster; | ||
| 954 | line_raster.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT; | ||
| 955 | line_raster.pNext = nullptr; | ||
| 956 | features.pNext = &line_raster; | ||
| 957 | physical.GetFeatures2KHR(features); | ||
| 958 | if (line_raster.rectangularLines && line_raster.smoothLines) { | ||
| 959 | extensions.push_back(VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME); | ||
| 960 | ext_line_rasterization = true; | ||
| 961 | } | ||
| 962 | } | ||
| 932 | if (has_khr_workgroup_memory_explicit_layout) { | 963 | if (has_khr_workgroup_memory_explicit_layout) { |
| 933 | VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR layout; | 964 | VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR layout; |
| 934 | layout.sType = | 965 | layout.sType = |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index d0adc0127..26100166f 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -259,6 +259,11 @@ public: | |||
| 259 | return ext_extended_dynamic_state; | 259 | return ext_extended_dynamic_state; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | /// Returns true if the device supports VK_EXT_line_rasterization. | ||
| 263 | bool IsExtLineRasterizationSupported() const { | ||
| 264 | return ext_line_rasterization; | ||
| 265 | } | ||
| 266 | |||
| 262 | /// Returns true if the device supports VK_EXT_vertex_input_dynamic_state. | 267 | /// Returns true if the device supports VK_EXT_vertex_input_dynamic_state. |
| 263 | bool IsExtVertexInputDynamicStateSupported() const { | 268 | bool IsExtVertexInputDynamicStateSupported() const { |
| 264 | return ext_vertex_input_dynamic_state; | 269 | return ext_vertex_input_dynamic_state; |
| @@ -382,6 +387,7 @@ private: | |||
| 382 | bool ext_transform_feedback{}; ///< Support for VK_EXT_transform_feedback. | 387 | bool ext_transform_feedback{}; ///< Support for VK_EXT_transform_feedback. |
| 383 | bool ext_custom_border_color{}; ///< Support for VK_EXT_custom_border_color. | 388 | bool ext_custom_border_color{}; ///< Support for VK_EXT_custom_border_color. |
| 384 | bool ext_extended_dynamic_state{}; ///< Support for VK_EXT_extended_dynamic_state. | 389 | bool ext_extended_dynamic_state{}; ///< Support for VK_EXT_extended_dynamic_state. |
| 390 | bool ext_line_rasterization{}; ///< Support for VK_EXT_line_rasterization. | ||
| 385 | bool ext_vertex_input_dynamic_state{}; ///< Support for VK_EXT_vertex_input_dynamic_state. | 391 | bool ext_vertex_input_dynamic_state{}; ///< Support for VK_EXT_vertex_input_dynamic_state. |
| 386 | bool ext_shader_stencil_export{}; ///< Support for VK_EXT_shader_stencil_export. | 392 | bool ext_shader_stencil_export{}; ///< Support for VK_EXT_shader_stencil_export. |
| 387 | bool ext_shader_atomic_int64{}; ///< Support for VK_KHR_shader_atomic_int64. | 393 | bool ext_shader_atomic_int64{}; ///< Support for VK_KHR_shader_atomic_int64. |