From 2fd702064678b2d3b1aaeda04cda44c290b02432 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Mon, 4 May 2020 19:34:15 -0700 Subject: [PATCH] rename GlobalRenderResourceContext to RenderResources --- crates/bevy_pbr/src/nodes/lights_node.rs | 4 ++-- crates/bevy_render/src/mesh.rs | 4 ++-- .../bevy_render/src/pipeline/pipeline_compiler.rs | 8 ++++---- .../src/render_graph/nodes/camera2d_node.rs | 4 ++-- .../src/render_graph/nodes/camera_node.rs | 4 ++-- .../src/render_graph/nodes/uniform_node.rs | 14 +++++++------- .../src/renderer/render_resource_context.rs | 10 +++++----- .../diagnostic/wgpu_resource_diagnostics_plugin.rs | 6 +++--- crates/bevy_wgpu/src/lib.rs | 4 ++-- .../src/renderer/wgpu_render_graph_executor.rs | 10 +++++----- crates/bevy_wgpu/src/wgpu_renderer.rs | 8 ++++---- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/crates/bevy_pbr/src/nodes/lights_node.rs b/crates/bevy_pbr/src/nodes/lights_node.rs index 7426b13646..5bbc9891b5 100644 --- a/crates/bevy_pbr/src/nodes/lights_node.rs +++ b/crates/bevy_pbr/src/nodes/lights_node.rs @@ -1,7 +1,7 @@ use bevy_render::{ render_graph::{CommandQueue, Node, ResourceSlots, SystemNode}, render_resource::{resource_name, BufferInfo, BufferUsage, RenderResourceAssignments}, - renderer::{GlobalRenderResourceContext, RenderContext}, + renderer::{RenderResources, RenderContext}, }; use crate::light::{Light, LightRaw}; @@ -53,7 +53,7 @@ impl SystemNode for LightsNode { let mut command_queue = self.command_queue.clone(); let max_lights = self.max_lights; SystemBuilder::new("light_node") - .read_resource::() + .read_resource::() // TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same .write_resource::() .with_query(<(Read, Read, Read)>::query()) diff --git a/crates/bevy_render/src/mesh.rs b/crates/bevy_render/src/mesh.rs index 27d8cca76a..604136b817 100644 --- a/crates/bevy_render/src/mesh.rs +++ b/crates/bevy_render/src/mesh.rs @@ -4,7 +4,7 @@ use crate::{ VertexBufferDescriptor, VertexBufferDescriptors, VertexFormat, }, render_resource::{BufferInfo, BufferUsage, RenderResourceAssignments}, - renderer::{GlobalRenderResourceContext, RenderResourceContext}, + renderer::{RenderResources, RenderResourceContext}, shader::AsUniforms, Renderable, Vertex, }; @@ -380,7 +380,7 @@ pub fn mesh_resource_provider_system(resources: &mut Resources) -> Box() + .read_resource::() .read_resource::>() .with_query(<(Read>, Write)>::query()) .build( diff --git a/crates/bevy_render/src/pipeline/pipeline_compiler.rs b/crates/bevy_render/src/pipeline/pipeline_compiler.rs index a6ec7974af..c1ded289a8 100644 --- a/crates/bevy_render/src/pipeline/pipeline_compiler.rs +++ b/crates/bevy_render/src/pipeline/pipeline_compiler.rs @@ -6,7 +6,7 @@ use crate::{ render_resource::{ BufferInfo, RenderResourceAssignments, RenderResourceAssignmentsId, ResourceInfo, }, - renderer::{GlobalRenderResourceContext, RenderResourceContext}, + renderer::{RenderResources, RenderResourceContext}, shader::{Shader, ShaderSource}, Renderable, }; @@ -289,8 +289,8 @@ pub fn update_shader_assignments(world: &mut World, resources: &Resources) { let mut pipeline_compiler = resources.get_mut::().unwrap(); let mut shader_storage = resources.get_mut::>().unwrap(); let vertex_buffer_descriptors = resources.get::().unwrap(); - let global_render_resource_context = - resources.get::().unwrap(); + let render_resources = + resources.get::().unwrap(); let mut pipeline_descriptor_storage = resources .get_mut::>() .unwrap(); @@ -308,7 +308,7 @@ pub fn update_shader_assignments(world: &mut World, resources: &Resources) { pipeline_compiler.update_shader_assignments( &vertex_buffer_descriptors, &mut shader_pipeline_assignments, - &*global_render_resource_context.context, + &*render_resources.context, &mut pipeline_descriptor_storage, &mut shader_storage, &renderable.pipelines, diff --git a/crates/bevy_render/src/render_graph/nodes/camera2d_node.rs b/crates/bevy_render/src/render_graph/nodes/camera2d_node.rs index c94332ba42..ccabd8b8f0 100644 --- a/crates/bevy_render/src/render_graph/nodes/camera2d_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/camera2d_node.rs @@ -5,7 +5,7 @@ use crate::{ camera::{ActiveCamera2d, Camera}, render_graph::{CommandQueue, Node, ResourceSlots, SystemNode}, render_resource::{resource_name, BufferInfo, BufferUsage, RenderResourceAssignments}, - renderer::{GlobalRenderResourceContext, RenderContext}, + renderer::{RenderResources, RenderContext}, }; use legion::prelude::*; @@ -36,7 +36,7 @@ impl SystemNode for Camera2dNode { let mut window_resized_event_reader = resources.get_event_reader::(); let mut command_queue = self.command_queue.clone(); SystemBuilder::new("camera_2d_resource_provider") - .read_resource::() + .read_resource::() // TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same .write_resource::() .read_resource::>() diff --git a/crates/bevy_render/src/render_graph/nodes/camera_node.rs b/crates/bevy_render/src/render_graph/nodes/camera_node.rs index 4a2fcae344..fa07cb1198 100644 --- a/crates/bevy_render/src/render_graph/nodes/camera_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/camera_node.rs @@ -1,7 +1,7 @@ use crate::{ render_graph::{CommandQueue, Node, ResourceSlots, SystemNode}, render_resource::{resource_name, BufferInfo, BufferUsage, RenderResourceAssignments}, - renderer::{GlobalRenderResourceContext, RenderContext}, + renderer::{RenderResources, RenderContext}, ActiveCamera, Camera, }; @@ -36,7 +36,7 @@ impl SystemNode for CameraNode { let mut window_resized_event_reader = resources.get_event_reader::(); let mut command_queue = self.command_queue.clone(); SystemBuilder::new("camera_resource_provider") - .read_resource::() + .read_resource::() // TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same .write_resource::() .read_resource::>() diff --git a/crates/bevy_render/src/render_graph/nodes/uniform_node.rs b/crates/bevy_render/src/render_graph/nodes/uniform_node.rs index 56dac6b190..967e979572 100644 --- a/crates/bevy_render/src/render_graph/nodes/uniform_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/uniform_node.rs @@ -5,7 +5,7 @@ use crate::{ BufferArrayInfo, BufferInfo, BufferUsage, RenderResource, RenderResourceAssignments, RenderResourceAssignmentsId, ResourceInfo, }, - renderer::{GlobalRenderResourceContext, RenderContext, RenderResourceContext}, + renderer::{RenderResources, RenderContext, RenderResourceContext}, shader::{AsUniforms, FieldBindType}, texture, Renderable, }; @@ -437,16 +437,16 @@ where std::any::type_name::() )) .read_resource::>() - .read_resource::() + .read_resource::() // TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same .with_query(<(Read, Read)>::query()) .with_query(<(Read, Write)>::query()) .build( move |_, world, - (textures, global_render_resource_context), + (textures, render_resources), (read_uniform_query, write_uniform_query)| { - let render_resource_context = &*global_render_resource_context.context; + let render_resource_context = &*render_resources.context; if let Some(staging_buffer_resource) = staging_buffer_resource { render_resource_context.remove_buffer(staging_buffer_resource); } @@ -599,16 +599,16 @@ where SystemBuilder::new("uniform_resource_provider") .read_resource::>() .read_resource::>() - .read_resource::() + .read_resource::() // TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same .with_query(<(Read>, Read)>::query()) .with_query(<(Read>, Write)>::query()) .build( move |_, world, - (assets, textures, global_render_resource_context), + (assets, textures, render_resources), (read_handle_query, write_handle_query)| { - let render_resource_context = &*global_render_resource_context.context; + let render_resource_context = &*render_resources.context; if let Some(staging_buffer_resource) = staging_buffer_resource { render_resource_context.remove_buffer(staging_buffer_resource); } diff --git a/crates/bevy_render/src/renderer/render_resource_context.rs b/crates/bevy_render/src/renderer/render_resource_context.rs index 3987ff0ca5..2e9ed441c7 100644 --- a/crates/bevy_render/src/renderer/render_resource_context.rs +++ b/crates/bevy_render/src/renderer/render_resource_context.rs @@ -7,16 +7,16 @@ use bevy_asset::{AssetStorage, Handle, HandleUntyped}; use bevy_window::{Window, WindowId}; use downcast_rs::{impl_downcast, Downcast}; -pub struct GlobalRenderResourceContext { +pub struct RenderResources { pub context: Box, } -impl GlobalRenderResourceContext { - pub fn new(context: T) -> GlobalRenderResourceContext +impl RenderResources { + pub fn new(context: T) -> RenderResources where T: RenderResourceContext, { - GlobalRenderResourceContext { + RenderResources { context: Box::new(context), } } @@ -82,4 +82,4 @@ impl dyn RenderResourceContext { } } -impl_downcast!(RenderResourceContext); +impl_downcast!(RenderResourceContext); \ No newline at end of file diff --git a/crates/bevy_wgpu/src/diagnostic/wgpu_resource_diagnostics_plugin.rs b/crates/bevy_wgpu/src/diagnostic/wgpu_resource_diagnostics_plugin.rs index a590fafc60..218ca26de5 100644 --- a/crates/bevy_wgpu/src/diagnostic/wgpu_resource_diagnostics_plugin.rs +++ b/crates/bevy_wgpu/src/diagnostic/wgpu_resource_diagnostics_plugin.rs @@ -1,7 +1,7 @@ use crate::renderer::WgpuRenderResourceContext; use bevy_app::{AppBuilder, AppPlugin}; use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics}; -use bevy_render::renderer::GlobalRenderResourceContext; +use bevy_render::renderer::RenderResources; use legion::prelude::{IntoSystem, Resource, ResourceMut}; #[derive(Default)] @@ -118,9 +118,9 @@ impl WgpuResourceDiagnosticsPlugin { pub fn diagnostic_system( mut diagnostics: ResourceMut, - global_resource_context: Resource, + render_resources: Resource, ) { - let render_resource_context = global_resource_context + let render_resource_context = render_resources .context .downcast_ref::() .unwrap(); diff --git a/crates/bevy_wgpu/src/lib.rs b/crates/bevy_wgpu/src/lib.rs index 7a3c307d50..287f1a55ae 100644 --- a/crates/bevy_wgpu/src/lib.rs +++ b/crates/bevy_wgpu/src/lib.rs @@ -10,7 +10,7 @@ pub use wgpu_renderer::*; pub use wgpu_resources::*; use bevy_app::{AppBuilder, AppPlugin, Events}; -use bevy_render::{renderer::GlobalRenderResourceContext, RENDER_STAGE}; +use bevy_render::{renderer::RenderResources, RENDER_STAGE}; use bevy_window::{WindowCreated, WindowResized}; use legion::prelude::*; use renderer::WgpuRenderResourceContext; @@ -34,7 +34,7 @@ pub fn wgpu_render_system(resources: &mut Resources) -> impl FnMut(&mut World, & window_created_event.get_reader(), )) }; - resources.insert(GlobalRenderResourceContext::new( + resources.insert(RenderResources::new( WgpuRenderResourceContext::new(wgpu_renderer.device.clone()), )); move |world, resources| { diff --git a/crates/bevy_wgpu/src/renderer/wgpu_render_graph_executor.rs b/crates/bevy_wgpu/src/renderer/wgpu_render_graph_executor.rs index 12b6260c0f..2b63a3b57b 100644 --- a/crates/bevy_wgpu/src/renderer/wgpu_render_graph_executor.rs +++ b/crates/bevy_wgpu/src/renderer/wgpu_render_graph_executor.rs @@ -1,7 +1,7 @@ use super::{WgpuRenderContext, WgpuRenderResourceContext}; use bevy_render::{ render_graph::{Edge, NodeId, ResourceSlots, StageBorrow}, - renderer::GlobalRenderResourceContext, + renderer::RenderResources, }; use legion::prelude::{Resources, World}; use std::{collections::HashMap, sync::Arc}; @@ -19,8 +19,8 @@ impl WgpuRenderGraphExecutor { queue: &mut wgpu::Queue, stages: &mut [StageBorrow], ) { - let mut global_context = resources.get_mut::().unwrap(); - let render_resource_context = global_context + let mut render_resources = resources.get_mut::().unwrap(); + let wgpu_render_resources = render_resources .context .downcast_mut::() .unwrap(); @@ -39,10 +39,10 @@ impl WgpuRenderGraphExecutor { let world = &*world; actual_thread_count += 1; let device = device.clone(); - let render_resource_context = render_resource_context.clone(); + let wgpu_render_resources = wgpu_render_resources.clone(); s.spawn(move |_| { let mut render_context = - WgpuRenderContext::new(device, render_resource_context); + WgpuRenderContext::new(device, wgpu_render_resources); let mut local_node_outputs = HashMap::new(); for job in jobs_chunk.iter_mut() { for node_state in job.node_states.iter_mut() { diff --git a/crates/bevy_wgpu/src/wgpu_renderer.rs b/crates/bevy_wgpu/src/wgpu_renderer.rs index c04695830d..aa220c7252 100644 --- a/crates/bevy_wgpu/src/wgpu_renderer.rs +++ b/crates/bevy_wgpu/src/wgpu_renderer.rs @@ -5,7 +5,7 @@ use bevy_app::{EventReader, Events}; use bevy_render::{ pipeline::update_shader_assignments, render_graph::{DependentNodeStager, RenderGraph, RenderGraphStager}, - renderer::GlobalRenderResourceContext, + renderer::RenderResources, }; use bevy_window::{WindowCreated, WindowResized, Windows}; use legion::prelude::*; @@ -60,8 +60,8 @@ impl WgpuRenderer { } pub fn handle_window_created_events(&mut self, resources: &Resources) { - let mut global_context = resources.get_mut::().unwrap(); - let render_resource_context = global_context + let mut render_resources = resources.get_mut::().unwrap(); + let render_resource_context = render_resources .context .downcast_mut::() .unwrap(); @@ -127,7 +127,7 @@ impl WgpuRenderer { self.handle_window_created_events(resources); self.run_graph(world, resources); - let render_resource_context = resources.get::().unwrap(); + let render_resource_context = resources.get::().unwrap(); render_resource_context .context .drop_all_swap_chain_textures();