diff --git a/Cargo.toml b/Cargo.toml index c7a03998db982..612429d602d9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4614,3 +4614,11 @@ description = "Gallery of Feathers Widgets" category = "UI (User Interface)" wasm = true hidden = true + +[patch.crates-io] +wgpu = { git = "https://github.com/MarijnS95/wgpu", branch = "instance-for-raw-display-handle" } +wgpu-types = { git = "https://github.com/MarijnS95/wgpu", branch = "instance-for-raw-display-handle" } +wgpu-hal = { git = "https://github.com/MarijnS95/wgpu", branch = "instance-for-raw-display-handle" } +wgpu-core = { git = "https://github.com/MarijnS95/wgpu", branch = "instance-for-raw-display-handle" } +wgpu-info = { git = "https://github.com/MarijnS95/wgpu", branch = "instance-for-raw-display-handle" } +wgpu-macros = { git = "https://github.com/MarijnS95/wgpu", branch = "instance-for-raw-display-handle" } diff --git a/crates/bevy_anti_aliasing/src/contrast_adaptive_sharpening/node.rs b/crates/bevy_anti_aliasing/src/contrast_adaptive_sharpening/node.rs index 663d481e887bd..070b57099707e 100644 --- a/crates/bevy_anti_aliasing/src/contrast_adaptive_sharpening/node.rs +++ b/crates/bevy_anti_aliasing/src/contrast_adaptive_sharpening/node.rs @@ -98,6 +98,7 @@ impl Node for CasNode { label: Some("contrast_adaptive_sharpening"), color_attachments: &[Some(RenderPassColorAttachment { view: destination, + depth_slice: None, resolve_target: None, ops: Operations::default(), })], diff --git a/crates/bevy_anti_aliasing/src/fxaa/node.rs b/crates/bevy_anti_aliasing/src/fxaa/node.rs index a58f21d9a7746..8881607cba4e4 100644 --- a/crates/bevy_anti_aliasing/src/fxaa/node.rs +++ b/crates/bevy_anti_aliasing/src/fxaa/node.rs @@ -64,6 +64,7 @@ impl ViewNode for FxaaNode { label: Some("fxaa_pass"), color_attachments: &[Some(RenderPassColorAttachment { view: destination, + depth_slice: None, resolve_target: None, ops: Operations::default(), })], diff --git a/crates/bevy_anti_aliasing/src/smaa/mod.rs b/crates/bevy_anti_aliasing/src/smaa/mod.rs index 33a916e489a96..cafab566a0732 100644 --- a/crates/bevy_anti_aliasing/src/smaa/mod.rs +++ b/crates/bevy_anti_aliasing/src/smaa/mod.rs @@ -896,6 +896,7 @@ fn perform_edge_detection( label: Some("SMAA edge detection pass"), color_attachments: &[Some(RenderPassColorAttachment { view: &smaa_textures.edge_detection_color_texture.default_view, + depth_slice: None, resolve_target: None, ops: default(), })], @@ -951,6 +952,7 @@ fn perform_blending_weight_calculation( label: Some("SMAA blending weight calculation pass"), color_attachments: &[Some(RenderPassColorAttachment { view: &smaa_textures.blend_texture.default_view, + depth_slice: None, resolve_target: None, ops: default(), })], @@ -1007,6 +1009,7 @@ fn perform_neighborhood_blending( label: Some("SMAA neighborhood blending pass"), color_attachments: &[Some(RenderPassColorAttachment { view: destination, + depth_slice: None, resolve_target: None, ops: default(), })], diff --git a/crates/bevy_anti_aliasing/src/taa/mod.rs b/crates/bevy_anti_aliasing/src/taa/mod.rs index f182108f1082a..658e31aa586f6 100644 --- a/crates/bevy_anti_aliasing/src/taa/mod.rs +++ b/crates/bevy_anti_aliasing/src/taa/mod.rs @@ -202,11 +202,13 @@ impl ViewNode for TemporalAntiAliasNode { color_attachments: &[ Some(RenderPassColorAttachment { view: view_target.destination, + depth_slice: None, resolve_target: None, ops: Operations::default(), }), Some(RenderPassColorAttachment { view: &taa_history_textures.write.default_view, + depth_slice: None, resolve_target: None, ops: Operations::default(), }), diff --git a/crates/bevy_camera/Cargo.toml b/crates/bevy_camera/Cargo.toml index 6ed3998a82165..d6cbd46667fef 100644 --- a/crates/bevy_camera/Cargo.toml +++ b/crates/bevy_camera/Cargo.toml @@ -26,7 +26,7 @@ bevy_color = { path = "../bevy_color", version = "0.17.0-dev", features = [ bevy_window = { path = "../bevy_window", version = "0.17.0-dev" } # other -wgpu-types = { version = "25", default-features = false } +wgpu-types = { version = "26", default-features = false } serde = { version = "1", default-features = false, features = ["derive"] } thiserror = { version = "2", default-features = false } downcast-rs = { version = "2", default-features = false, features = ["std"] } diff --git a/crates/bevy_color/Cargo.toml b/crates/bevy_color/Cargo.toml index 22ade1270900b..81a9795d580e8 100644 --- a/crates/bevy_color/Cargo.toml +++ b/crates/bevy_color/Cargo.toml @@ -20,7 +20,7 @@ serde = { version = "1.0", features = [ ], default-features = false, optional = true } thiserror = { version = "2", default-features = false } derive_more = { version = "2", default-features = false, features = ["from"] } -wgpu-types = { version = "25", default-features = false, optional = true } +wgpu-types = { version = "26", default-features = false, optional = true } encase = { version = "0.10", default-features = false, optional = true } [features] diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index 0308ebe72e508..09112794026ba 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -186,6 +186,7 @@ impl ViewNode for BloomNode { label: Some("bloom_downsampling_first_pass"), color_attachments: &[Some(RenderPassColorAttachment { view, + depth_slice: None, resolve_target: None, ops: Operations::default(), })], @@ -210,6 +211,7 @@ impl ViewNode for BloomNode { label: Some("bloom_downsampling_pass"), color_attachments: &[Some(RenderPassColorAttachment { view, + depth_slice: None, resolve_target: None, ops: Operations::default(), })], @@ -234,6 +236,7 @@ impl ViewNode for BloomNode { label: Some("bloom_upsampling_pass"), color_attachments: &[Some(RenderPassColorAttachment { view, + depth_slice: None, resolve_target: None, ops: Operations { load: LoadOp::Load, diff --git a/crates/bevy_core_pipeline/src/deferred/node.rs b/crates/bevy_core_pipeline/src/deferred/node.rs index ab87fccee6e89..a8e1b7ab8ed2a 100644 --- a/crates/bevy_core_pipeline/src/deferred/node.rs +++ b/crates/bevy_core_pipeline/src/deferred/node.rs @@ -176,6 +176,7 @@ fn run_deferred_prepass<'w>( load: bevy_render::render_resource::LoadOp::Load, store: StoreOp::Store, }, + depth_slice: None, } } #[cfg(any( diff --git a/crates/bevy_core_pipeline/src/dof/mod.rs b/crates/bevy_core_pipeline/src/dof/mod.rs index 0bd5c79365d12..0e65c4d0a4dfa 100644 --- a/crates/bevy_core_pipeline/src/dof/mod.rs +++ b/crates/bevy_core_pipeline/src/dof/mod.rs @@ -409,6 +409,7 @@ impl ViewNode for DepthOfFieldNode { let mut color_attachments: SmallVec<[_; 2]> = SmallVec::new(); color_attachments.push(Some(RenderPassColorAttachment { view: postprocess.destination, + depth_slice: None, resolve_target: None, ops: Operations { load: LoadOp::Clear(default()), @@ -429,6 +430,7 @@ impl ViewNode for DepthOfFieldNode { }; color_attachments.push(Some(RenderPassColorAttachment { view: &auxiliary_dof_texture.default_view, + depth_slice: None, resolve_target: None, ops: Operations { load: LoadOp::Clear(default()), diff --git a/crates/bevy_core_pipeline/src/motion_blur/node.rs b/crates/bevy_core_pipeline/src/motion_blur/node.rs index ade5f50d77466..5fb8eeebcdc02 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/node.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/node.rs @@ -84,6 +84,7 @@ impl ViewNode for MotionBlurNode { label: Some("motion_blur_pass"), color_attachments: &[Some(RenderPassColorAttachment { view: post_process.destination, + depth_slice: None, resolve_target: None, ops: Operations::default(), })], diff --git a/crates/bevy_core_pipeline/src/msaa_writeback.rs b/crates/bevy_core_pipeline/src/msaa_writeback.rs index 151660876aeb0..4b63de7dad131 100644 --- a/crates/bevy_core_pipeline/src/msaa_writeback.rs +++ b/crates/bevy_core_pipeline/src/msaa_writeback.rs @@ -87,6 +87,7 @@ impl ViewNode for MsaaWritebackNode { color_attachments: &[Some(RenderPassColorAttachment { // If MSAA is enabled, then the sampled texture will always exist view: target.sampled_main_texture_view().unwrap(), + depth_slice: None, resolve_target: Some(post_process.destination), ops: Operations { load: LoadOp::Clear(LinearRgba::BLACK.into()), diff --git a/crates/bevy_core_pipeline/src/post_process/mod.rs b/crates/bevy_core_pipeline/src/post_process/mod.rs index 6d9a7669f2221..72eac853a7d86 100644 --- a/crates/bevy_core_pipeline/src/post_process/mod.rs +++ b/crates/bevy_core_pipeline/src/post_process/mod.rs @@ -379,6 +379,7 @@ impl ViewNode for PostProcessingNode { label: Some("postprocessing pass"), color_attachments: &[Some(RenderPassColorAttachment { view: post_process.destination, + depth_slice: None, resolve_target: None, ops: Operations::default(), })], diff --git a/crates/bevy_core_pipeline/src/tonemapping/node.rs b/crates/bevy_core_pipeline/src/tonemapping/node.rs index 0f8f6edc49eb2..58dd673264d18 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/node.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/node.rs @@ -117,6 +117,7 @@ impl ViewNode for TonemappingNode { label: Some("tonemapping_pass"), color_attachments: &[Some(RenderPassColorAttachment { view: destination, + depth_slice: None, resolve_target: None, ops: Operations { load: LoadOp::Clear(Default::default()), // TODO shouldn't need to be cleared diff --git a/crates/bevy_image/Cargo.toml b/crates/bevy_image/Cargo.toml index 7b49b5210a2ae..10440c5ab0e84 100644 --- a/crates/bevy_image/Cargo.toml +++ b/crates/bevy_image/Cargo.toml @@ -70,7 +70,7 @@ image = { version = "0.25.2", default-features = false } # misc bitflags = { version = "2.3", features = ["serde"] } bytemuck = { version = "1.5" } -wgpu-types = { version = "25", default-features = false } +wgpu-types = { version = "26", default-features = false } serde = { version = "1", features = ["derive"] } thiserror = { version = "2", default-features = false } futures-lite = "2.0.1" diff --git a/crates/bevy_mesh/Cargo.toml b/crates/bevy_mesh/Cargo.toml index 0f37ac11417a9..026e96f5cebf6 100644 --- a/crates/bevy_mesh/Cargo.toml +++ b/crates/bevy_mesh/Cargo.toml @@ -26,7 +26,7 @@ bevy_platform = { path = "../bevy_platform", version = "0.17.0-dev", default-fea # other bitflags = { version = "2.3", features = ["serde"] } bytemuck = { version = "1.5" } -wgpu-types = { version = "25", default-features = false } +wgpu-types = { version = "26", default-features = false } serde = { version = "1", default-features = false, features = [ "derive", ], optional = true } diff --git a/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs b/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs index 160097fc50070..10104e10eefd9 100644 --- a/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs +++ b/crates/bevy_pbr/src/meshlet/visibility_buffer_raster_node.rs @@ -595,6 +595,7 @@ fn raster_pass( }), color_attachments: &[Some(RenderPassColorAttachment { view: dummy_render_target, + depth_slice: None, resolve_target: None, ops: Operations { load: LoadOp::Clear(LinearRgba::BLACK.into()), diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index a30f315269ecd..12e7b77f4d34d 100644 --- a/crates/bevy_pbr/src/ssr/mod.rs +++ b/crates/bevy_pbr/src/ssr/mod.rs @@ -302,6 +302,7 @@ impl ViewNode for ScreenSpaceReflectionsNode { label: Some("SSR pass"), color_attachments: &[Some(RenderPassColorAttachment { view: postprocess.destination, + depth_slice: None, resolve_target: None, ops: Operations::default(), })], diff --git a/crates/bevy_pbr/src/volumetric_fog/render.rs b/crates/bevy_pbr/src/volumetric_fog/render.rs index a49e9b62a4f78..abd886018b009 100644 --- a/crates/bevy_pbr/src/volumetric_fog/render.rs +++ b/crates/bevy_pbr/src/volumetric_fog/render.rs @@ -431,6 +431,7 @@ impl ViewNode for VolumetricFogNode { label: Some("volumetric lighting pass"), color_attachments: &[Some(RenderPassColorAttachment { view: view_target.main_texture_view(), + depth_slice: None, resolve_target: None, ops: Operations { load: LoadOp::Load, diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml index 8e2d4d0f38c4b..e2fa168b0785c 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -109,7 +109,7 @@ uuid = { version = "1.13.1", default-features = false, optional = true, features "serde", ] } variadics_please = "1.1" -wgpu-types = { version = "25", features = [ +wgpu-types = { version = "26", features = [ "serde", ], optional = true, default-features = false } diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 537f940922fc3..46509b35d00f6 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -90,7 +90,7 @@ codespan-reporting = "0.12.0" # It is enabled for now to avoid having to do a significant overhaul of the renderer just for wasm. # When the 'atomics' feature is enabled `fragile-send-sync-non-atomic` does nothing # and Bevy instead wraps `wgpu` types to verify they are not used off their origin thread. -wgpu = { version = "25", default-features = false, features = [ +wgpu = { version = "26", default-features = false, features = [ "wgsl", "dx12", "metal", @@ -99,7 +99,7 @@ wgpu = { version = "25", default-features = false, features = [ "naga-ir", "fragile-send-sync-non-atomic-wasm", ] } -naga = { version = "25", features = ["wgsl-in"] } +naga = { version = "26", features = ["wgsl-in"] } serde = { version = "1", features = ["derive"] } bytemuck = { version = "1.5", features = ["derive", "must_cast"] } downcast-rs = { version = "2", default-features = false, features = ["std"] } @@ -125,7 +125,7 @@ wesl = { version = "0.1.2", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] # Omit the `glsl` feature in non-WebAssembly by default. -naga_oil = { version = "0.18", default-features = false, features = [ +naga_oil = { git = "https://github.com/bevyengine/naga_oil", default-features = false, features = [ "test_shader", ] } @@ -136,7 +136,7 @@ send_wrapper = { version = "0.6.0" } proptest = "1" [target.'cfg(target_arch = "wasm32")'.dependencies] -naga_oil = { version = "0.18" } +naga_oil = { git = "https://github.com/bevyengine/naga_oil" } js-sys = "0.3" web-sys = { version = "0.3.67", features = [ 'Blob', diff --git a/crates/bevy_render/src/batching/gpu_preprocessing.rs b/crates/bevy_render/src/batching/gpu_preprocessing.rs index 2fb0172b219da..35bdfb51c4261 100644 --- a/crates/bevy_render/src/batching/gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/gpu_preprocessing.rs @@ -1123,8 +1123,7 @@ impl FromWorld for GpuPreprocessingSupport { device.limits().max_compute_workgroup_storage_size != 0; let downlevel_support = adapter.get_downlevel_capabilities().flags.contains( - DownlevelFlags::COMPUTE_SHADERS | - DownlevelFlags::VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW + DownlevelFlags::COMPUTE_SHADERS | DownlevelFlags::DEPTH_TEXTURE_AND_BUFFER_COPIES, ); let max_supported_mode = if device.limits().max_compute_workgroup_size_x == 0 diff --git a/crates/bevy_render/src/diagnostic/tracy_gpu.rs b/crates/bevy_render/src/diagnostic/tracy_gpu.rs index 7a66db4ea6da4..c429c0ee245af 100644 --- a/crates/bevy_render/src/diagnostic/tracy_gpu.rs +++ b/crates/bevy_render/src/diagnostic/tracy_gpu.rs @@ -56,7 +56,7 @@ fn initial_timestamp(device: &RenderDevice, queue: &RenderQueue) -> i64 { // Workaround for https://github.com/gfx-rs/wgpu/issues/6406 // TODO when that bug is fixed, merge these encoders together again let mut copy_encoder = device.create_command_encoder(&CommandEncoderDescriptor::default()); - copy_encoder.copy_buffer_to_buffer(&resolve_buffer, 0, &map_buffer, 0, QUERY_SIZE as _); + copy_encoder.copy_buffer_to_buffer(&resolve_buffer, 0, &map_buffer, 0, Some(QUERY_SIZE as _)); queue.submit([timestamp_encoder.finish(), copy_encoder.finish()]); map_buffer.slice(..).map_async(MapMode::Read, |_| ()); diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 994bc35bb3e1e..a59f9a8dc9616 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -90,7 +90,7 @@ use bevy_image::{CompressedImageFormatSupport, CompressedImageFormats}; use bevy_utils::prelude::default; pub use extract_param::Extract; -use bevy_window::{PrimaryWindow, RawHandleWrapperHolder}; +use bevy_window::{PrimaryWindow, RawDisplayHandleWrapper, RawHandleWrapperHolder}; use experimental::occlusion_culling::OcclusionCullingPlugin; use globals::GlobalsPlugin; use render_asset::{ @@ -355,11 +355,17 @@ impl Plugin for RenderPlugin { .single(app.world()) .ok() .cloned(); + + let display_handle = app + .world() + .get_resource::().unwrap(); + let settings = render_creation.clone(); let async_renderer = async move { let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { backends, flags: settings.instance_flags, + memory_budget_thresholds: settings.instance_memory_budget_thresholds, backend_options: wgpu::BackendOptions { gl: wgpu::GlBackendOptions { gles_minor_version: settings.gles3_minor_version, @@ -370,6 +376,7 @@ impl Plugin for RenderPlugin { }, noop: wgpu::NoopBackendOptions { enable: false }, }, + display: Some(display_handle.0), }); let surface = primary_window.and_then(|wrapper| { diff --git a/crates/bevy_render/src/render_graph/camera_driver_node.rs b/crates/bevy_render/src/render_graph/camera_driver_node.rs index d18c7d11333eb..714ceec18adf5 100644 --- a/crates/bevy_render/src/render_graph/camera_driver_node.rs +++ b/crates/bevy_render/src/render_graph/camera_driver_node.rs @@ -77,6 +77,7 @@ impl Node for CameraDriverNode { label: Some("no_camera_clear_pass"), color_attachments: &[Some(RenderPassColorAttachment { view: swap_chain_texture, + depth_slice: None, resolve_target: None, ops: Operations { load: LoadOp::Clear(clear_color_global.to_linear().into()), diff --git a/crates/bevy_render/src/render_phase/mod.rs b/crates/bevy_render/src/render_phase/mod.rs index c58318f654578..fb9433d804e2b 100644 --- a/crates/bevy_render/src/render_phase/mod.rs +++ b/crates/bevy_render/src/render_phase/mod.rs @@ -67,12 +67,12 @@ use bevy_ecs::{ prelude::*, system::{lifetimeless::SRes, SystemParamItem}, }; +use bevy_render::renderer::RenderAdapterInfo; +pub use bevy_render_macros::ShaderLabel; use core::{fmt::Debug, hash::Hash, iter, marker::PhantomData, ops::Range, slice::SliceIndex}; use smallvec::SmallVec; use tracing::warn; -pub use bevy_render_macros::ShaderLabel; - define_label!( #[diagnostic::on_unimplemented( note = "consider annotating `{Self}` with `#[derive(ShaderLabel)]`" @@ -658,9 +658,12 @@ where let mut draw_functions = draw_functions.write(); let render_device = world.resource::(); + let render_adapter_info = world.resource::(); let multi_draw_indirect_count_supported = render_device .features() - .contains(Features::MULTI_DRAW_INDIRECT_COUNT); + .contains(Features::MULTI_DRAW_INDIRECT_COUNT) + // TODO: https://github.com/gfx-rs/wgpu/issues/7974 + && !matches!(render_adapter_info.backend, wgpu::Backend::Dx12); match self.batch_sets { BinnedRenderPhaseBatchSets::DynamicUniforms(ref batch_sets) => { diff --git a/crates/bevy_render/src/render_resource/mod.rs b/crates/bevy_render/src/render_resource/mod.rs index f156b0ecb0feb..a55233e94bc6d 100644 --- a/crates/bevy_render/src/render_resource/mod.rs +++ b/crates/bevy_render/src/render_resource/mod.rs @@ -62,7 +62,7 @@ pub use wgpu::{ TexelCopyBufferInfo, TexelCopyBufferLayout, TexelCopyTextureInfo, TextureAspect, TextureDescriptor, TextureDimension, TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures, TextureSampleType, TextureUsages, TextureView as WgpuTextureView, - TextureViewDescriptor, TextureViewDimension, Tlas, TlasInstance, TlasPackage, VertexAttribute, + TextureViewDescriptor, TextureViewDimension, Tlas, TlasInstance, VertexAttribute, VertexBufferLayout as RawVertexBufferLayout, VertexFormat, VertexState as RawVertexState, VertexStepMode, COPY_BUFFER_ALIGNMENT, }; diff --git a/crates/bevy_render/src/renderer/graph_runner.rs b/crates/bevy_render/src/renderer/graph_runner.rs index 39f05ca6a85c6..ff2e421982dc7 100644 --- a/crates/bevy_render/src/renderer/graph_runner.rs +++ b/crates/bevy_render/src/renderer/graph_runner.rs @@ -68,8 +68,6 @@ impl RenderGraphRunner { render_device: RenderDevice, mut diagnostics_recorder: Option, queue: &wgpu::Queue, - #[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))] - adapter: &wgpu::Adapter, world: &World, finalizer: impl FnOnce(&mut wgpu::CommandEncoder), ) -> Result, RenderGraphRunnerError> { @@ -77,12 +75,7 @@ impl RenderGraphRunner { recorder.begin_frame(); } - let mut render_context = RenderContext::new( - render_device, - #[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))] - adapter.get_info(), - diagnostics_recorder, - ); + let mut render_context = RenderContext::new(render_device, diagnostics_recorder); Self::run_graph(graph, None, &mut render_context, world, &[], None)?; finalizer(render_context.command_encoder()); diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 5bcc62188d883..d1e6467ac016a 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -37,16 +37,12 @@ pub fn render_system(world: &mut World, state: &mut SystemState(); let render_device = world.resource::(); let render_queue = world.resource::(); - #[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))] - let render_adapter = world.resource::(); let res = RenderGraphRunner::run( graph, render_device.clone(), // TODO: is this clone really necessary? diagnostics_recorder, &render_queue.0, - #[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))] - &render_adapter.0, world, |encoder| { crate::view::screenshot::submit_screenshot_commands(world, encoder); @@ -247,6 +243,18 @@ pub async fn initialize_renderer( // err on the side of being conservative. We can't claim 'higher' limits that are supported // but we can constrain to 'lower' limits. limits = wgpu::Limits { + max_mesh_multiview_count: limits + .max_mesh_multiview_count + .min(constrained_limits.max_mesh_multiview_count), + max_mesh_output_layers: limits + .max_mesh_output_layers + .min(constrained_limits.max_mesh_output_layers), + max_task_workgroup_total_count: limits + .max_task_workgroup_total_count + .min(constrained_limits.max_task_workgroup_total_count), + max_task_workgroups_per_dimension: limits + .max_task_workgroups_per_dimension + .min(constrained_limits.max_task_workgroups_per_dimension), max_texture_dimension_1d: limits .max_texture_dimension_1d .min(constrained_limits.max_texture_dimension_1d), @@ -343,6 +351,15 @@ pub async fn initialize_renderer( max_non_sampler_bindings: limits .max_non_sampler_bindings .min(constrained_limits.max_non_sampler_bindings), + max_blas_primitive_count: limits + .max_blas_primitive_count + .min(constrained_limits.max_blas_primitive_count), + max_blas_geometry_count: limits + .max_blas_geometry_count + .min(constrained_limits.max_blas_geometry_count), + max_tlas_instance_count: limits + .max_tlas_instance_count + .min(constrained_limits.max_tlas_instance_count), max_color_attachments: limits .max_color_attachments .min(constrained_limits.max_color_attachments), @@ -355,6 +372,7 @@ pub async fn initialize_renderer( max_subgroup_size: limits .max_subgroup_size .min(constrained_limits.max_subgroup_size), + max_acceleration_structures_per_shader_stage: 0, }; } @@ -387,8 +405,6 @@ pub struct RenderContext<'w> { render_device: RenderDevice, command_encoder: Option, command_buffer_queue: Vec>, - #[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))] - force_serial: bool, diagnostics_recorder: Option>, } @@ -396,30 +412,12 @@ impl<'w> RenderContext<'w> { /// Creates a new [`RenderContext`] from a [`RenderDevice`]. pub fn new( render_device: RenderDevice, - #[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))] - adapter_info: AdapterInfo, diagnostics_recorder: Option, ) -> Self { - // HACK: Parallel command encoding is currently bugged on AMD + Windows/Linux + Vulkan - #[cfg(any(target_os = "windows", target_os = "linux"))] - let force_serial = - adapter_info.driver.contains("AMD") && adapter_info.backend == wgpu::Backend::Vulkan; - #[cfg(not(any( - target_os = "windows", - target_os = "linux", - all(target_arch = "wasm32", target_feature = "atomics") - )))] - let force_serial = { - drop(adapter_info); - false - }; - Self { render_device, command_encoder: None, command_buffer_queue: Vec::new(), - #[cfg(not(all(target_arch = "wasm32", target_feature = "atomics")))] - force_serial, diagnostics_recorder: diagnostics_recorder.map(Arc::new), } } @@ -522,14 +520,9 @@ impl<'w> RenderContext<'w> { } QueuedCommandBuffer::Task(command_buffer_generation_task) => { let render_device = self.render_device.clone(); - if self.force_serial { - command_buffers - .push((i, command_buffer_generation_task(render_device))); - } else { - task_pool.spawn(async move { - (i, command_buffer_generation_task(render_device)) - }); - } + task_pool.spawn(async move { + (i, command_buffer_generation_task(render_device)) + }); } } } diff --git a/crates/bevy_render/src/settings.rs b/crates/bevy_render/src/settings.rs index d4456953af6ce..411a21ceeb0bc 100644 --- a/crates/bevy_render/src/settings.rs +++ b/crates/bevy_render/src/settings.rs @@ -3,11 +3,11 @@ use crate::renderer::{ }; use alloc::borrow::Cow; -use wgpu::DxcShaderModel; pub use wgpu::{ Backends, Dx12Compiler, Features as WgpuFeatures, Gles3MinorVersion, InstanceFlags, Limits as WgpuLimits, MemoryHints, PowerPreference, }; +use wgpu::{DxcShaderModel, MemoryBudgetThresholds}; /// Configures the priority used when automatically configuring the features/limits of `wgpu`. #[derive(Clone)] @@ -53,6 +53,8 @@ pub struct WgpuSettings { pub instance_flags: InstanceFlags, /// This hints to the WGPU device about the preferred memory allocation strategy. pub memory_hints: MemoryHints, + /// The thresholds for device memory budget. + pub instance_memory_budget_thresholds: MemoryBudgetThresholds, /// If true, will force wgpu to use a software renderer, if available. pub force_fallback_adapter: bool, /// The name of the adapter to use. @@ -107,15 +109,10 @@ impl Default for WgpuSettings { Dx12Compiler::StaticDxc } else { let dxc = "dxcompiler.dll"; - let dxil = "dxil.dll"; - if cfg!(target_os = "windows") - && std::fs::metadata(dxc).is_ok() - && std::fs::metadata(dxil).is_ok() - { + if cfg!(target_os = "windows") && std::fs::metadata(dxc).is_ok() { Dx12Compiler::DynamicDxc { dxc_path: String::from(dxc), - dxil_path: String::from(dxil), max_shader_model: DxcShaderModel::V6_7, } } else { @@ -140,6 +137,7 @@ impl Default for WgpuSettings { gles3_minor_version, instance_flags, memory_hints: MemoryHints::default(), + instance_memory_budget_thresholds: MemoryBudgetThresholds::default(), force_fallback_adapter: false, adapter_name: None, } diff --git a/crates/bevy_render/src/texture/texture_attachment.rs b/crates/bevy_render/src/texture/texture_attachment.rs index ac3854227ff31..17ae6ea6c957f 100644 --- a/crates/bevy_render/src/texture/texture_attachment.rs +++ b/crates/bevy_render/src/texture/texture_attachment.rs @@ -40,6 +40,7 @@ impl ColorAttachment { RenderPassColorAttachment { view: &resolve_target.default_view, + depth_slice: None, resolve_target: Some(&self.texture.default_view), ops: Operations { load: match (self.clear_color, first_call) { @@ -63,6 +64,7 @@ impl ColorAttachment { RenderPassColorAttachment { view: &self.texture.default_view, + depth_slice: None, resolve_target: None, ops: Operations { load: match (self.clear_color, first_call) { @@ -146,6 +148,7 @@ impl OutputColorAttachment { RenderPassColorAttachment { view: &self.view, + depth_slice: None, resolve_target: None, ops: Operations { load: match (clear_color, first_call) { diff --git a/crates/bevy_render/src/view/window/screenshot.rs b/crates/bevy_render/src/view/window/screenshot.rs index 986f6927e5d12..a3ac1d47e0dea 100644 --- a/crates/bevy_render/src/view/window/screenshot.rs +++ b/crates/bevy_render/src/view/window/screenshot.rs @@ -595,6 +595,7 @@ fn render_screenshot( label: Some("screenshot_to_screen_pass"), color_attachments: &[Some(wgpu::RenderPassColorAttachment { view: texture_view, + depth_slice: None, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Load, diff --git a/crates/bevy_solari/src/scene/binder.rs b/crates/bevy_solari/src/scene/binder.rs index 4e75e7db6b3ce..d920c62ee10bb 100644 --- a/crates/bevy_solari/src/scene/binder.rs +++ b/crates/bevy_solari/src/scene/binder.rs @@ -71,14 +71,14 @@ pub fn prepare_raytracing_scene_bindings( let mut textures = CachedBindingArray::new(); let mut samplers = Vec::new(); let mut materials = StorageBufferList::::default(); - let mut tlas = TlasPackage::new(render_device.wgpu_device().create_tlas( - &CreateTlasDescriptor { + let mut tlas = render_device + .wgpu_device() + .create_tlas(&CreateTlasDescriptor { label: Some("tlas"), flags: AccelerationStructureFlags::PREFER_FAST_TRACE, update_mode: AccelerationStructureUpdateMode::Build, max_instances: instances_query.iter().len() as u32, - }, - )); + }); let mut transforms = StorageBufferList::::default(); let mut geometry_ids = StorageBufferList::::default(); let mut material_ids = StorageBufferList::::default(); diff --git a/crates/bevy_window/src/raw_handle.rs b/crates/bevy_window/src/raw_handle.rs index 0943315055fb6..57b8ab7483b1a 100644 --- a/crates/bevy_window/src/raw_handle.rs +++ b/crates/bevy_window/src/raw_handle.rs @@ -4,7 +4,7 @@ )] use alloc::sync::Arc; -use bevy_ecs::prelude::Component; +use bevy_ecs::{prelude::Component, resource::Resource}; use bevy_platform::sync::Mutex; use core::{any::Any, marker::PhantomData, ops::Deref}; use raw_window_handle::{ @@ -12,6 +12,14 @@ use raw_window_handle::{ RawWindowHandle, WindowHandle, }; +unsafe impl Send for RawDisplayHandleWrapper {} +// SAFETY: This is safe for the same reasons as the Send impl above. +unsafe impl Sync for RawDisplayHandleWrapper {} + +#[derive(Debug, Clone, Resource)] +pub struct RawDisplayHandleWrapper(pub RawDisplayHandle); + + /// A wrapper over a window. /// /// This allows us to extend the lifetime of the window, so it doesn't get eagerly dropped while a diff --git a/crates/bevy_winit/Cargo.toml b/crates/bevy_winit/Cargo.toml index 3ad2e4379e114..2b820bf37e7f2 100644 --- a/crates/bevy_winit/Cargo.toml +++ b/crates/bevy_winit/Cargo.toml @@ -56,7 +56,7 @@ approx = { version = "0.5", default-features = false } cfg-if = "1.0" raw-window-handle = "0.6" bytemuck = { version = "1.5", optional = true } -wgpu-types = { version = "25", optional = true } +wgpu-types = { version = "26", optional = true } accesskit = "0.19" tracing = { version = "0.1", default-features = false, features = ["std"] } diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index 65b7b6c04a084..72c775e125b65 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -17,7 +17,8 @@ extern crate alloc; use bevy_derive::Deref; use bevy_reflect::prelude::ReflectDefault; use bevy_reflect::Reflect; -use bevy_window::{RawHandleWrapperHolder, WindowEvent}; +use bevy_window::{RawDisplayHandleWrapper, RawHandleWrapperHolder, WindowEvent}; +use raw_window_handle::HasDisplayHandle; use core::cell::RefCell; use core::marker::PhantomData; use winit::{event_loop::EventLoop, window::WindowId}; @@ -134,6 +135,7 @@ impl Plugin for WinitPlugin { app.init_resource::() .init_resource::() .insert_resource(DisplayHandleWrapper(event_loop.owned_display_handle())) + .insert_resource(RawDisplayHandleWrapper(event_loop.display_handle().unwrap().as_raw())) .add_event::() .set_runner(|app| winit_runner(app, event_loop)) .add_systems( diff --git a/examples/shader/custom_post_processing.rs b/examples/shader/custom_post_processing.rs index 4cd925be01d82..806a84378535f 100644 --- a/examples/shader/custom_post_processing.rs +++ b/examples/shader/custom_post_processing.rs @@ -197,6 +197,7 @@ impl ViewNode for PostProcessNode { // We need to specify the post process destination view here // to make sure we write to the appropriate texture. view: post_process.destination, + depth_slice: None, resolve_target: None, ops: Operations::default(), })],