blob: 8230e13257541a3d91d286456ff00b98e6bf39ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// GPU texture readback utility for offline processing
// Synchronous blocking operation (waits for GPU completion)
#pragma once
// Protected with STRIP_ALL: only needed for dev tools, not final release
#if !defined(STRIP_ALL)
#include "platform/platform.h"
#include <vector>
#include <cstdint>
// Read texture pixels to CPU memory (synchronous, blocking)
// Format: BGRA8Unorm (4 bytes per pixel)
// Returns: width * height * 4 bytes
std::vector<uint8_t> read_texture_pixels(
WGPUInstance instance,
WGPUDevice device,
WGPUTexture texture,
int width,
int height);
// Read RGBA16Float texture and convert to BGRA8Unorm for saving
// Converts [-1,1] float range to [0,255] uint8 range
// Returns: width * height * 4 bytes (BGRA8)
std::vector<uint8_t> texture_readback_fp16_to_u8(
WGPUDevice device,
WGPUQueue queue,
WGPUTexture texture,
int width,
int height);
#endif // !defined(STRIP_ALL)
|