diff --git a/source/blender/gpu/vulkan/vk_buffer.hh b/source/blender/gpu/vulkan/vk_buffer.hh index f53b460fb8e..7f67091cd26 100644 --- a/source/blender/gpu/vulkan/vk_buffer.hh +++ b/source/blender/gpu/vulkan/vk_buffer.hh @@ -37,7 +37,6 @@ class VKBuffer : public NonCopyable { public: VKBuffer() = default; - VKBuffer(VKBuffer &&other) = default; virtual ~VKBuffer(); /** Has this buffer been allocated? */ diff --git a/source/blender/gpu/vulkan/vk_descriptor_set.cc b/source/blender/gpu/vulkan/vk_descriptor_set.cc index ba6c77fefac..4ed73a1464f 100644 --- a/source/blender/gpu/vulkan/vk_descriptor_set.cc +++ b/source/blender/gpu/vulkan/vk_descriptor_set.cc @@ -48,11 +48,12 @@ void VKDescriptorSetTracker::update_descriptor_set(VKContext &context, void VKDescriptorSetTracker::upload_descriptor_sets() { VKDevice &device = VKBackend::get().device; - VKDescriptorSetUpdator &updator = descriptor_sets; if (device.extensions_get().descriptor_buffer) { - updator = descriptor_buffers; + descriptor_buffers.upload_descriptor_sets(); + } + else { + descriptor_sets.upload_descriptor_sets(); } - updator.upload_descriptor_sets(); } /* -------------------------------------------------------------------- */ @@ -529,19 +530,21 @@ void VKDescriptorBufferUpdator::allocate_new_descriptor_set( vk_descriptor_set_layout); /* Ensure if there is still place left in the current buffer. */ - if (buffers.is_empty() || layout.size > buffers.last().size_in_bytes() - descriptor_set_head) { + if (buffers.is_empty() || + layout.size > buffers.last().get()->size_in_bytes() - descriptor_set_head) + { const VkDeviceSize default_buffer_size = 8 * 1024 * 1024; - buffers.append({}); - VKBuffer &buffer = buffers.last(); - buffer.create(default_buffer_size, - VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT | - VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT, - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, - 0, - VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT); - debug::object_label(buffer.vk_handle(), "DescriptorBuffer"); - descriptor_buffer_data = static_cast(buffer.mapped_memory_get()); - descriptor_buffer_device_address = buffer.device_address_get(); + buffers.append(std::make_unique()); + VKBuffer *buffer = buffers.last().get(); + buffer->create(default_buffer_size, + VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT | + VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT, + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, + 0, + VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT); + debug::object_label(buffer->vk_handle(), "DescriptorBuffer"); + descriptor_buffer_data = static_cast(buffer->mapped_memory_get()); + descriptor_buffer_device_address = buffer->device_address_get(); descriptor_buffer_offset = 0; descriptor_set_head = 0; descriptor_set_tail = 0; diff --git a/source/blender/gpu/vulkan/vk_descriptor_set.hh b/source/blender/gpu/vulkan/vk_descriptor_set.hh index 71feb3c27ba..e48337fe1eb 100644 --- a/source/blender/gpu/vulkan/vk_descriptor_set.hh +++ b/source/blender/gpu/vulkan/vk_descriptor_set.hh @@ -176,7 +176,7 @@ class VKDescriptorBufferUpdator : public VKDescriptorSetUpdator { /* Current layout of the descriptor set being filled. */ VKDescriptorBufferLayout layout; /* Descriptor buffers */ - Vector buffers; + Vector> buffers; /* Current descriptor buffer handle and offset. */ VkDeviceAddress descriptor_buffer_device_address = 0; diff --git a/source/blender/windowmanager/intern/wm_draw.cc b/source/blender/windowmanager/intern/wm_draw.cc index 51cd10f251a..f3f7111528a 100644 --- a/source/blender/windowmanager/intern/wm_draw.cc +++ b/source/blender/windowmanager/intern/wm_draw.cc @@ -1346,7 +1346,15 @@ void WM_window_pixels_read_sample_from_frontbuffer(const wmWindowManager *wm, GPU_context_active_set(static_cast(win->gpuctx)); } - GPU_frontbuffer_read_color(pos[0], pos[1], 1, 1, 3, GPU_DATA_FLOAT, r_col); + /* NOTE(@jbakker): Vulkan backend isn't able to read 3 channels from a 4 channel texture with + * data data-conversions is needed. Data conversion happens inline for all channels. This is a + * vulkan backend issue and should be solved. However the solution has a lot of branches that + * requires testing so a quick fix has been added to the place where this was used. The solution + * is to implement all the cases in 'VKFramebuffer::read'. + */ + blender::float4 color_with_alpha; + GPU_frontbuffer_read_color(pos[0], pos[1], 1, 1, 4, GPU_DATA_FLOAT, color_with_alpha); + copy_v3_v3(r_col, color_with_alpha.xyz()); if (setup_context) { if (wm->windrawable) {