Skip to content

Commit

Permalink
refactor: separate shaders (#21)
Browse files Browse the repository at this point in the history
* refactor: separate shaders

* feat: transform separation and shader entrypoint correction
  • Loading branch information
mosure authored Nov 16, 2023
1 parent 424e124 commit 54e44af
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 312 deletions.
56 changes: 56 additions & 0 deletions src/render/bindings.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#define_import_path bevy_gaussian_splatting::bindings

#import bevy_render::globals::Globals
#import bevy_render::view::View


struct GaussianInput {
@location(0) rotation: vec4<f32>,
@location(1) position: vec4<f32>,
@location(2) scale_opacity: vec4<f32>,
sh: array<f32, #{MAX_SH_COEFF_COUNT}>,
};

struct GaussianOutput {
@builtin(position) position: vec4<f32>,
@location(0) @interpolate(flat) color: vec4<f32>,
@location(1) @interpolate(flat) conic: vec3<f32>,
@location(2) @interpolate(linear) uv: vec2<f32>,
@location(3) @interpolate(linear) major_minor: vec2<f32>,
};

struct GaussianUniforms {
global_transform: mat4x4<f32>,
global_scale: f32,
};

struct DrawIndirect {
vertex_count: u32,
instance_count: atomic<u32>,
base_vertex: u32,
base_instance: u32,
}
struct SortingGlobal {
status_counters: array<array<atomic<u32>, #{RADIX_BASE}>, #{MAX_TILE_COUNT_C}>,
digit_histogram: array<array<atomic<u32>, #{RADIX_BASE}>, #{RADIX_DIGIT_PLACES}>,
assignment_counter: atomic<u32>,
}
struct Entry {
key: u32,
value: u32,
}


@group(0) @binding(0) var<uniform> view: View;
@group(0) @binding(1) var<uniform> globals: Globals;

@group(1) @binding(0) var<uniform> uniforms: GaussianUniforms;

@group(2) @binding(0) var<storage, read> points: array<GaussianInput>;

@group(3) @binding(0) var<uniform> sorting_pass_index: u32;
@group(3) @binding(1) var<storage, read_write> sorting: SortingGlobal;
@group(3) @binding(2) var<storage, read_write> draw_indirect: DrawIndirect;
@group(3) @binding(3) var<storage, read_write> input_entries: array<Entry>;
@group(3) @binding(4) var<storage, read_write> output_entries: array<Entry>;
@group(3) @binding(5) var<storage, read> sorted_entries: array<Entry>;
Loading

0 comments on commit 54e44af

Please sign in to comment.