Merge branch 'blender-v4.5-release'

This commit is contained in:
Jeroen Bakker
2025-06-10 10:24:44 +02:00
4 changed files with 28 additions and 18 deletions

View File

@@ -37,7 +37,6 @@ class VKBuffer : public NonCopyable {
public:
VKBuffer() = default;
VKBuffer(VKBuffer &&other) = default;
virtual ~VKBuffer();
/** Has this buffer been allocated? */

View File

@@ -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<uint8_t *>(buffer.mapped_memory_get());
descriptor_buffer_device_address = buffer.device_address_get();
buffers.append(std::make_unique<VKBuffer>());
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<uint8_t *>(buffer->mapped_memory_get());
descriptor_buffer_device_address = buffer->device_address_get();
descriptor_buffer_offset = 0;
descriptor_set_head = 0;
descriptor_set_tail = 0;

View File

@@ -176,7 +176,7 @@ class VKDescriptorBufferUpdator : public VKDescriptorSetUpdator {
/* Current layout of the descriptor set being filled. */
VKDescriptorBufferLayout layout;
/* Descriptor buffers */
Vector<VKBuffer> buffers;
Vector<std::unique_ptr<VKBuffer>> buffers;
/* Current descriptor buffer handle and offset. */
VkDeviceAddress descriptor_buffer_device_address = 0;

View File

@@ -1346,7 +1346,15 @@ void WM_window_pixels_read_sample_from_frontbuffer(const wmWindowManager *wm,
GPU_context_active_set(static_cast<GPUContext *>(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) {