From 3c10be859e71c05803983539616a1f8685b4780a Mon Sep 17 00:00:00 2001 From: Jerome Humbert Date: Sat, 2 Mar 2024 13:14:07 +0000 Subject: [PATCH] Fix regression in flipbook Fix a regression in the flipbook shader code where some variable previously emitted as `i32` by error instead of its actual `u32` type is now producing the correct literal value, resulting in an invalid shader operation between mismatching operand types. Cast the value to `i32` explicitly before emitting the shader code to ensure the value is emitted in the expected type. --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 12e8ff9f..82143ec6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -960,7 +960,8 @@ impl EffectShaderSource { render_context.sprite_grid_size { layout_flags |= LayoutFlags::FLIPBOOK; - let flipbook_row_count_code = grid_size.x.to_wgsl_string(); + // Note: row_count needs to be i32, not u32, because of sprite_index + let flipbook_row_count_code = (grid_size.x as i32).to_wgsl_string(); let flipbook_scale_code = Vec2::new(1.0 / grid_size.x as f32, 1.0 / grid_size.y as f32).to_wgsl_string(); (flipbook_scale_code, flipbook_row_count_code)