diff options
| author | 2021-06-25 05:25:19 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:39 -0400 | |
| commit | f94f0be5215369a6985247ad936d9d9f43c9b140 (patch) | |
| tree | 595b68392144a74b76a658b6c6ea2d898b6c6152 /src/video_core/renderer_vulkan | |
| parent | vk_graphics_pipeline: Implement line width (diff) | |
| download | yuzu-f94f0be5215369a6985247ad936d9d9f43c9b140.tar.gz yuzu-f94f0be5215369a6985247ad936d9d9f43c9b140.tar.xz yuzu-f94f0be5215369a6985247ad936d9d9f43c9b140.zip | |
vk_graphics_pipeline: Implement smooth lines
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/fixed_pipeline_state.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 21 |
3 files changed, 23 insertions, 0 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 | } |