Skip to content

Commit e14f3cf

Browse files
Fix 3D Gizmo webgpu rendering (#14653)
# Objective The changes made in #12252 introduced an previously fixed bug in webgpu rendering. ## Solution This fix is based on #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]>
1 parent 297c0a3 commit e14f3cf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

crates/bevy_gizmos/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,16 @@ impl<P: PhaseItem> RenderCommand<P> for DrawLineGizmo {
597597
}
598598

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

603-
pass.set_vertex_buffer(2, line_gizmo.color_buffer.slice(..));
604-
pass.set_vertex_buffer(3, line_gizmo.color_buffer.slice(..));
603+
pass.set_vertex_buffer(0, line_gizmo.position_buffer.slice(..buffer_size));
604+
pass.set_vertex_buffer(1, line_gizmo.position_buffer.slice(item_size..));
605+
606+
let item_size = VertexFormat::Float32x4.size();
607+
let buffer_size = line_gizmo.color_buffer.size() - item_size;
608+
pass.set_vertex_buffer(2, line_gizmo.color_buffer.slice(..buffer_size));
609+
pass.set_vertex_buffer(3, line_gizmo.color_buffer.slice(item_size..));
605610

606611
u32::max(line_gizmo.vertex_count, 1) - 1
607612
} else {
@@ -699,13 +704,11 @@ fn line_gizmo_vertex_buffer_layouts(strip: bool) -> Vec<VertexBufferLayout> {
699704
position_layout.clone(),
700705
{
701706
position_layout.attributes[0].shader_location = 1;
702-
position_layout.attributes[0].offset = Float32x3.size();
703707
position_layout
704708
},
705709
color_layout.clone(),
706710
{
707711
color_layout.attributes[0].shader_location = 3;
708-
color_layout.attributes[0].offset = Float32x4.size();
709712
color_layout
710713
},
711714
]

0 commit comments

Comments
 (0)