Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bevy 0.13 upgrade #89

Merged
merged 7 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_gaussian_splatting"
description = "bevy gaussian splatting render pipeline plugin"
version = "2.0.2"
version = "2.1.0"
edition = "2021"
authors = ["mosure <mitchell@mosure.me>"]
license = "MIT"
Expand Down Expand Up @@ -114,6 +114,7 @@ viewer = [
# "bevy_transform_gizmo",
"bevy/multi-threaded", # bevy screenshot functionality requires bevy/multi-threaded as of 0.12.1
"clap",
"bevy/bevy_ui",
]

web = [
Expand All @@ -128,13 +129,14 @@ web = [
]

webgl2 = ["bevy/webgl2"]
webgpu = ["bevy/webgpu"]


[dependencies]
bevy_args = { version = "1.2.0", optional = true }
bevy-inspector-egui = { version = "0.22", optional = true }
bevy_args = { version = "1.3.0", optional = true }
bevy-inspector-egui = { version = "0.23", optional = true }
bevy_mod_picking = { version = "0.17", optional = true }
bevy_panorbit_camera = { version = "0.12", optional = true }
bevy_panorbit_camera = { version = "0.14", optional = true }
bevy_transform_gizmo = { version = "0.10", optional = true }
bincode2 = { version = "2.0", optional = true }
byte-unit = { version = "5.0", optional = true }
Expand All @@ -152,7 +154,7 @@ rayon = { version = "1.8", optional = true }
serde = "1.0"
static_assertions = "1.1"
typenum = "1.17.0"
wgpu = "0.17.1"
wgpu = "0.19.1"


[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand All @@ -161,7 +163,7 @@ wasm-bindgen = "0.2.89"


[dependencies.bevy]
version = "0.12"
version = "0.13.0"
default-features = false
features = [
"bevy_asset",
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ fn setup_gaussian_cloud(

| `bevy_gaussian_splatting` | `bevy` |
| :-- | :-- |
| `0.4 - 1.0` | `0.12` |
| `2.1` | `0.13` |
| `0.4 - 2.0` | `0.12` |
| `0.1 - 0.3` | `0.11` |

## projects using this plugin
Expand Down
15 changes: 6 additions & 9 deletions examples/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ use bevy::{
render::renderer::RenderDevice,
};
use bevy_args::BevyArgsPlugin;
use bevy_panorbit_camera::{
PanOrbitCamera,
PanOrbitCameraPlugin,
};

use bevy_gaussian_splatting::{
GaussianCloud,
Expand All @@ -31,7 +27,7 @@ mod frame_capture {

use bevy::prelude::*;
use bevy::render::render_asset::RenderAssets;
use bevy::render::render_graph::{self, NodeRunError, RenderGraph, RenderGraphContext};
use bevy::render::render_graph::{self, NodeRunError, RenderGraph, RenderGraphContext, RenderLabel};
use bevy::render::renderer::{RenderContext, RenderDevice, RenderQueue};
use bevy::render::{Extract, RenderApp};

Expand Down Expand Up @@ -77,7 +73,8 @@ mod frame_capture {
}
}

pub const IMAGE_COPY: &str = "image_copy";
#[derive(Debug, Hash, PartialEq, Eq, Clone, RenderLabel)]
pub struct ImageCopyLabel;

pub struct ImageCopyPlugin;
impl Plugin for ImageCopyPlugin {
Expand All @@ -90,9 +87,9 @@ mod frame_capture {

let mut graph = render_app.world.get_resource_mut::<RenderGraph>().unwrap();

graph.add_node(IMAGE_COPY, ImageCopyDriver);
graph.add_node(ImageCopyLabel, ImageCopyDriver);

graph.add_node_edge(IMAGE_COPY, bevy::render::main_graph::node::CAMERA_DRIVER);
graph.add_node_edge(ImageCopyLabel, bevy::render::graph::CameraDriverLabel);
}
}

Expand Down Expand Up @@ -171,7 +168,7 @@ mod frame_capture {
.create_command_encoder(&CommandEncoderDescriptor::default());

let block_dimensions = src_image.texture_format.block_dimensions();
let block_size = src_image.texture_format.block_size(None).unwrap();
let block_size = src_image.texture_format.block_copy_size(None).unwrap();

let padded_bytes_per_row = RenderDevice::align_copy_bytes_per_row(
(src_image.size.x as usize / block_dimensions.0 as usize)
Expand Down
11 changes: 2 additions & 9 deletions src/gaussian/cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ use rand::{
seq::SliceRandom,
Rng,
};
use std::iter::FromIterator;

use bevy::{
prelude::*,
reflect::TypeUuid,
};
use bevy::prelude::*;
use serde::{
Deserialize,
Serialize,
Expand Down Expand Up @@ -52,11 +48,9 @@ use crate::gaussian::f16::{
Default,
PartialEq,
Reflect,
TypeUuid,
Serialize,
Deserialize,
)]
#[uuid = "ac2f08eb-bc32-aabb-ff21-51571ea332d5"]
pub struct GaussianCloud {
pub position_visibility: Vec<PositionVisibility>,

Expand All @@ -77,11 +71,10 @@ pub struct GaussianCloud {
Default,
PartialEq,
Reflect,
TypeUuid,
TypePath,
Serialize,
Deserialize,
)]
#[uuid = "ac2f08eb-bc32-aabb-ff21-51571ea332d5"]
pub struct GaussianCloud {
pub position_visibility: Vec<PositionVisibility>,

Expand Down
41 changes: 20 additions & 21 deletions src/morph/particle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,27 @@ use bevy::{
load_internal_asset,
LoadState,
},
core_pipeline::core_3d::CORE_3D,
core_pipeline::core_3d::graph::{
Core3d,
Node3d,
},
ecs::system::{
lifetimeless::SRes,
SystemParamItem,
},
reflect::TypeUuid,
render::{
Extract,
render_asset::{
PrepareAssetError,
RenderAsset,
RenderAssets,
RenderAssetPlugin,
RenderAssetUsages,
},
render_resource::{
BindGroup,
BindGroupEntry,
BindGroupLayout,
BindGroupLayoutDescriptor,
BindGroupLayoutEntry,
BindingResource,
BindingType,
Expand Down Expand Up @@ -111,13 +113,13 @@ impl Plugin for ParticleBehaviorPlugin {
if let Ok(render_app) = app.get_sub_app_mut(RenderApp) {
render_app
.add_render_graph_node::<ParticleBehaviorNode>(
CORE_3D,
Core3d,
node::MORPH,
)
.add_render_graph_edge(
CORE_3D,
Core3d,
node::MORPH,
bevy::core_pipeline::core_3d::graph::node::PREPASS,
Node3d::Prepass,
);

render_app
Expand Down Expand Up @@ -170,24 +172,19 @@ pub struct GpuParticleBehaviorBuffers {
}

impl RenderAsset for ParticleBehaviors {
type ExtractedAsset = ParticleBehaviors;
type PreparedAsset = GpuParticleBehaviorBuffers;
type Param = SRes<RenderDevice>;

fn extract_asset(&self) -> Self::ExtractedAsset {
self.clone()
}

fn prepare_asset(
particle_behaviors: Self::ExtractedAsset,
self,
render_device: &mut SystemParamItem<Self::Param>,
) -> Result<Self::PreparedAsset, PrepareAssetError<Self::ExtractedAsset>> {
let particle_behavior_count = particle_behaviors.0.len() as u32;
) -> Result<Self::PreparedAsset, PrepareAssetError<Self>> {
let particle_behavior_count = self.0.len() as u32;

let particle_behavior_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor {
label: Some("particle behavior buffer"),
contents: bytemuck::cast_slice(
particle_behaviors.0.as_slice()
self.0.as_slice()
),
usage: BufferUsages::VERTEX | BufferUsages::COPY_DST | BufferUsages::STORAGE,
});
Expand All @@ -197,6 +194,10 @@ impl RenderAsset for ParticleBehaviors {
particle_behavior_buffer,
})
}

fn asset_usage(&self) -> RenderAssetUsages {
RenderAssetUsages::RENDER_WORLD
}
}


Expand All @@ -211,9 +212,9 @@ impl FromWorld for ParticleBehaviorPipeline {
let render_device = render_world.resource::<RenderDevice>();
let gaussian_cloud_pipeline = render_world.resource::<GaussianCloudPipeline>();

let particle_behavior_layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor {
label: Some("gaussian_cloud_particle_behavior_layout"),
entries: &[
let particle_behavior_layout = render_device.create_bind_group_layout(
Some("gaussian_cloud_particle_behavior_layout"),
&[
BindGroupLayoutEntry {
binding: 7,
visibility: ShaderStages::COMPUTE,
Expand All @@ -225,7 +226,7 @@ impl FromWorld for ParticleBehaviorPipeline {
count: None,
},
],
});
);

let shader_defs = shader_defs(GaussianCloudPipelineKey::default());
let pipeline_cache = render_world.resource::<PipelineCache>();
Expand Down Expand Up @@ -453,11 +454,9 @@ impl Default for ParticleBehavior {
Default,
PartialEq,
Reflect,
TypeUuid,
Serialize,
Deserialize,
)]
#[uuid = "ac2f08eb-6463-2131-6772-51571ea332d5"]
pub struct ParticleBehaviors(pub Vec<ParticleBehavior>);


Expand Down
22 changes: 0 additions & 22 deletions src/morph/wavelet.rs

This file was deleted.

8 changes: 0 additions & 8 deletions src/morph/wavelet.wgsl

This file was deleted.

2 changes: 0 additions & 2 deletions src/query/select.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::iter::FromIterator;

use bevy::{
prelude::*,
asset::LoadState,
Expand Down
Loading
Loading