From 001939ca8e2c582650d3cd77d0cd0eabffc50ed2 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 17 Feb 2026 08:57:55 +0100 Subject: style: replace C++ casts with C-style casts Converts all static_cast<>, reinterpret_cast<> to C-style casts per CODING_STYLE.md guidelines. - Modified 12 files across gpu, 3d, util, tests, and tools - All builds passing, 34/34 tests passing - No functional changes, pure style cleanup Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/texture_readback.cc | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/gpu/texture_readback.cc') diff --git a/src/gpu/texture_readback.cc b/src/gpu/texture_readback.cc index bd3c79c..211beed 100644 --- a/src/gpu/texture_readback.cc +++ b/src/gpu/texture_readback.cc @@ -52,12 +52,12 @@ std::vector read_texture_pixels(WGPUInstance instance, .layout = { .bytesPerRow = aligned_bytes_per_row, - .rowsPerImage = static_cast(height), + .rowsPerImage = (uint32_t)(height), }, }; - const WGPUExtent3D copy_size = {static_cast(width), - static_cast(height), 1}; + const WGPUExtent3D copy_size = {(uint32_t)(width), + (uint32_t)(height), 1}; wgpuCommandEncoderCopyTextureToBuffer(encoder, &src, &dst, ©_size); @@ -77,7 +77,7 @@ std::vector read_texture_pixels(WGPUInstance instance, // Win32: Old callback API MapState map_state = {}; auto map_cb = [](WGPUBufferMapAsyncStatus status, void* userdata) { - MapState* state = static_cast(userdata); + MapState* state = (MapState*)(userdata); state->status = status; state->done = true; }; @@ -90,7 +90,7 @@ std::vector read_texture_pixels(WGPUInstance instance, void* userdata, void* user2) { (void)message; (void)user2; - MapState* state = static_cast(userdata); + MapState* state = (MapState*)(userdata); state->status = status; state->done = true; }; @@ -117,7 +117,7 @@ std::vector read_texture_pixels(WGPUInstance instance, } // Copy data from mapped buffer (handle row padding) - const uint8_t* mapped_data = static_cast( + 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 @@ -209,11 +209,11 @@ std::vector texture_readback_fp16_to_u8(WGPUDevice device, .layout = { .bytesPerRow = aligned_bytes_per_row, - .rowsPerImage = static_cast(height), + .rowsPerImage = (uint32_t)(height), }, }; - const WGPUExtent3D copy_size = {static_cast(width), - static_cast(height), 1}; + const WGPUExtent3D copy_size = {(uint32_t)(width), + (uint32_t)(height), 1}; wgpuCommandEncoderCopyTextureToBuffer(encoder, &src, &dst, ©_size); WGPUCommandBuffer commands = wgpuCommandEncoderFinish(encoder, nullptr); @@ -226,7 +226,7 @@ std::vector texture_readback_fp16_to_u8(WGPUDevice device, #if defined(DEMO_CROSS_COMPILE_WIN32) MapState map_state = {}; auto map_cb = [](WGPUBufferMapAsyncStatus status, void* userdata) { - MapState* state = static_cast(userdata); + MapState* state = (MapState*)(userdata); state->status = status; state->done = true; }; @@ -238,7 +238,7 @@ std::vector texture_readback_fp16_to_u8(WGPUDevice device, void* userdata, void* user2) { (void)message; (void)user2; - MapState* state = static_cast(userdata); + MapState* state = (MapState*)(userdata); state->status = status; state->done = true; }; @@ -259,14 +259,14 @@ std::vector texture_readback_fp16_to_u8(WGPUDevice device, } // Convert FP16 to U8 ([-1,1] → [0,255]) - const uint16_t* mapped_data = static_cast( + const uint16_t* mapped_data = (const uint16_t*)( wgpuBufferGetConstMappedRange(staging, 0, buffer_size)); std::vector pixels(width * height * 4); if (mapped_data) { for (int y = 0; y < height; ++y) { - const uint16_t* src_row = reinterpret_cast( - reinterpret_cast(mapped_data) + + 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]); @@ -281,10 +281,10 @@ std::vector texture_readback_fp16_to_u8(WGPUDevice device, a = (a + 1.0f) * 0.5f; int idx = (y * width + x) * 4; - pixels[idx + 0] = static_cast(b * 255.0f); // B - pixels[idx + 1] = static_cast(g * 255.0f); // G - pixels[idx + 2] = static_cast(r * 255.0f); // R - pixels[idx + 3] = static_cast(a * 255.0f); // A + pixels[idx + 0] = (uint8_t)(b * 255.0f); // B + pixels[idx + 1] = (uint8_t)(g * 255.0f); // G + pixels[idx + 2] = (uint8_t)(r * 255.0f); // R + pixels[idx + 3] = (uint8_t)(a * 255.0f); // A } } } -- cgit v1.2.3