bevy/crates
Nándor Szalma 7f74e3c2f9
Fix depth_bias and build errors on less capable platforms (#17079)
# Objective

- I'm compiling (parts of) bevy for an embedded platform with no 64bit
atomic and ctrlc handler support. Some compilation errors came up. This
PR contains the fixes for those.
- Fix depth_bias casting in PBR material (Fixes #14169)
  - Negative depth_bias values were casted to 0 before this PR
  - f32::INFINITY depth_bias value was casted to -1 before this PR

## Solutions

- Restrict 64bit atomic reflection to supported platforms
- Restrict ctrlc handler to supported platforms (linux, windows or macos
instead of "not wasm")
- The depth bias value (f32) is first casted to i32 then u64 in order to
preserve negative values

## Testing
- This version compiles on a platform with no 64bit atomic support, and
no ctrlc support
- CtrlC handler still works on Linux and Windows (I can't test on Macos)
- depth_bias:
```rust
println!("{}",f32::INFINITY as u64 as i32); // Prints: -1 (old implementation)
println!("{}",f32::INFINITY as i32 as u64 as i32); // Prints: 2147483647 (expected, new implementation)
```
Also ran a modified version of 3d_scene example with the following
results:

RED cube depth_bias: -1000.0
BLUE cube depth_bias: 0.0

![image](https://github.com/user-attachments/assets/d5a96759-dd3c-4a0a-97ff-821163873a0d)

RED cube depth_bias: -INF
BLUE cube depth_bias: 0.0

![image](https://github.com/user-attachments/assets/e4de22b4-0c31-4dea-8be1-12b700e440b9)

RED cube depth_bias: INF (case reported in #14169)
BLUE cube depth_bias: 0.0
(Im not completely sure whats going on with the shadows here, it seems
like depth_bias has some affect to those aswell, if this is
unintentional this issue was not introduced by this PR)

![image](https://github.com/user-attachments/assets/52d9348f-df27-468f-a001-2d3d3ff6b553)
2025-01-06 18:39:08 +00:00
..
bevy_a11y Update all previously-merged #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] attributes to include a reason field pointing to the tracking issue (#17136) 2025-01-06 05:40:08 +00:00
bevy_animation Update all previously-merged #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] attributes to include a reason field pointing to the tracking issue (#17136) 2025-01-06 05:40:08 +00:00
bevy_app Fix depth_bias and build errors on less capable platforms (#17079) 2025-01-06 18:39:08 +00:00
bevy_asset Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_audio Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_color Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_core_pipeline Introduce two-level bins for multidrawable meshes. (#16898) 2025-01-06 18:34:40 +00:00
bevy_derive Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_dev_tools Fix depth_bias and build errors on less capable platforms (#17079) 2025-01-06 18:39:08 +00:00
bevy_diagnostic Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_dylib Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_ecs Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_encase_derive Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_gilrs Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_gizmos Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_gltf Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_hierarchy Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_image Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_input Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_input_focus Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_internal Fix depth_bias and build errors on less capable platforms (#17079) 2025-01-06 18:39:08 +00:00
bevy_log Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_macro_utils Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_math Update all previously-merged #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] attributes to include a reason field pointing to the tracking issue (#17136) 2025-01-06 05:40:08 +00:00
bevy_mesh Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_mikktspace Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_pbr Fix depth_bias and build errors on less capable platforms (#17079) 2025-01-06 18:39:08 +00:00
bevy_picking Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_ptr Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_reflect Fix depth_bias and build errors on less capable platforms (#17079) 2025-01-06 18:39:08 +00:00
bevy_remote Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_render Introduce two-level bins for multidrawable meshes. (#16898) 2025-01-06 18:34:40 +00:00
bevy_scene Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_sprite Introduce two-level bins for multidrawable meshes. (#16898) 2025-01-06 18:34:40 +00:00
bevy_state Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_tasks Update all previously-merged #![deny(clippy::allow_attributes, clippy::allow_attributes_without_reason)] attributes to include a reason field pointing to the tracking issue (#17136) 2025-01-06 05:40:08 +00:00
bevy_text Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_time Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_transform Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_ui Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_utils Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_window Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00
bevy_winit Bump Version after Release (#17176) 2025-01-06 00:04:44 +00:00