|
Img2Num C++ (Internal Developer Docs) dev
API Documentation
|
RAII wrapper around a wgpu::Texture with upload and aligned readback. More...
#include <gpu_utils.h>
Collaboration diagram for gpu::Texture:Public Member Functions | |
| Texture (uint32_t width, uint32_t height, wgpu::TextureFormat format, wgpu::TextureUsage usage) | |
| Create a 2D texture. | |
| void | write (const void *data, size_t data_size, uint32_t bytes_per_pixel) |
| Upload tightly-packed pixel data to the texture. | |
| std::vector< uint8_t > | read (uint32_t bytes_per_pixel) |
| Blocking readback with automatic 256-byte row-alignment stripping. | |
| wgpu::TextureView | view () const |
| Create a default texture view. | |
| const wgpu::Texture & | handle () const |
| Underlying wgpu::Texture handle. | |
| uint32_t | width () const |
| Width of the texture in pixels. | |
| uint32_t | height () const |
| Height of the texture in pixels. | |
| wgpu::TextureFormat | format () const |
| Texel format of the texture. | |
| Texture (const Texture &)=delete | |
| Texture & | operator= (const Texture &)=delete |
| Texture (Texture &&other) noexcept | |
| Move constructor. Transfers ownership of the GPU texture. | |
| Texture & | operator= (Texture &&other) noexcept |
| Move assignment. Destroys the current texture and takes ownership. | |
| ~Texture () | |
| Destructor. Releases the GPU texture. | |
Private Attributes | |
| wgpu::Texture | texture_ {nullptr} |
| uint32_t | width_ {0} |
| uint32_t | height_ {0} |
| wgpu::TextureFormat | format_ {} |
RAII wrapper around a wgpu::Texture with upload and aligned readback.
Handles the 256-byte row-alignment requirement for CopyTextureToBuffer automatically during readback.
Definition at line 257 of file gpu_utils.h.
|
inline |
Create a 2D texture.
| width | Width in pixels. |
| height | Height in pixels. |
| format | Texel format (e.g. RGBA8Unorm, RGBA32Float). |
| usage | Texture usage flags. |
Definition at line 264 of file gpu_utils.h.
References format(), height(), and width().
Here is the call graph for this function:
|
inlinenoexcept |
Move constructor. Transfers ownership of the GPU texture.
Definition at line 365 of file gpu_utils.h.
|
inline |
Destructor. Releases the GPU texture.
Definition at line 393 of file gpu_utils.h.
|
inline |
Texel format of the texture.
Definition at line 356 of file gpu_utils.h.
Referenced by Texture().
Here is the caller graph for this function:
|
inline |
Underlying wgpu::Texture handle.
Definition at line 343 of file gpu_utils.h.
|
inline |
Height of the texture in pixels.
Definition at line 352 of file gpu_utils.h.
Referenced by Texture().
Here is the caller graph for this function:Move assignment. Destroys the current texture and takes ownership.
Definition at line 376 of file gpu_utils.h.
|
inline |
Blocking readback with automatic 256-byte row-alignment stripping.
Returns tightly-packed pixel data with no padding between rows.
| bytes_per_pixel | Bytes per pixel in the texture format. |
Definition at line 296 of file gpu_utils.h.
References gpu::map_and_wait().
Here is the call graph for this function:
|
inline |
Create a default texture view.
Definition at line 338 of file gpu_utils.h.
Referenced by gpu::BindEntry::texture().
Here is the caller graph for this function:
|
inline |
Width of the texture in pixels.
Definition at line 348 of file gpu_utils.h.
Referenced by Texture().
Here is the caller graph for this function:
|
inline |
Upload tightly-packed pixel data to the texture.
| data | Pointer to pixel data. |
| data_size | Total size in bytes. |
| bytes_per_pixel | Bytes per pixel (e.g. 4 for RGBA8, 16 for RGBA32Float). |
Definition at line 279 of file gpu_utils.h.
|
private |
Definition at line 403 of file gpu_utils.h.
|
private |
Definition at line 402 of file gpu_utils.h.
|
private |
Definition at line 400 of file gpu_utils.h.
|
private |
Definition at line 401 of file gpu_utils.h.