forked from blender/blender
main sync #3
@ -90,6 +90,12 @@ void VKBuffer::read(void *data) const
|
|||||||
memcpy(data, mapped_memory_, size_in_bytes_);
|
memcpy(data, mapped_memory_, size_in_bytes_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *VKBuffer::mapped_memory_get() const
|
||||||
|
{
|
||||||
|
BLI_assert_msg(is_mapped(), "Cannot access a non-mapped buffer.");
|
||||||
|
return mapped_memory_;
|
||||||
|
}
|
||||||
|
|
||||||
bool VKBuffer::is_mapped() const
|
bool VKBuffer::is_mapped() const
|
||||||
{
|
{
|
||||||
return mapped_memory_ != nullptr;
|
return mapped_memory_ != nullptr;
|
||||||
|
@ -49,6 +49,13 @@ class VKBuffer {
|
|||||||
return vk_buffer_;
|
return vk_buffer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the reference to the mapped memory.
|
||||||
|
*
|
||||||
|
* Can only be called when the buffer is (still) mapped.
|
||||||
|
*/
|
||||||
|
void *mapped_memory_get() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Check if this buffer is mapped. */
|
/** Check if this buffer is mapped. */
|
||||||
bool is_mapped() const;
|
bool is_mapped() const;
|
||||||
|
@ -11,20 +11,28 @@ namespace blender::gpu {
|
|||||||
|
|
||||||
VKPixelBuffer::VKPixelBuffer(int64_t size) : PixelBuffer(size)
|
VKPixelBuffer::VKPixelBuffer(int64_t size) : PixelBuffer(size)
|
||||||
{
|
{
|
||||||
|
VKContext &context = *VKContext::get();
|
||||||
|
buffer_.create(context,
|
||||||
|
size,
|
||||||
|
GPU_USAGE_STATIC,
|
||||||
|
static_cast<VkBufferUsageFlagBits>(VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
|
||||||
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *VKPixelBuffer::map()
|
void *VKPixelBuffer::map()
|
||||||
{
|
{
|
||||||
return nullptr;
|
/* Vulkan buffers are always mapped between allocation and freeing. */
|
||||||
|
return buffer_.mapped_memory_get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VKPixelBuffer::unmap()
|
void VKPixelBuffer::unmap()
|
||||||
{
|
{
|
||||||
|
/* Vulkan buffers are always mapped between allocation and freeing. */
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t VKPixelBuffer::get_native_handle()
|
int64_t VKPixelBuffer::get_native_handle()
|
||||||
{
|
{
|
||||||
return -1;
|
return int64_t(buffer_.vk_handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint VKPixelBuffer::get_size()
|
uint VKPixelBuffer::get_size()
|
||||||
|
@ -9,9 +9,13 @@
|
|||||||
|
|
||||||
#include "gpu_texture_private.hh"
|
#include "gpu_texture_private.hh"
|
||||||
|
|
||||||
|
#include "vk_buffer.hh"
|
||||||
|
|
||||||
namespace blender::gpu {
|
namespace blender::gpu {
|
||||||
|
|
||||||
class VKPixelBuffer : public PixelBuffer {
|
class VKPixelBuffer : public PixelBuffer {
|
||||||
|
VKBuffer buffer_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VKPixelBuffer(int64_t size);
|
VKPixelBuffer(int64_t size);
|
||||||
void *map() override;
|
void *map() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user