From 7d0b95a03ace98c4e859cd071a85127cffc43b6f Mon Sep 17 00:00:00 2001 From: jaydevelopsstuff <70743392+jaydevelopsstuff@users.noreply.github.com> Date: Mon, 8 Jun 2026 23:41:28 -0700 Subject: [PATCH 1/7] Create rust-toolchain.toml to specify toolchain as nightly --- rust-toolchain.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly" From eef7f85e3a4c891323646bf4b236b0558c9f9e79 Mon Sep 17 00:00:00 2001 From: jaydevelopsstuff <70743392+jaydevelopsstuff@users.noreply.github.com> Date: Mon, 8 Jun 2026 23:44:37 -0700 Subject: [PATCH 2/7] Upgrade to bevy 0.18 and wgpu 27 --- bevy_gpu_compute/Cargo.toml | 4 ++-- .../collision_detection_barebones/main.rs | 11 ++++++++--- .../collision_detection_barebones/visuals.rs | 16 +++++++++------- .../collision_detection_demonstration/main.rs | 11 ++++++++--- .../collision_detection_demonstration/visuals.rs | 16 +++++++++------- bevy_gpu_compute/src/plugin.rs | 2 +- bevy_gpu_compute/src/spawn_fallback_camera.rs | 11 ++++++----- .../src/system_params/task_deleter.rs | 4 ++-- .../update_on_pipeline_const_change.rs | 9 ++++++++- bevy_gpu_compute/src/task/lib.rs | 14 ++++++++------ .../helpers/get_gpu_output_as_bytes_vec.rs | 2 +- .../helpers/get_gpu_output_counter_value.rs | 2 +- .../task_components/configuration/wgsl_code.rs | 4 ++-- 13 files changed, 65 insertions(+), 41 deletions(-) diff --git a/bevy_gpu_compute/Cargo.toml b/bevy_gpu_compute/Cargo.toml index 835b37e..0ad23d5 100644 --- a/bevy_gpu_compute/Cargo.toml +++ b/bevy_gpu_compute/Cargo.toml @@ -17,10 +17,10 @@ exclude = [ [dependencies] bevy_gpu_compute_macro = { path = "../bevy_gpu_compute_macro", version = "0.1"} bevy_gpu_compute_core = { path = "../bevy_gpu_compute_core", version = "0.1"} -bevy = "0.15" +bevy = "0.18.1" futures = "0.3.31" pollster = "0.4.0" -wgpu = "23.0.1" +wgpu = "27" sysinfo = "0.33.0" bytemuck = {version = "1.21.0", features=["derive"]} diff --git a/bevy_gpu_compute/examples/collision_detection_barebones/main.rs b/bevy_gpu_compute/examples/collision_detection_barebones/main.rs index 132f770..8ab7b61 100644 --- a/bevy_gpu_compute/examples/collision_detection_barebones/main.rs +++ b/bevy_gpu_compute/examples/collision_detection_barebones/main.rs @@ -4,8 +4,9 @@ Demonstrates only the features from BevyGpuCompute necessary for collision detec use bevy::{ DefaultPlugins, app::{App, AppExit, Startup, Update}, + ecs::message::MessageWriter, log, - prelude::{EventWriter, IntoSystemConfigs, Local, Query, Res, ResMut, Resource}, + prelude::{IntoScheduleConfigs, Local, Query, Res, ResMut, Resource}, }; use bevy_gpu_compute::prelude::*; mod visuals; @@ -152,12 +153,16 @@ fn handle_task_results(mut gpu_task_reader: GpuTaskReader, mut state: ResMut, state: Res, mut exit: EventWriter) { +fn exit_and_show_results( + mut count: Local, + state: Res, + mut exit: MessageWriter, +) { if *count > EXIT_AFTER_FRAMES { let total_collisions = state.collisions_per_frame.iter().sum::(); log::trace!("total collisions count at exit: {}", total_collisions); log::info!("Example completed successfully"); - exit.send(AppExit::Success); + exit.write(AppExit::Success); } *count += 1; } diff --git a/bevy_gpu_compute/examples/collision_detection_barebones/visuals.rs b/bevy_gpu_compute/examples/collision_detection_barebones/visuals.rs index e28d8d0..d5d24d3 100644 --- a/bevy_gpu_compute/examples/collision_detection_barebones/visuals.rs +++ b/bevy_gpu_compute/examples/collision_detection_barebones/visuals.rs @@ -1,15 +1,17 @@ use bevy::{ asset::Handle, + camera::Projection, log, - prelude::{Color, Component, FromWorld, Resource, World}, - sprite::ColorMaterial, - utils::hashbrown::HashMap, + platform::collections::HashMap, + prelude::{Color, ColorMaterial, Component, FromWorld, Resource, World}, }; use bevy::{ asset::{Assets, RenderAssetUsages}, math::{Vec2, Vec3, bounding::BoundingCircle}, - prelude::{Camera2d, Commands, Mesh, Mesh2d, OrthographicProjection, Res, ResMut, Transform}, - sprite::MeshMaterial2d, + prelude::{ + Camera2d, Commands, Mesh, Mesh2d, MeshMaterial2d, OrthographicProjection, Res, ResMut, + Transform, + }, utils::default, }; @@ -53,12 +55,12 @@ pub fn spawn_entities( pub fn spawn_camera(mut commands: Commands) { commands.spawn(( Camera2d, - OrthographicProjection { + Projection::Orthographic(OrthographicProjection { near: -1000.0, far: 1000.0, scale: 0.1, ..OrthographicProjection::default_2d() - }, + }), Transform::from_xyz( 0., 0., 10.0, // 100.0, ), diff --git a/bevy_gpu_compute/examples/collision_detection_demonstration/main.rs b/bevy_gpu_compute/examples/collision_detection_demonstration/main.rs index 9056586..746adf9 100644 --- a/bevy_gpu_compute/examples/collision_detection_demonstration/main.rs +++ b/bevy_gpu_compute/examples/collision_detection_demonstration/main.rs @@ -5,8 +5,9 @@ Demonstrates all features of the BevyGpuCompute library use bevy::{ DefaultPlugins, app::{App, AppExit, PluginGroup, Startup, Update}, + ecs::message::MessageWriter, log::{self, LogPlugin}, - prelude::{EventWriter, IntoSystemConfigs, Local, Query, Res, ResMut, Resource}, + prelude::{IntoScheduleConfigs, Local, Query, Res, ResMut, Resource}, }; use bevy_gpu_compute::prelude::*; mod visuals; @@ -230,7 +231,11 @@ fn handle_task_results(mut gpu_task_reader: GpuTaskReader, mut state: ResMut, state: Res, mut exit: EventWriter) { +fn exit_and_show_results( + mut count: Local, + state: Res, + mut exit: MessageWriter, +) { if *count > EXIT_AFTER_FRAMES { let total_collisions = state.collisions_per_frame.iter().sum::(); log::trace!("total collisions count at exit: {}", total_collisions); @@ -251,7 +256,7 @@ fn exit_and_show_results(mut count: Local, state: Res, mut exit: Eve state.collisions_per_frame[2] ); log::info!("Example completed successfully"); - exit.send(AppExit::Success); + exit.write(AppExit::Success); } *count += 1; } diff --git a/bevy_gpu_compute/examples/collision_detection_demonstration/visuals.rs b/bevy_gpu_compute/examples/collision_detection_demonstration/visuals.rs index e28d8d0..d5d24d3 100644 --- a/bevy_gpu_compute/examples/collision_detection_demonstration/visuals.rs +++ b/bevy_gpu_compute/examples/collision_detection_demonstration/visuals.rs @@ -1,15 +1,17 @@ use bevy::{ asset::Handle, + camera::Projection, log, - prelude::{Color, Component, FromWorld, Resource, World}, - sprite::ColorMaterial, - utils::hashbrown::HashMap, + platform::collections::HashMap, + prelude::{Color, ColorMaterial, Component, FromWorld, Resource, World}, }; use bevy::{ asset::{Assets, RenderAssetUsages}, math::{Vec2, Vec3, bounding::BoundingCircle}, - prelude::{Camera2d, Commands, Mesh, Mesh2d, OrthographicProjection, Res, ResMut, Transform}, - sprite::MeshMaterial2d, + prelude::{ + Camera2d, Commands, Mesh, Mesh2d, MeshMaterial2d, OrthographicProjection, Res, ResMut, + Transform, + }, utils::default, }; @@ -53,12 +55,12 @@ pub fn spawn_entities( pub fn spawn_camera(mut commands: Commands) { commands.spawn(( Camera2d, - OrthographicProjection { + Projection::Orthographic(OrthographicProjection { near: -1000.0, far: 1000.0, scale: 0.1, ..OrthographicProjection::default_2d() - }, + }), Transform::from_xyz( 0., 0., 10.0, // 100.0, ), diff --git a/bevy_gpu_compute/src/plugin.rs b/bevy_gpu_compute/src/plugin.rs index d0322e8..67f1740 100644 --- a/bevy_gpu_compute/src/plugin.rs +++ b/bevy_gpu_compute/src/plugin.rs @@ -1,6 +1,6 @@ use bevy::{ app::{App, Plugin, Startup, Update}, - prelude::{AppExtStates, IntoSystemConfigs, States, in_state}, + prelude::{AppExtStates, IntoScheduleConfigs, States, in_state}, }; use crate::{ diff --git a/bevy_gpu_compute/src/spawn_fallback_camera.rs b/bevy_gpu_compute/src/spawn_fallback_camera.rs index eed7df8..22e437b 100644 --- a/bevy_gpu_compute/src/spawn_fallback_camera.rs +++ b/bevy_gpu_compute/src/spawn_fallback_camera.rs @@ -1,8 +1,9 @@ use bevy::{ + camera::Projection, log, prelude::{ - Camera, Camera2d, Commands, Component, DespawnRecursiveExt, Entity, OrthographicProjection, - Query, Res, Transform, + Camera, Camera2d, Commands, Component, Entity, OrthographicProjection, Query, Res, + Transform, }, time::Time, }; @@ -26,12 +27,12 @@ pub fn spawn_fallback_camera( ); commands.spawn(( Camera2d, - OrthographicProjection { + Projection::Orthographic(OrthographicProjection { near: -10.0, far: 10.0, scale: 1., ..OrthographicProjection::default_2d() - }, + }), Transform::from_xyz( 0., 0., 10.0, // 100.0, ), @@ -46,7 +47,7 @@ pub fn spawn_fallback_camera( let fallback_cam_len = fallback_cameras.iter().len(); if fallback_cam_len > 0 { fallback_cameras.iter().for_each(|(e, _)| { - commands.entity(e).despawn_recursive(); + commands.entity(e).despawn(); }); } } diff --git a/bevy_gpu_compute/src/system_params/task_deleter.rs b/bevy_gpu_compute/src/system_params/task_deleter.rs index 314c054..d2d18e0 100644 --- a/bevy_gpu_compute/src/system_params/task_deleter.rs +++ b/bevy_gpu_compute/src/system_params/task_deleter.rs @@ -1,6 +1,6 @@ use bevy::{ ecs::system::SystemParam, - prelude::{Commands, DespawnRecursiveExt, Entity, Query}, + prelude::{Commands, Entity, Query}, }; use crate::task::lib::BevyGpuComputeTask; @@ -20,6 +20,6 @@ impl BevyGpuComputeTaskDeleter<'_, '_> { .iter_mut() .find(|(_, task)| task.name() == name) .expect("Task not found"); - self.commands.entity(entity).despawn_recursive(); + self.commands.entity(entity).despawn(); } } diff --git a/bevy_gpu_compute/src/task/compute_pipeline/update_on_pipeline_const_change.rs b/bevy_gpu_compute/src/task/compute_pipeline/update_on_pipeline_const_change.rs index 20e3f78..d432919 100644 --- a/bevy_gpu_compute/src/task/compute_pipeline/update_on_pipeline_const_change.rs +++ b/bevy_gpu_compute/src/task/compute_pipeline/update_on_pipeline_const_change.rs @@ -26,6 +26,13 @@ pub fn update_compute_pipeline(task: &mut BevyGpuComputeTask, render_device: &Re "pipeline layout {:?}", task.runtime_state().pipeline_layout() ); + + let pipeline_consts = task.get_pipeline_consts(); + let constants_vec: Vec<(&str, f64)> = pipeline_consts + .iter() + .map(|(k, v)| (k.as_str(), *v)) + .collect(); + let compute_pipeline = render_device.create_compute_pipeline(&ComputePipelineDescriptor { label: Some(task.name()), layout: Some(task.runtime_state().pipeline_layout()), @@ -33,7 +40,7 @@ pub fn update_compute_pipeline(task: &mut BevyGpuComputeTask, render_device: &Re entry_point: Some(task.configuration().shader().entry_point_function_name()), // this is where we specify new values for pipeline constants... compilation_options: PipelineCompilationOptions { - constants: &task.get_pipeline_consts(), + constants: &constants_vec, zero_initialize_workgroup_memory: Default::default(), }, cache: None, diff --git a/bevy_gpu_compute/src/task/lib.rs b/bevy_gpu_compute/src/task/lib.rs index 2dcdcda..1e57213 100644 --- a/bevy_gpu_compute/src/task/lib.rs +++ b/bevy_gpu_compute/src/task/lib.rs @@ -82,12 +82,14 @@ impl BevyGpuComputeTask { render_device, iteration_space, max_output_vector_lengths, - WgslCode::from_string( - name, - render_device, - full_module.wgsl_code(iteration_space.num_dimmensions()), - "main".to_string(), - ), + unsafe { + WgslCode::from_string( + name, + render_device, + full_module.wgsl_code(iteration_space.num_dimmensions()), + "main".to_string(), + ) + }, ) } diff --git a/bevy_gpu_compute/src/task/outputs/helpers/get_gpu_output_as_bytes_vec.rs b/bevy_gpu_compute/src/task/outputs/helpers/get_gpu_output_as_bytes_vec.rs index 20656a2..91eb8ec 100644 --- a/bevy_gpu_compute/src/task/outputs/helpers/get_gpu_output_as_bytes_vec.rs +++ b/bevy_gpu_compute/src/task/outputs/helpers/get_gpu_output_as_bytes_vec.rs @@ -18,7 +18,7 @@ pub fn get_gpu_output_as_bytes_vec( slice.map_async(wgpu::MapMode::Read, move |result| { sender.send(result).unwrap(); }); - render_device.poll(wgpu::Maintain::Wait); + let _ = render_device.poll(wgpu::PollType::wait_indefinitely()); let result: Option> = if receiver.block_on().unwrap().is_ok() { let data = slice.get_mapped_range(); diff --git a/bevy_gpu_compute/src/task/outputs/helpers/get_gpu_output_counter_value.rs b/bevy_gpu_compute/src/task/outputs/helpers/get_gpu_output_counter_value.rs index aeac2b8..679b96e 100644 --- a/bevy_gpu_compute/src/task/outputs/helpers/get_gpu_output_counter_value.rs +++ b/bevy_gpu_compute/src/task/outputs/helpers/get_gpu_output_counter_value.rs @@ -24,7 +24,7 @@ pub fn get_gpu_output_counter_value( slice.map_async(wgpu::MapMode::Read, move |result| { sender.send(result).unwrap(); }); - render_device.poll(wgpu::Maintain::Wait); + let _ = render_device.poll(wgpu::PollType::wait_indefinitely()); let result = if receiver.block_on().unwrap().is_ok() { let data = slice.get_mapped_range(); let transformed_data = &*data; diff --git a/bevy_gpu_compute/src/task/task_components/configuration/wgsl_code.rs b/bevy_gpu_compute/src/task/task_components/configuration/wgsl_code.rs index 5f7d2a5..ac530c7 100644 --- a/bevy_gpu_compute/src/task/task_components/configuration/wgsl_code.rs +++ b/bevy_gpu_compute/src/task/task_components/configuration/wgsl_code.rs @@ -18,7 +18,7 @@ impl Default for WgslCode { } impl WgslCode { - pub fn from_string( + pub unsafe fn from_string( label: &str, render_device: &RenderDevice, wgsl_code: String, @@ -33,7 +33,7 @@ impl WgslCode { })), } } - pub fn from_file( + pub unsafe fn from_file( label: &str, render_device: &RenderDevice, file_path: &str, From f03a06caf0bd852df64e65f788d82e02b24e6fd1 Mon Sep 17 00:00:00 2001 From: jaydevelopsstuff <70743392+jaydevelopsstuff@users.noreply.github.com> Date: Mon, 8 Jun 2026 23:47:46 -0700 Subject: [PATCH 3/7] Explicitly wrap unsafe code in WgslCode even if fn is marked unsafe --- .../task/task_components/configuration/wgsl_code.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bevy_gpu_compute/src/task/task_components/configuration/wgsl_code.rs b/bevy_gpu_compute/src/task/task_components/configuration/wgsl_code.rs index ac530c7..3d8a6e6 100644 --- a/bevy_gpu_compute/src/task/task_components/configuration/wgsl_code.rs +++ b/bevy_gpu_compute/src/task/task_components/configuration/wgsl_code.rs @@ -27,10 +27,12 @@ impl WgslCode { Self { code: wgsl_code.clone(), entry_point_function_name, - shader_module: Some(render_device.create_shader_module(ShaderModuleDescriptor { - label: Some(label), - source: ShaderSource::Wgsl(wgsl_code.into()), - })), + shader_module: Some(unsafe { + render_device.create_shader_module(ShaderModuleDescriptor { + label: Some(label), + source: ShaderSource::Wgsl(wgsl_code.into()), + }) + }), } } pub unsafe fn from_file( @@ -40,7 +42,7 @@ impl WgslCode { entry_point_function_name: String, ) -> Self { let code = std::fs::read_to_string(file_path).unwrap(); - Self::from_string(label, render_device, code, entry_point_function_name) + unsafe { Self::from_string(label, render_device, code, entry_point_function_name) } } pub fn code(&self) -> &str { &self.code From c99bacfb415c4f7a216c96a340340d946c114c52 Mon Sep 17 00:00:00 2001 From: jaydevelopsstuff <70743392+jaydevelopsstuff@users.noreply.github.com> Date: Mon, 8 Jun 2026 23:58:23 -0700 Subject: [PATCH 4/7] Pin nightly version and specify components and profile for toolchain --- rust-toolchain.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d56faf..b18a715 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,4 @@ [toolchain] -channel = "nightly" +channel = "nightly-2026-06-07" +components = ["rustfmt", "clippy"] +profile = "minimal" From 529b67c8d7e599604586694f4ef0014d3ec97708 Mon Sep 17 00:00:00 2001 From: jaydevelopsstuff <70743392+jaydevelopsstuff@users.noreply.github.com> Date: Tue, 9 Jun 2026 00:01:01 -0700 Subject: [PATCH 5/7] Use prelude import instead of ecs::message for MessageWriter --- .../examples/collision_detection_barebones/main.rs | 3 +-- .../examples/collision_detection_demonstration/main.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/bevy_gpu_compute/examples/collision_detection_barebones/main.rs b/bevy_gpu_compute/examples/collision_detection_barebones/main.rs index 8ab7b61..82b979a 100644 --- a/bevy_gpu_compute/examples/collision_detection_barebones/main.rs +++ b/bevy_gpu_compute/examples/collision_detection_barebones/main.rs @@ -4,9 +4,8 @@ Demonstrates only the features from BevyGpuCompute necessary for collision detec use bevy::{ DefaultPlugins, app::{App, AppExit, Startup, Update}, - ecs::message::MessageWriter, log, - prelude::{IntoScheduleConfigs, Local, Query, Res, ResMut, Resource}, + prelude::{IntoScheduleConfigs, MessageWriter, Local, Query, Res, ResMut, Resource}, }; use bevy_gpu_compute::prelude::*; mod visuals; diff --git a/bevy_gpu_compute/examples/collision_detection_demonstration/main.rs b/bevy_gpu_compute/examples/collision_detection_demonstration/main.rs index 746adf9..4bc833b 100644 --- a/bevy_gpu_compute/examples/collision_detection_demonstration/main.rs +++ b/bevy_gpu_compute/examples/collision_detection_demonstration/main.rs @@ -5,9 +5,8 @@ Demonstrates all features of the BevyGpuCompute library use bevy::{ DefaultPlugins, app::{App, AppExit, PluginGroup, Startup, Update}, - ecs::message::MessageWriter, log::{self, LogPlugin}, - prelude::{IntoScheduleConfigs, Local, Query, Res, ResMut, Resource}, + prelude::{IntoScheduleConfigs, MessageWriter, Local, Query, Res, ResMut, Resource}, }; use bevy_gpu_compute::prelude::*; mod visuals; From 11430867fec93290c65ba233b536aadcd3779dfa Mon Sep 17 00:00:00 2001 From: jaydevelopsstuff <70743392+jaydevelopsstuff@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:22:23 -0700 Subject: [PATCH 6/7] Add safety comment for unsafe block in lib.rs --- bevy_gpu_compute/src/task/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/bevy_gpu_compute/src/task/lib.rs b/bevy_gpu_compute/src/task/lib.rs index 1e57213..1549a9a 100644 --- a/bevy_gpu_compute/src/task/lib.rs +++ b/bevy_gpu_compute/src/task/lib.rs @@ -82,6 +82,7 @@ impl BevyGpuComputeTask { render_device, iteration_space, max_output_vector_lengths, + // SAFETY: wgsl_shader_module is compiled and validated unsafe { WgslCode::from_string( name, From b8b8b8bf359d9e2de553572b4c165ef9b7b5bd44 Mon Sep 17 00:00:00 2001 From: jaydevelopsstuff <70743392+jaydevelopsstuff@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:39:53 -0700 Subject: [PATCH 7/7] Don't pin nightly version to a specific date --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b18a715..509da7f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2026-06-07" +channel = "nightly" components = ["rustfmt", "clippy"] profile = "minimal"