Skip to content

Commit

Permalink
Fix 3D Gizmo webgpu rendering (bevyengine#14653)
Browse files Browse the repository at this point in the history
# Objective

The changes made in bevyengine#12252
introduced an previously fixed bug in webgpu rendering.

## Solution

This fix is based on bevyengine#8910 and
applies the same vertex buffer layout assignment for the LineGizmo
Pipeline.

## Testing

- Tested the 3D Gizmo example in webgpu and webgl environments

Co-authored-by: Alice Cecile <[email protected]>
  • Loading branch information
AFKessen and alice-i-cecile committed Aug 9, 2024
1 parent 297c0a3 commit e14f3cf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,16 @@ impl<P: PhaseItem> RenderCommand<P> for DrawLineGizmo {
}

let instances = if line_gizmo.strip {
pass.set_vertex_buffer(0, line_gizmo.position_buffer.slice(..));
pass.set_vertex_buffer(1, line_gizmo.position_buffer.slice(..));
let item_size = VertexFormat::Float32x3.size();
let buffer_size = line_gizmo.position_buffer.size() - item_size;

pass.set_vertex_buffer(2, line_gizmo.color_buffer.slice(..));
pass.set_vertex_buffer(3, line_gizmo.color_buffer.slice(..));
pass.set_vertex_buffer(0, line_gizmo.position_buffer.slice(..buffer_size));
pass.set_vertex_buffer(1, line_gizmo.position_buffer.slice(item_size..));

let item_size = VertexFormat::Float32x4.size();
let buffer_size = line_gizmo.color_buffer.size() - item_size;
pass.set_vertex_buffer(2, line_gizmo.color_buffer.slice(..buffer_size));
pass.set_vertex_buffer(3, line_gizmo.color_buffer.slice(item_size..));

u32::max(line_gizmo.vertex_count, 1) - 1
} else {
Expand Down Expand Up @@ -699,13 +704,11 @@ fn line_gizmo_vertex_buffer_layouts(strip: bool) -> Vec<VertexBufferLayout> {
position_layout.clone(),
{
position_layout.attributes[0].shader_location = 1;
position_layout.attributes[0].offset = Float32x3.size();
position_layout
},
color_layout.clone(),
{
color_layout.attributes[0].shader_location = 3;
color_layout.attributes[0].offset = Float32x4.size();
color_layout
},
]
Expand Down

0 comments on commit e14f3cf

Please sign in to comment.