Skip to content

Ugrade to wgpu version 25.0 #19563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
38779ed
Wgpu 25 compile.
tychedelia May 14, 2025
f5969d7
Split view 0 into 0,1
tychedelia Jun 9, 2025
891184e
Fmt.
tychedelia Jun 9, 2025
ddf8b8e
.
tychedelia Jun 15, 2025
793bbaf
Merge main.
tychedelia Jun 20, 2025
776b471
Clean up and add empty bind group.
tychedelia Jun 20, 2025
c3b4350
Ci.
tychedelia Jun 20, 2025
dddade5
Bump codespan.
tychedelia Jun 20, 2025
b629a65
Add missing backends.
tychedelia Jun 20, 2025
a79f15a
Fix gizmos.
tychedelia Jun 20, 2025
9dde561
Fix prepass.
tychedelia Jun 20, 2025
aab1cfb
Fix skinning.
tychedelia Jun 20, 2025
88cba3d
Migration.
tychedelia Jun 20, 2025
8ab8f27
Markdown.
tychedelia Jun 20, 2025
56296bf
Markdown.
tychedelia Jun 20, 2025
e869d43
5488 fixed upstream.
tychedelia Jun 20, 2025
9b52a0b
Bindless resources 2->3
tychedelia Jun 20, 2025
88c9492
Add new caps.
tychedelia Jun 20, 2025
c180bd7
WebGPU compliant dual source blending.
tychedelia Jun 20, 2025
92db3a9
add necessary directive.
tychedelia Jun 21, 2025
31dc04c
Merge branch 'main' into wgpu-25-2
tychedelia Jun 23, 2025
042e567
Merge branch 'main' into wgpu-25-2
tychedelia Jun 24, 2025
9495fa6
Fmt.
tychedelia Jun 24, 2025
e7f11a7
Fix lightmaps.
tychedelia Jun 24, 2025
ef83e59
Fix decal.
tychedelia Jun 24, 2025
aa7dd74
GLSL
tychedelia Jun 24, 2025
03e61f2
GLSL
tychedelia Jun 24, 2025
a6179f9
Oops.
tychedelia Jun 24, 2025
1edac8a
Merge remote-tracking branch 'origin/main' into wgpu-25-2
tychedelia Jun 24, 2025
c821f35
Fix examples
tychedelia Jun 24, 2025
a480511
ShaderStages::all() is broken in WebGPU.
tychedelia Jun 24, 2025
653c8e3
Compute.
tychedelia Jun 24, 2025
8ec9340
Fix solari.
tychedelia Jun 24, 2025
5a72ae8
Solari.
tychedelia Jun 24, 2025
31236ca
Note exported float constants.
tychedelia Jun 24, 2025
d97817b
Merge branch 'main' into wgpu-25-2
tychedelia Jun 24, 2025
1bf8e58
Merge branch 'main' into wgpu-25-2
mockersf Jun 25, 2025
a91d387
Remove unecessary solari feature.
tychedelia Jun 25, 2025
ac04ed5
Fmt.
tychedelia Jun 25, 2025
f1cce9d
Update crates/bevy_pbr/src/atmosphere/render_sky.wgsl
tychedelia Jun 26, 2025
1284668
Update crates/bevy_pbr/src/atmosphere/render_sky.wgsl
tychedelia Jun 26, 2025
7a39c20
Clarify language.
tychedelia Jun 26, 2025
d62fd53
naga_oil released.
tychedelia Jun 26, 2025
dc195db
Merge branch 'main' into wgpu-25-2
tychedelia Jun 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/bevy_color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ serde = { version = "1.0", features = [
], default-features = false, optional = true }
thiserror = { version = "2", default-features = false }
derive_more = { version = "1", default-features = false, features = ["from"] }
wgpu-types = { version = "24", default-features = false, optional = true }
wgpu-types = { version = "25", default-features = false, optional = true }
encase = { version = "0.10", default-features = false, optional = true }

[features]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gizmos/src/line_joints.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct LineGizmoUniform {
#endif
}

@group(1) @binding(0) var<uniform> joints_gizmo: LineGizmoUniform;
@group(2) @binding(0) var<uniform> joints_gizmo: LineGizmoUniform;

struct VertexInput {
@location(0) position_a: vec3<f32>,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gizmos/src/lines.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct LineGizmoUniform {
#endif
}

@group(1) @binding(0) var<uniform> line_gizmo: LineGizmoUniform;
@group(2) @binding(0) var<uniform> line_gizmo: LineGizmoUniform;

struct VertexInput {
@location(0) position_a: vec3<f32>,
Expand Down
18 changes: 10 additions & 8 deletions crates/bevy_gizmos/src/pipeline_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ impl SpecializedRenderPipeline for LineGizmoPipeline {
.get_view_layout(key.view_key.into())
.clone();

let layout = vec![view_layout, self.uniform_layout.clone()];
let mut layout = view_layout.to_vec();
layout.push(self.uniform_layout.clone());

let fragment_entry_point = match key.line_style {
GizmoLineStyle::Solid => "fragment_solid",
Expand Down Expand Up @@ -221,7 +222,8 @@ impl SpecializedRenderPipeline for LineJointGizmoPipeline {
.get_view_layout(key.view_key.into())
.clone();

let layout = vec![view_layout, self.uniform_layout.clone()];
let mut layout = view_layout.to_vec();
layout.push(self.uniform_layout.clone());

if key.joints == GizmoLineJoint::None {
error!("There is no entry point for line joints with GizmoLineJoints::None. Please consider aborting the drawing process before reaching this stage.");
Expand Down Expand Up @@ -273,20 +275,20 @@ impl SpecializedRenderPipeline for LineJointGizmoPipeline {

type DrawLineGizmo3d = (
SetItemPipeline,
SetMeshViewBindGroup<0>,
SetLineGizmoBindGroup<1>,
SetMeshViewBindGroup<0, 1>,
SetLineGizmoBindGroup<2>,
DrawLineGizmo<false>,
);
type DrawLineGizmo3dStrip = (
SetItemPipeline,
SetMeshViewBindGroup<0>,
SetLineGizmoBindGroup<1>,
SetMeshViewBindGroup<0, 1>,
SetLineGizmoBindGroup<2>,
DrawLineGizmo<true>,
);
type DrawLineJointGizmo3d = (
SetItemPipeline,
SetMeshViewBindGroup<0>,
SetLineGizmoBindGroup<1>,
SetMeshViewBindGroup<0, 1>,
SetLineGizmoBindGroup<2>,
DrawLineJointGizmo,
);

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_image/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ image = { version = "0.25.2", default-features = false }
# misc
bitflags = { version = "2.3", features = ["serde"] }
bytemuck = { version = "1.5" }
wgpu-types = { version = "24", default-features = false }
wgpu-types = { version = "25", default-features = false }
serde = { version = "1", features = ["derive"] }
thiserror = { version = "2", default-features = false }
futures-lite = "2.0.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_mesh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev", default-fea
# other
bitflags = { version = "2.3", features = ["serde"] }
bytemuck = { version = "1.5" }
wgpu-types = { version = "24", default-features = false }
wgpu-types = { version = "25", default-features = false }
serde = { version = "1", features = ["derive"] }
hexasphere = "15.0"
thiserror = { version = "2", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_pbr/src/deferred/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,12 @@ impl SpecializedRenderPipeline for DeferredLightingLayout {
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]
shader_defs.push("SIXTEEN_BYTE_ALIGNMENT".into());

let mut layout = self.mesh_pipeline.get_view_layout(key.into()).to_vec();
layout.push(self.bind_group_layout_1.clone());

RenderPipelineDescriptor {
label: Some("deferred_lighting_pipeline".into()),
layout: vec![
self.mesh_pipeline.get_view_layout(key.into()).clone(),
self.bind_group_layout_1.clone(),
],
layout,
vertex: VertexState {
shader: self.deferred_lighting_shader.clone(),
shader_defs: shader_defs.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ fn shader_ref(path: PathBuf) -> ShaderRef {
const MESHLET_VISIBILITY_BUFFER_RESOLVE_SHADER_HANDLE: Handle<Shader> =
weak_handle!("69187376-3dea-4d0f-b3f5-185bde63d6a2");

pub const TONEMAPPING_LUT_TEXTURE_BINDING_INDEX: u32 = 26;
pub const TONEMAPPING_LUT_SAMPLER_BINDING_INDEX: u32 = 27;
pub const TONEMAPPING_LUT_TEXTURE_BINDING_INDEX: u32 = 18;
pub const TONEMAPPING_LUT_SAMPLER_BINDING_INDEX: u32 = 19;

/// Sets up the entire PBR infrastructure of bevy.
pub struct PbrPlugin {
Expand Down
14 changes: 7 additions & 7 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ use tracing::error;
/// In WGSL shaders, the material's binding would look like this:
///
/// ```wgsl
/// @group(2) @binding(0) var<uniform> color: vec4<f32>;
/// @group(2) @binding(1) var color_texture: texture_2d<f32>;
/// @group(2) @binding(2) var color_sampler: sampler;
/// @group(3) @binding(0) var<uniform> color: vec4<f32>;
/// @group(3) @binding(1) var color_texture: texture_2d<f32>;
/// @group(3) @binding(2) var color_sampler: sampler;
/// ```
pub trait Material: Asset + AsBindGroup + Clone + Sized {
/// Returns this material's vertex shader. If [`ShaderRef::Default`] is returned, the default mesh vertex shader
Expand Down Expand Up @@ -501,7 +501,7 @@ where
descriptor.fragment.as_mut().unwrap().shader = fragment_shader.clone();
}

descriptor.layout.insert(2, self.material_layout.clone());
descriptor.layout.insert(3, self.material_layout.clone());

M::specialize(self, &mut descriptor, layout, key)?;

Expand Down Expand Up @@ -543,9 +543,9 @@ impl<M: Material> FromWorld for MaterialPipeline<M> {

type DrawMaterial<M> = (
SetItemPipeline,
SetMeshViewBindGroup<0>,
SetMeshBindGroup<1>,
SetMaterialBindGroup<M, 2>,
SetMeshViewBindGroup<0, 1>,
SetMeshBindGroup<2>,
SetMaterialBindGroup<M, 3>,
DrawMesh,
);

Expand Down
58 changes: 42 additions & 16 deletions crates/bevy_pbr/src/prepass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ where
Render,
prepare_prepass_view_bind_group::<M>.in_set(RenderSystems::PrepareBindGroups),
)
.init_resource::<PrepassViewBindGroup>()
.init_resource::<SpecializedMeshPipelines<PrepassPipeline<M>>>()
.allow_ambiguous_resource::<SpecializedMeshPipelines<PrepassPipeline<M>>>();
}
Expand All @@ -105,7 +104,9 @@ where
return;
};

render_app.init_resource::<PrepassPipeline<M>>();
render_app
.init_resource::<PrepassPipeline<M>>()
.init_resource::<PrepassViewBindGroup>();
}
}

Expand Down Expand Up @@ -267,6 +268,7 @@ pub struct PrepassPipelineInternal {
pub view_layout_motion_vectors: BindGroupLayout,
pub view_layout_no_motion_vectors: BindGroupLayout,
pub mesh_layouts: MeshLayouts,
pub empty_layout: BindGroupLayout,
pub material_layout: BindGroupLayout,
pub prepass_material_vertex_shader: Option<Handle<Shader>>,
pub prepass_material_fragment_shader: Option<Handle<Shader>>,
Expand Down Expand Up @@ -376,6 +378,7 @@ impl<M: Material> FromWorld for PrepassPipeline<M> {
skins_use_uniform_buffers: skin::skins_use_uniform_buffers(render_device),
depth_clip_control_supported,
binding_arrays_are_usable: binding_arrays_are_usable(render_device, render_adapter),
empty_layout: render_device.create_bind_group_layout("prepass_empty_layout", &[]),
};
PrepassPipeline {
internal,
Expand Down Expand Up @@ -420,13 +423,14 @@ impl PrepassPipelineInternal {
layout: &MeshVertexBufferLayoutRef,
) -> Result<RenderPipelineDescriptor, SpecializedMeshPipelineError> {
let mut shader_defs = shader_defs;
let mut bind_group_layouts = vec![if mesh_key
.contains(MeshPipelineKey::MOTION_VECTOR_PREPASS)
{
self.view_layout_motion_vectors.clone()
} else {
self.view_layout_no_motion_vectors.clone()
}];
let mut bind_group_layouts = vec![
if mesh_key.contains(MeshPipelineKey::MOTION_VECTOR_PREPASS) {
self.view_layout_motion_vectors.clone()
} else {
self.view_layout_no_motion_vectors.clone()
},
self.empty_layout.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this empty_layout?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wgpu gets upset if you have a gap in bind groups i guess. should double check that this doesn't have any perf implications but it seems to work.

];
let mut vertex_attributes = Vec::new();

// Let the shader code know that it's running in a prepass pipeline.
Expand Down Expand Up @@ -551,7 +555,7 @@ impl PrepassPipelineInternal {
&mut vertex_attributes,
self.skins_use_uniform_buffers,
);
bind_group_layouts.insert(1, bind_group);
bind_group_layouts.insert(2, bind_group);
let vertex_buffer_layout = layout.0.get_layout(&vertex_attributes)?;
// Setup prepass fragment targets - normals in slot 0 (or None if not needed), motion vectors in slot 1
let mut targets = prepass_target_descriptors(
Expand Down Expand Up @@ -713,10 +717,29 @@ pub fn prepare_previous_view_uniforms(
}
}

#[derive(Default, Resource)]
#[derive(Resource)]
pub struct PrepassViewBindGroup {
pub motion_vectors: Option<BindGroup>,
pub no_motion_vectors: Option<BindGroup>,
pub empty_bind_group: BindGroup,
}

impl FromWorld for PrepassViewBindGroup {
fn from_world(world: &mut World) -> Self {
let pipeline = world.resource::<PrepassPipeline<StandardMaterial>>();

let render_device = world.resource::<RenderDevice>();
let empty_bind_group = render_device.create_bind_group(
"prepass_view_empty_bind_group",
&pipeline.internal.empty_layout,
&[],
);
PrepassViewBindGroup {
motion_vectors: None,
no_motion_vectors: None,
empty_bind_group,
}
}
}

pub fn prepare_prepass_view_bind_group<M: Material>(
Expand Down Expand Up @@ -1231,8 +1254,10 @@ pub fn queue_prepass_material_meshes<M: Material>(
}
}

pub struct SetPrepassViewBindGroup<const I: usize>;
impl<P: PhaseItem, const I: usize> RenderCommand<P> for SetPrepassViewBindGroup<I> {
pub struct SetPrepassViewBindGroup<const I: usize, const J: usize>;
impl<P: PhaseItem, const I: usize, const J: usize> RenderCommand<P>
for SetPrepassViewBindGroup<I, J>
{
type Param = SRes<PrepassViewBindGroup>;
type ViewQuery = (
Read<ViewUniformOffset>,
Expand Down Expand Up @@ -1274,15 +1299,16 @@ impl<P: PhaseItem, const I: usize> RenderCommand<P> for SetPrepassViewBindGroup<
);
}
}
pass.set_bind_group(J, &prepass_view_bind_group.empty_bind_group, &[]);

RenderCommandResult::Success
}
}

pub type DrawPrepass<M> = (
SetItemPipeline,
SetPrepassViewBindGroup<0>,
SetMeshBindGroup<1>,
SetMaterialBindGroup<M, 2>,
SetPrepassViewBindGroup<0, 1>,
SetMeshBindGroup<2>,
SetMaterialBindGroup<M, 3>,
DrawMesh,
);
9 changes: 5 additions & 4 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,7 @@ impl MeshPipeline {
}
}

pub fn get_view_layout(&self, layout_key: MeshPipelineViewLayoutKey) -> &BindGroupLayout {
pub fn get_view_layout(&self, layout_key: MeshPipelineViewLayoutKey) -> &[BindGroupLayout; 2] {
self.view_layouts.get_view_layout(layout_key)
}
}
Expand Down Expand Up @@ -2320,7 +2320,7 @@ impl SpecializedMeshPipeline for MeshPipeline {
shader_defs.push("PBR_SPECULAR_TEXTURES_SUPPORTED".into());
}

let mut bind_group_layout = vec![self.get_view_layout(key.into()).clone()];
let mut bind_group_layout = self.get_view_layout(key.into()).to_vec();

if key.msaa_samples() > 1 {
shader_defs.push("MULTISAMPLED".into());
Expand Down Expand Up @@ -2847,8 +2847,8 @@ fn prepare_mesh_bind_groups_for_phase(
groups
}

pub struct SetMeshViewBindGroup<const I: usize>;
impl<P: PhaseItem, const I: usize> RenderCommand<P> for SetMeshViewBindGroup<I> {
pub struct SetMeshViewBindGroup<const I: usize, const J: usize>;
impl<P: PhaseItem, const I: usize, const J: usize> RenderCommand<P> for SetMeshViewBindGroup<I, J> {
type Param = ();
type ViewQuery = (
Read<ViewUniformOffset>,
Expand Down Expand Up @@ -2891,6 +2891,7 @@ impl<P: PhaseItem, const I: usize> RenderCommand<P> for SetMeshViewBindGroup<I>
offsets.push(layers_count_offset.offset);
}
pass.set_bind_group(I, &mesh_view_bind_group.value, &offsets);
pass.set_bind_group(J, &mesh_view_bind_group.value_binding_array, &[]);

RenderCommandResult::Success
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/render/mesh_bindings.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#ifndef MESHLET_MESH_MATERIAL_PASS
#ifdef PER_OBJECT_BUFFER_BATCH_SIZE
@group(1) @binding(0) var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
@group(2) @binding(0) var<uniform> mesh: array<Mesh, #{PER_OBJECT_BUFFER_BATCH_SIZE}u>;
#else
@group(1) @binding(0) var<storage> mesh: array<Mesh>;
@group(2) @binding(0) var<storage> mesh: array<Mesh>;
#endif // PER_OBJECT_BUFFER_BATCH_SIZE
#endif // MESHLET_MESH_MATERIAL_PASS
Loading
Loading