Skip to content

Commit

Permalink
fix: webgl2 GL_ANGLE_multi_draw isn't default
Browse files Browse the repository at this point in the history
  • Loading branch information
mosure committed Jan 2, 2024
1 parent 02ff96b commit ca123dc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ web = [
"planar",
"sort_std",
"viewer",
"webgl2",
]

webgl2 = ["bevy/webgl2"]


[dependencies]
bevy-inspector-egui = { version = "0.22", optional = true }
Expand Down Expand Up @@ -139,7 +142,6 @@ features = [
"bevy_core_pipeline",
"bevy_render",
"bevy_winit",
"webgl2",
]


Expand Down
10 changes: 10 additions & 0 deletions src/render/gaussian.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,23 @@ fn get_entry(index: u32) -> Entry {
}
#endif

#ifdef WEBGL2
struct GaussianVertexOutput {
@builtin(position) position: vec4<f32>,
@location(0) color: vec4<f32>,
@location(1) conic: vec3<f32>,
@location(2) uv: vec2<f32>,
@location(3) major_minor: vec2<f32>,
};
#else
struct GaussianVertexOutput {
@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>,
};
#endif


// https://github.com/cvlab-epfl/gaussian-splatting-web/blob/905b3c0fb8961e42c79ef97e64609e82383ca1c2/src/shaders.ts#L185
Expand Down
8 changes: 8 additions & 0 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ pub fn shader_defs(
#[cfg(all(feature = "f32", feature = "buffer_texture"))]
shader_defs.push("PLANAR_TEXTURE_F32".into());


#[cfg(feature = "webgl2")]
shader_defs.push("WEBGL2".into());

match key.draw_mode {
GaussianCloudDrawMode::All => {},
GaussianCloudDrawMode::Selected => shader_defs.push("DRAW_SELECTED".into()),
Expand Down Expand Up @@ -1020,6 +1024,10 @@ impl<P: PhaseItem> RenderCommand<P> for DrawGaussianInstanced {
pass.set_bind_group(2, &bind_groups.cloud_bind_group, &[]); // TODO: abstract source of cloud_bind_group (e.g. packed vs. planar)
pass.set_bind_group(3, &bind_groups.sorted_bind_group, &[]);

#[cfg(feature = "webgl2")]
pass.draw(0..4, 0..gpu_gaussian_cloud.count as u32);

#[cfg(not(feature = "webgl2"))]
pass.draw_indirect(&gpu_gaussian_cloud.draw_indirect_buffer, 0);

RenderCommandResult::Success
Expand Down

0 comments on commit ca123dc

Please sign in to comment.