diff options
Diffstat (limited to 'src/gpu/texture_readback.cc')
| -rw-r--r-- | src/gpu/texture_readback.cc | 20 |
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, ©_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, ©_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]); |
