diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-14 14:15:07 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-14 14:15:07 +0100 |
| commit | 12f83d4615a38cb0b1ed8a3eb436c4acca170479 (patch) | |
| tree | f9058b6e526ff3015b10da2d20ac5e0b15638706 /doc | |
| parent | 61ced8aa1946cc32de4328cc75b5faf6b77723be (diff) | |
Refactor: add gpu_create_post_process_texture helper
Adds new helper for common post-process texture pattern (RenderAttachment
| TextureBinding | CopySrc usage). Refactors test_post_process_helper.cc
to use gpu_create_buffer() and gpu_create_post_process_texture(),
eliminating 91 lines of boilerplate.
- New: gpu_create_post_process_texture() in gpu.{h,cc}
- Refactor: test_post_process_helper.cc uses helpers instead of raw WGPU
- Doc: Updated WGPU_HELPERS.md with usage examples
- Verified: All tests passing (test_post_process_helper, test_demo_effects)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/WGPU_HELPERS.md | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/doc/WGPU_HELPERS.md b/doc/WGPU_HELPERS.md index 5642eef..f1d83d5 100644 --- a/doc/WGPU_HELPERS.md +++ b/doc/WGPU_HELPERS.md @@ -133,6 +133,45 @@ TextureWithView output = gpu_create_storage_texture_2d( --- +#### `gpu_create_post_process_texture` +```cpp +TextureWithView gpu_create_post_process_texture( + WGPUDevice device, uint32_t width, uint32_t height, + WGPUTextureFormat format); +``` + +**Purpose:** Create texture for post-processing effects (render target + input + readback). + +**Parameters:** +- `device` - WGPU device handle +- `width`, `height` - Texture dimensions +- `format` - Pixel format (typically `WGPUTextureFormat_RGBA8Unorm`) + +**Returns:** `TextureWithView` with usage flags: +- `WGPUTextureUsage_RenderAttachment` - Can render to it +- `WGPUTextureUsage_TextureBinding` - Can sample from it +- `WGPUTextureUsage_CopySrc` - Can read back pixels + +**Example:** +```cpp +// Create ping-pong buffers for multi-pass post-processing +TextureWithView buffer_a = gpu_create_post_process_texture( + device, 1920, 1080, WGPUTextureFormat_RGBA8Unorm); +TextureWithView buffer_b = gpu_create_post_process_texture( + device, 1920, 1080, WGPUTextureFormat_RGBA8Unorm); + +// Pass 1: Render to buffer_a +// Pass 2: Sample buffer_a, render to buffer_b +// Pass 3: Copy buffer_b to screen +``` + +**Common Use Cases:** +- Post-process ping-pong buffers +- Off-screen render targets that need sampling +- Test fixtures requiring texture readback + +--- + #### `gpu_create_mip_view` ```cpp WGPUTextureView gpu_create_mip_view(WGPUTexture texture, |
