Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ bevy_remote = ["bevy_internal/bevy_remote"]
# Enable passthrough loading for SPIR-V shaders (Only supported on Vulkan, shader capabilities and extensions must agree with the platform implementation)
spirv_shader_passthrough = ["bevy_internal/spirv_shader_passthrough"]

# Statically linked DXC shader compiler for DirectX 12
statically-linked-dxc = ["bevy_internal/statically-linked-dxc"]

# Tracing support, saving a file in Chrome Tracing format
trace_chrome = ["trace", "bevy_internal/trace_chrome"]

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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 = "23", default-features = false, optional = true }
wgpu-types = { version = "24", default-features = false, optional = true }
encase = { version = "0.10", default-features = false, optional = true }

[features]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ pub fn create_depth_pyramid_dummy_texture(
label: Some(texture_view_label),
format: Some(TextureFormat::R32Float),
dimension: Some(TextureViewDimension::D2),
usage: None,
aspect: TextureAspect::All,
base_mip_level: 0,
mip_level_count: Some(1),
Expand Down Expand Up @@ -551,6 +552,7 @@ impl ViewDepthPyramid {
label: Some(texture_view_label),
format: Some(TextureFormat::R32Float),
dimension: Some(TextureViewDimension::D2),
usage: None,
aspect: TextureAspect::All,
base_mip_level: i as u32,
mip_level_count: Some(1),
Expand Down
4 changes: 1 addition & 3 deletions crates/bevy_image/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ image = { version = "0.25.2", default-features = false }
# misc
bitflags = { version = "2.3", features = ["serde"] }
bytemuck = { version = "1.5" }
wgpu-types = { version = "23", default-features = false }
# TODO: remove dependency on wgpu once https://github.com/gfx-rs/wgpu/pull/6648, 6649 and 6650 have been released
wgpu = { version = "23.0.1", default-features = false }
wgpu-types = { version = "24", default-features = false }
serde = { version = "1", features = ["derive"] }
thiserror = { version = "2", default-features = false }
futures-lite = "2.0.1"
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_image/src/dds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

use ddsfile::{Caps2, D3DFormat, Dds, DxgiFormat};
use std::io::Cursor;
use wgpu::TextureViewDescriptor;
use wgpu_types::{Extent3d, TextureDimension, TextureFormat, TextureViewDimension};
use wgpu_types::{
Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor, TextureViewDimension,
};
#[cfg(debug_assertions)]
use {bevy_utils::once, tracing::warn};

Expand Down Expand Up @@ -283,8 +284,7 @@ pub fn dds_format_to_texture_format(

#[cfg(test)]
mod test {
use wgpu::util::TextureDataOrder;
use wgpu_types::{TextureDescriptor, TextureDimension, TextureFormat};
use wgpu_types::{TextureDataOrder, TextureDescriptor, TextureDimension, TextureFormat};

use crate::CompressedImageFormats;

Expand Down
12 changes: 6 additions & 6 deletions crates/bevy_image/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ use bevy_math::{AspectRatio, UVec2, UVec3, Vec2};
use core::hash::Hash;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use wgpu::{SamplerDescriptor, TextureViewDescriptor};
use wgpu_types::{
AddressMode, CompareFunction, Extent3d, Features, FilterMode, SamplerBorderColor,
TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
SamplerDescriptor, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
TextureViewDescriptor,
};

pub trait BevyDefault {
Expand Down Expand Up @@ -343,7 +343,7 @@ pub struct Image {
pub texture_descriptor: TextureDescriptor<Option<&'static str>, &'static [TextureFormat]>,
/// The [`ImageSampler`] to use during rendering.
pub sampler: ImageSampler,
pub texture_view_descriptor: Option<TextureViewDescriptor<'static>>,
pub texture_view_descriptor: Option<TextureViewDescriptor<Option<&'static str>>>,
pub asset_usage: RenderAssetUsages,
}

Expand Down Expand Up @@ -559,7 +559,7 @@ impl ImageSamplerDescriptor {
}
}

pub fn as_wgpu(&self) -> SamplerDescriptor {
pub fn as_wgpu(&self) -> SamplerDescriptor<Option<&str>> {
SamplerDescriptor {
label: self.label.as_deref(),
address_mode_u: self.address_mode_u.into(),
Expand Down Expand Up @@ -669,8 +669,8 @@ impl From<SamplerBorderColor> for ImageSamplerBorderColor {
}
}

impl<'a> From<SamplerDescriptor<'a>> for ImageSamplerDescriptor {
fn from(value: SamplerDescriptor) -> Self {
impl From<SamplerDescriptor<Option<&str>>> for ImageSamplerDescriptor {
fn from(value: SamplerDescriptor<Option<&str>>) -> Self {
ImageSamplerDescriptor {
label: value.label.map(ToString::to_string),
address_mode_u: value.address_mode_u.into(),
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_image/src/ktx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use ktx2::{
BasicDataFormatDescriptor, ChannelTypeQualifiers, ColorModel, DataFormatDescriptorHeader,
Header, SampleInformation,
};
use wgpu::TextureViewDescriptor;
use wgpu_types::{
AstcBlock, AstcChannel, Extent3d, TextureDimension, TextureFormat, TextureViewDimension,
AstcBlock, AstcChannel, Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor,
TextureViewDimension,
};

use super::{CompressedImageFormats, DataFormat, Image, TextureError, TranscodeFormat};
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ webp = ["bevy_image/webp"]
# Enable SPIR-V passthrough
spirv_shader_passthrough = ["bevy_render/spirv_shader_passthrough"]

# Statically linked DXC shader compiler for DirectX 12
# TODO: When wgpu switches to DirectX 12 instead of Vulkan by default on windows, make this a default feature
statically-linked-dxc = ["bevy_render/statically-linked-dxc"]

# Include tonemapping LUT KTX2 files.
tonemapping_luts = ["bevy_core_pipeline/tonemapping_luts"]

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 @@ -29,7 +29,7 @@ bevy_platform_support = { path = "../bevy_platform_support", version = "0.16.0-d
# other
bitflags = { version = "2.3", features = ["serde"] }
bytemuck = { version = "1.5" }
wgpu-types = { version = "23", default-features = false }
wgpu-types = { version = "24", default-features = false }
serde = { version = "1", features = ["derive"] }
hexasphere = "15.0"
thiserror = { version = "2", default-features = false }
Expand Down
7 changes: 3 additions & 4 deletions crates/bevy_mesh/src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use super::{
GenerateTangentsError, Indices, MeshAttributeData, MeshTrianglesError, MeshVertexAttribute,
MeshVertexAttributeId, MeshVertexBufferLayout, MeshVertexBufferLayoutRef,
MeshVertexBufferLayouts, MeshWindingInvertError, VertexAttributeValues, VertexBufferLayout,
VertexFormatSize,
};
use alloc::collections::BTreeMap;
use bevy_asset::{Asset, Handle, RenderAssetUsages};
Expand Down Expand Up @@ -379,7 +378,7 @@ impl Mesh {
pub fn get_vertex_size(&self) -> u64 {
self.attributes
.values()
.map(|data| data.attribute.format.get_size())
.map(|data| data.attribute.format.size())
.sum()
}

Expand Down Expand Up @@ -414,7 +413,7 @@ impl Mesh {
format: data.attribute.format,
shader_location: index as u32,
});
accumulated_offset += data.attribute.format.get_size();
accumulated_offset += data.attribute.format.size();
}

let layout = MeshVertexBufferLayout {
Expand Down Expand Up @@ -482,7 +481,7 @@ impl Mesh {
// bundle into interleaved buffers
let mut attribute_offset = 0;
for attribute_data in self.attributes.values() {
let attribute_size = attribute_data.attribute.format.get_size() as usize;
let attribute_size = attribute_data.attribute.format.size() as usize;
let attributes_bytes = attribute_data.values.get_bytes();
for (vertex_index, attribute_bytes) in attributes_bytes
.chunks_exact(attribute_size)
Expand Down
45 changes: 0 additions & 45 deletions crates/bevy_mesh/src/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,51 +165,6 @@ pub fn face_normal(a: [f32; 3], b: [f32; 3], c: [f32; 3]) -> [f32; 3] {
(b - a).cross(c - a).normalize().into()
}

pub trait VertexFormatSize {
fn get_size(self) -> u64;
}

impl VertexFormatSize for VertexFormat {
fn get_size(self) -> u64 {
use core::mem::size_of;
let size = match self {
VertexFormat::Uint8x2 | VertexFormat::Unorm8x2 => size_of::<u8>() * 2,
VertexFormat::Uint8x4 | VertexFormat::Unorm8x4 => size_of::<u8>() * 4,
VertexFormat::Sint8x2 | VertexFormat::Snorm8x2 => size_of::<i8>() * 2,
VertexFormat::Sint8x4 | VertexFormat::Snorm8x4 => size_of::<i8>() * 4,
VertexFormat::Unorm10_10_10_2 => 10 + 10 + 10 + 2,
VertexFormat::Uint16x2 | VertexFormat::Unorm16x2 => size_of::<u16>() * 2,
VertexFormat::Uint16x4 | VertexFormat::Unorm16x4 => size_of::<u16>() * 4,
VertexFormat::Sint16x2 | VertexFormat::Snorm16x2 => size_of::<i16>() * 2,
VertexFormat::Sint16x4 | VertexFormat::Snorm16x4 => size_of::<i16>() * 4,
// NOTE: As of the time of writing this code, `f16` is not a stabilized primitive, so we
// can't use `size_of::<f16>()` here.
VertexFormat::Float16x2 => 2 * 2,
VertexFormat::Float16x4 => 2 * 4,
VertexFormat::Float32 => size_of::<f32>(),
VertexFormat::Float32x2 => size_of::<f32>() * 2,
VertexFormat::Float32x3 => size_of::<f32>() * 3,
VertexFormat::Float32x4 => size_of::<f32>() * 4,
VertexFormat::Uint32 => size_of::<u32>(),
VertexFormat::Uint32x2 => size_of::<u32>() * 2,
VertexFormat::Uint32x3 => size_of::<u32>() * 3,
VertexFormat::Uint32x4 => size_of::<u32>() * 4,
VertexFormat::Sint32 => size_of::<i32>(),
VertexFormat::Sint32x2 => size_of::<i32>() * 2,
VertexFormat::Sint32x3 => size_of::<i32>() * 3,
VertexFormat::Sint32x4 => size_of::<i32>() * 4,
VertexFormat::Float64 => size_of::<f64>(),
VertexFormat::Float64x2 => size_of::<f64>() * 2,
VertexFormat::Float64x3 => size_of::<f64>() * 3,
VertexFormat::Float64x4 => size_of::<f64>() * 4,
};

// We can safely cast `size` (a `usize`) into a `u64`, as we don't even reach the limits of
// of a `u8`.
size.try_into().unwrap()
}
}

/// Contains an array where each entry describes a property of a single vertex.
/// Matches the [`VertexFormats`](VertexFormat).
#[derive(Clone, Debug, EnumVariantMeta)]
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_pbr/src/meshlet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ use self::{
},
visibility_buffer_raster_node::MeshletVisibilityBufferRasterPassNode,
};
use crate::graph::NodePbr;
use crate::PreviousGlobalTransform;
use crate::{graph::NodePbr, PreviousGlobalTransform};
use bevy_app::{App, Plugin};
use bevy_asset::{load_internal_asset, weak_handle, AssetApp, AssetId, Handle};
use bevy_core_pipeline::{
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl Node for MeshletVisibilityBufferRasterPassNode {
meshlet_view_resources.raster_cluster_rightmost_slot,
);
meshlet_view_resources.depth_pyramid.downsample_depth(
"meshlet early downsample depth",
"downsample_depth",
render_context,
meshlet_view_resources.view_size,
&meshlet_view_bind_groups.downsample_depth,
Expand Down Expand Up @@ -202,7 +202,7 @@ impl Node for MeshletVisibilityBufferRasterPassNode {
camera,
);
meshlet_view_resources.depth_pyramid.downsample_depth(
"meshlet late downsample depth",
"downsample_depth",
render_context,
meshlet_view_resources.view_size,
&meshlet_view_bind_groups.downsample_depth,
Expand Down Expand Up @@ -270,7 +270,7 @@ impl Node for MeshletVisibilityBufferRasterPassNode {
meshlet_view_resources.raster_cluster_rightmost_slot,
);
meshlet_view_resources.depth_pyramid.downsample_depth(
"meshlet early shadow downsample depth",
"downsample_depth",
render_context,
meshlet_view_resources.view_size,
&meshlet_view_bind_groups.downsample_depth,
Expand Down Expand Up @@ -315,7 +315,7 @@ impl Node for MeshletVisibilityBufferRasterPassNode {
camera,
);
meshlet_view_resources.depth_pyramid.downsample_depth(
"meshlet late shadow downsample depth",
"downsample_depth",
render_context,
meshlet_view_resources.view_size,
&meshlet_view_bind_groups.downsample_depth,
Expand Down
8 changes: 3 additions & 5 deletions crates/bevy_pbr/src/render/build_indirect_params.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ fn main(@builtin(global_invocation_id) global_invocation_id: vec3<u32>) {
// If we aren't using `multi_draw_indirect_count`, we have a 1:1 fixed
// assignment of batches to slots in the indirect parameters buffer, so we
// can just use the instance index as the index of our indirect parameters.
let early_instance_count =
atomicLoad(&indirect_parameters_metadata[instance_index].early_instance_count);
let late_instance_count =
atomicLoad(&indirect_parameters_metadata[instance_index].late_instance_count);
let early_instance_count = indirect_parameters_metadata[instance_index].early_instance_count;
let late_instance_count = indirect_parameters_metadata[instance_index].late_instance_count;

// If in the early phase, we draw only the early meshes. If in the late
// phase, we draw only the late meshes. If in the main phase, draw all the
Expand Down Expand Up @@ -135,4 +133,4 @@ fn main(@builtin(global_invocation_id) global_invocation_id: vec3<u32>) {
indirect_parameters[indirect_parameters_index].vertex_count =
current_input[mesh_index].index_count;
#endif // INDEXED
}
}
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/gpu_preprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ impl SpecializedComputePipeline for PreprocessPipeline {
type Key = PreprocessPipelineKey;

fn specialize(&self, key: Self::Key) -> ComputePipelineDescriptor {
let mut shader_defs = vec![];
let mut shader_defs = vec!["WRITE_INDIRECT_PARAMETERS_METADATA".into()];
if key.contains(PreprocessPipelineKey::FRUSTUM_CULLING) {
shader_defs.push("INDIRECT".into());
shader_defs.push("FRUSTUM_CULLING".into());
Expand Down
5 changes: 5 additions & 0 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ pub fn prepare_lights(
all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu"))
))]
dimension: Some(TextureViewDimension::Cube),
usage: None,
aspect: TextureAspect::DepthOnly,
base_mip_level: 0,
mip_level_count: None,
Expand Down Expand Up @@ -1120,6 +1121,7 @@ pub fn prepare_lights(
dimension: Some(TextureViewDimension::D2Array),
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]
dimension: Some(TextureViewDimension::D2),
usage: None,
aspect: TextureAspect::DepthOnly,
base_mip_level: 0,
mip_level_count: None,
Expand Down Expand Up @@ -1242,6 +1244,7 @@ pub fn prepare_lights(
label: Some("point_light_shadow_map_texture_view"),
format: None,
dimension: Some(TextureViewDimension::D2),
usage: None,
aspect: TextureAspect::All,
base_mip_level: 0,
mip_level_count: None,
Expand Down Expand Up @@ -1343,6 +1346,7 @@ pub fn prepare_lights(
label: Some("spot_light_shadow_map_texture_view"),
format: None,
dimension: Some(TextureViewDimension::D2),
usage: None,
aspect: TextureAspect::All,
base_mip_level: 0,
mip_level_count: None,
Expand Down Expand Up @@ -1477,6 +1481,7 @@ pub fn prepare_lights(
label: Some("directional_light_shadow_map_array_texture_view"),
format: None,
dimension: Some(TextureViewDimension::D2),
usage: None,
aspect: TextureAspect::All,
base_mip_level: 0,
mip_level_count: None,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1733,7 +1733,7 @@ impl FromWorld for MeshPipeline {
render_queue.write_texture(
texture.as_image_copy(),
&image.data,
ImageDataLayout {
TexelCopyBufferLayout {
offset: 0,
bytes_per_row: Some(image.width() * format_size as u32),
rows_per_image: None,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/render/shadow_sampling.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ fn search_for_blockers_in_shadow_map_hardware(
view_bindings::directional_shadow_textures,
view_bindings::directional_shadow_textures_linear_sampler,
light_local,
0.0,
0u,
);
#else // NO_ARRAY_TEXTURES_SUPPORT
let sampled_depth = textureSampleLevel(
view_bindings::directional_shadow_textures,
view_bindings::directional_shadow_textures_linear_sampler,
light_local,
array_index,
0.0,
0u,
);
#endif // NO_ARRAY_TEXTURES_SUPPORT
return select(vec2(0.0), vec2(sampled_depth, 1.0), sampled_depth >= depth);
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_pbr/src/ssr/raymarch.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ fn depth_raymarch_distance_fn_evaluate(
// * The shrink-wrap surface is no longer continuous, so it's possible for rays to miss it.

let linear_depth =
1.0 / textureSampleLevel(depth_prepass_texture, depth_linear_sampler, interp_uv, 0.0);
1.0 / textureSampleLevel(depth_prepass_texture, depth_linear_sampler, interp_uv, 0u);
let unfiltered_depth =
1.0 / textureSampleLevel(depth_prepass_texture, depth_nearest_sampler, interp_uv, 0.0);
1.0 / textureSampleLevel(depth_prepass_texture, depth_nearest_sampler, interp_uv, 0u);

var max_depth: f32;
var min_depth: f32;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ uuid = { version = "1.13.1", default-features = false, optional = true, features
"serde",
] }
variadics_please = "1.1"
wgpu-types = { version = "23", features = ["serde"], optional = true }
wgpu-types = { version = "24", features = ["serde"], optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
uuid = { version = "1.13.1", default-features = false, features = ["js"] }
Expand Down
Loading