diff options
| author | 2021-10-17 20:08:39 +0200 | |
|---|---|---|
| committer | 2021-11-16 22:11:31 +0100 | |
| commit | 50b4c774cb30380761936f4cb897c31fc2d49075 (patch) | |
| tree | f126ecb951da9894a6e450b8d9a043d46421a0c2 /src | |
| parent | Texture Cache: Fix downscaling and correct memory comsumption. (diff) | |
| download | yuzu-50b4c774cb30380761936f4cb897c31fc2d49075.tar.gz yuzu-50b4c774cb30380761936f4cb897c31fc2d49075.tar.xz yuzu-50b4c774cb30380761936f4cb897c31fc2d49075.zip | |
Vulkan: Fix Blit Depth Stencil
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.cpp | 27 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.h | 7 |
2 files changed, 20 insertions, 14 deletions
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index bc3e4b93d..239698423 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp | |||
| @@ -374,7 +374,7 @@ void BlitImageHelper::BlitColor(const Framebuffer* dst_framebuffer, VkImageView | |||
| 374 | }; | 374 | }; |
| 375 | const VkPipelineLayout layout = *one_texture_pipeline_layout; | 375 | const VkPipelineLayout layout = *one_texture_pipeline_layout; |
| 376 | const VkSampler sampler = is_linear ? *linear_sampler : *nearest_sampler; | 376 | const VkSampler sampler = is_linear ? *linear_sampler : *nearest_sampler; |
| 377 | const VkPipeline pipeline = FindOrEmplacePipeline(key); | 377 | const VkPipeline pipeline = FindOrEmplaceColorPipeline(key); |
| 378 | scheduler.RequestRenderpass(dst_framebuffer); | 378 | scheduler.RequestRenderpass(dst_framebuffer); |
| 379 | scheduler.Record([this, dst_region, src_region, pipeline, layout, sampler, | 379 | scheduler.Record([this, dst_region, src_region, pipeline, layout, sampler, |
| 380 | src_view](vk::CommandBuffer cmdbuf) { | 380 | src_view](vk::CommandBuffer cmdbuf) { |
| @@ -397,10 +397,13 @@ void BlitImageHelper::BlitDepthStencil(const Framebuffer* dst_framebuffer, | |||
| 397 | Tegra::Engines::Fermi2D::Operation operation) { | 397 | Tegra::Engines::Fermi2D::Operation operation) { |
| 398 | ASSERT(filter == Tegra::Engines::Fermi2D::Filter::Point); | 398 | ASSERT(filter == Tegra::Engines::Fermi2D::Filter::Point); |
| 399 | ASSERT(operation == Tegra::Engines::Fermi2D::Operation::SrcCopy); | 399 | ASSERT(operation == Tegra::Engines::Fermi2D::Operation::SrcCopy); |
| 400 | 400 | const BlitImagePipelineKey key{ | |
| 401 | .renderpass = dst_framebuffer->RenderPass(), | ||
| 402 | .operation = operation, | ||
| 403 | }; | ||
| 401 | const VkPipelineLayout layout = *two_textures_pipeline_layout; | 404 | const VkPipelineLayout layout = *two_textures_pipeline_layout; |
| 402 | const VkSampler sampler = *nearest_sampler; | 405 | const VkSampler sampler = *nearest_sampler; |
| 403 | const VkPipeline pipeline = BlitDepthStencilPipeline(dst_framebuffer->RenderPass()); | 406 | const VkPipeline pipeline = FindOrEmplaceDepthStencilPipeline(key); |
| 404 | scheduler.RequestRenderpass(dst_framebuffer); | 407 | scheduler.RequestRenderpass(dst_framebuffer); |
| 405 | scheduler.Record([dst_region, src_region, pipeline, layout, sampler, src_depth_view, | 408 | scheduler.Record([dst_region, src_region, pipeline, layout, sampler, src_depth_view, |
| 406 | src_stencil_view, this](vk::CommandBuffer cmdbuf) { | 409 | src_stencil_view, this](vk::CommandBuffer cmdbuf) { |
| @@ -492,7 +495,7 @@ void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_frameb | |||
| 492 | scheduler.InvalidateState(); | 495 | scheduler.InvalidateState(); |
| 493 | } | 496 | } |
| 494 | 497 | ||
| 495 | VkPipeline BlitImageHelper::FindOrEmplacePipeline(const BlitImagePipelineKey& key) { | 498 | VkPipeline BlitImageHelper::FindOrEmplaceColorPipeline(const BlitImagePipelineKey& key) { |
| 496 | const auto it = std::ranges::find(blit_color_keys, key); | 499 | const auto it = std::ranges::find(blit_color_keys, key); |
| 497 | if (it != blit_color_keys.end()) { | 500 | if (it != blit_color_keys.end()) { |
| 498 | return *blit_color_pipelines[std::distance(blit_color_keys.begin(), it)]; | 501 | return *blit_color_pipelines[std::distance(blit_color_keys.begin(), it)]; |
| @@ -546,12 +549,14 @@ VkPipeline BlitImageHelper::FindOrEmplacePipeline(const BlitImagePipelineKey& ke | |||
| 546 | return *blit_color_pipelines.back(); | 549 | return *blit_color_pipelines.back(); |
| 547 | } | 550 | } |
| 548 | 551 | ||
| 549 | VkPipeline BlitImageHelper::BlitDepthStencilPipeline(VkRenderPass renderpass) { | 552 | VkPipeline BlitImageHelper::FindOrEmplaceDepthStencilPipeline(const BlitImagePipelineKey& key) { |
| 550 | if (blit_depth_stencil_pipeline) { | 553 | const auto it = std::ranges::find(blit_depth_stencil_keys, key); |
| 551 | return *blit_depth_stencil_pipeline; | 554 | if (it != blit_depth_stencil_keys.end()) { |
| 555 | return *blit_depth_stencil_pipelines[std::distance(blit_depth_stencil_keys.begin(), it)]; | ||
| 552 | } | 556 | } |
| 557 | blit_depth_stencil_keys.push_back(key); | ||
| 553 | const std::array stages = MakeStages(*full_screen_vert, *blit_depth_stencil_frag); | 558 | const std::array stages = MakeStages(*full_screen_vert, *blit_depth_stencil_frag); |
| 554 | blit_depth_stencil_pipeline = device.GetLogical().CreateGraphicsPipeline({ | 559 | blit_depth_stencil_pipelines.push_back(device.GetLogical().CreateGraphicsPipeline({ |
| 555 | .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, | 560 | .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, |
| 556 | .pNext = nullptr, | 561 | .pNext = nullptr, |
| 557 | .flags = 0, | 562 | .flags = 0, |
| @@ -567,12 +572,12 @@ VkPipeline BlitImageHelper::BlitDepthStencilPipeline(VkRenderPass renderpass) { | |||
| 567 | .pColorBlendState = &PIPELINE_COLOR_BLEND_STATE_EMPTY_CREATE_INFO, | 572 | .pColorBlendState = &PIPELINE_COLOR_BLEND_STATE_EMPTY_CREATE_INFO, |
| 568 | .pDynamicState = &PIPELINE_DYNAMIC_STATE_CREATE_INFO, | 573 | .pDynamicState = &PIPELINE_DYNAMIC_STATE_CREATE_INFO, |
| 569 | .layout = *two_textures_pipeline_layout, | 574 | .layout = *two_textures_pipeline_layout, |
| 570 | .renderPass = renderpass, | 575 | .renderPass = key.renderpass, |
| 571 | .subpass = 0, | 576 | .subpass = 0, |
| 572 | .basePipelineHandle = VK_NULL_HANDLE, | 577 | .basePipelineHandle = VK_NULL_HANDLE, |
| 573 | .basePipelineIndex = 0, | 578 | .basePipelineIndex = 0, |
| 574 | }); | 579 | })); |
| 575 | return *blit_depth_stencil_pipeline; | 580 | return *blit_depth_stencil_pipelines.back(); |
| 576 | } | 581 | } |
| 577 | 582 | ||
| 578 | void BlitImageHelper::ConvertDepthToColorPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass) { | 583 | void BlitImageHelper::ConvertDepthToColorPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass) { |
diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index c0f4a16a4..d77f76678 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h | |||
| @@ -60,9 +60,9 @@ private: | |||
| 60 | void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, | 60 | void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, |
| 61 | const ImageView& src_image_view, u32 up_scale, u32 down_shift); | 61 | const ImageView& src_image_view, u32 up_scale, u32 down_shift); |
| 62 | 62 | ||
| 63 | [[nodiscard]] VkPipeline FindOrEmplacePipeline(const BlitImagePipelineKey& key); | 63 | [[nodiscard]] VkPipeline FindOrEmplaceColorPipeline(const BlitImagePipelineKey& key); |
| 64 | 64 | ||
| 65 | [[nodiscard]] VkPipeline BlitDepthStencilPipeline(VkRenderPass renderpass); | 65 | [[nodiscard]] VkPipeline FindOrEmplaceDepthStencilPipeline(const BlitImagePipelineKey& key); |
| 66 | 66 | ||
| 67 | void ConvertDepthToColorPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass); | 67 | void ConvertDepthToColorPipeline(vk::Pipeline& pipeline, VkRenderPass renderpass); |
| 68 | 68 | ||
| @@ -88,7 +88,8 @@ private: | |||
| 88 | 88 | ||
| 89 | std::vector<BlitImagePipelineKey> blit_color_keys; | 89 | std::vector<BlitImagePipelineKey> blit_color_keys; |
| 90 | std::vector<vk::Pipeline> blit_color_pipelines; | 90 | std::vector<vk::Pipeline> blit_color_pipelines; |
| 91 | vk::Pipeline blit_depth_stencil_pipeline; | 91 | std::vector<BlitImagePipelineKey> blit_depth_stencil_keys; |
| 92 | std::vector<vk::Pipeline> blit_depth_stencil_pipelines; | ||
| 92 | vk::Pipeline convert_d32_to_r32_pipeline; | 93 | vk::Pipeline convert_d32_to_r32_pipeline; |
| 93 | vk::Pipeline convert_r32_to_d32_pipeline; | 94 | vk::Pipeline convert_r32_to_d32_pipeline; |
| 94 | vk::Pipeline convert_d16_to_r16_pipeline; | 95 | vk::Pipeline convert_d16_to_r16_pipeline; |