vulkan/blit_image: Commit descriptor sets within worker thread
Fixes race condition caused. The descriptor pool is not thread safe, so we have to commit descriptor sets within the same thread.
This commit is contained in:
parent
f6796cad9c
commit
a55ff22900
1 changed files with 7 additions and 9 deletions
|
@ -376,11 +376,11 @@ void BlitImageHelper::BlitColor(const Framebuffer* dst_framebuffer, const ImageV
|
||||||
const VkImageView src_view = src_image_view.Handle(Shader::TextureType::Color2D);
|
const VkImageView src_view = src_image_view.Handle(Shader::TextureType::Color2D);
|
||||||
const VkSampler sampler = is_linear ? *linear_sampler : *nearest_sampler;
|
const VkSampler sampler = is_linear ? *linear_sampler : *nearest_sampler;
|
||||||
const VkPipeline pipeline = FindOrEmplacePipeline(key);
|
const VkPipeline pipeline = FindOrEmplacePipeline(key);
|
||||||
const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit();
|
|
||||||
scheduler.RequestRenderpass(dst_framebuffer);
|
scheduler.RequestRenderpass(dst_framebuffer);
|
||||||
scheduler.Record([dst_region, src_region, pipeline, layout, sampler, src_view, descriptor_set,
|
scheduler.Record([this, dst_region, src_region, pipeline, layout, sampler,
|
||||||
&device = device](vk::CommandBuffer cmdbuf) {
|
src_view](vk::CommandBuffer cmdbuf) {
|
||||||
// TODO: Barriers
|
// TODO: Barriers
|
||||||
|
const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit();
|
||||||
UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_view);
|
UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_view);
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set,
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set,
|
||||||
|
@ -402,12 +402,11 @@ void BlitImageHelper::BlitDepthStencil(const Framebuffer* dst_framebuffer,
|
||||||
const VkPipelineLayout layout = *two_textures_pipeline_layout;
|
const VkPipelineLayout layout = *two_textures_pipeline_layout;
|
||||||
const VkSampler sampler = *nearest_sampler;
|
const VkSampler sampler = *nearest_sampler;
|
||||||
const VkPipeline pipeline = BlitDepthStencilPipeline(dst_framebuffer->RenderPass());
|
const VkPipeline pipeline = BlitDepthStencilPipeline(dst_framebuffer->RenderPass());
|
||||||
const VkDescriptorSet descriptor_set = two_textures_descriptor_allocator.Commit();
|
|
||||||
scheduler.RequestRenderpass(dst_framebuffer);
|
scheduler.RequestRenderpass(dst_framebuffer);
|
||||||
scheduler.Record([dst_region, src_region, pipeline, layout, sampler, src_depth_view,
|
scheduler.Record([dst_region, src_region, pipeline, layout, sampler, src_depth_view,
|
||||||
src_stencil_view, descriptor_set,
|
src_stencil_view, this](vk::CommandBuffer cmdbuf) {
|
||||||
&device = device](vk::CommandBuffer cmdbuf) {
|
|
||||||
// TODO: Barriers
|
// TODO: Barriers
|
||||||
|
const VkDescriptorSet descriptor_set = two_textures_descriptor_allocator.Commit();
|
||||||
UpdateTwoTexturesDescriptorSet(device, descriptor_set, sampler, src_depth_view,
|
UpdateTwoTexturesDescriptorSet(device, descriptor_set, sampler, src_depth_view,
|
||||||
src_stencil_view);
|
src_stencil_view);
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||||
|
@ -448,14 +447,12 @@ void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_frameb
|
||||||
const VkPipelineLayout layout = *one_texture_pipeline_layout;
|
const VkPipelineLayout layout = *one_texture_pipeline_layout;
|
||||||
const VkImageView src_view = src_image_view.Handle(Shader::TextureType::Color2D);
|
const VkImageView src_view = src_image_view.Handle(Shader::TextureType::Color2D);
|
||||||
const VkSampler sampler = *nearest_sampler;
|
const VkSampler sampler = *nearest_sampler;
|
||||||
const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit();
|
|
||||||
const VkExtent2D extent{
|
const VkExtent2D extent{
|
||||||
.width = src_image_view.size.width,
|
.width = src_image_view.size.width,
|
||||||
.height = src_image_view.size.height,
|
.height = src_image_view.size.height,
|
||||||
};
|
};
|
||||||
scheduler.RequestRenderpass(dst_framebuffer);
|
scheduler.RequestRenderpass(dst_framebuffer);
|
||||||
scheduler.Record([pipeline, layout, sampler, src_view, descriptor_set, extent,
|
scheduler.Record([pipeline, layout, sampler, src_view, extent, this](vk::CommandBuffer cmdbuf) {
|
||||||
&device = device](vk::CommandBuffer cmdbuf) {
|
|
||||||
const VkOffset2D offset{
|
const VkOffset2D offset{
|
||||||
.x = 0,
|
.x = 0,
|
||||||
.y = 0,
|
.y = 0,
|
||||||
|
@ -476,6 +473,7 @@ void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_frameb
|
||||||
.tex_scale = {viewport.width, viewport.height},
|
.tex_scale = {viewport.width, viewport.height},
|
||||||
.tex_offset = {0.0f, 0.0f},
|
.tex_offset = {0.0f, 0.0f},
|
||||||
};
|
};
|
||||||
|
const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit();
|
||||||
UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_view);
|
UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_view);
|
||||||
|
|
||||||
// TODO: Barriers
|
// TODO: Barriers
|
||||||
|
|
Loading…
Reference in a new issue