Skip to content
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 by Bors] - Update wgpu to 0.12 and naga to 0.8 #3375

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion assets/shaders/custom_material.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[[block]]
struct CustomMaterial {
color: vec4<f32>;
};
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gltf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ thiserror = "1.0"
anyhow = "1.0.4"
base64 = "0.13.0"
percent-encoding = "2.1"
wgpu = "0.11.0"
wgpu = "0.12.0"
2 changes: 1 addition & 1 deletion crates/bevy_pbr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ bitflags = "1.2"
# direct dependency required for derive macro
bytemuck = { version = "1", features = ["derive"] }
crevice = { path = "../crevice", version = "0.8.0", features = ["glam"] }
wgpu = { version = "0.11.0", features = ["spirv"] }
wgpu = { version = "0.12.0", features = ["spirv"] }
1 change: 0 additions & 1 deletion crates/bevy_pbr/src/render/depth.wgsl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#import bevy_pbr::mesh_struct

// NOTE: Keep in sync with pbr.wgsl
[[block]]
struct View {
view_proj: mat4x4<f32>;
projection: mat4x4<f32>;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ impl SpecializedPipeline for ShadowPipeline {
strip_index_format: None,
front_face: FrontFace::Ccw,
cull_mode: None,
unclipped_depth: false,
polygon_mode: PolygonMode::Fill,
clamp_depth: false,
conservative: false,
},
depth_stencil: Some(DepthStencilState {
Expand Down
16 changes: 5 additions & 11 deletions crates/bevy_pbr/src/render/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use bevy_render::{
use bevy_transform::components::GlobalTransform;
use crevice::std140::AsStd140;
use wgpu::{
Extent3d, ImageCopyTexture, ImageDataLayout, Origin3d, TextureDimension, TextureFormat,
TextureViewDescriptor,
Extent3d, ImageCopyTexture, ImageDataLayout, Origin3d, SamplerBindingType, TextureDimension,
TextureFormat, TextureViewDescriptor,
};

#[derive(Default)]
Expand Down Expand Up @@ -210,10 +210,7 @@ impl FromWorld for MeshPipeline {
BindGroupLayoutEntry {
binding: 3,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler {
comparison: true,
filtering: true,
},
ty: BindingType::Sampler(SamplerBindingType::Comparison),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can someone verify if this isn't a behavorial change.

Copy link
Contributor Author

@vabka vabka Dec 18, 2021

Choose a reason for hiding this comment

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

+1
Also not sure

Copy link
Contributor Author

@vabka vabka Dec 18, 2021

Choose a reason for hiding this comment

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

I dont know what these options should affect. But with SamplingBindingType::Filtering in panics on start.
Result looks pretty same.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think comparison is fine for now. We might be able to rein this in, but this seems like the right choice for the current impl.

count: None,
},
// Directional Shadow Texture Array
Expand All @@ -231,10 +228,7 @@ impl FromWorld for MeshPipeline {
BindGroupLayoutEntry {
binding: 5,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler {
comparison: true,
filtering: true,
},
ty: BindingType::Sampler(SamplerBindingType::Comparison),
count: None,
},
// PointLights
Expand Down Expand Up @@ -493,8 +487,8 @@ impl SpecializedPipeline for MeshPipeline {
primitive: PrimitiveState {
front_face: FrontFace::Ccw,
cull_mode: Some(Face::Back),
unclipped_depth: false,
polygon_mode: PolygonMode::Fill,
clamp_depth: false,
conservative: false,
topology: PrimitiveTopology::TriangleList,
strip_index_format: None,
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_pbr/src/render/mesh_struct.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[[block]]
struct Mesh {
model: mat4x4<f32>;
inverse_transpose_model: mat4x4<f32>;
Expand Down
5 changes: 0 additions & 5 deletions crates/bevy_pbr/src/render/mesh_view_bind_group.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[[block]]
struct View {
view_proj: mat4x4<f32>;
inverse_view: mat4x4<f32>;
Expand Down Expand Up @@ -35,7 +34,6 @@ struct DirectionalLight {

let DIRECTIONAL_LIGHT_FLAGS_SHADOWS_ENABLED_BIT: u32 = 1u;

[[block]]
struct Lights {
// NOTE: this array size must be kept in sync with the constants defined bevy_pbr2/src/render/light.rs
directional_lights: array<DirectionalLight, 1u>;
Expand All @@ -56,18 +54,15 @@ struct Lights {
n_directional_lights: u32;
};

[[block]]
struct PointLights {
data: array<PointLight, 256u>;
};

[[block]]
struct ClusterLightIndexLists {
// each u32 contains 4 u8 indices into the PointLights array
data: array<vec4<u32>, 1024u>;
};

[[block]]
struct ClusterOffsetsAndCounts {
// each u32 contains a 24-bit index into ClusterLightIndexLists in the high 24 bits
// and an 8-bit count of the number of lights in the low 8 bits
Expand Down
26 changes: 6 additions & 20 deletions crates/bevy_pbr/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod mesh;

pub use light::*;
pub use mesh::*;
use wgpu::SamplerBindingType;

use crate::{AlphaMode, StandardMaterial, StandardMaterialUniformData, PBR_SHADER_HANDLE};
use bevy_asset::Handle;
Expand Down Expand Up @@ -81,10 +82,7 @@ impl FromWorld for PbrPipeline {
BindGroupLayoutEntry {
binding: 2,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: BindingType::Sampler(SamplerBindingType::Filtering),
count: None,
},
// Emissive Texture
Expand All @@ -102,10 +100,7 @@ impl FromWorld for PbrPipeline {
BindGroupLayoutEntry {
binding: 4,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: BindingType::Sampler(SamplerBindingType::Filtering),
count: None,
},
// Metallic Roughness Texture
Expand All @@ -123,10 +118,7 @@ impl FromWorld for PbrPipeline {
BindGroupLayoutEntry {
binding: 6,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: BindingType::Sampler(SamplerBindingType::Filtering),
count: None,
},
// Occlusion Texture
Expand All @@ -144,10 +136,7 @@ impl FromWorld for PbrPipeline {
BindGroupLayoutEntry {
binding: 8,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: BindingType::Sampler(SamplerBindingType::Filtering),
count: None,
},
// Normal Map Texture
Expand All @@ -165,10 +154,7 @@ impl FromWorld for PbrPipeline {
BindGroupLayoutEntry {
binding: 10,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: BindingType::Sampler(SamplerBindingType::Filtering),
count: None,
},
],
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_pbr/src/render/pbr.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
[[group(2), binding(0)]]
var<uniform> mesh: Mesh;

[[block]]
struct StandardMaterial {
base_color: vec4<f32>;
emissive: vec4<f32>;
Expand Down Expand Up @@ -505,7 +504,7 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4<f32> {
if ((material.flags & STANDARD_MATERIAL_FLAGS_ALPHA_MODE_OPAQUE) != 0u) {
// NOTE: If rendering as opaque, alpha should be ignored so set to 1.0
output_color.a = 1.0;
} elseif ((material.flags & STANDARD_MATERIAL_FLAGS_ALPHA_MODE_MASK) != 0u) {
} else if ((material.flags & STANDARD_MATERIAL_FLAGS_ALPHA_MODE_MASK) != 0u) {
if (output_color.a >= material.alpha_cutoff) {
// NOTE: If rendering as masked alpha and >= the cutoff, render as fully opaque
output_color.a = 1.0;
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ bevy_utils = { path = "../bevy_utils", version = "0.5.0" }
image = { version = "0.23.12", default-features = false }

# misc
wgpu = { version = "0.11.0", features = ["spirv"] }
naga = { version = "0.7.0", features = ["glsl-in", "spv-in", "spv-out", "wgsl-in", "wgsl-out"] }
wgpu = { version = "0.12.0", features = ["spirv"] }
naga = { version = "0.8.0", features = ["glsl-in", "spv-in", "spv-out", "wgsl-in", "wgsl-out"] }
serde = { version = "1", features = ["derive"] }
bitflags = "1.2.1"
smallvec = { version = "1.6", features = ["union", "const_generics"] }
Expand All @@ -53,4 +53,4 @@ regex = "1.5"
crevice = { path = "../crevice", version = "0.8.0", features = ["glam"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wgpu = { version = "0.11.0", features = ["spirv", "webgl"] }
wgpu = { version = "0.12.0", features = ["spirv", "webgl"] }
1 change: 1 addition & 0 deletions crates/bevy_render/src/render_resource/pipeline_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ impl RenderPipelineCache {
};

let descriptor = RawRenderPipelineDescriptor {
multiview: None,
depth_stencil: descriptor.depth_stencil.clone(),
label: descriptor.label.as_deref(),
layout,
Expand Down
19 changes: 3 additions & 16 deletions crates/bevy_render/src/render_resource/shader.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bevy_asset::{AssetLoader, Handle, LoadContext, LoadedAsset};
use bevy_reflect::{TypeUuid, Uuid};
use bevy_utils::{tracing::error, BoxedFuture, HashMap};
use naga::back::wgsl::WriterFlags;
use naga::{valid::ModuleInfo, Module};
use once_cell::sync::Lazy;
use regex::Regex;
Expand Down Expand Up @@ -29,9 +30,8 @@ pub enum ShaderReflectError {
#[error(transparent)]
SpirVParse(#[from] naga::front::spv::Error),
#[error(transparent)]
Validation(#[from] naga::valid::ValidationError),
Validation(#[from] naga::WithSpan<naga::valid::ValidationError>),
}

/// A shader, as defined by its [`ShaderSource`] and [`ShaderStage`](naga::ShaderStage)
/// This is an "unprocessed" shader. It can contain preprocessor directives.
#[derive(Debug, Clone, TypeUuid)]
Expand Down Expand Up @@ -204,7 +204,7 @@ impl ShaderReflection {
}

pub fn get_wgsl(&self) -> Result<String, naga::back::wgsl::Error> {
naga::back::wgsl::write_string(&self.module, &self.module_info)
naga::back::wgsl::write_string(&self.module, &self.module_info, WriterFlags::EXPLICIT_TYPES)
}
}

Expand Down Expand Up @@ -462,7 +462,6 @@ mod tests {
use crate::render_resource::{ProcessShaderError, Shader, ShaderImport, ShaderProcessor};
#[rustfmt::skip]
const WGSL: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -493,7 +492,6 @@ fn vertex(
";

const WGSL_ELSE: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -527,7 +525,6 @@ fn vertex(
";

const WGSL_NESTED_IFDEF: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -560,7 +557,6 @@ fn vertex(
";

const WGSL_NESTED_IFDEF_ELSE: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -599,7 +595,6 @@ fn vertex(
fn process_shader_def_defined() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -642,7 +637,6 @@ fn vertex(
fn process_shader_def_not_defined() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -683,7 +677,6 @@ fn vertex(
fn process_shader_def_else() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -849,7 +842,6 @@ void bar() { }
fn process_nested_shader_def_outer_defined_inner_not() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -890,7 +882,6 @@ fn vertex(
fn process_nested_shader_def_outer_defined_inner_else() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -933,7 +924,6 @@ fn vertex(
fn process_nested_shader_def_neither_defined() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -974,7 +964,6 @@ fn vertex(
fn process_nested_shader_def_neither_defined_else() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -1015,7 +1004,6 @@ fn vertex(
fn process_nested_shader_def_inner_defined_outer_not() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down Expand Up @@ -1056,7 +1044,6 @@ fn vertex(
fn process_nested_shader_def_both_defined() {
#[rustfmt::skip]
const EXPECTED: &str = r"
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_sprite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ guillotiere = "0.6.0"
thiserror = "1.0"
rectangle-pack = "0.4"
serde = { version = "1", features = ["derive"] }
wgpu = "0.12.0"
8 changes: 3 additions & 5 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use bevy_transform::components::GlobalTransform;
use bevy_utils::HashMap;
use bytemuck::{Pod, Zeroable};
use crevice::std140::AsStd140;
use wgpu::SamplerBindingType;

pub struct SpritePipeline {
view_layout: BindGroupLayout,
Expand Down Expand Up @@ -66,10 +67,7 @@ impl FromWorld for SpritePipeline {
BindGroupLayoutEntry {
binding: 1,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: BindingType::Sampler(SamplerBindingType::Filtering),
count: None,
},
],
Expand Down Expand Up @@ -140,8 +138,8 @@ impl SpecializedPipeline for SpritePipeline {
primitive: PrimitiveState {
front_face: FrontFace::Ccw,
cull_mode: None,
unclipped_depth: false,
polygon_mode: PolygonMode::Fill,
clamp_depth: false,
conservative: false,
topology: PrimitiveTopology::TriangleList,
strip_index_format: None,
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_sprite/src/render/sprite.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[[block]]
struct View {
view_proj: mat4x4<f32>;
world_position: vec3<f32>;
Expand Down
Loading