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: msaa toggle #77

Merged
merged 11 commits into from
Jan 20, 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
61 changes: 61 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
rust-toolchain:
- nightly

runs-on: ${{ matrix.os }}
timeout-minutes: 120

steps:
- uses: actions/checkout@v3

- name: Setup ${{ matrix.rust-toolchain }} rust toolchain with caching
uses: brndnmtthws/rust-action@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
components: rustfmt, clippy
enable-sccache: "true"

- name: build
run: cargo build


build_tools:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
rust-toolchain:
- nightly

runs-on: ${{ matrix.os }}
timeout-minutes: 120

steps:
- uses: actions/checkout@v3

- name: Setup ${{ matrix.rust-toolchain }} rust toolchain with caching
uses: brndnmtthws/rust-action@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
components: rustfmt, clippy
enable-sccache: "true"

- name: build_tools
run: cargo build --bin ply_to_gcloud
37 changes: 37 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: clippy

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
clippy:

strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
rust-toolchain:
- nightly

runs-on: ${{ matrix.os }}
timeout-minutes: 120

steps:
- uses: actions/checkout@v3

- name: Setup ${{ matrix.rust-toolchain }} rust toolchain with caching
uses: brndnmtthws/rust-action@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
components: rustfmt, clippy
enable-sccache: "true"

- name: lint
run: cargo clippy -- -Dwarnings
38 changes: 21 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
RUST_BACKTRACE: 1

jobs:
build:
test:

strategy:
fail-fast: false
Expand All @@ -33,26 +33,30 @@ jobs:
components: rustfmt, clippy
enable-sccache: "true"

- name: build
run: cargo build

- name: build_tools
run: cargo build --bin ply_to_gcloud

- name: lint
run: cargo clippy

- name: test (default)
run: cargo test

- name: test (web)
run: cargo test --no-default-features --features="web io_ply tooling"

# - name: gaussian render test
# run: cargo run --bin test_gaussian
test_web:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
rust-toolchain:
- nightly

runs-on: ${{ matrix.os }}
timeout-minutes: 120

# - name: radix sort test
# run: cargo run --bin test_radix --features="debug_gpu"
steps:
- uses: actions/checkout@v3

- name: Setup ${{ matrix.rust-toolchain }} rust toolchain with caching
uses: brndnmtthws/rust-action@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
components: rustfmt, clippy
enable-sccache: "true"

# TODO: test wasm build, deploy, and run
- name: test (web)
run: cargo test --no-default-features --features="web io_ply tooling"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Cargo.lock
.DS_Store

www/assets/
screenshots/
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ viewer = [
"bevy-inspector-egui",
"bevy_panorbit_camera",
# "bevy_transform_gizmo",
"bevy/multi-threaded", # bevy screenshot functionality requires bevy/multi-threaded as of 0.12.1
]

web = [
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

bevy gaussian splatting render pipeline plugin. view the [live demo](https://mosure.github.io/bevy_gaussian_splatting/index.html?arg1=cactus.gcloud)

![Alt text](docs/notferris.png)
![Alt text](docs/bevy_gaussian_splatting_demo.webp)
![Alt text](docs/go.gif)


Expand Down Expand Up @@ -76,7 +76,7 @@ fn setup_gaussian_cloud(
| `0.4 - 1.0` | `0.12` |
| `0.1 - 0.3` | `0.11` |

## Projects using this plugin
## projects using this plugin
- [kitt2](https://github.com/cs50victor/kitt2)

# credits
Expand Down
Binary file added docs/bevy_gaussian_splatting_demo.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion src/gaussian/cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ impl GaussianCloud {
coefficients: {
#[cfg(feature = "f16")]
{
let mut coefficients = [0 as u32; HALF_SH_COEFF_COUNT];
let mut coefficients = [0_u32; HALF_SH_COEFF_COUNT];

for coefficient in coefficients.iter_mut() {
let upper = rng.gen_range(-1.0..1.0);
Expand Down
75 changes: 32 additions & 43 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ use crate::{
#[cfg(feature = "packed")]
mod packed;

#[cfg(all(feature = "buffer_storage"))]
#[cfg(feature = "buffer_storage")]
mod planar;

#[cfg(feature = "buffer_texture")]
Expand Down Expand Up @@ -231,17 +231,34 @@ impl RenderAsset for GaussianCloud {
count,
draw_indirect_buffer,

#[cfg(feature = "debug_gpu")]
debug_gpu: gaussian_cloud,

#[cfg(feature = "packed")]
packed: packed::prepare_cloud(render_device, &gaussian_cloud),
#[cfg(feature = "buffer_storage")]
planar: planar::prepare_cloud(render_device, &gaussian_cloud),

#[cfg(feature = "debug_gpu")]
debug_gpu: gaussian_cloud,
})
}
}

#[cfg(feature = "buffer_storage")]
type GpuGaussianBundleQuery = (
Entity,
&'static Handle<GaussianCloud>,
&'static Handle<SortedEntries>,
&'static GaussianCloudSettings,
(),
);

#[cfg(feature = "buffer_texture")]
type GpuGaussianBundleQuery = (
Entity,
&'static Handle<GaussianCloud>,
&'static Handle<SortedEntries>,
&'static GaussianCloudSettings,
&'static texture::GpuTextureBuffers,
);

#[allow(clippy::too_many_arguments)]
fn queue_gaussians(
Expand All @@ -256,23 +273,8 @@ fn queue_gaussians(
&ExtractedView,
&mut RenderPhase<Transparent3d>,
)>,

#[cfg(feature = "buffer_storage")]
gaussian_splatting_bundles: Query<(
Entity,
&Handle<GaussianCloud>,
&Handle<SortedEntries>,
&GaussianCloudSettings,
(),
)>,
#[cfg(feature = "buffer_texture")]
gaussian_splatting_bundles: Query<(
Entity,
&Handle<GaussianCloud>,
&Handle<SortedEntries>,
&GaussianCloudSettings,
&texture::GpuTextureBuffers,
)>,
msaa: Res<Msaa>,
gaussian_splatting_bundles: Query<GpuGaussianBundleQuery>,
) {
// TODO: condition this system based on GaussianCloudBindGroup attachment
if gaussian_cloud_uniform.buffer().is_none() {
Expand Down Expand Up @@ -305,6 +307,7 @@ fn queue_gaussians(
visualize_bounding_box: settings.visualize_bounding_box,
visualize_depth: settings.visualize_depth,
draw_mode: settings.draw_mode,
sample_count: msaa.samples(),
};

let pipeline = pipelines.specialize(&pipeline_cache, &custom_pipeline, key);
Expand All @@ -327,8 +330,6 @@ fn queue_gaussians(
}




#[derive(Resource)]
pub struct GaussianCloudPipeline {
shader: Handle<Shader>,
Expand Down Expand Up @@ -392,9 +393,9 @@ impl FromWorld for GaussianCloudPipeline {
let read_only = false;

#[cfg(feature = "packed")]
let gaussian_cloud_layout = packed::get_bind_group_layout(&render_device, read_only);
let gaussian_cloud_layout = packed::get_bind_group_layout(render_device, read_only);
#[cfg(all(feature = "buffer_storage", not(feature = "packed")))]
let gaussian_cloud_layout = planar::get_bind_group_layout(&render_device, read_only);
let gaussian_cloud_layout = planar::get_bind_group_layout(render_device, read_only);
#[cfg(feature = "buffer_texture")]
let gaussian_cloud_layout = texture::get_bind_group_layout(&render_device, read_only);

Expand Down Expand Up @@ -575,6 +576,7 @@ pub struct GaussianCloudPipelineKey {
pub visualize_bounding_box: bool,
pub visualize_depth: bool,
pub draw_mode: GaussianCloudDrawMode,
pub sample_count: u32,
}

impl SpecializedRenderPipeline for GaussianCloudPipeline {
Expand Down Expand Up @@ -633,7 +635,7 @@ impl SpecializedRenderPipeline for GaussianCloudPipeline {
},
}),
multisample: MultisampleState {
count: 4, // TODO: disable MSAA for gaussian pipeline
count: key.sample_count,
mask: !0,
alpha_to_coverage_enabled: false,
},
Expand Down Expand Up @@ -741,20 +743,7 @@ fn queue_gaussian_bind_group(
asset_server: Res<AssetServer>,
gaussian_cloud_res: Res<RenderAssets<GaussianCloud>>,
sorted_entries_res: Res<RenderAssets<SortedEntries>>,

#[cfg(feature = "buffer_storage")]
gaussian_clouds: Query<(
Entity,
&Handle<GaussianCloud>,
&Handle<SortedEntries>,
)>,
#[cfg(feature = "buffer_texture")]
gaussian_clouds: Query<(
Entity,
&Handle<GaussianCloud>,
&Handle<SortedEntries>,
&texture::GpuTextureBuffers,
)>,
gaussian_clouds: Query<GpuGaussianBundleQuery>,

#[cfg(feature = "buffer_texture")]
gpu_images: Res<RenderAssets<Image>>,
Expand Down Expand Up @@ -785,7 +774,7 @@ fn queue_gaussian_bind_group(
let sorted_entries_handle = query.2;

#[cfg(feature = "buffer_texture")]
let texture_buffers = query.3;
let texture_buffers = query.4;

// TODO: add asset loading indicator (and maybe streamed loading)
if Some(LoadState::Loading) == asset_server.get_load_state(cloud_handle){
Expand All @@ -810,9 +799,9 @@ fn queue_gaussian_bind_group(
let sorted_entries = sorted_entries_res.get(sorted_entries_handle).unwrap();

#[cfg(feature = "packed")]
let cloud_bind_group = packed::get_bind_group(&render_device, &gaussian_cloud_pipeline, &cloud);
let cloud_bind_group = packed::get_bind_group(&render_device, &gaussian_cloud_pipeline, cloud);
#[cfg(all(feature = "buffer_storage", not(feature = "packed")))]
let cloud_bind_group = planar::get_bind_group(&render_device, &gaussian_cloud_pipeline, &cloud);
let cloud_bind_group = planar::get_bind_group(&render_device, &gaussian_cloud_pipeline, cloud);
#[cfg(feature = "buffer_texture")]
let cloud_bind_group = texture_buffers.bind_group.clone();

Expand Down
7 changes: 3 additions & 4 deletions src/sort/rayon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl Plugin for RayonSortPlugin {
}
}

#[allow(clippy::too_many_arguments)]
pub fn rayon_sort(
asset_server: Res<AssetServer>,
gaussian_clouds_res: Res<Assets<GaussianCloud>>,
Expand Down Expand Up @@ -67,10 +68,8 @@ pub fn rayon_sort(

if camera_movement {
*sort_done = false;
} else {
if *sort_done {
return;
}
} else if *sort_done {
return;
}

*last_camera_position = camera_position;
Expand Down
Loading