From a30a9878fe083240dbd98ae4ca93339cd8a8d667 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 17 Feb 2026 11:00:51 +0100 Subject: fix(build): Resolve Windows cross-compilation failures This commit fixes several issues that caused the Windows cross-compilation build (`scripts/build_win.sh`) to fail. The root causes were platform-specific API differences in the wgpu-native library and incorrect dependency tracking in the CMake build system for generated code. Changes: - **`tools/seq_compiler.py`**: The timeline generator now wraps `depthSlice` assignments in `#if !defined(DEMO_CROSS_COMPILE_WIN32)` directives to handle API differences in `WGPURenderPassColorAttachment`. - **`src/gpu/gpu.h`**: The `gpu_init_color_attachment` helper is now platform-aware, using a preprocessor guard for the `depthSlice` member. - **`src/effects/*.cc`**: All effects are updated to use the new platform-aware helper or have explicit guards for `depthSlice`. Also, replaced `WGPUTexelCopyTextureInfo` with the cross-platform alias `GpuTextureCopyInfo` in `rotating_cube_effect.cc`. - **`cmake`**: Added `tools/seq_compiler.py` as an explicit dependency to the `generate_timeline` and `generate_test_demo_timeline` custom commands. This ensures that changes to the generator script correctly trigger a rebuild of the generated C++ files. - **`scripts/build_win.sh`**: Removed the erroneous attempt to build the `seq_compiler.py` script as a native executable. With these changes, the Windows cross-compilation build now completes successfully. --- src/effects/flash_effect.cc | 6 +----- src/effects/gaussian_blur_effect.cc | 6 +----- src/effects/heptagon_effect.cc | 6 +----- src/effects/hybrid3_d_effect.cc | 7 +------ src/effects/particles_effect.cc | 8 ++------ src/effects/passthrough_effect.cc | 8 ++------ src/effects/peak_meter_effect.cc | 5 +---- src/effects/placeholder_effect.cc | 8 ++------ src/effects/rotating_cube_effect.cc | 6 ++++-- src/gpu/gpu.h | 2 ++ 10 files changed, 17 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/effects/flash_effect.cc b/src/effects/flash_effect.cc index c8638f0..7baf6a2 100644 --- a/src/effects/flash_effect.cc +++ b/src/effects/flash_effect.cc @@ -67,11 +67,7 @@ void Flash::render(WGPUCommandEncoder encoder, // Render pass WGPURenderPassColorAttachment color_attachment = {}; - color_attachment.view = output_view; - color_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; - color_attachment.loadOp = WGPULoadOp_Clear; - color_attachment.storeOp = WGPUStoreOp_Store; - color_attachment.clearValue = {0.0, 0.0, 0.0, 1.0}; + gpu_init_color_attachment(color_attachment, output_view); WGPURenderPassDescriptor pass_desc = {}; pass_desc.colorAttachmentCount = 1; diff --git a/src/effects/gaussian_blur_effect.cc b/src/effects/gaussian_blur_effect.cc index 02cd77e..7304321 100644 --- a/src/effects/gaussian_blur_effect.cc +++ b/src/effects/gaussian_blur_effect.cc @@ -68,11 +68,7 @@ void GaussianBlur::render(WGPUCommandEncoder encoder, // Render pass WGPURenderPassColorAttachment color_attachment = {}; - color_attachment.view = output_view; - color_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; - color_attachment.loadOp = WGPULoadOp_Clear; - color_attachment.storeOp = WGPUStoreOp_Store; - color_attachment.clearValue = {0.0, 0.0, 0.0, 1.0}; + gpu_init_color_attachment(color_attachment, output_view); WGPURenderPassDescriptor pass_desc = {}; pass_desc.colorAttachmentCount = 1; diff --git a/src/effects/heptagon_effect.cc b/src/effects/heptagon_effect.cc index 13d7aad..c472f2f 100644 --- a/src/effects/heptagon_effect.cc +++ b/src/effects/heptagon_effect.cc @@ -72,11 +72,7 @@ void Heptagon::render(WGPUCommandEncoder encoder, // Render pass WGPURenderPassColorAttachment color_attachment = {}; - color_attachment.view = output_view; - color_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; - color_attachment.loadOp = WGPULoadOp_Clear; - color_attachment.storeOp = WGPUStoreOp_Store; - color_attachment.clearValue = {0.0, 0.0, 0.0, 1.0}; + gpu_init_color_attachment(color_attachment, output_view); WGPURenderPassDescriptor pass_desc = {}; pass_desc.colorAttachmentCount = 1; diff --git a/src/effects/hybrid3_d_effect.cc b/src/effects/hybrid3_d_effect.cc index 1dd1c05..5832b57 100644 --- a/src/effects/hybrid3_d_effect.cc +++ b/src/effects/hybrid3_d_effect.cc @@ -106,12 +106,7 @@ void Hybrid3D::render(WGPUCommandEncoder encoder, // Render 3D scene using sequence encoder WGPURenderPassColorAttachment color_attachment = {}; -#if !defined(DEMO_CROSS_COMPILE_WIN32) - color_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; -#endif - color_attachment.view = color_view; - color_attachment.loadOp = WGPULoadOp_Clear; - color_attachment.storeOp = WGPUStoreOp_Store; + gpu_init_color_attachment(color_attachment, color_view); color_attachment.clearValue = {0.05f, 0.05f, 0.05f, 1.0f}; WGPURenderPassDepthStencilAttachment depth_attachment = {}; diff --git a/src/effects/particles_effect.cc b/src/effects/particles_effect.cc index 22e41e9..d83f303 100644 --- a/src/effects/particles_effect.cc +++ b/src/effects/particles_effect.cc @@ -84,12 +84,8 @@ void Particles::render(WGPUCommandEncoder encoder, // Run render pass (draw particles to output) WGPUTextureView output_view = nodes.get_view(output_nodes_[0]); - WGPURenderPassColorAttachment color_attachment = { - .view = output_view, - .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, - .loadOp = WGPULoadOp_Clear, - .storeOp = WGPUStoreOp_Store, - .clearValue = {0.0, 0.0, 0.0, 1.0}}; + WGPURenderPassColorAttachment color_attachment = {}; + gpu_init_color_attachment(color_attachment, output_view); WGPURenderPassDescriptor render_desc = { .colorAttachmentCount = 1, .colorAttachments = &color_attachment}; diff --git a/src/effects/passthrough_effect.cc b/src/effects/passthrough_effect.cc index 392102d..b9d9337 100644 --- a/src/effects/passthrough_effect.cc +++ b/src/effects/passthrough_effect.cc @@ -63,12 +63,8 @@ void Passthrough::render(WGPUCommandEncoder encoder, bind_group_ = wgpuDeviceCreateBindGroup(ctx_.device, &bg_desc); // Render pass - WGPURenderPassColorAttachment color_attachment = { - .view = output_view, - .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, - .loadOp = WGPULoadOp_Clear, - .storeOp = WGPUStoreOp_Store, - .clearValue = {0.0, 0.0, 0.0, 1.0}}; + WGPURenderPassColorAttachment color_attachment = {}; + gpu_init_color_attachment(color_attachment, output_view); WGPURenderPassDescriptor pass_desc = {}; pass_desc.colorAttachmentCount = 1; diff --git a/src/effects/peak_meter_effect.cc b/src/effects/peak_meter_effect.cc index 63be2c0..d823e20 100644 --- a/src/effects/peak_meter_effect.cc +++ b/src/effects/peak_meter_effect.cc @@ -81,11 +81,8 @@ void PeakMeter::render(WGPUCommandEncoder encoder, uniforms_buffer_.get(), {nullptr, 0}); WGPURenderPassColorAttachment color_attachment = {}; - color_attachment.view = output_view; - color_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; + gpu_init_color_attachment(color_attachment, output_view); color_attachment.loadOp = WGPULoadOp_Load; - color_attachment.storeOp = WGPUStoreOp_Store; - color_attachment.clearValue = {0.0, 0.0, 0.0, 1.0}; WGPURenderPassDescriptor pass_desc = {}; pass_desc.colorAttachmentCount = 1; diff --git a/src/effects/placeholder_effect.cc b/src/effects/placeholder_effect.cc index 6ba665a..3367f1c 100644 --- a/src/effects/placeholder_effect.cc +++ b/src/effects/placeholder_effect.cc @@ -45,12 +45,8 @@ void Placeholder::render(WGPUCommandEncoder encoder, pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, uniforms_buffer_.get(), {nullptr, 0}); - WGPURenderPassColorAttachment color_attachment = { - .view = output_view, - .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, - .loadOp = WGPULoadOp_Clear, - .storeOp = WGPUStoreOp_Store, - .clearValue = {0.0, 0.0, 0.0, 1.0}}; + WGPURenderPassColorAttachment color_attachment = {}; + gpu_init_color_attachment(color_attachment, output_view); WGPURenderPassDescriptor pass_desc = {}; pass_desc.colorAttachmentCount = 1; diff --git a/src/effects/rotating_cube_effect.cc b/src/effects/rotating_cube_effect.cc index 0f1781d..6c350a7 100644 --- a/src/effects/rotating_cube_effect.cc +++ b/src/effects/rotating_cube_effect.cc @@ -163,9 +163,9 @@ void RotatingCube::render(WGPUCommandEncoder encoder, WGPUTexture input_tex = nodes.get_texture(input_nodes_[0]); WGPUTexture output_tex = nodes.get_texture(output_nodes_[0]); if (input_tex && output_tex) { - WGPUTexelCopyTextureInfo src = { + GpuTextureCopyInfo src = { .texture = input_tex, .mipLevel = 0, .aspect = WGPUTextureAspect_All}; - WGPUTexelCopyTextureInfo dst = {.texture = output_tex, + GpuTextureCopyInfo dst = {.texture = output_tex, .mipLevel = 0, .aspect = WGPUTextureAspect_All}; WGPUExtent3D copy_size = {(uint32_t)params.resolution.x, @@ -181,7 +181,9 @@ void RotatingCube::render(WGPUCommandEncoder encoder, // Render pass with depth WGPURenderPassColorAttachment color_attachment = { .view = color_view, + #if !defined(DEMO_CROSS_COMPILE_WIN32) .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, +#endif // .loadOp = WGPULoadOp_Clear, .loadOp = WGPULoadOp_Load, .storeOp = WGPUStoreOp_Store, diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h index 5e928b2..de6c5ba 100644 --- a/src/gpu/gpu.h +++ b/src/gpu/gpu.h @@ -66,7 +66,9 @@ inline void gpu_init_color_attachment(WGPURenderPassColorAttachment& attachment, attachment.loadOp = WGPULoadOp_Clear; attachment.storeOp = WGPUStoreOp_Store; attachment.clearValue = {0.0f, 0.0f, 0.0f, 1.0f}; +#if !defined(DEMO_CROSS_COMPILE_WIN32) attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; +#endif } // Texture creation helper -- cgit v1.2.3