summaryrefslogtreecommitdiff
path: root/src/gpu/texture_readback.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-03-05 22:55:56 +0100
committerskal <pascal.massimino@gmail.com>2026-03-05 22:55:56 +0100
commit34afbd6ca21d2b960573d787e6eae46fa86b200e (patch)
tree08450aeff4c67fb300428e705910265e6cd59943 /src/gpu/texture_readback.cc
parent35c9ebb0a7ce0e726f631a2b04bb26098926cfab (diff)
style: run clang-format to adhere to coding style
Diffstat (limited to 'src/gpu/texture_readback.cc')
-rw-r--r--src/gpu/texture_readback.cc20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/gpu/texture_readback.cc b/src/gpu/texture_readback.cc
index 211beed..e512428 100644
--- a/src/gpu/texture_readback.cc
+++ b/src/gpu/texture_readback.cc
@@ -56,8 +56,7 @@ std::vector<uint8_t> read_texture_pixels(WGPUInstance instance,
},
};
- const WGPUExtent3D copy_size = {(uint32_t)(width),
- (uint32_t)(height), 1};
+ const WGPUExtent3D copy_size = {(uint32_t)(width), (uint32_t)(height), 1};
wgpuCommandEncoderCopyTextureToBuffer(encoder, &src, &dst, &copy_size);
@@ -117,8 +116,8 @@ std::vector<uint8_t> read_texture_pixels(WGPUInstance instance,
}
// Copy data from mapped buffer (handle row padding)
- const uint8_t* mapped_data = (const uint8_t*)(
- wgpuBufferGetConstMappedRange(staging, 0, buffer_size));
+ const uint8_t* mapped_data =
+ (const uint8_t*)(wgpuBufferGetConstMappedRange(staging, 0, buffer_size));
if (mapped_data) {
// If rows are aligned, copy row by row to remove padding
if (aligned_bytes_per_row != unaligned_bytes_per_row) {
@@ -212,8 +211,7 @@ std::vector<uint8_t> texture_readback_fp16_to_u8(WGPUDevice device,
.rowsPerImage = (uint32_t)(height),
},
};
- const WGPUExtent3D copy_size = {(uint32_t)(width),
- (uint32_t)(height), 1};
+ const WGPUExtent3D copy_size = {(uint32_t)(width), (uint32_t)(height), 1};
wgpuCommandEncoderCopyTextureToBuffer(encoder, &src, &dst, &copy_size);
WGPUCommandBuffer commands = wgpuCommandEncoderFinish(encoder, nullptr);
@@ -259,15 +257,15 @@ std::vector<uint8_t> texture_readback_fp16_to_u8(WGPUDevice device,
}
// Convert FP16 to U8 ([-1,1] → [0,255])
- const uint16_t* mapped_data = (const uint16_t*)(
- wgpuBufferGetConstMappedRange(staging, 0, buffer_size));
+ const uint16_t* mapped_data =
+ (const uint16_t*)(wgpuBufferGetConstMappedRange(staging, 0, buffer_size));
std::vector<uint8_t> pixels(width * height * 4);
if (mapped_data) {
for (int y = 0; y < height; ++y) {
- const uint16_t* src_row = (const uint16_t*)(
- (const uint8_t*)(mapped_data) +
- y * aligned_bytes_per_row);
+ const uint16_t* src_row =
+ (const uint16_t*)((const uint8_t*)(mapped_data) +
+ y * aligned_bytes_per_row);
for (int x = 0; x < width; ++x) {
float r = fp16_to_float(src_row[x * 4 + 0]);
float g = fp16_to_float(src_row[x * 4 + 1]);