diff options
| author | 2023-06-05 19:03:16 +0300 | |
|---|---|---|
| committer | 2023-06-27 18:00:09 -0700 | |
| commit | c339af37a73de144fbbad706e43aefe278640cd7 (patch) | |
| tree | 8be2da916483cb2d2fbea2e323ca4764bc8f417d | |
| parent | renderer_vulkan: Don't add transform feedback flag if unsupported (diff) | |
| download | yuzu-c339af37a73de144fbbad706e43aefe278640cd7.tar.gz yuzu-c339af37a73de144fbbad706e43aefe278640cd7.tar.xz yuzu-c339af37a73de144fbbad706e43aefe278640cd7.zip | |
renderer_vulkan: Respect viewport limit
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_device.h | 4 |
3 files changed, 19 insertions, 6 deletions
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index c1595642e..ad35cacac 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | |||
| @@ -652,13 +652,14 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) { | |||
| 652 | .pNext = nullptr, | 652 | .pNext = nullptr, |
| 653 | .negativeOneToOne = key.state.ndc_minus_one_to_one.Value() != 0 ? VK_TRUE : VK_FALSE, | 653 | .negativeOneToOne = key.state.ndc_minus_one_to_one.Value() != 0 ? VK_TRUE : VK_FALSE, |
| 654 | }; | 654 | }; |
| 655 | const u32 num_viewports = std::min<u32>(device.GetMaxViewports(), Maxwell::NumViewports); | ||
| 655 | VkPipelineViewportStateCreateInfo viewport_ci{ | 656 | VkPipelineViewportStateCreateInfo viewport_ci{ |
| 656 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, | 657 | .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, |
| 657 | .pNext = nullptr, | 658 | .pNext = nullptr, |
| 658 | .flags = 0, | 659 | .flags = 0, |
| 659 | .viewportCount = Maxwell::NumViewports, | 660 | .viewportCount = num_viewports, |
| 660 | .pViewports = nullptr, | 661 | .pViewports = nullptr, |
| 661 | .scissorCount = Maxwell::NumViewports, | 662 | .scissorCount = num_viewports, |
| 662 | .pScissors = nullptr, | 663 | .pScissors = nullptr, |
| 663 | }; | 664 | }; |
| 664 | if (device.IsNvViewportSwizzleSupported()) { | 665 | if (device.IsNvViewportSwizzleSupported()) { |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 84e3a30cc..268b955fb 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -925,7 +925,7 @@ void RasterizerVulkan::UpdateViewportsState(Tegra::Engines::Maxwell3D::Regs& reg | |||
| 925 | } | 925 | } |
| 926 | const bool is_rescaling{texture_cache.IsRescaling()}; | 926 | const bool is_rescaling{texture_cache.IsRescaling()}; |
| 927 | const float scale = is_rescaling ? Settings::values.resolution_info.up_factor : 1.0f; | 927 | const float scale = is_rescaling ? Settings::values.resolution_info.up_factor : 1.0f; |
| 928 | const std::array viewports{ | 928 | const std::array viewport_list{ |
| 929 | GetViewportState(device, regs, 0, scale), GetViewportState(device, regs, 1, scale), | 929 | GetViewportState(device, regs, 0, scale), GetViewportState(device, regs, 1, scale), |
| 930 | GetViewportState(device, regs, 2, scale), GetViewportState(device, regs, 3, scale), | 930 | GetViewportState(device, regs, 2, scale), GetViewportState(device, regs, 3, scale), |
| 931 | GetViewportState(device, regs, 4, scale), GetViewportState(device, regs, 5, scale), | 931 | GetViewportState(device, regs, 4, scale), GetViewportState(device, regs, 5, scale), |
| @@ -935,7 +935,11 @@ void RasterizerVulkan::UpdateViewportsState(Tegra::Engines::Maxwell3D::Regs& reg | |||
| 935 | GetViewportState(device, regs, 12, scale), GetViewportState(device, regs, 13, scale), | 935 | GetViewportState(device, regs, 12, scale), GetViewportState(device, regs, 13, scale), |
| 936 | GetViewportState(device, regs, 14, scale), GetViewportState(device, regs, 15, scale), | 936 | GetViewportState(device, regs, 14, scale), GetViewportState(device, regs, 15, scale), |
| 937 | }; | 937 | }; |
| 938 | scheduler.Record([viewports](vk::CommandBuffer cmdbuf) { cmdbuf.SetViewport(0, viewports); }); | 938 | scheduler.Record([this, viewport_list](vk::CommandBuffer cmdbuf) { |
| 939 | const u32 num_viewports = std::min<u32>(device.GetMaxViewports(), Maxwell::NumViewports); | ||
| 940 | const vk::Span<VkViewport> viewports(viewport_list.data(), num_viewports); | ||
| 941 | cmdbuf.SetViewport(0, viewports); | ||
| 942 | }); | ||
| 939 | } | 943 | } |
| 940 | 944 | ||
| 941 | void RasterizerVulkan::UpdateScissorsState(Tegra::Engines::Maxwell3D::Regs& regs) { | 945 | void RasterizerVulkan::UpdateScissorsState(Tegra::Engines::Maxwell3D::Regs& regs) { |
| @@ -948,7 +952,7 @@ void RasterizerVulkan::UpdateScissorsState(Tegra::Engines::Maxwell3D::Regs& regs | |||
| 948 | up_scale = Settings::values.resolution_info.up_scale; | 952 | up_scale = Settings::values.resolution_info.up_scale; |
| 949 | down_shift = Settings::values.resolution_info.down_shift; | 953 | down_shift = Settings::values.resolution_info.down_shift; |
| 950 | } | 954 | } |
| 951 | const std::array scissors{ | 955 | const std::array scissor_list{ |
| 952 | GetScissorState(regs, 0, up_scale, down_shift), | 956 | GetScissorState(regs, 0, up_scale, down_shift), |
| 953 | GetScissorState(regs, 1, up_scale, down_shift), | 957 | GetScissorState(regs, 1, up_scale, down_shift), |
| 954 | GetScissorState(regs, 2, up_scale, down_shift), | 958 | GetScissorState(regs, 2, up_scale, down_shift), |
| @@ -966,7 +970,11 @@ void RasterizerVulkan::UpdateScissorsState(Tegra::Engines::Maxwell3D::Regs& regs | |||
| 966 | GetScissorState(regs, 14, up_scale, down_shift), | 970 | GetScissorState(regs, 14, up_scale, down_shift), |
| 967 | GetScissorState(regs, 15, up_scale, down_shift), | 971 | GetScissorState(regs, 15, up_scale, down_shift), |
| 968 | }; | 972 | }; |
| 969 | scheduler.Record([scissors](vk::CommandBuffer cmdbuf) { cmdbuf.SetScissor(0, scissors); }); | 973 | scheduler.Record([this, scissor_list](vk::CommandBuffer cmdbuf) { |
| 974 | const u32 num_scissors = std::min<u32>(device.GetMaxViewports(), Maxwell::NumViewports); | ||
| 975 | const vk::Span<VkRect2D> scissors(scissor_list.data(), num_scissors); | ||
| 976 | cmdbuf.SetScissor(0, scissors); | ||
| 977 | }); | ||
| 970 | } | 978 | } |
| 971 | 979 | ||
| 972 | void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) { | 980 | void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) { |
diff --git a/src/video_core/vulkan_common/vulkan_device.h b/src/video_core/vulkan_common/vulkan_device.h index b84af3dfb..8a05a4fab 100644 --- a/src/video_core/vulkan_common/vulkan_device.h +++ b/src/video_core/vulkan_common/vulkan_device.h | |||
| @@ -588,6 +588,10 @@ public: | |||
| 588 | return properties.properties.limits.maxVertexInputBindings; | 588 | return properties.properties.limits.maxVertexInputBindings; |
| 589 | } | 589 | } |
| 590 | 590 | ||
| 591 | u32 GetMaxViewports() const { | ||
| 592 | return properties.properties.limits.maxViewports; | ||
| 593 | } | ||
| 594 | |||
| 591 | bool SupportsConditionalBarriers() const { | 595 | bool SupportsConditionalBarriers() const { |
| 592 | return supports_conditional_barriers; | 596 | return supports_conditional_barriers; |
| 593 | } | 597 | } |