|
Img2Num C++ (Internal Developer Docs) dev
API Documentation
|
RAII wrapper around a wgpu::Buffer with compile-time type safety. More...
#include <gpu_utils.h>
Collaboration diagram for gpu::Buffer< T >:Public Member Functions | |
| Buffer (size_t count, wgpu::BufferUsage usage) | |
Create a GPU buffer holding count elements of T. | |
| void | write (const T *data, size_t count, size_t offset_elements=0) |
| Upload data from CPU to GPU. | |
| void | write (const std::vector< T > &data) |
| Upload an entire vector to GPU. | |
| std::vector< T > | read () |
| Blocking readback: GPU → CPU. | |
| const wgpu::Buffer & | handle () const |
| Returns the underlying wgpu::Buffer handle. | |
| size_t | byte_size () const |
| Size in bytes. | |
| size_t | size () const |
| Element count. | |
| Buffer (const Buffer &)=delete | |
| Buffer & | operator= (const Buffer &)=delete |
| Buffer (Buffer &&other) noexcept | |
| Move constructor. Transfers ownership of the GPU buffer. | |
| Buffer & | operator= (Buffer &&other) noexcept |
| Move assignment. Destroys the current buffer and takes ownership. | |
| ~Buffer () | |
| Destructor. Releases the GPU buffer. | |
Private Attributes | |
| wgpu::Buffer | buffer_ {nullptr} |
| size_t | count_ {0} |
| size_t | byte_size_ {0} |
RAII wrapper around a wgpu::Buffer with compile-time type safety.
T must be a trivially copyable type. The buffer is destroyed when this object goes out of scope.
| T | Element type (e.g. float, uint32_t, FilterParams). |
Definition at line 131 of file gpu_utils.h.
|
inline |
Create a GPU buffer holding count elements of T.
| count | Number of elements. |
| usage | wgpu::BufferUsage flags. |
Definition at line 138 of file gpu_utils.h.
|
inlinenoexcept |
Move constructor. Transfers ownership of the GPU buffer.
Definition at line 211 of file gpu_utils.h.
|
inline |
Destructor. Releases the GPU buffer.
Definition at line 237 of file gpu_utils.h.
|
inline |
Size in bytes.
Definition at line 197 of file gpu_utils.h.
Referenced by gpu::BindEntry::buffer_entry().
Here is the caller graph for this function:
|
inline |
Returns the underlying wgpu::Buffer handle.
Definition at line 192 of file gpu_utils.h.
Referenced by gpu::BindEntry::buffer_entry().
Here is the caller graph for this function:
|
inlinenoexcept |
Move assignment. Destroys the current buffer and takes ownership.
Definition at line 221 of file gpu_utils.h.
|
inline |
Blocking readback: GPU → CPU.
Creates an internal staging buffer, copies, maps, waits, and returns the data. Works on both native Dawn and Emscripten.
Definition at line 166 of file gpu_utils.h.
References gpu::map_and_wait().
Here is the call graph for this function:
|
inline |
|
inline |
Upload an entire vector to GPU.
Definition at line 158 of file gpu_utils.h.
References gpu::Buffer< T >::write().
Here is the call graph for this function:
|
inline |
Upload data from CPU to GPU.
| data | Pointer to source data. |
| count | Number of elements to write. |
| offset_elements | Element offset into the buffer (default 0). |
Definition at line 151 of file gpu_utils.h.
Referenced by gpu::Buffer< T >::write().
Here is the caller graph for this function:
|
private |
Definition at line 244 of file gpu_utils.h.
|
private |
Definition at line 246 of file gpu_utils.h.
|
private |
Definition at line 245 of file gpu_utils.h.