mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 14:10:19 +00:00
Updated to wgpu 0.16.0, wgpu-hal 0.16.0 and naga 0.12.0 (#8446)
# Objective - Updated to wgpu 0.16.0 and wgpu-hal 0.16.0 --- ## Changelog 1. Upgrade wgpu to 0.16.0 and wgpu-hal to 0.16.0 2. Fix the error in native when using a filterable `TextureSampleType::Float` on a multisample `BindingType::Texture`. ([https://github.com/gfx-rs/wgpu/pull/3686](https://github.com/gfx-rs/wgpu/pull/3686)) --------- Co-authored-by: François <mockersf@gmail.com>
This commit is contained in:
parent
75130bd5ec
commit
4d54ce14aa
13 changed files with 42 additions and 61 deletions
|
@ -30,7 +30,6 @@ use downsampling_pipeline::{
|
|||
prepare_downsampling_pipeline, BloomDownsamplingPipeline, BloomDownsamplingPipelineIds,
|
||||
BloomUniforms,
|
||||
};
|
||||
use std::num::NonZeroU32;
|
||||
use upsampling_pipeline::{
|
||||
prepare_upsampling_pipeline, BloomUpsamplingPipeline, UpsamplingPipelineIds,
|
||||
};
|
||||
|
@ -310,7 +309,7 @@ impl BloomTexture {
|
|||
fn view(&self, base_mip_level: u32) -> TextureView {
|
||||
self.texture.texture.create_view(&TextureViewDescriptor {
|
||||
base_mip_level,
|
||||
mip_level_count: NonZeroU32::new(1),
|
||||
mip_level_count: Some(1u32),
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -561,7 +561,7 @@ pub fn get_bind_group_layout_entries(
|
|||
visibility: ShaderStages::FRAGMENT,
|
||||
ty: BindingType::Texture {
|
||||
multisampled,
|
||||
sample_type: TextureSampleType::Float { filterable: true },
|
||||
sample_type: TextureSampleType::Float { filterable: false },
|
||||
view_dimension: TextureViewDimension::D2,
|
||||
},
|
||||
count: None,
|
||||
|
@ -572,7 +572,7 @@ pub fn get_bind_group_layout_entries(
|
|||
visibility: ShaderStages::FRAGMENT,
|
||||
ty: BindingType::Texture {
|
||||
multisampled,
|
||||
sample_type: TextureSampleType::Float { filterable: true },
|
||||
sample_type: TextureSampleType::Float { filterable: false },
|
||||
view_dimension: TextureViewDimension::D2,
|
||||
},
|
||||
count: None,
|
||||
|
|
|
@ -30,10 +30,7 @@ use bevy_utils::{
|
|||
tracing::{error, warn},
|
||||
HashMap,
|
||||
};
|
||||
use std::{
|
||||
hash::Hash,
|
||||
num::{NonZeroU32, NonZeroU64},
|
||||
};
|
||||
use std::{hash::Hash, num::NonZeroU64};
|
||||
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
||||
pub enum RenderLightSystems {
|
||||
|
@ -998,7 +995,7 @@ pub fn prepare_lights(
|
|||
base_mip_level: 0,
|
||||
mip_level_count: None,
|
||||
base_array_layer: (light_index * 6 + face_index) as u32,
|
||||
array_layer_count: NonZeroU32::new(1),
|
||||
array_layer_count: Some(1u32),
|
||||
});
|
||||
|
||||
let view_light_entity = commands
|
||||
|
@ -1060,7 +1057,7 @@ pub fn prepare_lights(
|
|||
base_mip_level: 0,
|
||||
mip_level_count: None,
|
||||
base_array_layer: (num_directional_cascades_enabled + light_index) as u32,
|
||||
array_layer_count: NonZeroU32::new(1),
|
||||
array_layer_count: Some(1u32),
|
||||
});
|
||||
|
||||
let view_light_entity = commands
|
||||
|
@ -1124,7 +1121,7 @@ pub fn prepare_lights(
|
|||
base_mip_level: 0,
|
||||
mip_level_count: None,
|
||||
base_array_layer: directional_depth_texture_array_index,
|
||||
array_layer_count: NonZeroU32::new(1),
|
||||
array_layer_count: Some(1u32),
|
||||
});
|
||||
directional_depth_texture_array_index += 1;
|
||||
|
||||
|
|
|
@ -514,12 +514,7 @@ impl FromWorld for MeshPipeline {
|
|||
&image.data,
|
||||
ImageDataLayout {
|
||||
offset: 0,
|
||||
bytes_per_row: Some(
|
||||
std::num::NonZeroU32::new(
|
||||
image.texture_descriptor.size.width * format_size as u32,
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
bytes_per_row: Some(image.texture_descriptor.size.width * format_size as u32),
|
||||
rows_per_image: None,
|
||||
},
|
||||
image.texture_descriptor.size,
|
||||
|
|
|
@ -55,10 +55,10 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.11.0-dev" }
|
|||
image = { version = "0.24", default-features = false }
|
||||
|
||||
# misc
|
||||
wgpu = { version = "0.15.0" }
|
||||
wgpu-hal = "0.15.1"
|
||||
wgpu = { version = "0.16.0" }
|
||||
wgpu-hal = "0.16.0"
|
||||
codespan-reporting = "0.11.0"
|
||||
naga = { version = "0.11.0", features = ["wgsl-in"] }
|
||||
naga = { version = "0.12.0", features = ["wgsl-in"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
bitflags = "1.2.1"
|
||||
smallvec = { version = "1.6", features = ["union", "const_generics"] }
|
||||
|
|
|
@ -128,7 +128,7 @@ impl ProcessedShader {
|
|||
ProcessedShader::Wgsl(source) => naga::front::wgsl::parse_str(source)?,
|
||||
#[cfg(feature = "shader_format_glsl")]
|
||||
ProcessedShader::Glsl(source, shader_stage) => {
|
||||
let mut parser = naga::front::glsl::Parser::default();
|
||||
let mut parser = naga::front::glsl::Frontend::default();
|
||||
parser
|
||||
.parse(&naga::front::glsl::Options::from(*shader_stage), source)
|
||||
.map_err(ShaderReflectError::GlslParse)?
|
||||
|
@ -152,7 +152,7 @@ impl ProcessedShader {
|
|||
};
|
||||
const CAPABILITIES: &[(Features, Capabilities)] = &[
|
||||
(Features::PUSH_CONSTANTS, Capabilities::PUSH_CONSTANT),
|
||||
(Features::SHADER_FLOAT64, Capabilities::FLOAT64),
|
||||
(Features::SHADER_F64, Capabilities::FLOAT64),
|
||||
(
|
||||
Features::SHADER_PRIMITIVE_INDEX,
|
||||
Capabilities::PRIMITIVE_INDEX,
|
||||
|
|
|
@ -215,7 +215,7 @@ pub fn dds_format_to_texture_format(
|
|||
}
|
||||
|
||||
DxgiFormat::BC6H_Typeless | DxgiFormat::BC6H_UF16 => TextureFormat::Bc6hRgbUfloat,
|
||||
DxgiFormat::BC6H_SF16 => TextureFormat::Bc6hRgbSfloat,
|
||||
DxgiFormat::BC6H_SF16 => TextureFormat::Bc6hRgbFloat,
|
||||
DxgiFormat::BC7_Typeless | DxgiFormat::BC7_UNorm | DxgiFormat::BC7_UNorm_sRGB => {
|
||||
if is_srgb {
|
||||
TextureFormat::Bc7RgbaUnormSrgb
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use std::num::NonZeroU32;
|
||||
|
||||
use crate::{render_resource::*, texture::DefaultImageSampler};
|
||||
use bevy_derive::{Deref, DerefMut};
|
||||
use bevy_ecs::{
|
||||
|
@ -54,7 +52,7 @@ fn fallback_image_new(
|
|||
image.texture_descriptor.usage |= TextureUsages::RENDER_ATTACHMENT;
|
||||
|
||||
// We can't create textures with data when it's a depth texture or when using multiple samples
|
||||
let texture = if format.describe().sample_type == TextureSampleType::Depth || samples > 1 {
|
||||
let texture = if format.is_depth_stencil_format() || samples > 1 {
|
||||
render_device.create_texture(&image.texture_descriptor)
|
||||
} else {
|
||||
render_device.create_texture_with_data(render_queue, &image.texture_descriptor, &image.data)
|
||||
|
@ -62,7 +60,7 @@ fn fallback_image_new(
|
|||
|
||||
let texture_view = texture.create_view(&TextureViewDescriptor {
|
||||
dimension: Some(dimension),
|
||||
array_layer_count: NonZeroU32::new(extents.depth_or_array_layers),
|
||||
array_layer_count: Some(extents.depth_or_array_layers),
|
||||
..TextureViewDescriptor::default()
|
||||
});
|
||||
let sampler = match image.sampler_descriptor {
|
||||
|
|
|
@ -386,15 +386,15 @@ impl Image {
|
|||
|
||||
/// Whether the texture format is compressed or uncompressed
|
||||
pub fn is_compressed(&self) -> bool {
|
||||
let format_description = self.texture_descriptor.format.describe();
|
||||
let format_description = self.texture_descriptor.format;
|
||||
format_description
|
||||
.required_features
|
||||
.contains(wgpu::Features::TEXTURE_COMPRESSION_ASTC_LDR)
|
||||
.required_features()
|
||||
.contains(wgpu::Features::TEXTURE_COMPRESSION_ASTC)
|
||||
|| format_description
|
||||
.required_features
|
||||
.required_features()
|
||||
.contains(wgpu::Features::TEXTURE_COMPRESSION_BC)
|
||||
|| format_description
|
||||
.required_features
|
||||
.required_features()
|
||||
.contains(wgpu::Features::TEXTURE_COMPRESSION_ETC2)
|
||||
}
|
||||
}
|
||||
|
@ -482,9 +482,9 @@ pub trait TextureFormatPixelInfo {
|
|||
|
||||
impl TextureFormatPixelInfo for TextureFormat {
|
||||
fn pixel_size(&self) -> usize {
|
||||
let info = self.describe();
|
||||
match info.block_dimensions {
|
||||
(1, 1) => info.block_size.into(),
|
||||
let info = self;
|
||||
match info.block_dimensions() {
|
||||
(1, 1) => info.block_size(None).unwrap() as usize,
|
||||
_ => panic!("Using pixel_size for compressed textures is invalid"),
|
||||
}
|
||||
}
|
||||
|
@ -568,7 +568,7 @@ bitflags::bitflags! {
|
|||
impl CompressedImageFormats {
|
||||
pub fn from_features(features: wgpu::Features) -> Self {
|
||||
let mut supported_compressed_formats = Self::default();
|
||||
if features.contains(wgpu::Features::TEXTURE_COMPRESSION_ASTC_LDR) {
|
||||
if features.contains(wgpu::Features::TEXTURE_COMPRESSION_ASTC) {
|
||||
supported_compressed_formats |= Self::ASTC_LDR;
|
||||
}
|
||||
if features.contains(wgpu::Features::TEXTURE_COMPRESSION_BC) {
|
||||
|
@ -593,7 +593,7 @@ impl CompressedImageFormats {
|
|||
| TextureFormat::Bc5RgUnorm
|
||||
| TextureFormat::Bc5RgSnorm
|
||||
| TextureFormat::Bc6hRgbUfloat
|
||||
| TextureFormat::Bc6hRgbSfloat
|
||||
| TextureFormat::Bc6hRgbFloat
|
||||
| TextureFormat::Bc7RgbaUnorm
|
||||
| TextureFormat::Bc7RgbaUnormSrgb => self.contains(CompressedImageFormats::BC),
|
||||
TextureFormat::Etc2Rgb8Unorm
|
||||
|
|
|
@ -154,12 +154,13 @@ pub fn ktx2_buffer_to_image(
|
|||
TranscodeFormat::Uastc(data_format) => {
|
||||
let (transcode_block_format, texture_format) =
|
||||
get_transcoded_formats(supported_compressed_formats, data_format, is_srgb);
|
||||
let texture_format_info = texture_format.describe();
|
||||
let texture_format_info = texture_format;
|
||||
let (block_width_pixels, block_height_pixels) = (
|
||||
texture_format_info.block_dimensions.0 as u32,
|
||||
texture_format_info.block_dimensions.1 as u32,
|
||||
texture_format_info.block_dimensions().0,
|
||||
texture_format_info.block_dimensions().1,
|
||||
);
|
||||
let block_bytes = texture_format_info.block_size as u32;
|
||||
// Texture is not a depth or stencil format, it is possible to pass `None` and unwrap
|
||||
let block_bytes = texture_format_info.block_size(None).unwrap();
|
||||
|
||||
let transcoder = LowLevelUastcTranscoder::new();
|
||||
for (level, level_data) in levels.iter().enumerate() {
|
||||
|
@ -233,12 +234,13 @@ pub fn ktx2_buffer_to_image(
|
|||
}
|
||||
|
||||
// Reorder data from KTX2 MipXLayerYFaceZ to wgpu LayerYFaceZMipX
|
||||
let texture_format_info = texture_format.describe();
|
||||
let texture_format_info = texture_format;
|
||||
let (block_width_pixels, block_height_pixels) = (
|
||||
texture_format_info.block_dimensions.0 as usize,
|
||||
texture_format_info.block_dimensions.1 as usize,
|
||||
texture_format_info.block_dimensions().0 as usize,
|
||||
texture_format_info.block_dimensions().1 as usize,
|
||||
);
|
||||
let block_bytes = texture_format_info.block_size as usize;
|
||||
// Texture is not a depth or stencil format, it is possible to pass `None` and unwrap
|
||||
let block_bytes = texture_format_info.block_size(None).unwrap() as usize;
|
||||
|
||||
let mut wgpu_data = vec![Vec::default(); (layer_count * face_count) as usize];
|
||||
for (level, level_data) in levels.iter().enumerate() {
|
||||
|
@ -1037,7 +1039,7 @@ pub fn ktx2_dfd_to_texture_format(
|
|||
if sample_information[0].lower == 0 {
|
||||
TextureFormat::Bc6hRgbUfloat
|
||||
} else {
|
||||
TextureFormat::Bc6hRgbSfloat
|
||||
TextureFormat::Bc6hRgbFloat
|
||||
}
|
||||
}
|
||||
Some(ColorModel::BC7) => {
|
||||
|
@ -1311,7 +1313,7 @@ pub fn ktx2_format_to_texture_format(
|
|||
ktx2::Format::BC5_UNORM_BLOCK => TextureFormat::Bc5RgUnorm,
|
||||
ktx2::Format::BC5_SNORM_BLOCK => TextureFormat::Bc5RgSnorm,
|
||||
ktx2::Format::BC6H_UFLOAT_BLOCK => TextureFormat::Bc6hRgbUfloat,
|
||||
ktx2::Format::BC6H_SFLOAT_BLOCK => TextureFormat::Bc6hRgbSfloat,
|
||||
ktx2::Format::BC6H_SFLOAT_BLOCK => TextureFormat::Bc6hRgbFloat,
|
||||
ktx2::Format::BC7_UNORM_BLOCK | ktx2::Format::BC7_SRGB_BLOCK => {
|
||||
if is_srgb {
|
||||
TextureFormat::Bc7RgbaUnormSrgb
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{borrow::Cow, num::NonZeroU32, path::Path};
|
||||
use std::{borrow::Cow, path::Path};
|
||||
|
||||
use bevy_app::Plugin;
|
||||
use bevy_asset::{load_internal_asset, HandleUntyped};
|
||||
|
@ -117,7 +117,7 @@ pub(crate) fn layout_data(width: u32, height: u32, format: TextureFormat) -> Ima
|
|||
ImageDataLayout {
|
||||
bytes_per_row: if height > 1 {
|
||||
// 1 = 1 row
|
||||
NonZeroU32::new(get_aligned_size(width, 1, format.pixel_size() as u32))
|
||||
Some(get_aligned_size(width, 1, format.pixel_size() as u32))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
|
|
|
@ -232,12 +232,7 @@ impl FromWorld for Mesh2dPipeline {
|
|||
&image.data,
|
||||
ImageDataLayout {
|
||||
offset: 0,
|
||||
bytes_per_row: Some(
|
||||
std::num::NonZeroU32::new(
|
||||
image.texture_descriptor.size.width * format_size as u32,
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
bytes_per_row: Some(image.texture_descriptor.size.width * format_size as u32),
|
||||
rows_per_image: None,
|
||||
},
|
||||
image.texture_descriptor.size,
|
||||
|
|
|
@ -109,12 +109,7 @@ impl FromWorld for SpritePipeline {
|
|||
&image.data,
|
||||
ImageDataLayout {
|
||||
offset: 0,
|
||||
bytes_per_row: Some(
|
||||
std::num::NonZeroU32::new(
|
||||
image.texture_descriptor.size.width * format_size as u32,
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
bytes_per_row: Some(image.texture_descriptor.size.width * format_size as u32),
|
||||
rows_per_image: None,
|
||||
},
|
||||
image.texture_descriptor.size,
|
||||
|
|
Loading…
Reference in a new issue