mirror of
https://github.com/bevyengine/bevy
synced 2025-01-08 11:18:55 +00:00
18 lines
593 B
WebGPU Shading Language
18 lines
593 B
WebGPU Shading Language
|
#define_import_path bevy_render::instance_index
|
||
|
|
||
|
#ifdef BASE_INSTANCE_WORKAROUND
|
||
|
// naga and wgpu should polyfill WGSL instance_index functionality where it is
|
||
|
// not available in GLSL. Until that is done, we can work around it in bevy
|
||
|
// using a push constant which is converted to a uniform by naga and wgpu.
|
||
|
// https://github.com/gfx-rs/wgpu/issues/1573
|
||
|
var<push_constant> base_instance: i32;
|
||
|
|
||
|
fn get_instance_index(instance_index: u32) -> u32 {
|
||
|
return u32(base_instance) + instance_index;
|
||
|
}
|
||
|
#else
|
||
|
fn get_instance_index(instance_index: u32) -> u32 {
|
||
|
return instance_index;
|
||
|
}
|
||
|
#endif
|