core: span allocation with shared free list and geometric growth
Amp-Thread-ID: https://ampcode.com/threads/T-01a0b2dd-db32-712d-99ce-12ce4a86d979 Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
+22
-2
@@ -1,28 +1,46 @@
|
||||
//! The arena and allocator compile natively for `cargo test`; everything touching WebGPU is wasm-only.
|
||||
#![cfg_attr(not(target_arch = "wasm32"), allow(dead_code))]
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use std::cell::RefCell;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use std::rc::Rc;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use serde::Deserialize;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[path = "render_graph/compiler.rs"]
|
||||
mod compiler;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[path = "renderer/wgpu.rs"]
|
||||
mod gpu;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[path = "render_graph/gpu_resource.rs"]
|
||||
mod gpu_resource;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[path = "render_graph/render_graph.rs"]
|
||||
mod graph;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[path = "renderer/render.rs"]
|
||||
mod render;
|
||||
mod render_data;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[path = "render_graph/store.rs"]
|
||||
mod store;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use gpu::Wgpu;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use render::RenderLoop;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use render_data::RenderData;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use store::Store;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[derive(Deserialize)]
|
||||
struct RowRequest {
|
||||
name: String,
|
||||
@@ -31,6 +49,7 @@ struct RowRequest {
|
||||
format: String,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[wasm_bindgen]
|
||||
pub struct Core {
|
||||
data: Rc<RefCell<RenderData>>,
|
||||
@@ -39,6 +58,7 @@ pub struct Core {
|
||||
render: Rc<RenderLoop>,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[wasm_bindgen]
|
||||
impl Core {
|
||||
#[wasm_bindgen(constructor)]
|
||||
@@ -128,11 +148,11 @@ impl Core {
|
||||
.map_err(JsError::new)
|
||||
}
|
||||
|
||||
pub fn allocate_object(&self, name: &str) -> Result<String, JsError> {
|
||||
pub fn allocate_object(&self, name: &str, count: u32) -> Result<String, JsError> {
|
||||
let (id, grew) = self
|
||||
.data
|
||||
.borrow_mut()
|
||||
.allocate_object(name)
|
||||
.allocate_object(name, count)
|
||||
.map_err(JsError::new)?;
|
||||
let rows = self
|
||||
.data
|
||||
|
||||
Reference in New Issue
Block a user