MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer Class Reference

Public Member Functions

void close ()
PythonBuffer & operator= (const PythonBuffer &)=delete
 PythonBuffer (const mxvk::VulkanContext &context, VkDeviceSize size, VkBufferUsageFlags usage)
 PythonBuffer (const PythonBuffer &)=delete
size_t size () const
bool valid () const
void write (nanobind::ndarray< uint8_t, nanobind::c_contig, nanobind::device::cpu > bytes)
 ~PythonBuffer ()

Detailed Description

Definition at line 276 of file mxvk_nanobind.cpp.

Constructor & Destructor Documentation

◆ PythonBuffer() [1/2]

anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer::PythonBuffer ( const mxvk::VulkanContext & context,
VkDeviceSize size,
VkBufferUsageFlags usage )
inline

Definition at line 278 of file mxvk_nanobind.cpp.

278: device(context.device) { mxvk::create_buffer(context, size, usage, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, resource); }
void create_buffer(const VulkanContext &context, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, BufferResource &buffer)
Create and bind a Vulkan buffer allocation.
VkDevice device
Logical device used to create and destroy resources.

◆ ~PythonBuffer()

anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer::~PythonBuffer ( )
inline

◆ PythonBuffer() [2/2]

anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer::PythonBuffer ( const PythonBuffer & )
delete

Member Function Documentation

◆ close()

void anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer::close ( )
inline

Definition at line 293 of file mxvk_nanobind.cpp.

293 {
294 if (device != VK_NULL_HANDLE && resource.buffer != VK_NULL_HANDLE)
295 mxvk::destroy_buffer(device, resource);
296 device = VK_NULL_HANDLE;
297 }
void destroy_buffer(VkDevice device, BufferResource &buffer)
Unmap and destroy a BufferResource.

◆ operator=()

PythonBuffer & anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer::operator= ( const PythonBuffer & )
delete

◆ size()

size_t anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer::size ( ) const
inlinenodiscard

Definition at line 299 of file mxvk_nanobind.cpp.

299{ return static_cast<size_t>(resource.size); }

◆ valid()

bool anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer::valid ( ) const
inlinenodiscard

Definition at line 300 of file mxvk_nanobind.cpp.

300{ return resource.buffer != VK_NULL_HANDLE; }

◆ write()

void anonymous_namespace{mxvk_nanobind.cpp}::PythonBuffer::write ( nanobind::ndarray< uint8_t, nanobind::c_contig, nanobind::device::cpu > bytes)
inline

Definition at line 285 of file mxvk_nanobind.cpp.

285 {
286 if (bytes.nbytes() > resource.size)
287 throw nanobind::value_error("buffer upload is larger than the allocated buffer");
288 mxvk::map_buffer(device, resource);
289 std::memcpy(resource.mapped, bytes.data(), bytes.nbytes());
290 mxvk::unmap_buffer(device, resource);
291 }
void unmap_buffer(VkDevice device, BufferResource &buffer)
Unmap a BufferResource if it is currently mapped.
void map_buffer(VkDevice device, BufferResource &buffer)
Persistently map a host-visible buffer allocation.

The documentation for this class was generated from the following file: