[TEST] Unify another section of the blits on MSAA path

This commit is contained in:
CamilleLaVey 2026-08-22 23:13:20 -04:00
parent 9392ccf124
commit 3d453e6236
2 changed files with 35 additions and 107 deletions

View file

@ -667,24 +667,13 @@ void BlitImageHelper::BlitColor(const Framebuffer* dst_framebuffer, const ImageV
.renderpass = dst_framebuffer->RenderPass(), .renderpass = dst_framebuffer->RenderPass(),
.operation = operation, .operation = operation,
}; };
const VkPipelineLayout layout = *one_texture_pipeline_layout; VkSampler sampler = *nearest_sampler;
const VkSampler sampler = is_linear ? *linear_sampler : *nearest_sampler; if (is_linear) {
const VkPipeline pipeline = FindOrEmplaceColorPipeline(key); sampler = *linear_sampler;
const VkImageView src_view = src_image_view.Handle(Shader::TextureType::Color2D); }
BlitImpl(dst_framebuffer, src_image_view, dst_region, src_region,
RecordShaderReadBarrier(scheduler, src_image_view); FindOrEmplaceColorPipeline(key), sampler,
scheduler.RequestRenderpass(dst_framebuffer); src_image_view.Handle(Shader::TextureType::Color2D), VK_NULL_HANDLE, false);
scheduler.Record([this, dst_region, src_region, pipeline, layout, sampler,
src_view](vk::CommandBuffer cmdbuf) {
const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit();
UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_view);
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set,
nullptr);
BindBlitState(cmdbuf, layout, dst_region, src_region);
cmdbuf.Draw(3, 1, 0, 0);
});
scheduler.InvalidateState();
} }
void BlitImageHelper::BlitColor(const Framebuffer* dst_framebuffer, VkImageView src_image_view, void BlitImageHelper::BlitColor(const Framebuffer* dst_framebuffer, VkImageView src_image_view,
@ -713,16 +702,15 @@ void BlitImageHelper::BlitColor(const Framebuffer* dst_framebuffer, VkImageView
}); });
} }
void BlitImageHelper::BlitMSAAImpl(const Framebuffer* dst_framebuffer, void BlitImageHelper::BlitImpl(const Framebuffer* dst_framebuffer,
const ImageView& src_image_view, const Region2D& dst_region, const ImageView& src_image_view, const Region2D& dst_region,
const Region2D& src_region, VkPipeline pipeline, const Region2D& src_region, VkPipeline pipeline, VkSampler sampler,
VkImageView src_view, VkImageView src_stencil_view, VkImageView src_view, VkImageView src_stencil_view,
bool blit_stencil) { bool blit_stencil) {
VkPipelineLayout layout = *one_texture_pipeline_layout; VkPipelineLayout layout = *one_texture_pipeline_layout;
if (blit_stencil) { if (blit_stencil) {
layout = *two_textures_pipeline_layout; layout = *two_textures_pipeline_layout;
} }
const VkSampler sampler = *nearest_sampler;
RecordShaderReadBarrier(scheduler, src_image_view); RecordShaderReadBarrier(scheduler, src_image_view);
scheduler.RequestRenderpass(dst_framebuffer); scheduler.RequestRenderpass(dst_framebuffer);
@ -753,9 +741,9 @@ void BlitImageHelper::BlitColorMSAA(const Framebuffer* dst_framebuffer,
.renderpass = dst_framebuffer->RenderPass(), .renderpass = dst_framebuffer->RenderPass(),
.samples = dst_framebuffer->Samples(), .samples = dst_framebuffer->Samples(),
}; };
BlitMSAAImpl(dst_framebuffer, src_image_view, dst_region, src_region, BlitImpl(dst_framebuffer, src_image_view, dst_region, src_region,
FindOrEmplaceBlitColorMSAAPipeline(key), FindOrEmplaceBlitColorMSAAPipeline(key), *nearest_sampler,
src_image_view.Handle(Shader::TextureType::Color2D), VK_NULL_HANDLE, false); src_image_view.Handle(Shader::TextureType::Color2D), VK_NULL_HANDLE, false);
} }
void BlitImageHelper::BlitDepthStencilMSAA(const Framebuffer* dst_framebuffer, void BlitImageHelper::BlitDepthStencilMSAA(const Framebuffer* dst_framebuffer,
@ -771,31 +759,16 @@ void BlitImageHelper::BlitDepthStencilMSAA(const Framebuffer* dst_framebuffer,
if (blit_stencil) { if (blit_stencil) {
src_stencil_view = src_image_view.StencilView(); src_stencil_view = src_image_view.StencilView();
} }
BlitMSAAImpl(dst_framebuffer, src_image_view, dst_region, src_region, BlitImpl(dst_framebuffer, src_image_view, dst_region, src_region,
FindOrEmplaceBlitDepthStencilMSAAPipeline(key, blit_stencil), FindOrEmplaceBlitDepthStencilMSAAPipeline(key, blit_stencil), *nearest_sampler,
src_image_view.DepthView(), src_stencil_view, blit_stencil); src_image_view.DepthView(), src_stencil_view, blit_stencil);
} }
void BlitImageHelper::BlitDepth(const Framebuffer* dst_framebuffer, ImageView& src_image_view, void BlitImageHelper::BlitDepth(const Framebuffer* dst_framebuffer, ImageView& src_image_view,
const Region2D& dst_region, const Region2D& src_region) { const Region2D& dst_region, const Region2D& src_region) {
const VkPipeline pipeline = FindOrEmplaceBlitDepthPipeline(dst_framebuffer->RenderPass()); BlitImpl(dst_framebuffer, src_image_view, dst_region, src_region,
const VkPipelineLayout layout = *one_texture_pipeline_layout; FindOrEmplaceBlitDepthPipeline(dst_framebuffer->RenderPass()), *nearest_sampler,
const VkSampler sampler = *nearest_sampler; src_image_view.DepthView(), VK_NULL_HANDLE, false);
const VkImageView src_depth_view = src_image_view.DepthView();
RecordShaderReadBarrier(scheduler, src_image_view);
scheduler.RequestRenderpass(dst_framebuffer);
scheduler.Record([this, dst_region, src_region, pipeline, layout, sampler,
src_depth_view](vk::CommandBuffer cmdbuf) {
const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit();
UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_depth_view);
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set,
nullptr);
BindBlitState(cmdbuf, layout, dst_region, src_region);
cmdbuf.Draw(3, 1, 0, 0);
});
scheduler.InvalidateState();
} }
void BlitImageHelper::ResolveDepthStencil(const Framebuffer* dst_framebuffer, void BlitImageHelper::ResolveDepthStencil(const Framebuffer* dst_framebuffer,
@ -803,36 +776,14 @@ void BlitImageHelper::ResolveDepthStencil(const Framebuffer* dst_framebuffer,
const Region2D& src_region) { const Region2D& src_region) {
const bool resolve_stencil = const bool resolve_stencil =
dst_framebuffer->HasAspectStencilBit() && device.IsExtShaderStencilExportSupported(); dst_framebuffer->HasAspectStencilBit() && device.IsExtShaderStencilExportSupported();
const VkPipeline pipeline = VkImageView src_stencil_view = VK_NULL_HANDLE;
FindOrEmplaceResolveDepthStencilPipeline(dst_framebuffer->RenderPass(), resolve_stencil); if (resolve_stencil) {
const VkPipelineLayout layout = src_stencil_view = src_image_view.StencilView();
resolve_stencil ? *two_textures_pipeline_layout : *one_texture_pipeline_layout; }
const VkSampler sampler = *nearest_sampler; BlitImpl(dst_framebuffer, src_image_view, dst_region, src_region,
const VkImageView src_depth_view = src_image_view.DepthView(); FindOrEmplaceResolveDepthStencilPipeline(dst_framebuffer->RenderPass(),
const VkImageView src_stencil_view = resolve_stencil),
resolve_stencil ? src_image_view.StencilView() : VK_NULL_HANDLE; *nearest_sampler, src_image_view.DepthView(), src_stencil_view, resolve_stencil);
RecordShaderReadBarrier(scheduler, src_image_view);
scheduler.RequestRenderpass(dst_framebuffer);
scheduler.Record([this, dst_region, src_region, pipeline, layout, sampler, src_depth_view,
src_stencil_view, resolve_stencil](vk::CommandBuffer cmdbuf) {
if (resolve_stencil) {
const VkDescriptorSet descriptor_set = two_textures_descriptor_allocator.Commit();
UpdateTwoTexturesDescriptorSet(device, descriptor_set, sampler, src_depth_view,
src_stencil_view);
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set,
nullptr);
} else {
const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit();
UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_depth_view);
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set,
nullptr);
}
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
BindBlitState(cmdbuf, layout, dst_region, src_region);
cmdbuf.Draw(3, 1, 0, 0);
});
scheduler.InvalidateState();
} }
void BlitImageHelper::BlitDepthStencil(const Framebuffer* dst_framebuffer, void BlitImageHelper::BlitDepthStencil(const Framebuffer* dst_framebuffer,
@ -847,40 +798,16 @@ void BlitImageHelper::BlitDepthStencil(const Framebuffer* dst_framebuffer,
.renderpass = dst_framebuffer->RenderPass(), .renderpass = dst_framebuffer->RenderPass(),
.operation = operation, .operation = operation,
}; };
VkPipelineLayout layout{};
VkPipeline pipeline{}; VkPipeline pipeline{};
VkImageView src_stencil_view = VK_NULL_HANDLE; VkImageView src_stencil_view = VK_NULL_HANDLE;
if (blit_stencil) { if (blit_stencil) {
layout = *two_textures_pipeline_layout;
pipeline = FindOrEmplaceDepthStencilPipeline(key); pipeline = FindOrEmplaceDepthStencilPipeline(key);
src_stencil_view = src_image_view.StencilView(); src_stencil_view = src_image_view.StencilView();
} else { } else {
layout = *one_texture_pipeline_layout;
pipeline = FindOrEmplaceBlitDepthPipeline(key.renderpass); pipeline = FindOrEmplaceBlitDepthPipeline(key.renderpass);
} }
const VkSampler sampler = *nearest_sampler; BlitImpl(dst_framebuffer, src_image_view, dst_region, src_region, pipeline, *nearest_sampler,
const VkImageView src_depth_view = src_image_view.DepthView(); src_image_view.DepthView(), src_stencil_view, blit_stencil);
RecordShaderReadBarrier(scheduler, src_image_view);
scheduler.RequestRenderpass(dst_framebuffer);
scheduler.Record([dst_region, src_region, pipeline, layout, sampler, src_depth_view,
src_stencil_view, blit_stencil, this](vk::CommandBuffer cmdbuf) {
VkDescriptorSet descriptor_set{};
if (blit_stencil) {
descriptor_set = two_textures_descriptor_allocator.Commit();
UpdateTwoTexturesDescriptorSet(device, descriptor_set, sampler, src_depth_view,
src_stencil_view);
} else {
descriptor_set = one_texture_descriptor_allocator.Commit();
UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_depth_view);
}
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set,
nullptr);
BindBlitState(cmdbuf, layout, dst_region, src_region);
cmdbuf.Draw(3, 1, 0, 0);
});
scheduler.InvalidateState();
} }
void BlitImageHelper::ConvertD32ToR32(const Framebuffer* dst_framebuffer, void BlitImageHelper::ConvertD32ToR32(const Framebuffer* dst_framebuffer,

View file

@ -151,9 +151,10 @@ private:
VkPipelineStageFlags post_dst_stages; VkPipelineStageFlags post_dst_stages;
}; };
void BlitMSAAImpl(const Framebuffer* dst_framebuffer, const ImageView& src_image_view, void BlitImpl(const Framebuffer* dst_framebuffer, const ImageView& src_image_view,
const Region2D& dst_region, const Region2D& src_region, VkPipeline pipeline, const Region2D& dst_region, const Region2D& src_region, VkPipeline pipeline,
VkImageView src_view, VkImageView src_stencil_view, bool blit_stencil); VkSampler sampler, VkImageView src_view, VkImageView src_stencil_view,
bool blit_stencil);
void CopyMSAAImpl(VkRenderPass renderpass, VkPipeline pipeline, VkPipelineLayout layout, void CopyMSAAImpl(VkRenderPass renderpass, VkPipeline pipeline, VkPipelineLayout layout,
VkImage dst_image, VkFormat dst_vk_format, VkImage src_image, VkImage dst_image, VkFormat dst_vk_format, VkImage src_image,