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] - Upgrade to wgpu 0.11 #2933

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/bevyengine/bevy"
resolver = "2"

[workspace]
exclude = ["benches"]
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_render/src/render_graph/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
LoadOp, Operations, PassDescriptor, RenderPassColorAttachment,
RenderPassDepthStencilAttachment, TextureAttachment,
},
texture::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsage},
texture::{Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages},
Color,
};
use bevy_ecs::{reflect::ReflectComponent, world::World};
Expand Down Expand Up @@ -126,7 +126,7 @@ pub(crate) fn add_base_graph(config: &BaseRenderGraphConfig, world: &mut World)
dimension: TextureDimension::D2,
format: TextureFormat::Depth32Float, /* PERF: vulkan docs recommend using 24
* bit depth for better performance */
usage: TextureUsage::OUTPUT_ATTACHMENT,
usage: TextureUsages::OUTPUT_ATTACHMENT,
},
),
);
Expand Down Expand Up @@ -220,7 +220,7 @@ pub(crate) fn add_base_graph(config: &BaseRenderGraphConfig, world: &mut World)
sample_count: msaa.samples,
dimension: TextureDimension::D2,
format: TextureFormat::default(),
usage: TextureUsage::OUTPUT_ATTACHMENT,
usage: TextureUsages::OUTPUT_ATTACHMENT,
},
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Node for WindowSwapChainNode {

let render_resource_context = render_context.resources_mut();

// create window swapchain when window is resized or created
// reconfigure surface window is resized or created
if self
.window_created_event_reader
.iter(window_created_events)
Expand All @@ -62,10 +62,10 @@ impl Node for WindowSwapChainNode {
.iter(window_resized_events)
.any(|e| e.id == window.id())
{
render_resource_context.create_swap_chain(window);
render_resource_context.configure_surface(window);
}

let swap_chain_texture = render_resource_context.next_swap_chain_texture(window);
let swap_chain_texture = render_resource_context.next_surface_frame(window);
output.set(
WINDOW_TEXTURE,
RenderResourceId::Texture(swap_chain_texture),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ impl HeadlessRenderResourceContext {
}

impl RenderResourceContext for HeadlessRenderResourceContext {
fn create_swap_chain(&self, _window: &Window) {}
fn configure_surface(&self, _window: &Window) {}

fn next_swap_chain_texture(&self, _window: &Window) -> TextureId {
fn next_surface_frame(&self, _window: &Window) -> TextureId {
TextureId::new()
}

fn drop_swap_chain_texture(&self, _render_resource: TextureId) {}
fn drop_surface_frame(&self, _render_resource: TextureId) {}

fn drop_all_swap_chain_textures(&self) {}
fn drop_all_surface_frames(&self) {}

fn create_sampler(&self, _sampler_descriptor: &SamplerDescriptor) -> SamplerId {
SamplerId::new()
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_render/src/renderer/render_resource_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use downcast_rs::{impl_downcast, Downcast};
use std::ops::Range;

pub trait RenderResourceContext: Downcast + Send + Sync + 'static {
fn create_swap_chain(&self, window: &Window);
fn next_swap_chain_texture(&self, window: &Window) -> TextureId;
fn drop_swap_chain_texture(&self, resource: TextureId);
fn drop_all_swap_chain_textures(&self);
fn configure_surface(&self, window: &Window);
fn next_surface_frame(&self, window: &Window) -> TextureId;
fn drop_surface_frame(&self, resource: TextureId);
fn drop_all_surface_frames(&self);
fn create_sampler(&self, sampler_descriptor: &SamplerDescriptor) -> SamplerId;
fn create_texture(&self, texture_descriptor: TextureDescriptor) -> TextureId;
fn create_buffer(&self, buffer_info: BufferInfo) -> BufferId;
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_render/src/shader/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ pub fn glsl_to_spirv(
impl Into<shaderc::ShaderKind> for ShaderStage {
fn into(self) -> shaderc::ShaderKind {
match self {
ShaderStage::Vertex => shaderc::ShaderKind::Vertex,
ShaderStage::Fragment => shaderc::ShaderKind::Fragment,
ShaderStage::Compute => shaderc::ShaderKind::Compute,
ShaderStages::VERTEX => shaderc::ShaderKind::Vertex,
ShaderStages::FRAGMENT => shaderc::ShaderKind::Fragment,
ShaderStages::COMPUTE => shaderc::ShaderKind::Compute,
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_render/src/texture/texture_descriptor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{Extent3d, Texture, TextureDimension, TextureFormat, TextureUsage};
use super::{Extent3d, Texture, TextureDimension, TextureFormat, TextureUsages};

/// Describes a texture
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
Expand All @@ -8,7 +8,7 @@ pub struct TextureDescriptor {
pub sample_count: u32,
pub dimension: TextureDimension,
pub format: TextureFormat,
pub usage: TextureUsage,
pub usage: TextureUsages,
}

impl From<&Texture> for TextureDescriptor {
Expand All @@ -19,7 +19,7 @@ impl From<&Texture> for TextureDescriptor {
sample_count: 1,
dimension: texture.dimension,
format: texture.format,
usage: TextureUsage::SAMPLED | TextureUsage::COPY_DST,
usage: TextureUsages::SAMPLED | TextureUsages::COPY_DST,
}
}
}
Expand All @@ -36,7 +36,7 @@ impl Default for TextureDescriptor {
sample_count: 1,
dimension: TextureDimension::D2,
format: TextureFormat::Rgba8UnormSrgb,
usage: TextureUsage::SAMPLED | TextureUsage::COPY_DST,
usage: TextureUsages::SAMPLED | TextureUsages::COPY_DST,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/texture/texture_dimension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl Default for TextureFormat {

bitflags::bitflags! {
#[repr(transparent)]
pub struct TextureUsage: u32 {
pub struct TextureUsages: u32 {
const COPY_SRC = 1;
const COPY_DST = 2;
const SAMPLED = 4;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/render/sprite_sheet.vert
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct Rect {
vec2 end;
};

layout(set = 1, binding = 1) buffer TextureAtlas_textures {
layout(set = 1, binding = 1) readonly buffer TextureAtlas_textures {
Rect[] Textures;
};

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bevy_winit = { path = "../bevy_winit", optional = true, version = "0.5.0" }
bevy_utils = { path = "../bevy_utils", version = "0.5.0" }

# other
wgpu = "0.9"
wgpu = { version = "0.11.0", features = ["spirv"] }
futures-lite = "1.4.0"
crossbeam-channel = "0.5.0"
crossbeam-utils = "0.8.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ impl WgpuResourceDiagnosticsPlugin {
DiagnosticId::from_u128(305855369913076220671125671543184691267);
pub const SHADER_MODULES: DiagnosticId =
DiagnosticId::from_u128(287681470908132753275843248383768232237);
pub const SWAP_CHAINS: DiagnosticId =
DiagnosticId::from_u128(199253035828743332241465305105689014605);
pub const SWAP_CHAIN_OUTPUTS: DiagnosticId =
pub const SURFACE_FRAMES: DiagnosticId =
DiagnosticId::from_u128(112048874168736161226721327099863374234);
pub const TEXTURES: DiagnosticId =
DiagnosticId::from_u128(305955424195390184883220102469231911115);
Expand All @@ -47,10 +45,8 @@ impl WgpuResourceDiagnosticsPlugin {
10,
));

diagnostics.add(Diagnostic::new(Self::SWAP_CHAINS, "swap_chains", 10));

diagnostics.add(Diagnostic::new(
Self::SWAP_CHAIN_OUTPUTS,
Self::SURFACE_FRAMES,
"swap_chain_outputs",
10,
));
Expand Down Expand Up @@ -99,19 +95,10 @@ impl WgpuResourceDiagnosticsPlugin {
);

diagnostics.add_measurement(
Self::SWAP_CHAINS,
render_resource_context
.resources
.window_swap_chains
.read()
.len() as f64,
);

diagnostics.add_measurement(
Self::SWAP_CHAIN_OUTPUTS,
Self::SURFACE_FRAMES,
render_resource_context
.resources
.swap_chain_frames
.surface_textures
.read()
.len() as f64,
);
Expand Down
9 changes: 5 additions & 4 deletions crates/bevy_wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@ pub enum WgpuFeature {
TimestampQuery,
PipelineStatisticsQuery,
MappablePrimaryBuffers,
SampledTextureBindingArray,
SampledTextureArrayDynamicIndexing,
SampledTextureArrayNonUniformIndexing,
UnsizedBindingArray,
MultiDrawIndirect,
MultiDrawIndirectCount,
PushConstants,
AddressModeClampToBorder,
NonFillPolygonMode,
PolygonModeLine,
TextureCompressionEtc2,
TextureCompressionAstcLdr,
TextureAdapterSpecificFormatFeatures,
Expand Down Expand Up @@ -70,6 +67,8 @@ pub struct WgpuLimits {
pub max_vertex_buffers: u32,
pub max_vertex_attributes: u32,
pub max_vertex_buffer_array_stride: u32,
pub min_storage_buffer_offset_alignment: u32,
pub min_uniform_buffer_offset_alignment: u32,
}

impl Default for WgpuLimits {
Expand All @@ -96,6 +95,8 @@ impl Default for WgpuLimits {
max_vertex_buffers: default.max_vertex_buffers,
max_vertex_attributes: default.max_vertex_attributes,
max_vertex_buffer_array_stride: default.max_vertex_buffer_array_stride,
min_storage_buffer_offset_alignment: default.min_storage_buffer_offset_alignment,
min_uniform_buffer_offset_alignment: default.min_uniform_buffer_offset_alignment,
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions crates/bevy_wgpu/src/renderer/wgpu_render_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,15 @@ fn get_texture_view<'a>(
panic!("Color attachment {} does not exist.", name);
}
},
TextureAttachment::Id(render_resource) => refs.textures.get(render_resource).unwrap_or_else(|| &refs.swap_chain_frames.get(render_resource).unwrap().output.view),
TextureAttachment::Input(_) => panic!("Encountered unset `TextureAttachment::Input`. The `RenderGraph` executor should always set `TextureAttachment::Inputs` to `TextureAttachment::RenderResource` before running. This is a bug, please report it!"),
TextureAttachment::Id(render_resource) => refs
.textures
.get(render_resource)
.unwrap_or_else(|| &refs.surface_textures.get(render_resource).unwrap().0),
TextureAttachment::Input(_) => panic!(
"Encountered unset `TextureAttachment::Input`. The `RenderGraph` executor should \
always set `TextureAttachment::Inputs` to `TextureAttachment::RenderResource` before \
running. This is a bug, please report it!"
),
}
}

Expand Down
Loading