From f98918fd5cb31b4e59a1505b25427bff39b7898e Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Mon, 11 May 2020 14:07:09 -0700 Subject: [PATCH] remove buffer array info --- .../src/render_graph/nodes/uniform_node.rs | 41 ++----------------- .../src/render_resource/resource_info.rs | 11 ----- 2 files changed, 4 insertions(+), 48 deletions(-) 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 eeec5a9e19..6dc30ec625 100644 --- a/crates/bevy_render/src/render_graph/nodes/uniform_node.rs +++ b/crates/bevy_render/src/render_graph/nodes/uniform_node.rs @@ -2,7 +2,7 @@ use crate::{ pipeline::VertexBufferDescriptors, render_graph::{CommandQueue, Node, ResourceSlots, SystemNode}, render_resource::{ - BufferArrayInfo, BufferInfo, BufferUsage, RenderResource, RenderResourceAssignment, + BufferInfo, BufferUsage, RenderResource, RenderResourceAssignment, RenderResourceAssignments, RenderResourceAssignmentsId, ResourceInfo, }, renderer::{RenderContext, RenderResourceContext, RenderResources}, @@ -136,36 +136,9 @@ where render_resource_context: &dyn RenderResourceContext, align: bool, ) { - let new_capacity = if let Some(buffer) = buffer_array_status.buffer { - let mut new_capacity = None; - render_resource_context.get_resource_info(buffer, &mut |resource_info| { - new_capacity = if let Some(ResourceInfo::Buffer(BufferInfo { - array_info: Some(array_info), - .. - })) = resource_info - { - if array_info.item_capacity < buffer_array_status.new_item_count { - // over capacity. lets resize - Some( - buffer_array_status.new_item_count - + buffer_array_status.new_item_count / 2, - ) - } else { - // under capacity. no change needed - None - } - } else { - // incorrect resource type. overwrite with new buffer - Some(buffer_array_status.new_item_count) - }; - }); - new_capacity - } else { - // buffer does not exist. create it now. - Some(buffer_array_status.new_item_count) - }; - - if let Some(new_capacity) = new_capacity { + if buffer_array_status.current_item_capacity < buffer_array_status.new_item_count { + let new_capacity = + buffer_array_status.new_item_count + buffer_array_status.new_item_count / 2; let mut item_size = buffer_array_status.item_size; if align { item_size = Self::get_aligned_dynamic_uniform_size(item_size); @@ -174,14 +147,8 @@ where let total_size = item_size * new_capacity; let buffer = render_resource_context.create_buffer(BufferInfo { - array_info: Some(BufferArrayInfo { - item_capacity: new_capacity, - item_size, - ..Default::default() - }), size: total_size, buffer_usage: BufferUsage::COPY_DST | BufferUsage::UNIFORM, - is_dynamic: true, }); buffer_array_status.current_item_capacity = new_capacity; diff --git a/crates/bevy_render/src/render_resource/resource_info.rs b/crates/bevy_render/src/render_resource/resource_info.rs index d9ffc2f450..e3f4b4396c 100644 --- a/crates/bevy_render/src/render_resource/resource_info.rs +++ b/crates/bevy_render/src/render_resource/resource_info.rs @@ -1,18 +1,9 @@ use crate::render_resource::BufferUsage; -#[derive(Default, Debug, Clone, Eq, PartialEq)] -pub struct BufferArrayInfo { - pub item_size: usize, - pub item_capacity: usize, -} - #[derive(Debug, Clone, Eq, PartialEq)] pub struct BufferInfo { pub size: usize, pub buffer_usage: BufferUsage, - // TODO: remove array info and is_dynamic - pub array_info: Option, - pub is_dynamic: bool, } impl Default for BufferInfo { @@ -20,8 +11,6 @@ impl Default for BufferInfo { BufferInfo { size: 0, buffer_usage: BufferUsage::NONE, - array_info: None, - is_dynamic: false, } } }