From 8f3f5141591a65e413a217d73196afb32c4a70ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kurt=20K=C3=BChnert?= Date: Sun, 5 Nov 2023 15:37:29 +0100 Subject: [PATCH] rename Render to Gpu --- crates/bevy_asset/src/io/embedded/mod.rs | 4 +- crates/bevy_core_pipeline/src/blit/mod.rs | 47 ++++--- .../src/bloom/downsampling_pipeline.rs | 15 +- crates/bevy_core_pipeline/src/bloom/mod.rs | 18 +-- .../src/bloom/upsampling_pipeline.rs | 69 +++++----- .../src/contrast_adaptive_sharpening/mod.rs | 69 +++++----- .../src/contrast_adaptive_sharpening/node.rs | 6 +- .../src/core_2d/main_pass_2d_node.rs | 2 +- crates/bevy_core_pipeline/src/core_2d/mod.rs | 2 +- .../src/core_3d/camera_3d.rs | 2 +- .../src/core_3d/main_opaque_pass_3d_node.rs | 6 +- .../core_3d/main_transmissive_pass_3d_node.rs | 6 +- .../core_3d/main_transparent_pass_3d_node.rs | 2 +- crates/bevy_core_pipeline/src/core_3d/mod.rs | 32 ++--- .../src/deferred/copy_lighting_id.rs | 16 +-- crates/bevy_core_pipeline/src/deferred/mod.rs | 2 +- .../bevy_core_pipeline/src/deferred/node.rs | 10 +- .../src/fullscreen_vertex_shader/mod.rs | 2 +- crates/bevy_core_pipeline/src/fxaa/mod.rs | 6 +- crates/bevy_core_pipeline/src/fxaa/node.rs | 8 +- .../bevy_core_pipeline/src/msaa_writeback.rs | 6 +- crates/bevy_core_pipeline/src/prepass/mod.rs | 2 +- crates/bevy_core_pipeline/src/prepass/node.rs | 8 +- crates/bevy_core_pipeline/src/skybox/mod.rs | 19 ++- crates/bevy_core_pipeline/src/taa/mod.rs | 24 ++-- .../bevy_core_pipeline/src/tonemapping/mod.rs | 6 +- .../src/tonemapping/node.rs | 10 +- .../bevy_core_pipeline/src/upscaling/mod.rs | 2 +- .../bevy_core_pipeline/src/upscaling/node.rs | 8 +- crates/bevy_encase_derive/src/lib.rs | 2 +- crates/bevy_gizmos/src/lib.rs | 26 ++-- crates/bevy_gizmos/src/pipeline_2d.rs | 2 +- crates/bevy_gizmos/src/pipeline_3d.rs | 2 +- crates/bevy_gltf/src/lib.rs | 6 +- crates/bevy_gltf/src/loader.rs | 2 +- crates/bevy_gltf/src/vertex_attributes.rs | 2 +- crates/bevy_internal/src/lib.rs | 6 +- crates/bevy_pbr/src/deferred/mod.rs | 14 +- crates/bevy_pbr/src/environment_map/mod.rs | 2 +- crates/bevy_pbr/src/extended_material.rs | 44 +++--- crates/bevy_pbr/src/lib.rs | 2 +- crates/bevy_pbr/src/light.rs | 12 +- crates/bevy_pbr/src/material.rs | 20 +-- crates/bevy_pbr/src/pbr_material.rs | 2 +- crates/bevy_pbr/src/prepass/mod.rs | 29 ++-- .../bevy_pbr/src/prepass/prepass_bindings.rs | 2 +- crates/bevy_pbr/src/render/fog.rs | 10 +- crates/bevy_pbr/src/render/light.rs | 54 ++++---- crates/bevy_pbr/src/render/mesh.rs | 44 +++--- crates/bevy_pbr/src/render/mesh_bindings.rs | 62 ++++----- .../bevy_pbr/src/render/mesh_view_bindings.rs | 14 +- crates/bevy_pbr/src/render/morph.rs | 12 +- crates/bevy_pbr/src/render/skin.rs | 12 +- crates/bevy_pbr/src/ssao/mod.rs | 46 +++---- crates/bevy_pbr/src/wireframe.rs | 3 +- .../bevy_render/macros/src/as_bind_group.rs | 130 +++++++++--------- crates/bevy_render/src/batching/mod.rs | 10 +- crates/bevy_render/src/camera/camera.rs | 5 +- .../src/camera/camera_driver_node.rs | 4 +- .../src/camera/manual_texture_view.rs | 12 +- crates/bevy_render/src/color/mod.rs | 5 +- crates/bevy_render/src/extract_component.rs | 15 +- crates/bevy_render/src/globals.rs | 12 +- .../src/gpu_component_array_buffer.rs | 12 +- .../batched_uniform_buffer.rs | 13 +- .../bind_group.rs | 42 +++--- .../bind_group_entries.rs | 12 +- .../bind_group_layout.rs | 2 +- .../buffer.rs | 2 +- .../buffer_vec.rs | 46 +++---- .../gpu_array_buffer.rs | 32 ++--- .../{render_resource => gpu_resource}/mod.rs | 21 +-- .../pipeline.rs | 6 +- .../pipeline_cache.rs | 48 +++---- .../pipeline_specializer.rs | 6 +- .../resource_macros.rs | 0 .../shader.rs | 0 .../storage_buffer.rs | 46 +++---- .../texture.rs | 6 +- .../uniform_buffer.rs | 60 ++++---- crates/bevy_render/src/lib.rs | 77 +++++------ crates/bevy_render/src/mesh/mesh/mod.rs | 29 ++-- crates/bevy_render/src/mesh/morph.rs | 2 +- crates/bevy_render/src/mesh/shape/capsule.rs | 2 +- crates/bevy_render/src/mesh/shape/cylinder.rs | 2 +- .../bevy_render/src/mesh/shape/icosphere.rs | 2 +- crates/bevy_render/src/mesh/shape/mod.rs | 2 +- .../src/mesh/shape/regular_polygon.rs | 2 +- crates/bevy_render/src/mesh/shape/torus.rs | 2 +- crates/bevy_render/src/mesh/shape/uvsphere.rs | 7 +- .../bevy_render/src/render_graph/context.rs | 2 +- .../bevy_render/src/render_graph/node_slot.rs | 2 +- .../src/render_phase/draw_state.rs | 12 +- crates/bevy_render/src/render_phase/mod.rs | 6 +- .../{render_device.rs => gpu_device.rs} | 88 +++++------- .../bevy_render/src/renderer/graph_runner.rs | 9 +- crates/bevy_render/src/renderer/mod.rs | 77 +++++------ crates/bevy_render/src/settings.rs | 89 ++++++------ .../bevy_render/src/texture/fallback_image.rs | 66 ++++----- crates/bevy_render/src/texture/image.rs | 25 ++-- .../bevy_render/src/texture/image_loader.rs | 6 +- crates/bevy_render/src/texture/mod.rs | 8 +- .../bevy_render/src/texture/texture_cache.rs | 10 +- crates/bevy_render/src/view/mod.rs | 35 +++-- crates/bevy_render/src/view/window/mod.rs | 30 ++-- .../bevy_render/src/view/window/screenshot.rs | 37 ++--- crates/bevy_sprite/src/lib.rs | 2 +- .../bevy_sprite/src/mesh2d/color_material.rs | 2 +- crates/bevy_sprite/src/mesh2d/material.rs | 40 ++---- crates/bevy_sprite/src/mesh2d/mesh.rs | 40 +++--- crates/bevy_sprite/src/render/mod.rs | 32 ++--- .../bevy_sprite/src/texture_atlas_builder.rs | 2 +- crates/bevy_text/src/font.rs | 2 +- crates/bevy_text/src/font_atlas.rs | 2 +- crates/bevy_ui/src/render/mod.rs | 18 +-- crates/bevy_ui/src/render/pipeline.rs | 10 +- crates/bevy_ui/src/render/render_pass.rs | 2 +- .../src/render/ui_material_pipeline.rs | 40 ++---- crates/bevy_ui/src/ui_material.rs | 4 +- examples/2d/custom_gltf_vertex_attribute.rs | 2 +- examples/2d/mesh2d_manual.rs | 8 +- examples/3d/3d_shapes.rs | 2 +- examples/3d/anti_aliasing.rs | 2 +- examples/3d/deferred_rendering.rs | 2 +- examples/3d/generate_custom_mesh.rs | 2 +- examples/3d/lines.rs | 4 +- examples/3d/parallax_mapping.rs | 2 +- examples/3d/render_to_texture.rs | 2 +- examples/3d/skybox.rs | 9 +- examples/3d/tonemapping.rs | 2 +- examples/3d/wireframe.rs | 8 +- examples/app/no_renderer.rs | 4 +- examples/shader/animate_shader.rs | 2 +- examples/shader/array_texture.rs | 2 +- .../shader/compute_shader_game_of_life.rs | 10 +- examples/shader/custom_vertex_attribute.rs | 4 +- examples/shader/extended_material.rs | 2 +- examples/shader/fallback_image.rs | 2 +- examples/shader/post_processing.rs | 20 +-- examples/shader/shader_defs.rs | 4 +- examples/shader/shader_instancing.rs | 8 +- examples/shader/shader_material.rs | 2 +- examples/shader/shader_material_glsl.rs | 4 +- .../shader_material_screenspace_texture.rs | 2 +- examples/shader/shader_prepass.rs | 2 +- examples/shader/texture_binding_array.rs | 18 +-- examples/stress_tests/bevymark.rs | 2 +- examples/stress_tests/many_cubes.rs | 2 +- examples/ui/ui_material.rs | 2 +- 149 files changed, 1139 insertions(+), 1211 deletions(-) rename crates/bevy_render/src/{render_resource => gpu_resource}/batched_uniform_buffer.rs (93%) rename crates/bevy_render/src/{render_resource => gpu_resource}/bind_group.rs (91%) rename crates/bevy_render/src/{render_resource => gpu_resource}/bind_group_entries.rs (96%) rename crates/bevy_render/src/{render_resource => gpu_resource}/bind_group_layout.rs (93%) rename crates/bevy_render/src/{render_resource => gpu_resource}/buffer.rs (95%) rename crates/bevy_render/src/{render_resource => gpu_resource}/buffer_vec.rs (72%) rename crates/bevy_render/src/{render_resource => gpu_resource}/gpu_array_buffer.rs (82%) rename crates/bevy_render/src/{render_resource => gpu_resource}/mod.rs (60%) rename crates/bevy_render/src/{render_resource => gpu_resource}/pipeline.rs (95%) rename crates/bevy_render/src/{render_resource => gpu_resource}/pipeline_cache.rs (96%) rename crates/bevy_render/src/{render_resource => gpu_resource}/pipeline_specializer.rs (98%) rename crates/bevy_render/src/{render_resource => gpu_resource}/resource_macros.rs (100%) rename crates/bevy_render/src/{render_resource => gpu_resource}/shader.rs (100%) rename crates/bevy_render/src/{render_resource => gpu_resource}/storage_buffer.rs (83%) rename crates/bevy_render/src/{render_resource => gpu_resource}/texture.rs (92%) rename crates/bevy_render/src/{render_resource => gpu_resource}/uniform_buffer.rs (87%) rename crates/bevy_render/src/renderer/{render_device.rs => gpu_device.rs} (66%) diff --git a/crates/bevy_asset/src/io/embedded/mod.rs b/crates/bevy_asset/src/io/embedded/mod.rs index e5470cd3d5c3f..9204f855ef308 100644 --- a/crates/bevy_asset/src/io/embedded/mod.rs +++ b/crates/bevy_asset/src/io/embedded/mod.rs @@ -135,12 +135,12 @@ macro_rules! embedded_path { /// * `src` /// * `render` /// * `rock.wgsl` -/// * `mod.rs` +/// * `gpu_resource` /// * `lib.rs` /// * `Cargo.toml` /// /// `rock.wgsl` is a WGSL shader asset that the `bevy_rock` plugin author wants to bundle with their crate. They invoke the following -/// in `bevy_rock/src/render/mod.rs`: +/// in `bevy_rock/src/render/gpu_resource`: /// /// `embedded_asset!(app, "rock.wgsl")` /// diff --git a/crates/bevy_core_pipeline/src/blit/mod.rs b/crates/bevy_core_pipeline/src/blit/mod.rs index b6698838f4a54..5765ef7417801 100644 --- a/crates/bevy_core_pipeline/src/blit/mod.rs +++ b/crates/bevy_core_pipeline/src/blit/mod.rs @@ -1,7 +1,7 @@ use bevy_app::{App, Plugin}; use bevy_asset::{load_internal_asset, Handle}; use bevy_ecs::prelude::*; -use bevy_render::{render_resource::*, renderer::RenderDevice, RenderApp}; +use bevy_render::{gpu_resource::*, renderer::GpuDevice, RenderApp}; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; @@ -34,32 +34,31 @@ pub struct BlitPipeline { impl FromWorld for BlitPipeline { fn from_world(render_world: &mut World) -> Self { - let render_device = render_world.resource::(); + let gpu_device = render_world.resource::(); - let texture_bind_group = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { - label: Some("blit_bind_group_layout"), - entries: &[ - BindGroupLayoutEntry { - binding: 0, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Texture { - sample_type: TextureSampleType::Float { filterable: false }, - view_dimension: TextureViewDimension::D2, - multisampled: false, - }, - count: None, + let texture_bind_group = gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + label: Some("blit_bind_group_layout"), + entries: &[ + BindGroupLayoutEntry { + binding: 0, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Texture { + sample_type: TextureSampleType::Float { filterable: false }, + view_dimension: TextureViewDimension::D2, + multisampled: false, }, - BindGroupLayoutEntry { - binding: 1, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Sampler(SamplerBindingType::NonFiltering), - count: None, - }, - ], - }); + count: None, + }, + BindGroupLayoutEntry { + binding: 1, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Sampler(SamplerBindingType::NonFiltering), + count: None, + }, + ], + }); - let sampler = render_device.create_sampler(&SamplerDescriptor::default()); + let sampler = gpu_device.create_sampler(&SamplerDescriptor::default()); BlitPipeline { texture_bind_group, diff --git a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs index 747f4ee4c87d4..7f2af958b718c 100644 --- a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs @@ -6,7 +6,7 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_math::Vec4; -use bevy_render::{render_resource::*, renderer::RenderDevice}; +use bevy_render::{gpu_resource::*, renderer::GpuDevice}; #[derive(Component)] pub struct BloomDownsamplingPipelineIds { @@ -39,7 +39,7 @@ pub struct BloomUniforms { impl FromWorld for BloomDownsamplingPipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.resource::(); + let gpu_device = world.resource::(); // Input texture binding let texture = BindGroupLayoutEntry { @@ -74,14 +74,13 @@ impl FromWorld for BloomDownsamplingPipeline { }; // Bind group layout - let bind_group_layout = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { - label: Some("bloom_downsampling_bind_group_layout_with_settings"), - entries: &[texture, sampler, settings], - }); + let bind_group_layout = gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + label: Some("bloom_downsampling_bind_group_layout_with_settings"), + entries: &[texture, sampler, settings], + }); // Sampler - let sampler = render_device.create_sampler(&SamplerDescriptor { + let sampler = gpu_device.create_sampler(&SamplerDescriptor { min_filter: FilterMode::Linear, mag_filter: FilterMode::Linear, address_mode_u: AddressMode::ClampToEdge, diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index 4c0d8ebf8f9cd..622dcc77b7235 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -17,10 +17,10 @@ use bevy_render::{ extract_component::{ ComponentUniforms, DynamicUniformIndex, ExtractComponentPlugin, UniformComponentPlugin, }, + gpu_resource::*, prelude::Color, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, - render_resource::*, - renderer::{RenderContext, RenderDevice}, + renderer::{GpuDevice, RenderContext}, texture::{CachedTexture, TextureCache}, view::ViewTarget, Render, RenderApp, RenderSet, @@ -170,7 +170,7 @@ impl ViewNode for BloomNode { // First downsample pass { - let downsampling_first_bind_group = render_context.render_device().create_bind_group( + let downsampling_first_bind_group = render_context.gpu_device().create_bind_group( "bloom_downsampling_first_bind_group", &downsampling_pipeline_res.bind_group_layout, &BindGroupEntries::sequential(( @@ -325,7 +325,7 @@ impl BloomTexture { fn prepare_bloom_textures( mut commands: Commands, mut texture_cache: ResMut, - render_device: Res, + gpu_device: Res, views: Query<(Entity, &ExtractedCamera), With>, ) { for (entity, camera) in &views { @@ -354,12 +354,12 @@ fn prepare_bloom_textures( }; #[cfg(any(not(feature = "webgl"), not(target_arch = "wasm32")))] - let texture = texture_cache.get(&render_device, texture_descriptor); + let texture = texture_cache.get(&gpu_device, texture_descriptor); #[cfg(all(feature = "webgl", target_arch = "wasm32"))] let texture: Vec = (0..mip_count) .map(|mip| { texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { size: Extent3d { width: (texture_descriptor.size.width >> mip).max(1), @@ -389,7 +389,7 @@ struct BloomBindGroups { fn prepare_bloom_bind_groups( mut commands: Commands, - render_device: Res, + gpu_device: Res, downsampling_pipeline: Res, upsampling_pipeline: Res, views: Query<(Entity, &BloomTexture)>, @@ -402,7 +402,7 @@ fn prepare_bloom_bind_groups( let mut downsampling_bind_groups = Vec::with_capacity(bind_group_count); for mip in 1..bloom_texture.mip_count { - downsampling_bind_groups.push(render_device.create_bind_group( + downsampling_bind_groups.push(gpu_device.create_bind_group( "bloom_downsampling_bind_group", &downsampling_pipeline.bind_group_layout, &BindGroupEntries::sequential(( @@ -415,7 +415,7 @@ fn prepare_bloom_bind_groups( let mut upsampling_bind_groups = Vec::with_capacity(bind_group_count); for mip in (0..bloom_texture.mip_count).rev() { - upsampling_bind_groups.push(render_device.create_bind_group( + upsampling_bind_groups.push(gpu_device.create_bind_group( "bloom_upsampling_bind_group", &upsampling_pipeline.bind_group_layout, &BindGroupEntries::sequential(( diff --git a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs index 996ccce08343a..84f5cd96151f2 100644 --- a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs @@ -8,7 +8,7 @@ use bevy_ecs::{ system::{Commands, Query, Res, ResMut, Resource}, world::{FromWorld, World}, }; -use bevy_render::{render_resource::*, renderer::RenderDevice, view::ViewTarget}; +use bevy_render::{gpu_resource::*, renderer::GpuDevice, view::ViewTarget}; #[derive(Component)] pub struct UpsamplingPipelineIds { @@ -29,43 +29,42 @@ pub struct BloomUpsamplingPipelineKeys { impl FromWorld for BloomUpsamplingPipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.resource::(); + let gpu_device = world.resource::(); - let bind_group_layout = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { - label: Some("bloom_upsampling_bind_group_layout"), - entries: &[ - // Input texture - BindGroupLayoutEntry { - binding: 0, - ty: BindingType::Texture { - sample_type: TextureSampleType::Float { filterable: true }, - view_dimension: TextureViewDimension::D2, - multisampled: false, - }, - visibility: ShaderStages::FRAGMENT, - count: None, - }, - // Sampler - BindGroupLayoutEntry { - binding: 1, - ty: BindingType::Sampler(SamplerBindingType::Filtering), - visibility: ShaderStages::FRAGMENT, - count: None, + let bind_group_layout = gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + label: Some("bloom_upsampling_bind_group_layout"), + entries: &[ + // Input texture + BindGroupLayoutEntry { + binding: 0, + ty: BindingType::Texture { + sample_type: TextureSampleType::Float { filterable: true }, + view_dimension: TextureViewDimension::D2, + multisampled: false, }, - // BloomUniforms - BindGroupLayoutEntry { - binding: 2, - ty: BindingType::Buffer { - ty: BufferBindingType::Uniform, - has_dynamic_offset: true, - min_binding_size: Some(BloomUniforms::min_size()), - }, - visibility: ShaderStages::FRAGMENT, - count: None, + visibility: ShaderStages::FRAGMENT, + count: None, + }, + // Sampler + BindGroupLayoutEntry { + binding: 1, + ty: BindingType::Sampler(SamplerBindingType::Filtering), + visibility: ShaderStages::FRAGMENT, + count: None, + }, + // BloomUniforms + BindGroupLayoutEntry { + binding: 2, + ty: BindingType::Buffer { + ty: BufferBindingType::Uniform, + has_dynamic_offset: true, + min_binding_size: Some(BloomUniforms::min_size()), }, - ], - }); + visibility: ShaderStages::FRAGMENT, + count: None, + }, + ], + }); BloomUpsamplingPipeline { bind_group_layout } } diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs index 89879938e8a8b..5705f2103d85d 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs @@ -9,10 +9,10 @@ use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_reflect::Reflect; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin}, + gpu_resource::*, prelude::Camera, render_graph::RenderGraphApp, - render_resource::*, - renderer::RenderDevice, + renderer::GpuDevice, texture::BevyDefault, view::{ExtractedView, ViewTarget}, Render, RenderApp, RenderSet, @@ -168,42 +168,41 @@ pub struct CASPipeline { impl FromWorld for CASPipeline { fn from_world(render_world: &mut World) -> Self { - let render_device = render_world.resource::(); - let texture_bind_group = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { - label: Some("sharpening_texture_bind_group_layout"), - entries: &[ - BindGroupLayoutEntry { - binding: 0, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Texture { - sample_type: TextureSampleType::Float { filterable: true }, - view_dimension: TextureViewDimension::D2, - multisampled: false, - }, - count: None, + let gpu_device = render_world.resource::(); + let texture_bind_group = gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + label: Some("sharpening_texture_bind_group_layout"), + entries: &[ + BindGroupLayoutEntry { + binding: 0, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Texture { + sample_type: TextureSampleType::Float { filterable: true }, + view_dimension: TextureViewDimension::D2, + multisampled: false, }, - BindGroupLayoutEntry { - binding: 1, - visibility: ShaderStages::FRAGMENT, - ty: BindingType::Sampler(SamplerBindingType::Filtering), - count: None, - }, - // CAS Settings - BindGroupLayoutEntry { - binding: 2, - ty: BindingType::Buffer { - ty: BufferBindingType::Uniform, - has_dynamic_offset: true, - min_binding_size: Some(CASUniform::min_size()), - }, - visibility: ShaderStages::FRAGMENT, - count: None, + count: None, + }, + BindGroupLayoutEntry { + binding: 1, + visibility: ShaderStages::FRAGMENT, + ty: BindingType::Sampler(SamplerBindingType::Filtering), + count: None, + }, + // CAS Settings + BindGroupLayoutEntry { + binding: 2, + ty: BindingType::Buffer { + ty: BufferBindingType::Uniform, + has_dynamic_offset: true, + min_binding_size: Some(CASUniform::min_size()), }, - ], - }); + visibility: ShaderStages::FRAGMENT, + count: None, + }, + ], + }); - let sampler = render_device.create_sampler(&SamplerDescriptor::default()); + let sampler = gpu_device.create_sampler(&SamplerDescriptor::default()); CASPipeline { texture_bind_group, diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/node.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/node.rs index 5bb8b87ebc58b..32530d690d404 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/node.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/node.rs @@ -5,11 +5,11 @@ use bevy_ecs::prelude::*; use bevy_ecs::query::QueryState; use bevy_render::{ extract_component::{ComponentUniforms, DynamicUniformIndex}, - render_graph::{Node, NodeRunError, RenderGraphContext}, - render_resource::{ + gpu_resource::{ BindGroup, BindGroupEntries, BufferId, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, TextureViewId, }, + render_graph::{Node, NodeRunError, RenderGraphContext}, renderer::RenderContext, view::{ExtractedView, ViewTarget}, }; @@ -77,7 +77,7 @@ impl Node for CASNode { bind_group } cached_bind_group => { - let bind_group = render_context.render_device().create_bind_group( + let bind_group = render_context.gpu_device().create_bind_group( "cas_bind_group", &sharpening_pipeline.texture_bind_group, &BindGroupEntries::sequential(( diff --git a/crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs b/crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs index 708193524b70a..40e6c90c0c780 100644 --- a/crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs +++ b/crates/bevy_core_pipeline/src/core_2d/main_pass_2d_node.rs @@ -5,9 +5,9 @@ use crate::{ use bevy_ecs::prelude::*; use bevy_render::{ camera::ExtractedCamera, + gpu_resource::{LoadOp, Operations, RenderPassDescriptor}, render_graph::{Node, NodeRunError, RenderGraphContext}, render_phase::RenderPhase, - render_resource::{LoadOp, Operations, RenderPassDescriptor}, renderer::RenderContext, view::{ExtractedView, ViewTarget}, }; diff --git a/crates/bevy_core_pipeline/src/core_2d/mod.rs b/crates/bevy_core_pipeline/src/core_2d/mod.rs index 530d48cde38a5..78e245415c226 100644 --- a/crates/bevy_core_pipeline/src/core_2d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_2d/mod.rs @@ -29,12 +29,12 @@ use bevy_ecs::prelude::*; use bevy_render::{ camera::Camera, extract_component::ExtractComponentPlugin, + gpu_resource::CachedRenderPipelineId, render_graph::{EmptyNode, RenderGraphApp, ViewNodeRunner}, render_phase::{ sort_phase_system, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, RenderPhase, }, - render_resource::CachedRenderPipelineId, Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_utils::{nonmax::NonMaxU32, FloatOrd}; diff --git a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs index 33579994c9aca..728bdceb854a2 100644 --- a/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs +++ b/crates/bevy_core_pipeline/src/core_3d/camera_3d.rs @@ -7,8 +7,8 @@ use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; use bevy_render::{ camera::{Camera, CameraRenderGraph, Projection}, extract_component::ExtractComponent, + gpu_resource::{LoadOp, TextureUsages}, primitives::Frustum, - render_resource::{LoadOp, TextureUsages}, view::{ColorGrading, VisibleEntities}, }; use bevy_transform::prelude::{GlobalTransform, Transform}; diff --git a/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs index a64ed8f4c8bef..3510bd02c2f8a 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs @@ -7,11 +7,11 @@ use crate::{ use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ camera::ExtractedCamera, - render_graph::{NodeRunError, RenderGraphContext, ViewNode}, - render_phase::RenderPhase, - render_resource::{ + gpu_resource::{ LoadOp, Operations, PipelineCache, RenderPassDepthStencilAttachment, RenderPassDescriptor, }, + render_graph::{NodeRunError, RenderGraphContext, ViewNode}, + render_phase::RenderPhase, renderer::RenderContext, view::{ViewDepthTexture, ViewTarget, ViewUniformOffset}, }; diff --git a/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs index 18c04e0d5a828..a4f291a726f3c 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs @@ -3,11 +3,11 @@ use crate::core_3d::Transmissive3d; use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ camera::ExtractedCamera, - render_graph::{NodeRunError, RenderGraphContext, ViewNode}, - render_phase::RenderPhase, - render_resource::{ + gpu_resource::{ Extent3d, LoadOp, Operations, RenderPassDepthStencilAttachment, RenderPassDescriptor, }, + render_graph::{NodeRunError, RenderGraphContext, ViewNode}, + render_phase::RenderPhase, renderer::RenderContext, view::{ViewDepthTexture, ViewTarget}, }; diff --git a/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs index ce5a2127f1d44..072a34b598db0 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs @@ -2,9 +2,9 @@ use crate::core_3d::Transparent3d; use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ camera::ExtractedCamera, + gpu_resource::{LoadOp, Operations, RenderPassDepthStencilAttachment, RenderPassDescriptor}, render_graph::{NodeRunError, RenderGraphContext, ViewNode}, render_phase::RenderPhase, - render_resource::{LoadOp, Operations, RenderPassDepthStencilAttachment, RenderPassDescriptor}, renderer::RenderContext, view::{ViewDepthTexture, ViewTarget}, }; diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index f003ed6191f2b..f119f8a751702 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -43,17 +43,17 @@ use bevy_ecs::prelude::*; use bevy_render::{ camera::{Camera, ExtractedCamera}, extract_component::ExtractComponentPlugin, + gpu_resource::{ + CachedRenderPipelineId, Extent3d, FilterMode, Sampler, SamplerDescriptor, Texture, + TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, TextureView, + }, prelude::Msaa, render_graph::{EmptyNode, RenderGraphApp, ViewNodeRunner}, render_phase::{ sort_phase_system, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, RenderPhase, }, - render_resource::{ - CachedRenderPipelineId, Extent3d, FilterMode, Sampler, SamplerDescriptor, Texture, - TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, TextureView, - }, - renderer::RenderDevice, + renderer::GpuDevice, texture::{BevyDefault, TextureCache}, view::{ExtractedView, ViewDepthTexture, ViewTarget}, Extract, ExtractSchedule, Render, RenderApp, RenderSet, @@ -499,7 +499,7 @@ pub fn prepare_core_3d_depth_textures( mut commands: Commands, mut texture_cache: ResMut, msaa: Res, - render_device: Res, + gpu_device: Res, views_3d: Query< (Entity, &ExtractedCamera, Option<&DepthPrepass>, &Camera3d), ( @@ -555,7 +555,7 @@ pub fn prepare_core_3d_depth_textures( view_formats: &[], }; - texture_cache.get(&render_device, descriptor) + texture_cache.get(&gpu_device, descriptor) }) .clone(); @@ -576,7 +576,7 @@ pub struct ViewTransmissionTexture { pub fn prepare_core_3d_transmission_textures( mut commands: Commands, mut texture_cache: ResMut, - render_device: Res, + gpu_device: Res, views_3d: Query< ( Entity, @@ -637,11 +637,11 @@ pub fn prepare_core_3d_transmission_textures( view_formats: &[], }; - texture_cache.get(&render_device, descriptor) + texture_cache.get(&gpu_device, descriptor) }) .clone(); - let sampler = render_device.create_sampler(&SamplerDescriptor { + let sampler = gpu_device.create_sampler(&SamplerDescriptor { label: Some("view_transmission_sampler"), mag_filter: FilterMode::Linear, min_filter: FilterMode::Linear, @@ -677,7 +677,7 @@ pub fn prepare_prepass_textures( mut commands: Commands, mut texture_cache: ResMut, msaa: Res, - render_device: Res, + gpu_device: Res, views_3d: Query< ( Entity, @@ -729,7 +729,7 @@ pub fn prepare_prepass_textures( | TextureUsages::TEXTURE_BINDING, view_formats: &[], }; - texture_cache.get(&render_device, descriptor) + texture_cache.get(&gpu_device, descriptor) }) .clone() }); @@ -739,7 +739,7 @@ pub fn prepare_prepass_textures( .entry(camera.target.clone()) .or_insert_with(|| { texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { label: Some("prepass_normal_texture"), size, @@ -761,7 +761,7 @@ pub fn prepare_prepass_textures( .entry(camera.target.clone()) .or_insert_with(|| { texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { label: Some("prepass_motion_vectors_textures"), size, @@ -783,7 +783,7 @@ pub fn prepare_prepass_textures( .entry(camera.target.clone()) .or_insert_with(|| { texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { label: Some("prepass_deferred_texture"), size, @@ -805,7 +805,7 @@ pub fn prepare_prepass_textures( .entry(camera.target.clone()) .or_insert_with(|| { texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { label: Some("deferred_lighting_pass_id_texture"), size, diff --git a/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs b/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs index c60306286900a..8ac36ea15ac7d 100644 --- a/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs +++ b/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs @@ -8,8 +8,8 @@ use bevy_ecs::prelude::*; use bevy_math::UVec2; use bevy_render::{ camera::ExtractedCamera, - render_resource::*, - renderer::RenderDevice, + gpu_resource::*, + renderer::GpuDevice, texture::{CachedTexture, TextureCache}, view::ViewTarget, Render, RenderApp, RenderSet, @@ -17,8 +17,8 @@ use bevy_render::{ use bevy_ecs::query::QueryItem; use bevy_render::{ + gpu_resource::{Operations, PipelineCache, RenderPassDescriptor}, render_graph::{NodeRunError, RenderGraphContext, ViewNode}, - render_resource::{Operations, PipelineCache, RenderPassDescriptor}, renderer::RenderContext, }; @@ -91,7 +91,7 @@ impl ViewNode for CopyDeferredLightingIdNode { return Ok(()); }; - let bind_group = render_context.render_device().create_bind_group( + let bind_group = render_context.gpu_device().create_bind_group( "copy_deferred_lighting_id_bind_group", ©_deferred_lighting_id_pipeline.layout, &BindGroupEntries::single(&deferred_lighting_pass_id_texture.default_view), @@ -126,9 +126,9 @@ struct CopyDeferredLightingIdPipeline { impl FromWorld for CopyDeferredLightingIdPipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.resource::(); + let gpu_device = world.resource::(); - let layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + let layout = gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("copy_deferred_lighting_id_bind_group_layout"), entries: &[BindGroupLayoutEntry { binding: 0, @@ -182,7 +182,7 @@ pub struct DeferredLightingIdDepthTexture { fn prepare_deferred_lighting_id_textures( mut commands: Commands, mut texture_cache: ResMut, - render_device: Res, + gpu_device: Res, views: Query<(Entity, &ExtractedCamera), With>, ) { for (entity, camera) in &views { @@ -205,7 +205,7 @@ fn prepare_deferred_lighting_id_textures( usage: TextureUsages::RENDER_ATTACHMENT | TextureUsages::COPY_SRC, view_formats: &[], }; - let texture = texture_cache.get(&render_device, texture_descriptor); + let texture = texture_cache.get(&gpu_device, texture_descriptor); commands .entity(entity) .insert(DeferredLightingIdDepthTexture { texture }); diff --git a/crates/bevy_core_pipeline/src/deferred/mod.rs b/crates/bevy_core_pipeline/src/deferred/mod.rs index a8a56e39a1163..5c3a38a12432c 100644 --- a/crates/bevy_core_pipeline/src/deferred/mod.rs +++ b/crates/bevy_core_pipeline/src/deferred/mod.rs @@ -5,8 +5,8 @@ use std::{cmp::Reverse, ops::Range}; use bevy_ecs::prelude::*; use bevy_render::{ + gpu_resource::{CachedRenderPipelineId, TextureFormat}, render_phase::{CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem}, - render_resource::{CachedRenderPipelineId, TextureFormat}, }; use bevy_utils::{nonmax::NonMaxU32, FloatOrd}; diff --git a/crates/bevy_core_pipeline/src/deferred/node.rs b/crates/bevy_core_pipeline/src/deferred/node.rs index f598e8393ea70..6176457b6fa45 100644 --- a/crates/bevy_core_pipeline/src/deferred/node.rs +++ b/crates/bevy_core_pipeline/src/deferred/node.rs @@ -4,13 +4,13 @@ use bevy_render::render_graph::ViewNode; use bevy_render::{ camera::ExtractedCamera, - prelude::Color, - render_graph::{NodeRunError, RenderGraphContext}, - render_phase::RenderPhase, - render_resource::{ + gpu_resource::{ LoadOp, Operations, RenderPassColorAttachment, RenderPassDepthStencilAttachment, RenderPassDescriptor, }, + prelude::Color, + render_graph::{NodeRunError, RenderGraphContext}, + render_phase::RenderPhase, renderer::RenderContext, view::ViewDepthTexture, }; @@ -106,7 +106,7 @@ impl ViewNode for DeferredGBufferPrepassNode { if let Some(deferred_texture) = &view_prepass_textures.deferred { render_context.command_encoder().clear_texture( &deferred_texture.texture, - &bevy_render::render_resource::ImageSubresourceRange::default(), + &bevy_render::gpu_resource::ImageSubresourceRange::default(), ); } diff --git a/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs b/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs index d01c34477503d..1470c588ae51e 100644 --- a/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs +++ b/crates/bevy_core_pipeline/src/fullscreen_vertex_shader/mod.rs @@ -1,5 +1,5 @@ use bevy_asset::Handle; -use bevy_render::{prelude::Shader, render_resource::VertexState}; +use bevy_render::{gpu_resource::VertexState, prelude::Shader}; pub const FULLSCREEN_SHADER_HANDLE: Handle = Handle::weak_from_u128(7837534426033940724); diff --git a/crates/bevy_core_pipeline/src/fxaa/mod.rs b/crates/bevy_core_pipeline/src/fxaa/mod.rs index df37eaa1a8e76..e40bc5d52c35d 100644 --- a/crates/bevy_core_pipeline/src/fxaa/mod.rs +++ b/crates/bevy_core_pipeline/src/fxaa/mod.rs @@ -10,11 +10,11 @@ use bevy_ecs::prelude::*; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, + gpu_resource::*, prelude::Camera, render_graph::RenderGraphApp, render_graph::ViewNodeRunner, - render_resource::*, - renderer::RenderDevice, + renderer::GpuDevice, texture::BevyDefault, view::{ExtractedView, ViewTarget}, Render, RenderApp, RenderSet, @@ -130,7 +130,7 @@ pub struct FxaaPipeline { impl FromWorld for FxaaPipeline { fn from_world(render_world: &mut World) -> Self { let texture_bind_group = render_world - .resource::() + .resource::() .create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("fxaa_texture_bind_group_layout"), entries: &[ diff --git a/crates/bevy_core_pipeline/src/fxaa/node.rs b/crates/bevy_core_pipeline/src/fxaa/node.rs index 7eaf4dce268ad..89a42e28e454c 100644 --- a/crates/bevy_core_pipeline/src/fxaa/node.rs +++ b/crates/bevy_core_pipeline/src/fxaa/node.rs @@ -4,11 +4,11 @@ use crate::fxaa::{CameraFxaaPipeline, Fxaa, FxaaPipeline}; use bevy_ecs::prelude::*; use bevy_ecs::query::QueryItem; use bevy_render::{ - render_graph::{NodeRunError, RenderGraphContext, ViewNode}, - render_resource::{ + gpu_resource::{ BindGroup, BindGroupEntries, FilterMode, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, TextureViewId, }, + render_graph::{NodeRunError, RenderGraphContext, ViewNode}, renderer::RenderContext, view::ViewTarget, }; @@ -52,7 +52,7 @@ impl ViewNode for FxaaNode { Some((id, bind_group)) if source.id() == *id => bind_group, cached_bind_group => { let sampler = render_context - .render_device() + .gpu_device() .create_sampler(&SamplerDescriptor { mipmap_filter: FilterMode::Linear, mag_filter: FilterMode::Linear, @@ -60,7 +60,7 @@ impl ViewNode for FxaaNode { ..default() }); - let bind_group = render_context.render_device().create_bind_group( + let bind_group = render_context.gpu_device().create_bind_group( None, &fxaa_pipeline.texture_bind_group, &BindGroupEntries::sequential((source, &sampler)), diff --git a/crates/bevy_core_pipeline/src/msaa_writeback.rs b/crates/bevy_core_pipeline/src/msaa_writeback.rs index d80bc0fce7bc9..1caafa188c4d6 100644 --- a/crates/bevy_core_pipeline/src/msaa_writeback.rs +++ b/crates/bevy_core_pipeline/src/msaa_writeback.rs @@ -7,13 +7,13 @@ use bevy_app::{App, Plugin}; use bevy_ecs::prelude::*; use bevy_render::{ camera::ExtractedCamera, + gpu_resource::BindGroupEntries, render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext}, - render_resource::BindGroupEntries, renderer::RenderContext, view::{Msaa, ViewTarget}, Render, RenderSet, }; -use bevy_render::{render_resource::*, RenderApp}; +use bevy_render::{gpu_resource::*, RenderApp}; /// This enables "msaa writeback" support for the `core_2d` and `core_3d` pipelines, which can be enabled on cameras /// using [`bevy_render::camera::Camera::msaa_writeback`]. See the docs on that field for more information. @@ -91,7 +91,7 @@ impl Node for MsaaWritebackNode { depth_stencil_attachment: None, }; - let bind_group = render_context.render_device().create_bind_group( + let bind_group = render_context.gpu_device().create_bind_group( None, &blit_pipeline.texture_bind_group, &BindGroupEntries::sequential((post_process.source, &blit_pipeline.sampler)), diff --git a/crates/bevy_core_pipeline/src/prepass/mod.rs b/crates/bevy_core_pipeline/src/prepass/mod.rs index 63b8c764af5ff..1ce263e9dc4c5 100644 --- a/crates/bevy_core_pipeline/src/prepass/mod.rs +++ b/crates/bevy_core_pipeline/src/prepass/mod.rs @@ -32,8 +32,8 @@ use std::{cmp::Reverse, ops::Range}; use bevy_ecs::prelude::*; use bevy_reflect::Reflect; use bevy_render::{ + gpu_resource::{CachedRenderPipelineId, Extent3d, TextureFormat}, render_phase::{CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem}, - render_resource::{CachedRenderPipelineId, Extent3d, TextureFormat}, texture::CachedTexture, }; use bevy_utils::{nonmax::NonMaxU32, FloatOrd}; diff --git a/crates/bevy_core_pipeline/src/prepass/node.rs b/crates/bevy_core_pipeline/src/prepass/node.rs index 5b64ad7bf4284..dbf8f56ac9a02 100644 --- a/crates/bevy_core_pipeline/src/prepass/node.rs +++ b/crates/bevy_core_pipeline/src/prepass/node.rs @@ -3,13 +3,13 @@ use bevy_ecs::query::QueryItem; use bevy_render::render_graph::ViewNode; use bevy_render::{ camera::ExtractedCamera, - prelude::Color, - render_graph::{NodeRunError, RenderGraphContext}, - render_phase::RenderPhase, - render_resource::{ + gpu_resource::{ LoadOp, Operations, RenderPassColorAttachment, RenderPassDepthStencilAttachment, RenderPassDescriptor, }, + prelude::Color, + render_graph::{NodeRunError, RenderGraphContext}, + render_phase::RenderPhase, renderer::RenderContext, view::ViewDepthTexture, }; diff --git a/crates/bevy_core_pipeline/src/skybox/mod.rs b/crates/bevy_core_pipeline/src/skybox/mod.rs index 11caa03afd8aa..24a163c944585 100644 --- a/crates/bevy_core_pipeline/src/skybox/mod.rs +++ b/crates/bevy_core_pipeline/src/skybox/mod.rs @@ -8,8 +8,7 @@ use bevy_ecs::{ }; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, - render_asset::RenderAssets, - render_resource::{ + gpu_resource::{ BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType, BufferBindingType, CachedRenderPipelineId, ColorTargetState, ColorWrites, CompareFunction, DepthBiasState, DepthStencilState, @@ -18,7 +17,8 @@ use bevy_render::{ SpecializedRenderPipelines, StencilFaceState, StencilState, TextureFormat, TextureSampleType, TextureViewDimension, VertexState, }, - renderer::RenderDevice, + render_asset::RenderAssets, + renderer::GpuDevice, texture::{BevyDefault, Image}, view::{ExtractedView, Msaa, ViewTarget, ViewUniform, ViewUniforms}, Render, RenderApp, RenderSet, @@ -58,9 +58,9 @@ impl Plugin for SkyboxPlugin { Err(_) => return, }; - let render_device = render_app.world.resource::().clone(); + let gpu_device = render_app.world.resource::().clone(); - render_app.insert_resource(SkyboxPipeline::new(&render_device)); + render_app.insert_resource(SkyboxPipeline::new(&gpu_device)); } } @@ -79,7 +79,7 @@ struct SkyboxPipeline { } impl SkyboxPipeline { - fn new(render_device: &RenderDevice) -> Self { + fn new(gpu_device: &GpuDevice) -> Self { let bind_group_layout_descriptor = BindGroupLayoutDescriptor { label: Some("skybox_bind_group_layout"), entries: &[ @@ -113,8 +113,7 @@ impl SkyboxPipeline { }; Self { - bind_group_layout: render_device - .create_bind_group_layout(&bind_group_layout_descriptor), + bind_group_layout: gpu_device.create_bind_group_layout(&bind_group_layout_descriptor), } } } @@ -217,14 +216,14 @@ fn prepare_skybox_bind_groups( pipeline: Res, view_uniforms: Res, images: Res>, - render_device: Res, + gpu_device: Res, views: Query<(Entity, &Skybox)>, ) { for (entity, skybox) in &views { if let (Some(skybox), Some(view_uniforms)) = (images.get(&skybox.0), view_uniforms.uniforms.binding()) { - let bind_group = render_device.create_bind_group( + let bind_group = gpu_device.create_bind_group( "skybox_bind_group", &pipeline.bind_group_layout, &BindGroupEntries::sequential(( diff --git a/crates/bevy_core_pipeline/src/taa/mod.rs b/crates/bevy_core_pipeline/src/taa/mod.rs index de4069c9abe7d..ca1e827e7e345 100644 --- a/crates/bevy_core_pipeline/src/taa/mod.rs +++ b/crates/bevy_core_pipeline/src/taa/mod.rs @@ -18,9 +18,7 @@ use bevy_math::vec2; use bevy_reflect::Reflect; use bevy_render::{ camera::{ExtractedCamera, MipBias, TemporalJitter}, - prelude::{Camera, Projection}, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, - render_resource::{ + gpu_resource::{ BindGroupEntries, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType, CachedRenderPipelineId, ColorTargetState, ColorWrites, Extent3d, FilterMode, FragmentState, MultisampleState, Operations, PipelineCache, PrimitiveState, @@ -29,7 +27,9 @@ use bevy_render::{ SpecializedRenderPipelines, TextureDescriptor, TextureDimension, TextureFormat, TextureSampleType, TextureUsages, TextureViewDimension, }, - renderer::{RenderContext, RenderDevice}, + prelude::{Camera, Projection}, + render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + renderer::{GpuDevice, RenderContext}, texture::{BevyDefault, CachedTexture, TextureCache}, view::{ExtractedView, Msaa, ViewTarget}, ExtractSchedule, MainWorld, Render, RenderApp, RenderSet, @@ -200,7 +200,7 @@ impl ViewNode for TemporalAntiAliasNode { }; let view_target = view_target.post_process_write(); - let taa_bind_group = render_context.render_device().create_bind_group( + let taa_bind_group = render_context.gpu_device().create_bind_group( "taa_bind_group", &pipelines.taa_bind_group_layout, &BindGroupEntries::sequential(( @@ -251,15 +251,15 @@ struct TaaPipeline { impl FromWorld for TaaPipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.resource::(); + let gpu_device = world.resource::(); - let nearest_sampler = render_device.create_sampler(&SamplerDescriptor { + let nearest_sampler = gpu_device.create_sampler(&SamplerDescriptor { label: Some("taa_nearest_sampler"), mag_filter: FilterMode::Nearest, min_filter: FilterMode::Nearest, ..SamplerDescriptor::default() }); - let linear_sampler = render_device.create_sampler(&SamplerDescriptor { + let linear_sampler = gpu_device.create_sampler(&SamplerDescriptor { label: Some("taa_linear_sampler"), mag_filter: FilterMode::Linear, min_filter: FilterMode::Linear, @@ -267,7 +267,7 @@ impl FromWorld for TaaPipeline { }); let taa_bind_group_layout = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("taa_bind_group_layout"), entries: &[ // View target (read) @@ -451,7 +451,7 @@ pub struct TemporalAntiAliasHistoryTextures { fn prepare_taa_history_textures( mut commands: Commands, mut texture_cache: ResMut, - render_device: Res, + gpu_device: Res, frame_count: Res, views: Query<(Entity, &ExtractedCamera, &ExtractedView), With>, ) { @@ -477,10 +477,10 @@ fn prepare_taa_history_textures( }; texture_descriptor.label = Some("taa_history_1_texture"); - let history_1_texture = texture_cache.get(&render_device, texture_descriptor.clone()); + let history_1_texture = texture_cache.get(&gpu_device, texture_descriptor.clone()); texture_descriptor.label = Some("taa_history_2_texture"); - let history_2_texture = texture_cache.get(&render_device, texture_descriptor); + let history_2_texture = texture_cache.get(&gpu_device, texture_descriptor); let textures = if frame_count.0 % 2 == 0 { TemporalAntiAliasHistoryTextures { diff --git a/crates/bevy_core_pipeline/src/tonemapping/mod.rs b/crates/bevy_core_pipeline/src/tonemapping/mod.rs index bb4dec7f3bc49..6916a870676ec 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/mod.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/mod.rs @@ -7,10 +7,10 @@ use bevy_render::camera::Camera; use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin}; use bevy_render::extract_resource::{ExtractResource, ExtractResourcePlugin}; use bevy_render::render_asset::RenderAssets; -use bevy_render::renderer::RenderDevice; +use bevy_render::renderer::GpuDevice; use bevy_render::texture::{CompressedImageFormats, Image, ImageSampler, ImageType}; use bevy_render::view::{ViewTarget, ViewUniform}; -use bevy_render::{render_resource::*, Render, RenderApp, RenderSet}; +use bevy_render::{gpu_resource::*, Render, RenderApp, RenderSet}; mod node; @@ -279,7 +279,7 @@ impl FromWorld for TonemappingPipeline { entries.extend(get_lut_bind_group_layout_entries([3, 4])); let tonemap_texture_bind_group = render_world - .resource::() + .resource::() .create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("tonemapping_hdr_texture_bind_group_layout"), entries: &entries, diff --git a/crates/bevy_core_pipeline/src/tonemapping/node.rs b/crates/bevy_core_pipeline/src/tonemapping/node.rs index 1d1c95d970850..9c67b62928f79 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/node.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/node.rs @@ -4,12 +4,12 @@ use crate::tonemapping::{TonemappingLuts, TonemappingPipeline, ViewTonemappingPi use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ - render_asset::RenderAssets, - render_graph::{NodeRunError, RenderGraphContext, ViewNode}, - render_resource::{ + gpu_resource::{ BindGroup, BindGroupEntries, BufferId, LoadOp, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, TextureViewId, }, + render_asset::RenderAssets, + render_graph::{NodeRunError, RenderGraphContext, ViewNode}, renderer::RenderContext, texture::Image, view::{ViewTarget, ViewUniformOffset, ViewUniforms}, @@ -82,14 +82,14 @@ impl ViewNode for TonemappingNode { } cached_bind_group => { let sampler = render_context - .render_device() + .gpu_device() .create_sampler(&SamplerDescriptor::default()); let tonemapping_luts = world.resource::(); let lut_bindings = get_lut_bindings(gpu_images, tonemapping_luts, tonemapping); - let bind_group = render_context.render_device().create_bind_group( + let bind_group = render_context.gpu_device().create_bind_group( None, &tonemapping_pipeline.texture_bind_group, &BindGroupEntries::sequential(( diff --git a/crates/bevy_core_pipeline/src/upscaling/mod.rs b/crates/bevy_core_pipeline/src/upscaling/mod.rs index 76475c8692bf5..9d7484a6de3e9 100644 --- a/crates/bevy_core_pipeline/src/upscaling/mod.rs +++ b/crates/bevy_core_pipeline/src/upscaling/mod.rs @@ -3,7 +3,7 @@ use bevy_app::prelude::*; use bevy_ecs::prelude::*; use bevy_render::camera::{CameraOutputMode, ExtractedCamera}; use bevy_render::view::ViewTarget; -use bevy_render::{render_resource::*, Render, RenderApp, RenderSet}; +use bevy_render::{gpu_resource::*, Render, RenderApp, RenderSet}; mod node; diff --git a/crates/bevy_core_pipeline/src/upscaling/node.rs b/crates/bevy_core_pipeline/src/upscaling/node.rs index 536b2b9437515..2cd54a8bc72c2 100644 --- a/crates/bevy_core_pipeline/src/upscaling/node.rs +++ b/crates/bevy_core_pipeline/src/upscaling/node.rs @@ -2,11 +2,11 @@ use crate::{blit::BlitPipeline, upscaling::ViewUpscalingPipeline}; use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ camera::{CameraOutputMode, ExtractedCamera}, - render_graph::{NodeRunError, RenderGraphContext, ViewNode}, - render_resource::{ + gpu_resource::{ BindGroup, BindGroupEntries, LoadOp, Operations, PipelineCache, RenderPassColorAttachment, RenderPassDescriptor, SamplerDescriptor, TextureViewId, }, + render_graph::{NodeRunError, RenderGraphContext, ViewNode}, renderer::RenderContext, view::ViewTarget, }; @@ -53,10 +53,10 @@ impl ViewNode for UpscalingNode { Some((id, bind_group)) if upscaled_texture.id() == *id => bind_group, cached_bind_group => { let sampler = render_context - .render_device() + .gpu_device() .create_sampler(&SamplerDescriptor::default()); - let bind_group = render_context.render_device().create_bind_group( + let bind_group = render_context.gpu_device().create_bind_group( None, &blit_pipeline.texture_bind_group, &BindGroupEntries::sequential((upscaled_texture, &sampler)), diff --git a/crates/bevy_encase_derive/src/lib.rs b/crates/bevy_encase_derive/src/lib.rs index cc81b6edd52d0..15b9e5337b4a6 100644 --- a/crates/bevy_encase_derive/src/lib.rs +++ b/crates/bevy_encase_derive/src/lib.rs @@ -11,7 +11,7 @@ fn bevy_encase_path() -> syn::Path { .get_subcrate("render") .map(|bevy_render_path| { let mut segments = bevy_render_path.segments; - segments.push(BevyManifest::parse_str("render_resource")); + segments.push(BevyManifest::parse_str("gpu_resource")); syn::Path { leading_colon: None, segments, diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index 446605b43e4f8..0fd24b6e1fdf7 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -48,16 +48,16 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; use bevy_render::{ color::Color, extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin}, - primitives::Aabb, - render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, - render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass}, - render_resource::{ + gpu_resource::{ BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType, Buffer, BufferBindingType, BufferInitDescriptor, BufferUsages, Shader, ShaderStages, ShaderType, VertexAttribute, VertexBufferLayout, VertexFormat, VertexStepMode, }, - renderer::RenderDevice, + primitives::Aabb, + render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets}, + render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass}, + renderer::GpuDevice, view::RenderLayers, Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; @@ -115,8 +115,8 @@ impl Plugin for GizmoPlugin { return; }; - let render_device = render_app.world.resource::(); - let layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + let gpu_device = render_app.world.resource::(); + let layout = gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[BindGroupLayoutEntry { binding: 0, visibility: ShaderStages::VERTEX, @@ -371,7 +371,7 @@ impl RenderAsset for LineGizmo { type PreparedAsset = GpuLineGizmo; - type Param = SRes; + type Param = SRes; fn extract_asset(&self) -> Self::ExtractedAsset { self.clone() @@ -379,17 +379,17 @@ impl RenderAsset for LineGizmo { fn prepare_asset( line_gizmo: Self::ExtractedAsset, - render_device: &mut SystemParamItem, + gpu_device: &mut SystemParamItem, ) -> Result> { let position_buffer_data = cast_slice(&line_gizmo.positions); - let position_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor { + let position_buffer = gpu_device.create_buffer_with_data(&BufferInitDescriptor { usage: BufferUsages::VERTEX, label: Some("LineGizmo Position Buffer"), contents: position_buffer_data, }); let color_buffer_data = cast_slice(&line_gizmo.colors); - let color_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor { + let color_buffer = gpu_device.create_buffer_with_data(&BufferInitDescriptor { usage: BufferUsages::VERTEX, label: Some("LineGizmo Color Buffer"), contents: color_buffer_data, @@ -417,12 +417,12 @@ struct LineGizmoUniformBindgroup { fn prepare_line_gizmo_bind_group( mut commands: Commands, line_gizmo_uniform_layout: Res, - render_device: Res, + gpu_device: Res, line_gizmo_uniforms: Res>, ) { if let Some(binding) = line_gizmo_uniforms.uniforms().binding() { commands.insert_resource(LineGizmoUniformBindgroup { - bindgroup: render_device.create_bind_group( + bindgroup: gpu_device.create_bind_group( "LineGizmoUniform bindgroup", &line_gizmo_uniform_layout.layout, &BindGroupEntries::single(binding), diff --git a/crates/bevy_gizmos/src/pipeline_2d.rs b/crates/bevy_gizmos/src/pipeline_2d.rs index 5b64598eb403f..8f12f7fceaf5b 100644 --- a/crates/bevy_gizmos/src/pipeline_2d.rs +++ b/crates/bevy_gizmos/src/pipeline_2d.rs @@ -13,9 +13,9 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_render::{ + gpu_resource::*, render_asset::{prepare_assets, RenderAssets}, render_phase::{AddRenderCommand, DrawFunctions, RenderPhase, SetItemPipeline}, - render_resource::*, texture::BevyDefault, view::{ExtractedView, Msaa, RenderLayers, ViewTarget}, Render, RenderApp, RenderSet, diff --git a/crates/bevy_gizmos/src/pipeline_3d.rs b/crates/bevy_gizmos/src/pipeline_3d.rs index 2cb016753513b..1adb026cb89f0 100644 --- a/crates/bevy_gizmos/src/pipeline_3d.rs +++ b/crates/bevy_gizmos/src/pipeline_3d.rs @@ -18,9 +18,9 @@ use bevy_ecs::{ }; use bevy_pbr::{MeshPipeline, MeshPipelineKey, SetMeshViewBindGroup}; use bevy_render::{ + gpu_resource::*, render_asset::{prepare_assets, RenderAssets}, render_phase::{AddRenderCommand, DrawFunctions, RenderPhase, SetItemPipeline}, - render_resource::*, texture::BevyDefault, view::{ExtractedView, Msaa, RenderLayers, ViewTarget}, Render, RenderApp, RenderSet, diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs index 559c8ae3c8e63..381c134d5a4af 100644 --- a/crates/bevy_gltf/src/lib.rs +++ b/crates/bevy_gltf/src/lib.rs @@ -20,7 +20,7 @@ use bevy_pbr::StandardMaterial; use bevy_reflect::{Reflect, TypePath}; use bevy_render::{ mesh::{Mesh, MeshVertexAttribute}, - renderer::RenderDevice, + renderer::GpuDevice, texture::CompressedImageFormats, }; use bevy_scene::Scene; @@ -59,8 +59,8 @@ impl Plugin for GltfPlugin { } fn finish(&self, app: &mut App) { - let supported_compressed_formats = match app.world.get_resource::() { - Some(render_device) => CompressedImageFormats::from_features(render_device.features()), + let supported_compressed_formats = match app.world.get_resource::() { + Some(gpu_device) => CompressedImageFormats::from_features(gpu_device.features()), None => CompressedImageFormats::NONE, }; diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index abdbc1a3cbe50..9f5b200ab71a8 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -15,6 +15,7 @@ use bevy_pbr::{ use bevy_render::{ camera::{Camera, OrthographicProjection, PerspectiveProjection, Projection, ScalingMode}, color::Color, + gpu_resource::{Face, PrimitiveTopology}, mesh::{ morph::{MeshMorphWeights, MorphAttributes, MorphTargetImage, MorphWeights}, skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, @@ -22,7 +23,6 @@ use bevy_render::{ }, prelude::SpatialBundle, primitives::Aabb, - render_resource::{Face, PrimitiveTopology}, texture::{ CompressedImageFormats, Image, ImageAddressMode, ImageFilterMode, ImageLoaderSettings, ImageSampler, ImageSamplerDescriptor, ImageType, TextureError, diff --git a/crates/bevy_gltf/src/vertex_attributes.rs b/crates/bevy_gltf/src/vertex_attributes.rs index 49f99241875bf..dc245b2ef2ad5 100644 --- a/crates/bevy_gltf/src/vertex_attributes.rs +++ b/crates/bevy_gltf/src/vertex_attributes.rs @@ -1,7 +1,7 @@ use bevy_render::{ + gpu_resource::VertexFormat, mesh::{MeshVertexAttribute, VertexAttributeValues as Values}, prelude::Mesh, - render_resource::VertexFormat, }; use bevy_utils::HashMap; use gltf::{ diff --git a/crates/bevy_internal/src/lib.rs b/crates/bevy_internal/src/lib.rs index 8e6bf57e52909..a0e341867dfbd 100644 --- a/crates/bevy_internal/src/lib.rs +++ b/crates/bevy_internal/src/lib.rs @@ -139,9 +139,9 @@ pub mod pbr { #[cfg(feature = "bevy_render")] pub mod render { //! Cameras, meshes, textures, shaders, and pipelines. - //! Use [`RenderDevice::features`](crate::render::renderer::RenderDevice::features), - //! [`RenderDevice::limits`](crate::render::renderer::RenderDevice::limits), and the - //! [`RenderAdapterInfo`](crate::render::renderer::RenderAdapterInfo) resource to + //! Use [`GpuDevice::features`](crate::render::renderer::GpuDevice::features), + //! [`GpuDevice::limits`](crate::render::renderer::GpuDevice::limits), and the + //! [`RenderAdapterInfo`](crate::render::renderer::GpuAdapterInfo) resource to //! get runtime information about the actual adapter, backend, features, and limits. pub use bevy_render::*; } diff --git a/crates/bevy_pbr/src/deferred/mod.rs b/crates/bevy_pbr/src/deferred/mod.rs index f679f638d42ac..ceb63a95984e1 100644 --- a/crates/bevy_pbr/src/deferred/mod.rs +++ b/crates/bevy_pbr/src/deferred/mod.rs @@ -16,17 +16,17 @@ use bevy_render::{ extract_component::{ ComponentUniforms, ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin, }, + gpu_resource::{self, Operations, PipelineCache, RenderPassDescriptor}, render_asset::RenderAssets, render_graph::{NodeRunError, RenderGraphContext, ViewNode, ViewNodeRunner}, - render_resource::{self, Operations, PipelineCache, RenderPassDescriptor}, - renderer::{RenderContext, RenderDevice}, + renderer::{GpuDevice, RenderContext}, texture::Image, view::{ViewTarget, ViewUniformOffset}, Render, RenderSet, }; use bevy_render::{ - render_graph::RenderGraphApp, render_resource::*, texture::BevyDefault, view::ExtractedView, + gpu_resource::*, render_graph::RenderGraphApp, texture::BevyDefault, view::ExtractedView, RenderApp, }; @@ -191,7 +191,7 @@ impl ViewNode for DeferredOpaquePass3dPbrLightingNode { return Ok(()); }; - let bind_group_1 = render_context.render_device().create_bind_group( + let bind_group_1 = render_context.gpu_device().create_bind_group( "deferred_lighting_layout_group_1", &deferred_lighting_layout.bind_group_layout_1, &BindGroupEntries::single(deferred_lighting_pass_id_binding), @@ -375,14 +375,14 @@ impl SpecializedRenderPipeline for DeferredLightingLayout { impl FromWorld for DeferredLightingLayout { fn from_world(world: &mut World) -> Self { - let render_device = world.resource::(); - let layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + let gpu_device = world.resource::(); + let layout = gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("deferred_lighting_layout"), entries: &[BindGroupLayoutEntry { binding: 0, visibility: ShaderStages::VERTEX_FRAGMENT, ty: BindingType::Buffer { - ty: render_resource::BufferBindingType::Uniform, + ty: gpu_resource::BufferBindingType::Uniform, has_dynamic_offset: false, min_binding_size: Some(PbrDeferredLightingDepthId::min_size()), }, diff --git a/crates/bevy_pbr/src/environment_map/mod.rs b/crates/bevy_pbr/src/environment_map/mod.rs index 9e8a1d517585f..823ceadf8cb96 100644 --- a/crates/bevy_pbr/src/environment_map/mod.rs +++ b/crates/bevy_pbr/src/environment_map/mod.rs @@ -5,8 +5,8 @@ use bevy_ecs::{prelude::Component, query::With}; use bevy_reflect::Reflect; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, + gpu_resource::*, render_asset::RenderAssets, - render_resource::*, texture::{FallbackImageCubemap, Image}, }; diff --git a/crates/bevy_pbr/src/extended_material.rs b/crates/bevy_pbr/src/extended_material.rs index 096c3f6315d1b..5a7fce0b96776 100644 --- a/crates/bevy_pbr/src/extended_material.rs +++ b/crates/bevy_pbr/src/extended_material.rs @@ -1,13 +1,13 @@ use bevy_asset::{Asset, Handle}; use bevy_reflect::TypePath; use bevy_render::{ - mesh::MeshVertexBufferLayout, - render_asset::RenderAssets, - render_resource::{ + gpu_resource::{ AsBindGroup, AsBindGroupError, BindGroupLayout, RenderPipelineDescriptor, Shader, ShaderRef, SpecializedMeshPipelineError, UnpreparedBindGroup, }, - renderer::RenderDevice, + mesh::MeshVertexBufferLayout, + render_asset::RenderAssets, + renderer::GpuDevice, texture::{FallbackImage, Image}, }; @@ -109,23 +109,17 @@ impl AsBindGroup for ExtendedMaterial { fn unprepared_bind_group( &self, layout: &BindGroupLayout, - render_device: &RenderDevice, + gpu_device: &GpuDevice, images: &RenderAssets, fallback_image: &FallbackImage, - ) -> Result, AsBindGroupError> - { + ) -> Result, AsBindGroupError> { // add together the bindings of the base material and the user material let UnpreparedBindGroup { mut bindings, data: base_data, - } = B::unprepared_bind_group(&self.base, layout, render_device, images, fallback_image)?; - let extended_bindgroup = E::unprepared_bind_group( - &self.extension, - layout, - render_device, - images, - fallback_image, - )?; + } = B::unprepared_bind_group(&self.base, layout, gpu_device, images, fallback_image)?; + let extended_bindgroup = + E::unprepared_bind_group(&self.extension, layout, gpu_device, images, fallback_image)?; bindings.extend(extended_bindgroup.bindings); @@ -136,55 +130,55 @@ impl AsBindGroup for ExtendedMaterial { } fn bind_group_layout_entries( - render_device: &RenderDevice, - ) -> Vec + gpu_device: &GpuDevice, + ) -> Vec where Self: Sized, { // add together the bindings of the standard material and the user material - let mut entries = B::bind_group_layout_entries(render_device); - entries.extend(E::bind_group_layout_entries(render_device)); + let mut entries = B::bind_group_layout_entries(gpu_device); + entries.extend(E::bind_group_layout_entries(gpu_device)); entries } } impl Material for ExtendedMaterial { - fn vertex_shader() -> bevy_render::render_resource::ShaderRef { + fn vertex_shader() -> bevy_render::gpu_resource::ShaderRef { match E::vertex_shader() { ShaderRef::Default => B::vertex_shader(), specified => specified, } } - fn fragment_shader() -> bevy_render::render_resource::ShaderRef { + fn fragment_shader() -> bevy_render::gpu_resource::ShaderRef { match E::fragment_shader() { ShaderRef::Default => B::fragment_shader(), specified => specified, } } - fn prepass_vertex_shader() -> bevy_render::render_resource::ShaderRef { + fn prepass_vertex_shader() -> bevy_render::gpu_resource::ShaderRef { match E::prepass_vertex_shader() { ShaderRef::Default => B::prepass_vertex_shader(), specified => specified, } } - fn prepass_fragment_shader() -> bevy_render::render_resource::ShaderRef { + fn prepass_fragment_shader() -> bevy_render::gpu_resource::ShaderRef { match E::prepass_fragment_shader() { ShaderRef::Default => B::prepass_fragment_shader(), specified => specified, } } - fn deferred_vertex_shader() -> bevy_render::render_resource::ShaderRef { + fn deferred_vertex_shader() -> bevy_render::gpu_resource::ShaderRef { match E::deferred_vertex_shader() { ShaderRef::Default => B::deferred_vertex_shader(), specified => specified, } } - fn deferred_fragment_shader() -> bevy_render::render_resource::ShaderRef { + fn deferred_fragment_shader() -> bevy_render::gpu_resource::ShaderRef { match E::deferred_fragment_shader() { ShaderRef::Default => B::deferred_fragment_shader(), specified => specified, diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index 8e1cfdd41d34b..48f7019fc13bb 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -61,11 +61,11 @@ use bevy_render::{ camera::{CameraUpdateSystem, Projection}, extract_component::ExtractComponentPlugin, extract_resource::ExtractResourcePlugin, + gpu_resource::Shader, prelude::Color, render_asset::prepare_assets, render_graph::RenderGraph, render_phase::sort_phase_system, - render_resource::Shader, texture::Image, view::VisibilitySystems, ExtractSchedule, Render, RenderApp, RenderSet, diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index 54ea52e5b972c..6fff3e19e3b96 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -8,9 +8,9 @@ use bevy_render::{ color::Color, extract_component::ExtractComponent, extract_resource::ExtractResource, + gpu_resource::BufferBindingType, primitives::{Aabb, CascadesFrusta, CubemapFrusta, Frustum, HalfSpace, Sphere}, - render_resource::BufferBindingType, - renderer::RenderDevice, + renderer::GpuDevice, view::{InheritedVisibility, RenderLayers, ViewVisibility, VisibleEntities}, }; use bevy_transform::{components::GlobalTransform, prelude::Transform}; @@ -1183,10 +1183,10 @@ pub(crate) fn assign_lights_to_clusters( mut lights: Local>, mut cluster_aabb_spheres: Local>>, mut max_point_lights_warning_emitted: Local, - render_device: Option>, + gpu_device: Option>, ) { - let render_device = match render_device { - Some(render_device) => render_device, + let gpu_device = match gpu_device { + Some(gpu_device) => gpu_device, None => return, }; @@ -1223,7 +1223,7 @@ pub(crate) fn assign_lights_to_clusters( ); let clustered_forward_buffer_binding_type = - render_device.get_supported_read_only_binding_type(CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT); + gpu_device.get_supported_read_only_binding_type(CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT); let supports_storage_buffers = matches!( clustered_forward_buffer_binding_type, BufferBindingType::Storage { .. } diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index d5884bb65530c..3f9be811bb5ce 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -20,12 +20,12 @@ use bevy_render::{ camera::TemporalJitter, extract_instances::{ExtractInstancesPlugin, ExtractedInstances}, extract_resource::ExtractResource, + gpu_resource::*, mesh::{Mesh, MeshVertexBufferLayout}, prelude::Image, render_asset::{prepare_assets, RenderAssets}, render_phase::*, - render_resource::*, - renderer::RenderDevice, + renderer::GpuDevice, texture::FallbackImage, view::{ExtractedView, Msaa, VisibleEntities}, Extract, ExtractSchedule, Render, RenderApp, RenderSet, @@ -49,7 +49,7 @@ use std::marker::PhantomData; /// # use bevy_pbr::{Material, MaterialMeshBundle}; /// # use bevy_ecs::prelude::*; /// # use bevy_reflect::{TypeUuid, TypePath}; -/// # use bevy_render::{render_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color}; +/// # use bevy_render::{gpu_resource::{AsBindGroup, ShaderRef}, texture::Image, color::Color}; /// # use bevy_asset::{Handle, AssetServer, Assets, Asset}; /// /// #[derive(AsBindGroup, Debug, Clone, Asset, TypePath)] @@ -345,11 +345,11 @@ where impl FromWorld for MaterialPipeline { fn from_world(world: &mut World) -> Self { let asset_server = world.resource::(); - let render_device = world.resource::(); + let gpu_device = world.resource::(); MaterialPipeline { mesh_pipeline: world.resource::().clone(), - material_layout: M::bind_group_layout(render_device), + material_layout: M::bind_group_layout(gpu_device), vertex_shader: match M::vertex_shader() { ShaderRef::Default => None, ShaderRef::Handle(handle) => Some(handle), @@ -856,7 +856,7 @@ pub fn prepare_materials( mut prepare_next_frame: Local>, mut extracted_assets: ResMut>, mut render_materials: ResMut>, - render_device: Res, + gpu_device: Res, images: Res>, fallback_image: Res, pipeline: Res>, @@ -866,7 +866,7 @@ pub fn prepare_materials( for (id, material) in queued_assets.into_iter() { match prepare_material( &material, - &render_device, + &gpu_device, &images, &fallback_image, &pipeline, @@ -888,7 +888,7 @@ pub fn prepare_materials( for (id, material) in std::mem::take(&mut extracted_assets.extracted) { match prepare_material( &material, - &render_device, + &gpu_device, &images, &fallback_image, &pipeline, @@ -906,7 +906,7 @@ pub fn prepare_materials( fn prepare_material( material: &M, - render_device: &RenderDevice, + gpu_device: &GpuDevice, images: &RenderAssets, fallback_image: &FallbackImage, pipeline: &MaterialPipeline, @@ -914,7 +914,7 @@ fn prepare_material( ) -> Result, AsBindGroupError> { let prepared = material.as_bind_group( &pipeline.material_layout, - render_device, + gpu_device, images, fallback_image, )?; diff --git a/crates/bevy_pbr/src/pbr_material.rs b/crates/bevy_pbr/src/pbr_material.rs index 77257bc8daadb..3171b97a26819 100644 --- a/crates/bevy_pbr/src/pbr_material.rs +++ b/crates/bevy_pbr/src/pbr_material.rs @@ -2,7 +2,7 @@ use bevy_asset::{Asset, Handle}; use bevy_math::Vec4; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - color::Color, mesh::MeshVertexBufferLayout, render_asset::RenderAssets, render_resource::*, + color::Color, gpu_resource::*, mesh::MeshVertexBufferLayout, render_asset::RenderAssets, texture::Image, }; diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index 6f2dfed69e12d..75465189a094a 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -17,12 +17,12 @@ use bevy_math::{Affine3A, Mat4}; use bevy_render::{ batching::batch_and_prepare_render_phase, globals::{GlobalsBuffer, GlobalsUniform}, + gpu_resource::*, mesh::MeshVertexBufferLayout, prelude::{Camera, Mesh}, render_asset::RenderAssets, render_phase::*, - render_resource::*, - renderer::{RenderDevice, RenderQueue}, + renderer::{GpuDevice, GpuQueue}, view::{ExtractedView, Msaa, ViewUniform, ViewUniformOffset, ViewUniforms, VisibleEntities}, Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; @@ -226,11 +226,11 @@ pub struct PrepassPipeline { impl FromWorld for PrepassPipeline { fn from_world(world: &mut World) -> Self { - let render_device = world.resource::(); + let gpu_device = world.resource::(); let asset_server = world.resource::(); let view_layout_motion_vectors = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[ // View BindGroupLayoutEntry { @@ -270,7 +270,7 @@ impl FromWorld for PrepassPipeline { }); let view_layout_no_motion_vectors = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[ // View BindGroupLayoutEntry { @@ -324,7 +324,7 @@ impl FromWorld for PrepassPipeline { ShaderRef::Handle(handle) => Some(handle), ShaderRef::Path(path) => Some(asset_server.load(path)), }, - material_layout: M::bind_group_layout(render_device), + material_layout: M::bind_group_layout(gpu_device), material_pipeline: world.resource::>().clone(), _marker: PhantomData, } @@ -637,8 +637,8 @@ pub struct PreviousViewProjectionUniformOffset { pub fn prepare_previous_view_projection_uniforms( mut commands: Commands, - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, mut view_uniforms: ResMut, views: Query< (Entity, &ExtractedView, Option<&PreviousViewProjection>), @@ -647,10 +647,9 @@ pub fn prepare_previous_view_projection_uniforms( ) { let views_iter = views.iter(); let view_count = views_iter.len(); - let Some(mut writer) = - view_uniforms - .uniforms - .get_writer(view_count, &render_device, &render_queue) + let Some(mut writer) = view_uniforms + .uniforms + .get_writer(view_count, &gpu_device, &gpu_queue) else { return; }; @@ -676,7 +675,7 @@ pub struct PrepassViewBindGroup { } pub fn prepare_prepass_view_bind_group( - render_device: Res, + gpu_device: Res, prepass_pipeline: Res>, view_uniforms: Res, globals_buffer: Res, @@ -687,14 +686,14 @@ pub fn prepare_prepass_view_bind_group( view_uniforms.uniforms.binding(), globals_buffer.buffer.binding(), ) { - prepass_view_bind_group.no_motion_vectors = Some(render_device.create_bind_group( + prepass_view_bind_group.no_motion_vectors = Some(gpu_device.create_bind_group( "prepass_view_no_motion_vectors_bind_group", &prepass_pipeline.view_layout_no_motion_vectors, &BindGroupEntries::sequential((view_binding.clone(), globals_binding.clone())), )); if let Some(previous_view_proj_binding) = previous_view_proj_uniforms.uniforms.binding() { - prepass_view_bind_group.motion_vectors = Some(render_device.create_bind_group( + prepass_view_bind_group.motion_vectors = Some(gpu_device.create_bind_group( "prepass_view_motion_vectors_bind_group", &prepass_pipeline.view_layout_motion_vectors, &BindGroupEntries::sequential(( diff --git a/crates/bevy_pbr/src/prepass/prepass_bindings.rs b/crates/bevy_pbr/src/prepass/prepass_bindings.rs index b72ddd1e318cd..3d7ff89b7fa01 100644 --- a/crates/bevy_pbr/src/prepass/prepass_bindings.rs +++ b/crates/bevy_pbr/src/prepass/prepass_bindings.rs @@ -1,5 +1,5 @@ use bevy_core_pipeline::prepass::ViewPrepassTextures; -use bevy_render::render_resource::{ +use bevy_render::gpu_resource::{ BindGroupLayoutEntry, BindingType, ShaderStages, TextureAspect, TextureSampleType, TextureView, TextureViewDescriptor, TextureViewDimension, }; diff --git a/crates/bevy_pbr/src/render/fog.rs b/crates/bevy_pbr/src/render/fog.rs index 1738b261b578e..7917a218caff7 100644 --- a/crates/bevy_pbr/src/render/fog.rs +++ b/crates/bevy_pbr/src/render/fog.rs @@ -4,8 +4,8 @@ use bevy_ecs::prelude::*; use bevy_math::{Vec3, Vec4}; use bevy_render::{ extract_component::ExtractComponentPlugin, - render_resource::{DynamicUniformBuffer, Shader, ShaderType}, - renderer::{RenderDevice, RenderQueue}, + gpu_resource::{DynamicUniformBuffer, Shader, ShaderType}, + renderer::{GpuDevice, GpuQueue}, view::ExtractedView, Render, RenderApp, RenderSet, }; @@ -47,8 +47,8 @@ pub struct FogMeta { /// Prepares fog metadata and writes the fog-related uniform buffers to the GPU pub fn prepare_fog( mut commands: Commands, - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, mut fog_meta: ResMut, views: Query<(Entity, Option<&FogSettings>), With>, ) { @@ -56,7 +56,7 @@ pub fn prepare_fog( let view_count = views_iter.len(); let Some(mut writer) = fog_meta .gpu_fogs - .get_writer(view_count, &render_device, &render_queue) + .get_writer(view_count, &gpu_device, &gpu_queue) else { return; }; diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 62a7367520756..fd9d9cb0bf201 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -4,12 +4,12 @@ use bevy_math::{Mat4, UVec3, UVec4, Vec2, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles use bevy_render::{ camera::Camera, color::Color, + gpu_resource::*, mesh::Mesh, render_asset::RenderAssets, render_graph::{Node, NodeRunError, RenderGraphContext}, render_phase::*, - render_resource::*, - renderer::{RenderContext, RenderDevice, RenderQueue}, + renderer::{GpuDevice, GpuQueue, RenderContext}, texture::*, view::{ExtractedView, ViewVisibility, VisibleEntities}, Extract, @@ -118,10 +118,10 @@ impl GpuPointLights { } } - fn write_buffer(&mut self, render_device: &RenderDevice, render_queue: &RenderQueue) { + fn write_buffer(&mut self, gpu_device: &GpuDevice, gpu_queue: &GpuQueue) { match self { - GpuPointLights::Uniform(buffer) => buffer.write_buffer(render_device, render_queue), - GpuPointLights::Storage(buffer) => buffer.write_buffer(render_device, render_queue), + GpuPointLights::Uniform(buffer) => buffer.write_buffer(gpu_device, gpu_queue), + GpuPointLights::Storage(buffer) => buffer.write_buffer(gpu_device, gpu_queue), } } @@ -220,10 +220,10 @@ pub struct ShadowSamplers { // TODO: this pattern for initializing the shaders / pipeline isn't ideal. this should be handled by the asset system impl FromWorld for ShadowSamplers { fn from_world(world: &mut World) -> Self { - let render_device = world.resource::(); + let gpu_device = world.resource::(); ShadowSamplers { - point_light_sampler: render_device.create_sampler(&SamplerDescriptor { + point_light_sampler: gpu_device.create_sampler(&SamplerDescriptor { address_mode_u: AddressMode::ClampToEdge, address_mode_v: AddressMode::ClampToEdge, address_mode_w: AddressMode::ClampToEdge, @@ -233,7 +233,7 @@ impl FromWorld for ShadowSamplers { compare: Some(CompareFunction::GreaterEqual), ..Default::default() }), - directional_light_sampler: render_device.create_sampler(&SamplerDescriptor { + directional_light_sampler: gpu_device.create_sampler(&SamplerDescriptor { address_mode_u: AddressMode::ClampToEdge, address_mode_v: AddressMode::ClampToEdge, address_mode_w: AddressMode::ClampToEdge, @@ -548,7 +548,7 @@ impl FromWorld for GlobalLightMeta { fn from_world(world: &mut World) -> Self { Self::new( world - .resource::() + .resource::() .get_supported_read_only_binding_type(CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT), ) } @@ -636,8 +636,8 @@ pub fn prepare_lights( mut commands: Commands, mut texture_cache: ResMut, images: Res>, - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, mut global_light_meta: ResMut, mut light_meta: ResMut, views: Query< @@ -662,7 +662,7 @@ pub fn prepare_lights( let Some(mut view_gpu_lights_writer) = light_meta .view_gpu_lights - .get_writer(views_count, &render_device, &render_queue) + .get_writer(views_count, &gpu_device, &gpu_queue) else { return; }; @@ -681,7 +681,7 @@ pub fn prepare_lights( let mut directional_lights: Vec<_> = directional_lights.iter().collect::>(); #[cfg(any(not(feature = "webgl"), not(target_arch = "wasm32")))] - let max_texture_array_layers = render_device.limits().max_texture_array_layers as usize; + let max_texture_array_layers = gpu_device.limits().max_texture_array_layers as usize; #[cfg(any(not(feature = "webgl"), not(target_arch = "wasm32")))] let max_texture_cubes = max_texture_array_layers / 6; #[cfg(all(feature = "webgl", target_arch = "wasm32"))] @@ -888,12 +888,12 @@ pub fn prepare_lights( global_light_meta.gpu_point_lights.set(gpu_point_lights); global_light_meta .gpu_point_lights - .write_buffer(&render_device, &render_queue); + .write_buffer(&gpu_device, &gpu_queue); // set up light data for each view for (entity, extracted_view, clusters, environment_map) in &views { let point_light_depth_texture = texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { size: Extent3d { width: point_light_shadow_map.size as u32, @@ -910,13 +910,13 @@ pub fn prepare_lights( }, ); let directional_light_depth_texture = texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { size: Extent3d { width: (directional_light_shadow_map.size as u32) - .min(render_device.limits().max_texture_dimension_2d), + .min(gpu_device.limits().max_texture_dimension_2d), height: (directional_light_shadow_map.size as u32) - .min(render_device.limits().max_texture_dimension_2d), + .min(gpu_device.limits().max_texture_dimension_2d), depth_or_array_layers: (num_directional_cascades_enabled + spot_light_shadow_maps_count) .max(1) as u32, @@ -1408,21 +1408,21 @@ impl ViewClusterBindings { self.n_indices += 1; } - pub fn write_buffers(&mut self, render_device: &RenderDevice, render_queue: &RenderQueue) { + pub fn write_buffers(&mut self, gpu_device: &GpuDevice, gpu_queue: &GpuQueue) { match &mut self.buffers { ViewClusterBuffers::Uniform { cluster_light_index_lists, cluster_offsets_and_counts, } => { - cluster_light_index_lists.write_buffer(render_device, render_queue); - cluster_offsets_and_counts.write_buffer(render_device, render_queue); + cluster_light_index_lists.write_buffer(gpu_device, gpu_queue); + cluster_offsets_and_counts.write_buffer(gpu_device, gpu_queue); } ViewClusterBuffers::Storage { cluster_light_index_lists, cluster_offsets_and_counts, } => { - cluster_light_index_lists.write_buffer(render_device, render_queue); - cluster_offsets_and_counts.write_buffer(render_device, render_queue); + cluster_light_index_lists.write_buffer(gpu_device, gpu_queue); + cluster_offsets_and_counts.write_buffer(gpu_device, gpu_queue); } } } @@ -1474,8 +1474,8 @@ impl ViewClusterBindings { pub fn prepare_clusters( mut commands: Commands, - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, mesh_pipeline: Res, global_light_meta: Res, views: Query< @@ -1487,7 +1487,7 @@ pub fn prepare_clusters( With>, >, ) { - let render_device = render_device.into_inner(); + let gpu_device = gpu_device.into_inner(); let supports_storage_buffers = matches!( mesh_pipeline.clustered_forward_buffer_binding_type, BufferBindingType::Storage { .. } @@ -1533,7 +1533,7 @@ pub fn prepare_clusters( } } - view_clusters_bindings.write_buffers(render_device, &render_queue); + view_clusters_bindings.write_buffers(gpu_device, &gpu_queue); commands.get_or_spawn(entity).insert(view_clusters_bindings); } diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index 8c87d27129c2d..b5ef0c69f396f 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -16,11 +16,11 @@ use bevy_render::{ batch_and_prepare_render_phase, write_batched_instance_buffer, GetBatchData, NoAutomaticBatching, }, + gpu_resource::*, mesh::*, render_asset::RenderAssets, render_phase::{PhaseItem, RenderCommand, RenderCommandResult, TrackedRenderPass}, - render_resource::*, - renderer::{RenderDevice, RenderQueue}, + renderer::{GpuDevice, GpuQueue}, texture::*, view::{ViewTarget, ViewUniformOffset, ViewVisibility}, Extract, ExtractSchedule, Render, RenderApp, RenderSet, @@ -155,9 +155,9 @@ impl Plugin for MeshRenderPlugin { let mut mesh_bindings_shader_defs = Vec::with_capacity(1); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { - if let Some(per_object_buffer_batch_size) = GpuArrayBuffer::::batch_size( - render_app.world.resource::(), - ) { + if let Some(per_object_buffer_batch_size) = + GpuArrayBuffer::::batch_size(render_app.world.resource::()) + { mesh_bindings_shader_defs.push(ShaderDefVal::UInt( "PER_OBJECT_BUFFER_BATCH_SIZE".into(), per_object_buffer_batch_size, @@ -166,7 +166,7 @@ impl Plugin for MeshRenderPlugin { render_app .insert_resource(GpuArrayBuffer::::new( - render_app.world.resource::(), + render_app.world.resource::(), )) .init_resource::(); } @@ -353,30 +353,30 @@ pub struct MeshPipeline { impl FromWorld for MeshPipeline { fn from_world(world: &mut World) -> Self { let mut system_state: SystemState<( - Res, + Res, Res, - Res, + Res, )> = SystemState::new(world); - let (render_device, default_sampler, render_queue) = system_state.get_mut(world); - let clustered_forward_buffer_binding_type = render_device - .get_supported_read_only_binding_type(CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT); + let (gpu_device, default_sampler, gpu_queue) = system_state.get_mut(world); + let clustered_forward_buffer_binding_type = + gpu_device.get_supported_read_only_binding_type(CLUSTERED_FORWARD_STORAGE_BUFFER_COUNT); let view_layouts = - generate_view_layouts(&render_device, clustered_forward_buffer_binding_type); + generate_view_layouts(&gpu_device, clustered_forward_buffer_binding_type); // A 1x1x1 'all 1.0' texture to use as a dummy texture to use in place of optional StandardMaterial textures let dummy_white_gpu_image = { let image = Image::default(); - let texture = render_device.create_texture(&image.texture_descriptor); + let texture = gpu_device.create_texture(&image.texture_descriptor); let sampler = match image.sampler { ImageSampler::Default => (**default_sampler).clone(), ImageSampler::Descriptor(ref descriptor) => { - render_device.create_sampler(&descriptor.as_wgpu()) + gpu_device.create_sampler(&descriptor.as_wgpu()) } }; let format_size = image.texture_descriptor.format.pixel_size(); - render_queue.write_texture( + gpu_queue.write_texture( ImageCopyTexture { texture: &texture, mip_level: 0, @@ -407,8 +407,8 @@ impl FromWorld for MeshPipeline { view_layouts, clustered_forward_buffer_binding_type, dummy_white_gpu_image, - mesh_layouts: MeshLayouts::new(&render_device), - per_object_buffer_batch_size: GpuArrayBuffer::::batch_size(&render_device), + mesh_layouts: MeshLayouts::new(&gpu_device), + per_object_buffer_batch_size: GpuArrayBuffer::::batch_size(&gpu_device), #[cfg(debug_assertions)] did_warn_about_too_many_textures: Arc::new(AtomicBool::new(false)), } @@ -952,7 +952,7 @@ pub fn prepare_mesh_bind_group( meshes: Res>, mut groups: ResMut, mesh_pipeline: Res, - render_device: Res, + gpu_device: Res, mesh_uniforms: Res>, skins_uniform: Res, weights_uniform: Res, @@ -962,20 +962,20 @@ pub fn prepare_mesh_bind_group( let Some(model) = mesh_uniforms.binding() else { return; }; - groups.model_only = Some(layouts.model_only(&render_device, &model)); + groups.model_only = Some(layouts.model_only(&gpu_device, &model)); let skin = skins_uniform.buffer.buffer(); if let Some(skin) = skin { - groups.skinned = Some(layouts.skinned(&render_device, &model, skin)); + groups.skinned = Some(layouts.skinned(&gpu_device, &model, skin)); } if let Some(weights) = weights_uniform.buffer.buffer() { for (id, gpu_mesh) in meshes.iter() { if let Some(targets) = gpu_mesh.morph_targets.as_ref() { let group = if let Some(skin) = skin.filter(|_| is_skinned(&gpu_mesh.layout)) { - layouts.morphed_skinned(&render_device, &model, skin, weights, targets) + layouts.morphed_skinned(&gpu_device, &model, skin, weights, targets) } else { - layouts.morphed(&render_device, &model, weights, targets) + layouts.morphed(&gpu_device, &model, weights, targets) }; groups.morph_targets.insert(id, group); } diff --git a/crates/bevy_pbr/src/render/mesh_bindings.rs b/crates/bevy_pbr/src/render/mesh_bindings.rs index df935e1805c8a..a6d2c3e86b6df 100644 --- a/crates/bevy_pbr/src/render/mesh_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_bindings.rs @@ -1,7 +1,7 @@ //! Bind group layout related definitions for the mesh pipeline. use bevy_math::Mat4; -use bevy_render::{mesh::morph::MAX_MORPH_WEIGHTS, render_resource::*, renderer::RenderDevice}; +use bevy_render::{gpu_resource::*, mesh::morph::MAX_MORPH_WEIGHTS, renderer::GpuDevice}; use crate::render::skin::MAX_JOINTS; @@ -16,11 +16,11 @@ mod layout_entry { use super::{JOINT_BUFFER_SIZE, MORPH_BUFFER_SIZE}; use crate::MeshUniform; use bevy_render::{ - render_resource::{ + gpu_resource::{ BindGroupLayoutEntry, BindingType, BufferBindingType, BufferSize, GpuArrayBuffer, ShaderStages, TextureSampleType, TextureViewDimension, }, - renderer::RenderDevice, + renderer::GpuDevice, }; fn buffer(binding: u32, size: u64, visibility: ShaderStages) -> BindGroupLayoutEntry { @@ -35,11 +35,11 @@ mod layout_entry { }, } } - pub(super) fn model(render_device: &RenderDevice, binding: u32) -> BindGroupLayoutEntry { + pub(super) fn model(gpu_device: &GpuDevice, binding: u32) -> BindGroupLayoutEntry { GpuArrayBuffer::::binding_layout( binding, ShaderStages::VERTEX_FRAGMENT, - render_device, + gpu_device, ) } pub(super) fn skinning(binding: u32) -> BindGroupLayoutEntry { @@ -65,7 +65,7 @@ mod layout_entry { /// for bind groups. mod entry { use super::{JOINT_BUFFER_SIZE, MORPH_BUFFER_SIZE}; - use bevy_render::render_resource::{ + use bevy_render::gpu_resource::{ BindGroupEntry, BindingResource, Buffer, BufferBinding, BufferSize, TextureView, }; @@ -121,46 +121,46 @@ impl MeshLayouts { /// Prepare the layouts used by the default bevy [`Mesh`]. /// /// [`Mesh`]: bevy_render::prelude::Mesh - pub fn new(render_device: &RenderDevice) -> Self { + pub fn new(gpu_device: &GpuDevice) -> Self { MeshLayouts { - model_only: Self::model_only_layout(render_device), - skinned: Self::skinned_layout(render_device), - morphed: Self::morphed_layout(render_device), - morphed_skinned: Self::morphed_skinned_layout(render_device), + model_only: Self::model_only_layout(gpu_device), + skinned: Self::skinned_layout(gpu_device), + morphed: Self::morphed_layout(gpu_device), + morphed_skinned: Self::morphed_skinned_layout(gpu_device), } } // ---------- create individual BindGroupLayouts ---------- - fn model_only_layout(render_device: &RenderDevice) -> BindGroupLayout { - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { - entries: &[layout_entry::model(render_device, 0)], + fn model_only_layout(gpu_device: &GpuDevice) -> BindGroupLayout { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + entries: &[layout_entry::model(gpu_device, 0)], label: Some("mesh_layout"), }) } - fn skinned_layout(render_device: &RenderDevice) -> BindGroupLayout { - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + fn skinned_layout(gpu_device: &GpuDevice) -> BindGroupLayout { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[ - layout_entry::model(render_device, 0), + layout_entry::model(gpu_device, 0), layout_entry::skinning(1), ], label: Some("skinned_mesh_layout"), }) } - fn morphed_layout(render_device: &RenderDevice) -> BindGroupLayout { - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + fn morphed_layout(gpu_device: &GpuDevice) -> BindGroupLayout { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[ - layout_entry::model(render_device, 0), + layout_entry::model(gpu_device, 0), layout_entry::weights(2), layout_entry::targets(3), ], label: Some("morphed_mesh_layout"), }) } - fn morphed_skinned_layout(render_device: &RenderDevice) -> BindGroupLayout { - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + fn morphed_skinned_layout(gpu_device: &GpuDevice) -> BindGroupLayout { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { entries: &[ - layout_entry::model(render_device, 0), + layout_entry::model(gpu_device, 0), layout_entry::skinning(1), layout_entry::weights(2), layout_entry::targets(3), @@ -171,8 +171,8 @@ impl MeshLayouts { // ---------- BindGroup methods ---------- - pub fn model_only(&self, render_device: &RenderDevice, model: &BindingResource) -> BindGroup { - render_device.create_bind_group( + pub fn model_only(&self, gpu_device: &GpuDevice, model: &BindingResource) -> BindGroup { + gpu_device.create_bind_group( "model_only_mesh_bind_group", &self.model_only, &[entry::model(0, model.clone())], @@ -180,11 +180,11 @@ impl MeshLayouts { } pub fn skinned( &self, - render_device: &RenderDevice, + gpu_device: &GpuDevice, model: &BindingResource, skin: &Buffer, ) -> BindGroup { - render_device.create_bind_group( + gpu_device.create_bind_group( "skinned_mesh_bind_group", &self.skinned, &[entry::model(0, model.clone()), entry::skinning(1, skin)], @@ -192,12 +192,12 @@ impl MeshLayouts { } pub fn morphed( &self, - render_device: &RenderDevice, + gpu_device: &GpuDevice, model: &BindingResource, weights: &Buffer, targets: &TextureView, ) -> BindGroup { - render_device.create_bind_group( + gpu_device.create_bind_group( "morphed_mesh_bind_group", &self.morphed, &[ @@ -209,13 +209,13 @@ impl MeshLayouts { } pub fn morphed_skinned( &self, - render_device: &RenderDevice, + gpu_device: &GpuDevice, model: &BindingResource, skin: &Buffer, weights: &Buffer, targets: &TextureView, ) -> BindGroup { - render_device.create_bind_group( + gpu_device.create_bind_group( "morphed_skinned_mesh_bind_group", &self.morphed_skinned, &[ diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.rs b/crates/bevy_pbr/src/render/mesh_view_bindings.rs index 853c253209a68..83f59e95ff918 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.rs @@ -14,13 +14,13 @@ use bevy_ecs::{ }; use bevy_render::{ globals::{GlobalsBuffer, GlobalsUniform}, - render_asset::RenderAssets, - render_resource::{ + gpu_resource::{ BindGroup, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType, BufferBindingType, DynamicBindGroupEntries, SamplerBindingType, ShaderStages, ShaderType, TextureFormat, TextureSampleType, TextureViewDimension, }, - renderer::RenderDevice, + render_asset::RenderAssets, + renderer::GpuDevice, texture::{BevyDefault, FallbackImageCubemap, FallbackImageMsaa, FallbackImageZero, Image}, view::{Msaa, ViewUniform, ViewUniforms}, }; @@ -333,7 +333,7 @@ fn layout_entries( /// Generates all possible view layouts for the mesh pipeline, based on all combinations of /// [`MeshPipelineViewLayoutKey`] flags. pub fn generate_view_layouts( - render_device: &RenderDevice, + gpu_device: &GpuDevice, clustered_forward_buffer_binding_type: BufferBindingType, ) -> [MeshPipelineViewLayout; MeshPipelineViewLayoutKey::COUNT] { array::from_fn(|i| { @@ -347,7 +347,7 @@ pub fn generate_view_layouts( .count(); MeshPipelineViewLayout { - bind_group_layout: render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + bind_group_layout: gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some(key.label().as_str()), entries: &entries, }), @@ -365,7 +365,7 @@ pub struct MeshViewBindGroup { #[allow(clippy::too_many_arguments)] pub fn prepare_mesh_view_bind_groups( mut commands: Commands, - render_device: Res, + gpu_device: Res, mesh_pipeline: Res, shadow_samplers: Res, light_meta: Res, @@ -482,7 +482,7 @@ pub fn prepare_mesh_view_bind_groups( entries.extend_with_indices(((21, transmission_view), (22, transmission_sampler))); commands.entity(entity).insert(MeshViewBindGroup { - value: render_device.create_bind_group("mesh_view_bind_group", layout, &entries), + value: gpu_device.create_bind_group("mesh_view_bind_group", layout, &entries), }); } } diff --git a/crates/bevy_pbr/src/render/morph.rs b/crates/bevy_pbr/src/render/morph.rs index 61dfef75d5280..beeec206a10df 100644 --- a/crates/bevy_pbr/src/render/morph.rs +++ b/crates/bevy_pbr/src/render/morph.rs @@ -4,9 +4,9 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::prelude::*; use bevy_render::{ batching::NoAutomaticBatching, + gpu_resource::{BufferUsages, BufferVec}, mesh::morph::{MeshMorphWeights, MAX_MORPH_WEIGHTS}, - render_resource::{BufferUsages, BufferVec}, - renderer::{RenderDevice, RenderQueue}, + renderer::{GpuDevice, GpuQueue}, view::ViewVisibility, Extract, }; @@ -35,16 +35,16 @@ impl Default for MorphUniform { } pub fn prepare_morphs( - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, mut uniform: ResMut, ) { if uniform.buffer.is_empty() { return; } let len = uniform.buffer.len(); - uniform.buffer.reserve(len, &render_device); - uniform.buffer.write_buffer(&render_device, &render_queue); + uniform.buffer.reserve(len, &gpu_device); + uniform.buffer.write_buffer(&gpu_device, &gpu_queue); } const fn can_align(step: usize, target: usize) -> bool { diff --git a/crates/bevy_pbr/src/render/skin.rs b/crates/bevy_pbr/src/render/skin.rs index bfb12fd794427..0a226ea558858 100644 --- a/crates/bevy_pbr/src/render/skin.rs +++ b/crates/bevy_pbr/src/render/skin.rs @@ -4,9 +4,9 @@ use bevy_ecs::prelude::*; use bevy_math::Mat4; use bevy_render::{ batching::NoAutomaticBatching, + gpu_resource::{BufferUsages, BufferVec}, mesh::skinning::{SkinnedMesh, SkinnedMeshInverseBindposes}, - render_resource::{BufferUsages, BufferVec}, - renderer::{RenderDevice, RenderQueue}, + renderer::{GpuDevice, GpuQueue}, view::ViewVisibility, Extract, }; @@ -48,8 +48,8 @@ impl Default for SkinUniform { } pub fn prepare_skins( - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, mut uniform: ResMut, ) { if uniform.buffer.is_empty() { @@ -57,8 +57,8 @@ pub fn prepare_skins( } let len = uniform.buffer.len(); - uniform.buffer.reserve(len, &render_device); - uniform.buffer.write_buffer(&render_device, &render_queue); + uniform.buffer.reserve(len, &gpu_device); + uniform.buffer.write_buffer(&gpu_device, &gpu_queue); } // Notes on implementation: diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index 62a7d4e5a4a6a..04ce3ce6e0697 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -18,10 +18,10 @@ use bevy_render::{ camera::{ExtractedCamera, TemporalJitter}, extract_component::ExtractComponent, globals::{GlobalsBuffer, GlobalsUniform}, + gpu_resource::*, prelude::Camera, render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, - render_resource::*, - renderer::{RenderAdapter, RenderContext, RenderDevice, RenderQueue}, + renderer::{GpuAdapter, GpuDevice, GpuQueue, RenderContext}, texture::{CachedTexture, TextureCache}, view::{Msaa, ViewUniform, ViewUniformOffset, ViewUniforms}, Extract, ExtractSchedule, Render, RenderApp, RenderSet, @@ -79,7 +79,7 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin { if !render_app .world - .resource::() + .resource::() .get_texture_format_features(TextureFormat::R16Float) .allowed_usages .contains(TextureUsages::STORAGE_BINDING) @@ -90,7 +90,7 @@ impl Plugin for ScreenSpaceAmbientOcclusionPlugin { if render_app .world - .resource::() + .resource::() .limits() .max_storage_textures_per_shader_stage < 5 @@ -311,13 +311,13 @@ struct SsaoPipelines { impl FromWorld for SsaoPipelines { fn from_world(world: &mut World) -> Self { - let render_device = world.resource::(); - let render_queue = world.resource::(); + let gpu_device = world.resource::(); + let gpu_queue = world.resource::(); let pipeline_cache = world.resource::(); - let hilbert_index_lut = render_device + let hilbert_index_lut = gpu_device .create_texture_with_data( - render_queue, + gpu_queue, &(TextureDescriptor { label: Some("ssao_hilbert_index_lut"), size: Extent3d { @@ -336,7 +336,7 @@ impl FromWorld for SsaoPipelines { ) .create_view(&TextureViewDescriptor::default()); - let point_clamp_sampler = render_device.create_sampler(&SamplerDescriptor { + let point_clamp_sampler = gpu_device.create_sampler(&SamplerDescriptor { min_filter: FilterMode::Nearest, mag_filter: FilterMode::Nearest, mipmap_filter: FilterMode::Nearest, @@ -346,7 +346,7 @@ impl FromWorld for SsaoPipelines { }); let common_bind_group_layout = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("ssao_common_bind_group_layout"), entries: &[ BindGroupLayoutEntry { @@ -379,7 +379,7 @@ impl FromWorld for SsaoPipelines { count: None, }; let preprocess_depth_bind_group_layout = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("ssao_preprocess_depth_bind_group_layout"), entries: &[ BindGroupLayoutEntry { @@ -413,7 +413,7 @@ impl FromWorld for SsaoPipelines { }); let gtao_bind_group_layout = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("ssao_gtao_bind_group_layout"), entries: &[ BindGroupLayoutEntry { @@ -480,7 +480,7 @@ impl FromWorld for SsaoPipelines { }); let spatial_denoise_bind_group_layout = - render_device.create_bind_group_layout(&BindGroupLayoutDescriptor { + gpu_device.create_bind_group_layout(&BindGroupLayoutDescriptor { label: Some("ssao_spatial_denoise_bind_group_layout"), entries: &[ BindGroupLayoutEntry { @@ -631,7 +631,7 @@ pub struct ScreenSpaceAmbientOcclusionTextures { fn prepare_ssao_textures( mut commands: Commands, mut texture_cache: ResMut, - render_device: Res, + gpu_device: Res, views: Query<(Entity, &ExtractedCamera), With>, ) { for (entity, camera) in &views { @@ -645,7 +645,7 @@ fn prepare_ssao_textures( }; let preprocessed_depth_texture = texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { label: Some("ssao_preprocessed_depth_texture"), size, @@ -659,7 +659,7 @@ fn prepare_ssao_textures( ); let ssao_noisy_texture = texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { label: Some("ssao_noisy_texture"), size, @@ -673,7 +673,7 @@ fn prepare_ssao_textures( ); let ssao_texture = texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { label: Some("ssao_texture"), size, @@ -687,7 +687,7 @@ fn prepare_ssao_textures( ); let depth_differences_texture = texture_cache.get( - &render_device, + &gpu_device, TextureDescriptor { label: Some("ssao_depth_differences_texture"), size, @@ -749,7 +749,7 @@ struct SsaoBindGroups { fn prepare_ssao_bind_groups( mut commands: Commands, - render_device: Res, + gpu_device: Res, pipelines: Res, view_uniforms: Res, global_uniforms: Res, @@ -767,7 +767,7 @@ fn prepare_ssao_bind_groups( }; for (entity, ssao_textures, prepass_textures) in &views { - let common_bind_group = render_device.create_bind_group( + let common_bind_group = gpu_device.create_bind_group( "ssao_common_bind_group", &pipelines.common_bind_group_layout, &BindGroupEntries::sequential((&pipelines.point_clamp_sampler, view_uniforms.clone())), @@ -787,7 +787,7 @@ fn prepare_ssao_bind_groups( }) }; - let preprocess_depth_bind_group = render_device.create_bind_group( + let preprocess_depth_bind_group = gpu_device.create_bind_group( "ssao_preprocess_depth_bind_group", &pipelines.preprocess_depth_bind_group_layout, &BindGroupEntries::sequential(( @@ -800,7 +800,7 @@ fn prepare_ssao_bind_groups( )), ); - let gtao_bind_group = render_device.create_bind_group( + let gtao_bind_group = gpu_device.create_bind_group( "ssao_gtao_bind_group", &pipelines.gtao_bind_group_layout, &BindGroupEntries::sequential(( @@ -813,7 +813,7 @@ fn prepare_ssao_bind_groups( )), ); - let spatial_denoise_bind_group = render_device.create_bind_group( + let spatial_denoise_bind_group = gpu_device.create_bind_group( "ssao_spatial_denoise_bind_group", &pipelines.spatial_denoise_bind_group_layout, &BindGroupEntries::sequential(( diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index 2d533e7e52f5c..21826be926359 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -6,9 +6,8 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath, TypeUuid}; use bevy_render::{ color::Color, extract_resource::ExtractResource, + gpu_resource::*, mesh::{Mesh, MeshVertexBufferLayout}, - prelude::*, - render_resource::*, }; pub const WIREFRAME_SHADER_HANDLE: Handle = Handle::weak_from_u128(192598014480025766); diff --git a/crates/bevy_render/macros/src/as_bind_group.rs b/crates/bevy_render/macros/src/as_bind_group.rs index dca3cea1dfc8d..1cc4246c812ed 100644 --- a/crates/bevy_render/macros/src/as_bind_group.rs +++ b/crates/bevy_render/macros/src/as_bind_group.rs @@ -58,16 +58,16 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { } else if attr_ident == UNIFORM_ATTRIBUTE_NAME { let (binding_index, converted_shader_type) = get_uniform_binding_attr(attr)?; binding_impls.push(quote! {{ - use #render_path::render_resource::AsBindGroupShaderType; - let mut buffer = #render_path::render_resource::encase::UniformBuffer::new(Vec::new()); + use #render_path::gpu_resource::AsBindGroupShaderType; + let mut buffer = #render_path::gpu_resource::encase::UniformBuffer::new(Vec::new()); let converted: #converted_shader_type = self.as_bind_group_shader_type(images); buffer.write(&converted).unwrap(); ( #binding_index, - #render_path::render_resource::OwnedBindingResource::Buffer(render_device.create_buffer_with_data( - &#render_path::render_resource::BufferInitDescriptor { + #render_path::gpu_resource::OwnedBindingResource::Buffer(gpu_device.create_buffer_with_data( + &#render_path::gpu_resource::BufferInitDescriptor { label: None, - usage: #render_path::render_resource::BufferUsages::COPY_DST | #render_path::render_resource::BufferUsages::UNIFORM, + usage: #render_path::gpu_resource::BufferUsages::COPY_DST | #render_path::gpu_resource::BufferUsages::UNIFORM, contents: buffer.as_ref(), }, )) @@ -75,13 +75,13 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { }}); binding_layouts.push(quote!{ - #render_path::render_resource::BindGroupLayoutEntry { + #render_path::gpu_resource::BindGroupLayoutEntry { binding: #binding_index, - visibility: #render_path::render_resource::ShaderStages::all(), - ty: #render_path::render_resource::BindingType::Buffer { - ty: #render_path::render_resource::BufferBindingType::Uniform, + visibility: #render_path::gpu_resource::ShaderStages::all(), + ty: #render_path::gpu_resource::BindingType::Buffer { + ty: #render_path::gpu_resource::BufferBindingType::Uniform, has_dynamic_offset: false, - min_binding_size: Some(<#converted_shader_type as #render_path::render_resource::ShaderType>::min_size()), + min_binding_size: Some(<#converted_shader_type as #render_path::gpu_resource::ShaderType>::min_size()), }, count: None, } @@ -204,7 +204,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { buffer, } = get_storage_binding_attr(nested_meta_items)?; let visibility = - visibility.hygienic_quote("e! { #render_path::render_resource }); + visibility.hygienic_quote("e! { #render_path::gpu_resource }); let field_name = field.ident.as_ref().unwrap(); let field_ty = &field.ty; @@ -212,29 +212,29 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { let min_binding_size = if buffer { quote! {None} } else { - quote! {Some(<#field_ty as #render_path::render_resource::ShaderType>::min_size())} + quote! {Some(<#field_ty as #render_path::gpu_resource::ShaderType>::min_size())} }; if buffer { binding_impls.push(quote! { ( #binding_index, - #render_path::render_resource::OwnedBindingResource::Buffer({ + #render_path::gpu_resource::OwnedBindingResource::Buffer({ self.#field_name.clone() }) ) }); } else { binding_impls.push(quote! {{ - use #render_path::render_resource::AsBindGroupShaderType; - let mut buffer = #render_path::render_resource::encase::StorageBuffer::new(Vec::new()); + use #render_path::gpu_resource::AsBindGroupShaderType; + let mut buffer = #render_path::gpu_resource::encase::StorageBuffer::new(Vec::new()); buffer.write(&self.#field_name).unwrap(); ( #binding_index, - #render_path::render_resource::OwnedBindingResource::Buffer(render_device.create_buffer_with_data( - &#render_path::render_resource::BufferInitDescriptor { + #render_path::gpu_resource::OwnedBindingResource::Buffer(gpu_device.create_buffer_with_data( + &#render_path::gpu_resource::BufferInitDescriptor { label: None, - usage: #render_path::render_resource::BufferUsages::COPY_DST | #render_path::render_resource::BufferUsages::STORAGE, + usage: #render_path::gpu_resource::BufferUsages::COPY_DST | #render_path::gpu_resource::BufferUsages::STORAGE, contents: buffer.as_ref(), }, )) @@ -243,11 +243,11 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { } binding_layouts.push(quote! { - #render_path::render_resource::BindGroupLayoutEntry { + #render_path::gpu_resource::BindGroupLayoutEntry { binding: #binding_index, visibility: #visibility, - ty: #render_path::render_resource::BindingType::Buffer { - ty: #render_path::render_resource::BufferBindingType::Storage { read_only: #read_only }, + ty: #render_path::gpu_resource::BindingType::Buffer { + ty: #render_path::gpu_resource::BufferBindingType::Storage { read_only: #read_only }, has_dynamic_offset: false, min_binding_size: #min_binding_size, }, @@ -264,17 +264,17 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { } = tex_attrs.as_ref().unwrap(); let visibility = - visibility.hygienic_quote("e! { #render_path::render_resource }); + visibility.hygienic_quote("e! { #render_path::gpu_resource }); let fallback_image = get_fallback_image(&render_path, *dimension); binding_impls.push(quote! { ( #binding_index, - #render_path::render_resource::OwnedBindingResource::TextureView({ + #render_path::gpu_resource::OwnedBindingResource::TextureView({ let handle: Option<&#asset_path::Handle<#render_path::texture::Image>> = (&self.#field_name).into(); if let Some(handle) = handle { - images.get(handle).ok_or_else(|| #render_path::render_resource::AsBindGroupError::RetryNextUpdate)?.texture_view.clone() + images.get(handle).ok_or_else(|| #render_path::gpu_resource::AsBindGroupError::RetryNextUpdate)?.texture_view.clone() } else { #fallback_image.texture_view.clone() } @@ -283,13 +283,13 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { }); binding_layouts.push(quote! { - #render_path::render_resource::BindGroupLayoutEntry { + #render_path::gpu_resource::BindGroupLayoutEntry { binding: #binding_index, visibility: #visibility, - ty: #render_path::render_resource::BindingType::Texture { + ty: #render_path::gpu_resource::BindingType::Texture { multisampled: #multisampled, - sample_type: #render_path::render_resource::#sample_type, - view_dimension: #render_path::render_resource::#dimension, + sample_type: #render_path::gpu_resource::#sample_type, + view_dimension: #render_path::gpu_resource::#dimension, }, count: None, } @@ -306,17 +306,17 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { .expect("sampler attribute must have matching texture attribute"); let visibility = - visibility.hygienic_quote("e! { #render_path::render_resource }); + visibility.hygienic_quote("e! { #render_path::gpu_resource }); let fallback_image = get_fallback_image(&render_path, *dimension); binding_impls.push(quote! { ( #binding_index, - #render_path::render_resource::OwnedBindingResource::Sampler({ + #render_path::gpu_resource::OwnedBindingResource::Sampler({ let handle: Option<&#asset_path::Handle<#render_path::texture::Image>> = (&self.#field_name).into(); if let Some(handle) = handle { - images.get(handle).ok_or_else(|| #render_path::render_resource::AsBindGroupError::RetryNextUpdate)?.sampler.clone() + images.get(handle).ok_or_else(|| #render_path::gpu_resource::AsBindGroupError::RetryNextUpdate)?.sampler.clone() } else { #fallback_image.sampler.clone() } @@ -325,10 +325,10 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { }); binding_layouts.push(quote!{ - #render_path::render_resource::BindGroupLayoutEntry { + #render_path::gpu_resource::BindGroupLayoutEntry { binding: #binding_index, visibility: #visibility, - ty: #render_path::render_resource::BindingType::Sampler(#render_path::render_resource::#sampler_binding_type), + ty: #render_path::gpu_resource::BindingType::Sampler(#render_path::gpu_resource::#sampler_binding_type), count: None, } }); @@ -351,14 +351,14 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { let field_name = field.ident.as_ref().unwrap(); let field_ty = &field.ty; binding_impls.push(quote! {{ - let mut buffer = #render_path::render_resource::encase::UniformBuffer::new(Vec::new()); + let mut buffer = #render_path::gpu_resource::encase::UniformBuffer::new(Vec::new()); buffer.write(&self.#field_name).unwrap(); ( #binding_index, - #render_path::render_resource::OwnedBindingResource::Buffer(render_device.create_buffer_with_data( - &#render_path::render_resource::BufferInitDescriptor { + #render_path::gpu_resource::OwnedBindingResource::Buffer(gpu_device.create_buffer_with_data( + &#render_path::gpu_resource::BufferInitDescriptor { label: None, - usage: #render_path::render_resource::BufferUsages::COPY_DST | #render_path::render_resource::BufferUsages::UNIFORM, + usage: #render_path::gpu_resource::BufferUsages::COPY_DST | #render_path::gpu_resource::BufferUsages::UNIFORM, contents: buffer.as_ref(), }, )) @@ -366,13 +366,13 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { }}); binding_layouts.push(quote!{ - #render_path::render_resource::BindGroupLayoutEntry { + #render_path::gpu_resource::BindGroupLayoutEntry { binding: #binding_index, - visibility: #render_path::render_resource::ShaderStages::all(), - ty: #render_path::render_resource::BindingType::Buffer { - ty: #render_path::render_resource::BufferBindingType::Uniform, + visibility: #render_path::gpu_resource::ShaderStages::all(), + ty: #render_path::gpu_resource::BindingType::Buffer { + ty: #render_path::gpu_resource::BufferBindingType::Uniform, has_dynamic_offset: false, - min_binding_size: Some(<#field_ty as #render_path::render_resource::ShaderType>::min_size()), + min_binding_size: Some(<#field_ty as #render_path::gpu_resource::ShaderType>::min_size()), }, count: None, } @@ -387,7 +387,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { let field_name = uniform_fields.iter().map(|f| f.ident.as_ref().unwrap()); let field_type = uniform_fields.iter().map(|f| &f.ty); field_struct_impls.push(quote! { - #[derive(#render_path::render_resource::ShaderType)] + #[derive(#render_path::gpu_resource::ShaderType)] struct #uniform_struct_name<'a> { #(#field_name: &'a #field_type,)* } @@ -395,16 +395,16 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { let field_name = uniform_fields.iter().map(|f| f.ident.as_ref().unwrap()); binding_impls.push(quote! {{ - let mut buffer = #render_path::render_resource::encase::UniformBuffer::new(Vec::new()); + let mut buffer = #render_path::gpu_resource::encase::UniformBuffer::new(Vec::new()); buffer.write(&#uniform_struct_name { #(#field_name: &self.#field_name,)* }).unwrap(); ( #binding_index, - #render_path::render_resource::OwnedBindingResource::Buffer(render_device.create_buffer_with_data( - &#render_path::render_resource::BufferInitDescriptor { + #render_path::gpu_resource::OwnedBindingResource::Buffer(gpu_device.create_buffer_with_data( + &#render_path::gpu_resource::BufferInitDescriptor { label: None, - usage: #render_path::render_resource::BufferUsages::COPY_DST | #render_path::render_resource::BufferUsages::UNIFORM, + usage: #render_path::gpu_resource::BufferUsages::COPY_DST | #render_path::gpu_resource::BufferUsages::UNIFORM, contents: buffer.as_ref(), }, )) @@ -412,13 +412,13 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { }}); binding_layouts.push(quote!{ - #render_path::render_resource::BindGroupLayoutEntry { + #render_path::gpu_resource::BindGroupLayoutEntry { binding: #binding_index, - visibility: #render_path::render_resource::ShaderStages::all(), - ty: #render_path::render_resource::BindingType::Buffer { - ty: #render_path::render_resource::BufferBindingType::Uniform, + visibility: #render_path::gpu_resource::ShaderStages::all(), + ty: #render_path::gpu_resource::BindingType::Buffer { + ty: #render_path::gpu_resource::BufferBindingType::Uniform, has_dynamic_offset: false, - min_binding_size: Some(<#uniform_struct_name as #render_path::render_resource::ShaderType>::min_size()), + min_binding_size: Some(<#uniform_struct_name as #render_path::gpu_resource::ShaderType>::min_size()), }, count: None, } @@ -441,7 +441,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { Ok(TokenStream::from(quote! { #(#field_struct_impls)* - impl #impl_generics #render_path::render_resource::AsBindGroup for #struct_name #ty_generics #where_clause { + impl #impl_generics #render_path::gpu_resource::AsBindGroup for #struct_name #ty_generics #where_clause { type Data = #prepared_data; fn label() -> Option<&'static str> { @@ -450,20 +450,20 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { fn unprepared_bind_group( &self, - layout: &#render_path::render_resource::BindGroupLayout, - render_device: &#render_path::renderer::RenderDevice, + layout: &#render_path::gpu_resource::BindGroupLayout, + gpu_device: &#render_path::renderer::GpuDevice, images: &#render_path::render_asset::RenderAssets<#render_path::texture::Image>, fallback_image: &#render_path::texture::FallbackImage, - ) -> Result<#render_path::render_resource::UnpreparedBindGroup, #render_path::render_resource::AsBindGroupError> { + ) -> Result<#render_path::gpu_resource::UnpreparedBindGroup, #render_path::gpu_resource::AsBindGroupError> { let bindings = vec![#(#binding_impls,)*]; - Ok(#render_path::render_resource::UnpreparedBindGroup { + Ok(#render_path::gpu_resource::UnpreparedBindGroup { bindings, data: #get_prepared_data, }) } - fn bind_group_layout_entries(render_device: &#render_path::renderer::RenderDevice) -> Vec<#render_path::render_resource::BindGroupLayoutEntry> { + fn bind_group_layout_entries(gpu_device: &#render_path::renderer::GpuDevice) -> Vec<#render_path::gpu_resource::BindGroupLayoutEntry> { vec![#(#binding_layouts,)*] } } @@ -475,13 +475,13 @@ fn get_fallback_image( dimension: BindingTextureDimension, ) -> proc_macro2::TokenStream { quote! { - match #render_path::render_resource::#dimension { - #render_path::render_resource::TextureViewDimension::D1 => &fallback_image.d1, - #render_path::render_resource::TextureViewDimension::D2 => &fallback_image.d2, - #render_path::render_resource::TextureViewDimension::D2Array => &fallback_image.d2_array, - #render_path::render_resource::TextureViewDimension::Cube => &fallback_image.cube, - #render_path::render_resource::TextureViewDimension::CubeArray => &fallback_image.cube_array, - #render_path::render_resource::TextureViewDimension::D3 => &fallback_image.d3, + match #render_path::gpu_resource::#dimension { + #render_path::gpu_resource::TextureViewDimension::D1 => &fallback_image.d1, + #render_path::gpu_resource::TextureViewDimension::D2 => &fallback_image.d2, + #render_path::gpu_resource::TextureViewDimension::D2Array => &fallback_image.d2_array, + #render_path::gpu_resource::TextureViewDimension::Cube => &fallback_image.cube, + #render_path::gpu_resource::TextureViewDimension::CubeArray => &fallback_image.cube_array, + #render_path::gpu_resource::TextureViewDimension::D3 => &fallback_image.d3, } } } diff --git a/crates/bevy_render/src/batching/mod.rs b/crates/bevy_render/src/batching/mod.rs index bb4fe79670b18..d8388257c775e 100644 --- a/crates/bevy_render/src/batching/mod.rs +++ b/crates/bevy_render/src/batching/mod.rs @@ -7,9 +7,9 @@ use bevy_ecs::{ use bevy_utils::nonmax::NonMaxU32; use crate::{ + gpu_resource::{CachedRenderPipelineId, GpuArrayBuffer, GpuArrayBufferable}, render_phase::{CachedRenderPipelinePhaseItem, DrawFunctionId, RenderPhase}, - render_resource::{CachedRenderPipelineId, GpuArrayBuffer, GpuArrayBufferable}, - renderer::{RenderDevice, RenderQueue}, + renderer::{GpuDevice, GpuQueue}, }; /// Add this component to mesh entities to disable automatic batching @@ -121,11 +121,11 @@ pub fn batch_and_prepare_render_phase( - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, gpu_array_buffer: ResMut>, ) { let gpu_array_buffer = gpu_array_buffer.into_inner(); - gpu_array_buffer.write_buffer(&render_device, &render_queue); + gpu_array_buffer.write_buffer(&gpu_device, &gpu_queue); gpu_array_buffer.clear(); } diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index be6349689b7cb..1706d7934ac99 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -1,10 +1,10 @@ use crate::{ camera::CameraProjection, camera::{ManualTextureViewHandle, ManualTextureViews}, + gpu_resource::{BlendState, GpuColor, LoadOp, TextureFormat, TextureView}, prelude::Image, primitives::Frustum, render_asset::RenderAssets, - render_resource::TextureView, view::{ColorGrading, ExtractedView, ExtractedWindows, RenderLayers, VisibleEntities}, Extract, }; @@ -28,7 +28,6 @@ use bevy_window::{ NormalizedWindowRef, PrimaryWindow, Window, WindowCreated, WindowRef, WindowResized, }; use std::{borrow::Cow, ops::Range}; -use wgpu::{BlendState, LoadOp, TextureFormat}; use super::Projection; @@ -368,7 +367,7 @@ pub enum CameraOutputMode { blend_state: Option, /// The color attachment load operation that will be used by the pipeline that writes the intermediate render textures to the final render /// target texture. - color_attachment_load_op: wgpu::LoadOp, + color_attachment_load_op: LoadOp, }, /// Skips writing the camera output to the configured render target. The output will remain in the /// Render Target's "intermediate" textures, which a camera with a higher order should write to the render target diff --git a/crates/bevy_render/src/camera/camera_driver_node.rs b/crates/bevy_render/src/camera/camera_driver_node.rs index 38ba4ac185749..98c4228a6982b 100644 --- a/crates/bevy_render/src/camera/camera_driver_node.rs +++ b/crates/bevy_render/src/camera/camera_driver_node.rs @@ -1,12 +1,12 @@ use crate::{ camera::{ExtractedCamera, NormalizedRenderTarget, SortedCameras}, + gpu_resource::{GpuColor, LoadOp, Operations, RenderPassColorAttachment, RenderPassDescriptor}, render_graph::{Node, NodeRunError, RenderGraphContext}, renderer::RenderContext, view::ExtractedWindows, }; use bevy_ecs::{prelude::QueryState, world::World}; use bevy_utils::HashSet; -use wgpu::{LoadOp, Operations, RenderPassColorAttachment, RenderPassDescriptor}; pub struct CameraDriverNode { cameras: QueryState<&'static ExtractedCamera>, @@ -76,7 +76,7 @@ impl Node for CameraDriverNode { view: swap_chain_texture, resolve_target: None, ops: Operations { - load: LoadOp::Clear(wgpu::Color::BLACK), + load: LoadOp::Clear(GpuColor::BLACK), store: true, }, })], diff --git a/crates/bevy_render/src/camera/manual_texture_view.rs b/crates/bevy_render/src/camera/manual_texture_view.rs index b843f0ecafd4f..eaa571c1a4120 100644 --- a/crates/bevy_render/src/camera/manual_texture_view.rs +++ b/crates/bevy_render/src/camera/manual_texture_view.rs @@ -1,12 +1,12 @@ -use crate::extract_resource::ExtractResource; -use crate::render_resource::TextureView; -use crate::texture::BevyDefault; -use bevy_ecs::system::Resource; -use bevy_ecs::{prelude::Component, reflect::ReflectComponent}; +use crate::{ + extract_resource::ExtractResource, + gpu_resource::{TextureFormat, TextureView}, + texture::BevyDefault, +}; +use bevy_ecs::{prelude::Component, reflect::ReflectComponent, system::Resource}; use bevy_math::UVec2; use bevy_reflect::prelude::*; use bevy_utils::HashMap; -use wgpu::TextureFormat; /// A unique id that corresponds to a specific [`ManualTextureView`] in the [`ManualTextureViews`] collection. #[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Component, Reflect)] diff --git a/crates/bevy_render/src/color/mod.rs b/crates/bevy_render/src/color/mod.rs index b4139b8787482..fd4ecddb6df3c 100644 --- a/crates/bevy_render/src/color/mod.rs +++ b/crates/bevy_render/src/color/mod.rs @@ -2,6 +2,7 @@ mod colorspace; pub use colorspace::*; +use crate::gpu_resource::GpuColor; use bevy_math::{Vec3, Vec4}; use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize}; use serde::{Deserialize, Serialize}; @@ -1278,7 +1279,7 @@ impl From for Color { } } -impl From for wgpu::Color { +impl From for GpuColor { fn from(color: Color) -> Self { if let Color::RgbaLinear { red, @@ -1287,7 +1288,7 @@ impl From for wgpu::Color { alpha, } = color.as_rgba_linear() { - wgpu::Color { + GpuColor { r: red as f64, g: green as f64, b: blue as f64, diff --git a/crates/bevy_render/src/extract_component.rs b/crates/bevy_render/src/extract_component.rs index 7577517f12197..a3e5eebdf0d3d 100644 --- a/crates/bevy_render/src/extract_component.rs +++ b/crates/bevy_render/src/extract_component.rs @@ -1,6 +1,6 @@ use crate::{ - render_resource::{encase::internal::WriteInto, DynamicUniformBuffer, ShaderType}, - renderer::{RenderDevice, RenderQueue}, + gpu_resource::{encase::internal::WriteInto, DynamicUniformBuffer, ShaderType}, + renderer::{GpuDevice, GpuQueue}, view::ViewVisibility, Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; @@ -125,8 +125,8 @@ impl Default for ComponentUniforms { /// They are transformed into uniforms and stored in the [`ComponentUniforms`] resource. fn prepare_uniform_components( mut commands: Commands, - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, mut component_uniforms: ResMut>, components: Query<(Entity, &C)>, ) where @@ -134,10 +134,9 @@ fn prepare_uniform_components( { let components_iter = components.iter(); let count = components_iter.len(); - let Some(mut writer) = - component_uniforms - .uniforms - .get_writer(count, &render_device, &render_queue) + let Some(mut writer) = component_uniforms + .uniforms + .get_writer(count, &gpu_device, &gpu_queue) else { return; }; diff --git a/crates/bevy_render/src/globals.rs b/crates/bevy_render/src/globals.rs index d337be44b93bc..584d2808ee758 100644 --- a/crates/bevy_render/src/globals.rs +++ b/crates/bevy_render/src/globals.rs @@ -1,8 +1,8 @@ use crate::{ extract_resource::ExtractResource, + gpu_resource::{ShaderType, UniformBuffer}, prelude::Shader, - render_resource::{ShaderType, UniformBuffer}, - renderer::{RenderDevice, RenderQueue}, + renderer::{GpuDevice, GpuQueue}, Extract, ExtractSchedule, Render, RenderApp, RenderSet, }; use bevy_app::{App, Plugin}; @@ -67,8 +67,8 @@ pub struct GlobalsBuffer { } fn prepare_globals_buffer( - render_device: Res, - render_queue: Res, + gpu_device: Res, + gpu_queue: Res, mut globals_buffer: ResMut, time: Res