Files
test2/source/blender/gpu/vulkan/vk_pixel_buffer.cc
Jeroen Bakker 2feb435780 Fix: Vulkan: Memory allocation on no-rebar capable platforms
Memory areas was requested to be preferable host visible. On some
platforms this would fail to allocate. Best is to not add preferable
host visible for typically large allocations.

This PR also gives the caller the responsibility to set the allocation flags.

Pull Request: https://projects.blender.org/blender/blender/pulls/133528
2025-01-24 11:54:59 +01:00

47 lines
1023 B
C++

/* SPDX-FileCopyrightText: 2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup gpu
*/
#include "vk_pixel_buffer.hh"
#include "vk_context.hh"
namespace blender::gpu {
VKPixelBuffer::VKPixelBuffer(size_t size) : PixelBuffer(size)
{
buffer_.create(size,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
VmaAllocationCreateFlags(0));
debug::object_label(buffer_.vk_handle(), "PixelBuffer");
}
void *VKPixelBuffer::map()
{
/* Vulkan buffers are always mapped between allocation and freeing. */
return buffer_.mapped_memory_get();
}
void VKPixelBuffer::unmap()
{
/* Vulkan buffers are always mapped between allocation and freeing. */
}
int64_t VKPixelBuffer::get_native_handle()
{
return int64_t(buffer_.vk_handle());
}
size_t VKPixelBuffer::get_size()
{
return size_;
}
} // namespace blender::gpu