From 128c169503a254b373a400e246c409bd51053d29 Mon Sep 17 00:00:00 2001 From: SpecificProtagonist Date: Tue, 27 Sep 2022 18:11:40 +0000 Subject: [PATCH] remove copyless (#6100) # Objective Remove copyless copyless apparently isn't needed anymore to prevent extraneous memcopies and therefore got deprecated: https://github.com/kvark/copyless/issues/22 --- crates/bevy_render/Cargo.toml | 1 - crates/bevy_render/src/render_phase/mod.rs | 4 +--- crates/bevy_render/src/render_resource/buffer_vec.rs | 3 +-- crates/bevy_sprite/Cargo.toml | 1 - crates/bevy_sprite/src/render/mod.rs | 5 ++--- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 2bd7342aec3f3..9e7c676ac1564 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -65,7 +65,6 @@ hex = "0.4.2" hexasphere = "7.2" parking_lot = "0.12.1" regex = "1.5" -copyless = "0.1.5" ddsfile = { version = "0.5.0", optional = true } ktx2 = { version = "0.3.0", optional = true } # For ktx2 supercompression diff --git a/crates/bevy_render/src/render_phase/mod.rs b/crates/bevy_render/src/render_phase/mod.rs index e762385b0fe3c..7c2686eebfe65 100644 --- a/crates/bevy_render/src/render_phase/mod.rs +++ b/crates/bevy_render/src/render_phase/mod.rs @@ -6,8 +6,6 @@ pub use draw_state::*; use bevy_ecs::prelude::{Component, Query}; -use copyless::VecHelper; - /// A resource to collect and sort draw requests for specific [`PhaseItems`](PhaseItem). #[derive(Component)] pub struct RenderPhase { @@ -24,7 +22,7 @@ impl RenderPhase { /// Adds a [`PhaseItem`] to this render phase. #[inline] pub fn add(&mut self, item: I) { - self.items.alloc().init(item); + self.items.push(item); } /// Sorts all of its [`PhaseItems`](PhaseItem). diff --git a/crates/bevy_render/src/render_resource/buffer_vec.rs b/crates/bevy_render/src/render_resource/buffer_vec.rs index af4616427b8ca..1d3086796dbc5 100644 --- a/crates/bevy_render/src/render_resource/buffer_vec.rs +++ b/crates/bevy_render/src/render_resource/buffer_vec.rs @@ -3,7 +3,6 @@ use crate::{ renderer::{RenderDevice, RenderQueue}, }; use bevy_core::{cast_slice, Pod}; -use copyless::VecHelper; use wgpu::BufferUsages; /// A structure for storing raw bytes that have already been properly formatted @@ -72,7 +71,7 @@ impl BufferVec { pub fn push(&mut self, value: T) -> usize { let index = self.values.len(); - self.values.alloc().init(value); + self.values.push(value); index } diff --git a/crates/bevy_sprite/Cargo.toml b/crates/bevy_sprite/Cargo.toml index ff1ff15c478ab..2fd1225965017 100644 --- a/crates/bevy_sprite/Cargo.toml +++ b/crates/bevy_sprite/Cargo.toml @@ -31,4 +31,3 @@ guillotiere = "0.6.0" thiserror = "1.0" rectangle-pack = "0.4" bitflags = "1.2" -copyless = "0.1.5" diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index 93a3894cdd76d..35f09d8a2f2a8 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -31,7 +31,6 @@ use bevy_transform::components::GlobalTransform; use bevy_utils::FloatOrd; use bevy_utils::HashMap; use bytemuck::{Pod, Zeroable}; -use copyless::VecHelper; use fixedbitset::FixedBitSet; #[derive(Resource)] @@ -253,7 +252,7 @@ pub fn extract_sprites( continue; } // PERF: we don't check in this function that the `Image` asset is ready, since it should be in most cases and hashing the handle is expensive - extracted_sprites.sprites.alloc().init(ExtractedSprite { + extracted_sprites.sprites.push(ExtractedSprite { entity, color: sprite.color, transform: *transform, @@ -272,7 +271,7 @@ pub fn extract_sprites( } if let Some(texture_atlas) = texture_atlases.get(texture_atlas_handle) { let rect = Some(texture_atlas.textures[atlas_sprite.index as usize]); - extracted_sprites.sprites.alloc().init(ExtractedSprite { + extracted_sprites.sprites.push(ExtractedSprite { entity, color: atlas_sprite.color, transform: *transform,