rename GlobalRenderResourceContext to RenderResources

This commit is contained in:
Carter Anderson 2020-05-04 19:34:15 -07:00
parent 7560ecf9d8
commit 2fd7020646
11 changed files with 38 additions and 38 deletions

View file

@ -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::<GlobalRenderResourceContext>()
.read_resource::<RenderResources>()
// TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same
.write_resource::<RenderResourceAssignments>()
.with_query(<(Read<Light>, Read<LocalToWorld>, Read<Translation>)>::query())

View file

@ -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<dyn Sched
let vertex_buffer_descriptor = Vertex::get_vertex_buffer_descriptor().unwrap();
vertex_buffer_descriptors.set(vertex_buffer_descriptor.clone());
SystemBuilder::new("mesh_resource_provider")
.read_resource::<GlobalRenderResourceContext>()
.read_resource::<RenderResources>()
.read_resource::<AssetStorage<Mesh>>()
.with_query(<(Read<Handle<Mesh>>, Write<Renderable>)>::query())
.build(

View file

@ -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::<PipelineCompiler>().unwrap();
let mut shader_storage = resources.get_mut::<AssetStorage<Shader>>().unwrap();
let vertex_buffer_descriptors = resources.get::<VertexBufferDescriptors>().unwrap();
let global_render_resource_context =
resources.get::<GlobalRenderResourceContext>().unwrap();
let render_resources =
resources.get::<RenderResources>().unwrap();
let mut pipeline_descriptor_storage = resources
.get_mut::<AssetStorage<PipelineDescriptor>>()
.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,

View file

@ -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::<WindowResized>();
let mut command_queue = self.command_queue.clone();
SystemBuilder::new("camera_2d_resource_provider")
.read_resource::<GlobalRenderResourceContext>()
.read_resource::<RenderResources>()
// TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same
.write_resource::<RenderResourceAssignments>()
.read_resource::<Events<WindowResized>>()

View file

@ -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::<WindowResized>();
let mut command_queue = self.command_queue.clone();
SystemBuilder::new("camera_resource_provider")
.read_resource::<GlobalRenderResourceContext>()
.read_resource::<RenderResources>()
// TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same
.write_resource::<RenderResourceAssignments>()
.read_resource::<Events<WindowResized>>()

View file

@ -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::<T>()
))
.read_resource::<AssetStorage<Texture>>()
.read_resource::<GlobalRenderResourceContext>()
.read_resource::<RenderResources>()
// TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same
.with_query(<(Read<T>, Read<Renderable>)>::query())
.with_query(<(Read<T>, Write<Renderable>)>::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::<AssetStorage<T>>()
.read_resource::<AssetStorage<Texture>>()
.read_resource::<GlobalRenderResourceContext>()
.read_resource::<RenderResources>()
// TODO: this write on RenderResourceAssignments will prevent this system from running in parallel with other systems that do the same
.with_query(<(Read<Handle<T>>, Read<Renderable>)>::query())
.with_query(<(Read<Handle<T>>, Write<Renderable>)>::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);
}

View file

@ -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<dyn RenderResourceContext>,
}
impl GlobalRenderResourceContext {
pub fn new<T>(context: T) -> GlobalRenderResourceContext
impl RenderResources {
pub fn new<T>(context: T) -> RenderResources
where
T: RenderResourceContext,
{
GlobalRenderResourceContext {
RenderResources {
context: Box::new(context),
}
}

View file

@ -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<Diagnostics>,
global_resource_context: Resource<GlobalRenderResourceContext>,
render_resources: Resource<RenderResources>,
) {
let render_resource_context = global_resource_context
let render_resource_context = render_resources
.context
.downcast_ref::<WgpuRenderResourceContext>()
.unwrap();

View file

@ -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| {

View file

@ -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::<GlobalRenderResourceContext>().unwrap();
let render_resource_context = global_context
let mut render_resources = resources.get_mut::<RenderResources>().unwrap();
let wgpu_render_resources = render_resources
.context
.downcast_mut::<WgpuRenderResourceContext>()
.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() {

View file

@ -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::<GlobalRenderResourceContext>().unwrap();
let render_resource_context = global_context
let mut render_resources = resources.get_mut::<RenderResources>().unwrap();
let render_resource_context = render_resources
.context
.downcast_mut::<WgpuRenderResourceContext>()
.unwrap();
@ -127,7 +127,7 @@ impl WgpuRenderer {
self.handle_window_created_events(resources);
self.run_graph(world, resources);
let render_resource_context = resources.get::<GlobalRenderResourceContext>().unwrap();
let render_resource_context = resources.get::<RenderResources>().unwrap();
render_resource_context
.context
.drop_all_swap_chain_textures();