Skip to content

Commit 669d139

Browse files
JMS55alice-i-cecileIceSentrymockersf
authored
Upgrade to wgpu v24 (#17542)
Didn't remove WgpuWrapper. Not sure if it's needed or not still. ## Testing - Did you test these changes? If so, how? Example runner - Are there any parts that need more testing? Web (portable atomics thingy?), DXC. ## Migration Guide - Bevy has upgraded to [wgpu v24](https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#v2400-2025-01-15). - When using the DirectX 12 rendering backend, the new priority system for choosing a shader compiler is as follows: - If the `WGPU_DX12_COMPILER` environment variable is set at runtime, it is used - Else if the new `statically-linked-dxc` feature is enabled, a custom version of DXC will be statically linked into your app at compile time. - Else Bevy will look in the app's working directory for `dxcompiler.dll` and `dxil.dll` at runtime. - Else if they are missing, Bevy will fall back to FXC (not recommended) --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: IceSentry <c.giguere42@gmail.com> Co-authored-by: François Mockers <francois.mockers@vleue.com>
1 parent 33e8333 commit 669d139

File tree

42 files changed

+174
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+174
-175
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ bevy_remote = ["bevy_internal/bevy_remote"]
256256
# Enable passthrough loading for SPIR-V shaders (Only supported on Vulkan, shader capabilities and extensions must agree with the platform implementation)
257257
spirv_shader_passthrough = ["bevy_internal/spirv_shader_passthrough"]
258258

259+
# Statically linked DXC shader compiler for DirectX 12
260+
statically-linked-dxc = ["bevy_internal/statically-linked-dxc"]
261+
259262
# Tracing support, saving a file in Chrome Tracing format
260263
trace_chrome = ["trace", "bevy_internal/trace_chrome"]
261264

crates/bevy_color/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ serde = { version = "1.0", features = [
2222
], default-features = false, optional = true }
2323
thiserror = { version = "2", default-features = false }
2424
derive_more = { version = "1", default-features = false, features = ["from"] }
25-
wgpu-types = { version = "23", default-features = false, optional = true }
25+
wgpu-types = { version = "24", default-features = false, optional = true }
2626
encase = { version = "0.10", default-features = false, optional = true }
2727

2828
[features]

crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ pub fn create_depth_pyramid_dummy_texture(
484484
label: Some(texture_view_label),
485485
format: Some(TextureFormat::R32Float),
486486
dimension: Some(TextureViewDimension::D2),
487+
usage: None,
487488
aspect: TextureAspect::All,
488489
base_mip_level: 0,
489490
mip_level_count: Some(1),
@@ -551,6 +552,7 @@ impl ViewDepthPyramid {
551552
label: Some(texture_view_label),
552553
format: Some(TextureFormat::R32Float),
553554
dimension: Some(TextureViewDimension::D2),
555+
usage: None,
554556
aspect: TextureAspect::All,
555557
base_mip_level: i as u32,
556558
mip_level_count: Some(1),

crates/bevy_image/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ image = { version = "0.25.2", default-features = false }
6363
# misc
6464
bitflags = { version = "2.3", features = ["serde"] }
6565
bytemuck = { version = "1.5" }
66-
wgpu-types = { version = "23", default-features = false }
67-
# TODO: remove dependency on wgpu once https://github.com/gfx-rs/wgpu/pull/6648, 6649 and 6650 have been released
68-
wgpu = { version = "23.0.1", default-features = false }
66+
wgpu-types = { version = "24", default-features = false }
6967
serde = { version = "1", features = ["derive"] }
7068
thiserror = { version = "2", default-features = false }
7169
futures-lite = "2.0.1"

crates/bevy_image/src/dds.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
33
use ddsfile::{Caps2, D3DFormat, Dds, DxgiFormat};
44
use std::io::Cursor;
5-
use wgpu::TextureViewDescriptor;
6-
use wgpu_types::{Extent3d, TextureDimension, TextureFormat, TextureViewDimension};
5+
use wgpu_types::{
6+
Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor, TextureViewDimension,
7+
};
78
#[cfg(debug_assertions)]
89
use {bevy_utils::once, tracing::warn};
910

@@ -283,8 +284,7 @@ pub fn dds_format_to_texture_format(
283284

284285
#[cfg(test)]
285286
mod test {
286-
use wgpu::util::TextureDataOrder;
287-
use wgpu_types::{TextureDescriptor, TextureDimension, TextureFormat};
287+
use wgpu_types::{TextureDataOrder, TextureDescriptor, TextureDimension, TextureFormat};
288288

289289
use crate::CompressedImageFormats;
290290

crates/bevy_image/src/image.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use bevy_math::{AspectRatio, UVec2, UVec3, Vec2};
1313
use core::hash::Hash;
1414
use serde::{Deserialize, Serialize};
1515
use thiserror::Error;
16-
use wgpu::{SamplerDescriptor, TextureViewDescriptor};
1716
use wgpu_types::{
1817
AddressMode, CompareFunction, Extent3d, Features, FilterMode, SamplerBorderColor,
19-
TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
18+
SamplerDescriptor, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
19+
TextureViewDescriptor,
2020
};
2121

2222
pub trait BevyDefault {
@@ -343,7 +343,7 @@ pub struct Image {
343343
pub texture_descriptor: TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>,
344344
/// The [`ImageSampler`] to use during rendering.
345345
pub sampler: ImageSampler,
346-
pub texture_view_descriptor: Option<TextureViewDescriptor<'static>>,
346+
pub texture_view_descriptor: Option<TextureViewDescriptor<Option<&'static str>>>,
347347
pub asset_usage: RenderAssetUsages,
348348
}
349349

@@ -559,7 +559,7 @@ impl ImageSamplerDescriptor {
559559
}
560560
}
561561

562-
pub fn as_wgpu(&self) -> SamplerDescriptor {
562+
pub fn as_wgpu(&self) -> SamplerDescriptor<Option<&str>> {
563563
SamplerDescriptor {
564564
label: self.label.as_deref(),
565565
address_mode_u: self.address_mode_u.into(),
@@ -669,8 +669,8 @@ impl From<SamplerBorderColor> for ImageSamplerBorderColor {
669669
}
670670
}
671671

672-
impl<'a> From<SamplerDescriptor<'a>> for ImageSamplerDescriptor {
673-
fn from(value: SamplerDescriptor) -> Self {
672+
impl From<SamplerDescriptor<Option<&str>>> for ImageSamplerDescriptor {
673+
fn from(value: SamplerDescriptor<Option<&str>>) -> Self {
674674
ImageSamplerDescriptor {
675675
label: value.label.map(ToString::to_string),
676676
address_mode_u: value.address_mode_u.into(),

crates/bevy_image/src/ktx2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use ktx2::{
1313
BasicDataFormatDescriptor, ChannelTypeQualifiers, ColorModel, DataFormatDescriptorHeader,
1414
Header, SampleInformation,
1515
};
16-
use wgpu::TextureViewDescriptor;
1716
use wgpu_types::{
18-
AstcBlock, AstcChannel, Extent3d, TextureDimension, TextureFormat, TextureViewDimension,
17+
AstcBlock, AstcChannel, Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor,
18+
TextureViewDimension,
1919
};
2020

2121
use super::{CompressedImageFormats, DataFormat, Image, TextureError, TranscodeFormat};

crates/bevy_internal/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ webp = ["bevy_image/webp"]
5959
# Enable SPIR-V passthrough
6060
spirv_shader_passthrough = ["bevy_render/spirv_shader_passthrough"]
6161

62+
# Statically linked DXC shader compiler for DirectX 12
63+
# TODO: When wgpu switches to DirectX 12 instead of Vulkan by default on windows, make this a default feature
64+
statically-linked-dxc = ["bevy_render/statically-linked-dxc"]
65+
6266
# Include tonemapping LUT KTX2 files.
6367
tonemapping_luts = ["bevy_core_pipeline/tonemapping_luts"]
6468

crates/bevy_mesh/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bevy_platform_support = { path = "../bevy_platform_support", version = "0.16.0-d
2929
# other
3030
bitflags = { version = "2.3", features = ["serde"] }
3131
bytemuck = { version = "1.5" }
32-
wgpu-types = { version = "23", default-features = false }
32+
wgpu-types = { version = "24", default-features = false }
3333
serde = { version = "1", features = ["derive"] }
3434
hexasphere = "15.0"
3535
thiserror = { version = "2", default-features = false }

crates/bevy_mesh/src/mesh.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use super::{
66
GenerateTangentsError, Indices, MeshAttributeData, MeshTrianglesError, MeshVertexAttribute,
77
MeshVertexAttributeId, MeshVertexBufferLayout, MeshVertexBufferLayoutRef,
88
MeshVertexBufferLayouts, MeshWindingInvertError, VertexAttributeValues, VertexBufferLayout,
9-
VertexFormatSize,
109
};
1110
use alloc::collections::BTreeMap;
1211
use bevy_asset::{Asset, Handle, RenderAssetUsages};
@@ -379,7 +378,7 @@ impl Mesh {
379378
pub fn get_vertex_size(&self) -> u64 {
380379
self.attributes
381380
.values()
382-
.map(|data| data.attribute.format.get_size())
381+
.map(|data| data.attribute.format.size())
383382
.sum()
384383
}
385384

@@ -414,7 +413,7 @@ impl Mesh {
414413
format: data.attribute.format,
415414
shader_location: index as u32,
416415
});
417-
accumulated_offset += data.attribute.format.get_size();
416+
accumulated_offset += data.attribute.format.size();
418417
}
419418

420419
let layout = MeshVertexBufferLayout {
@@ -482,7 +481,7 @@ impl Mesh {
482481
// bundle into interleaved buffers
483482
let mut attribute_offset = 0;
484483
for attribute_data in self.attributes.values() {
485-
let attribute_size = attribute_data.attribute.format.get_size() as usize;
484+
let attribute_size = attribute_data.attribute.format.size() as usize;
486485
let attributes_bytes = attribute_data.values.get_bytes();
487486
for (vertex_index, attribute_bytes) in attributes_bytes
488487
.chunks_exact(attribute_size)

0 commit comments

Comments
 (0)