Skip to content

Commit 9095810

Browse files
authored
Ensure instance_index push constant is always used in prepass.wgsl (#10706)
# Objective Kind of helps #10509 ## Solution Add a line to `prepass.wgsl` that ensure the `instance_index` push constant is always used on WebGL 2. This is not a full fix, as the _second_ a custom shader is used that doesn't use the push constant, the breakage will resurface. We have satisfying medium term and long term solutions. This is just a short term hack for 0.12.1 that will make more cases work. See #10509 for more details.
1 parent 879893c commit 9095810

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

crates/bevy_pbr/src/prepass/prepass.wgsl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
107107
// See https://github.com/gfx-rs/naga/issues/2416
108108
out.instance_index = get_instance_index(vertex_no_morph.instance_index);
109109
#endif
110+
#ifdef BASE_INSTANCE_WORKAROUND
111+
// Hack: this ensures the push constant is always used, which works around this issue:
112+
// https://github.com/bevyengine/bevy/issues/10509
113+
// This can be removed when wgpu 0.19 is released
114+
out.position.x += min(f32(get_instance_index(0u)), 0.0);
115+
#endif
110116

111117
return out;
112118
}

crates/bevy_pbr/src/render/mesh.wgsl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ fn vertex(vertex_no_morph: Vertex) -> VertexOutput {
8888
out.instance_index = get_instance_index(vertex_no_morph.instance_index);
8989
#endif
9090

91+
#ifdef BASE_INSTANCE_WORKAROUND
92+
// Hack: this ensures the push constant is always used, which works around this issue:
93+
// https://github.com/bevyengine/bevy/issues/10509
94+
// This can be removed when wgpu 0.19 is released
95+
out.position.x += min(f32(get_instance_index(0u)), 0.0);
96+
#endif
97+
9198
return out;
9299
}
93100

0 commit comments

Comments
 (0)