Drop the manual extent overrides in favor of the derivation

This commit is contained in:
Dennis Kobert
2026-08-22 15:55:49 +00:00
parent 0b2aa3798a
commit c0f50d41d7
6 changed files with 43 additions and 35 deletions

View File

@@ -1,10 +1,9 @@
use core_types::context::{ContextModification, Ctx, DeriveCtx};
use core_types::extent::{ExtentIn, LevelIn, ValueIn};
use core_types::gpoll::{Extent, GPoll, Interrupt};
use core_types::gpoll::Interrupt;
/// Filters out what should be unused components of the context based on the specified requirements.
/// This node is inserted by the compiler to "zero out" unused context components.
#[node_macro::node(category(""), extent(context_modification_extent))]
#[node_macro::node(category(""))]
fn context_modification<T>(
ctx: impl Ctx + DeriveCtx,
/// The data to pass through, evaluated with the stripped down context.
@@ -15,7 +14,3 @@ fn context_modification<T>(
let scope = ctx.scope().nullified(modification.features, Some(modification.sources()));
value.eval(&ctx.nullified(modification.features, &scope))
}
fn context_modification_extent(value: ExtentIn<'_>, _modification: ValueIn<'_, ContextModification>, level: LevelIn) -> GPoll<Extent> {
value.at(level)
}

View File

@@ -1,5 +1,4 @@
use core_types::Ctx;
use core_types::list::List;
use glam::{DAffine2, DVec2};
use raster_types::{CPU, Raster};

View File

@@ -1,8 +1,7 @@
use core_types::arena::ArenaCell;
use core_types::context::{Ctx, CtxSnapshot, DeriveCtx, ExtractAll, InjectIndex};
use core_types::extent::{ExtentIn, LevelIn};
use core_types::frame_table::{FrameTable, Lookup};
use core_types::gpoll::{Extent, Finality, GPoll};
use core_types::gpoll::{Finality, GPoll};
use core_types::graphene_hash::CacheHash;
use core_types::memo::IORecord;
use core_types::record::{LevelStatus, OwnedRecord, RecordCapture, RecordValue, copy_record_bytes, record_from_bytes};
@@ -13,7 +12,7 @@ use std::sync::Mutex;
/// Helps speed up repeated renders in a computationally-heavy part of the node graph.
///
/// Stores a deep copy of the last record that flowed through this node and replays it on subsequent renders if the context has not changed.
#[node_macro::node(category("General"), path(graphene_core::memo), extent(memoize_extent))]
#[node_macro::node(category("General"), path(graphene_core::memo))]
fn memoize<'e>(
ctx: impl Ctx + CacheHash + ExtractArena<'e>,
#[data] cache: Arc<Mutex<Option<(u64, OwnedRecord, Finality)>>>,
@@ -45,11 +44,7 @@ fn memoize<'e>(
result
}
fn memoize_extent(content: ExtentIn<'_>, level: LevelIn) -> GPoll<Extent> {
content.at(level)
}
#[node_macro::node(category(""), path(graphene_core::memo), extent(frame_memo_extent))]
#[node_macro::node(category(""), path(graphene_core::memo))]
fn frame_memo<'e>(
ctx: impl Ctx + CacheHash + ExtractArena<'e>,
#[data] cell: ArenaCell<FrameTable<Box<[u8]>, 32>>,
@@ -92,14 +87,10 @@ fn frame_memo<'e>(
}
}
fn frame_memo_extent(content: ExtentIn<'_>, level: LevelIn) -> GPoll<Extent> {
content.at(level)
}
type MonitorValue = Arc<Mutex<Option<IORecord<CtxSnapshot, RecordCapture>>>>;
/// The Monitor node is used by the editor to access the data flowing through it.
#[node_macro::node(category(""), path(graphene_core::memo), serialize(serialize_monitor), properties("monitor_properties"), extent(monitor_extent))]
#[node_macro::node(category(""), path(graphene_core::memo), serialize(serialize_monitor), properties("monitor_properties"))]
fn monitor<'e>(
ctx: impl Ctx + DeriveCtx + ExtractAll + ExtractArena<'e> + InjectIndex + Copy,
#[data] io: MonitorValue,
@@ -126,10 +117,6 @@ fn monitor<'e>(
result
}
fn monitor_extent(content: ExtentIn<'_>, level: LevelIn) -> GPoll<Extent> {
content.at(level)
}
fn serialize_monitor(io: &MonitorValue) -> Option<Arc<dyn std::any::Any + Send + Sync>> {
let io = io.lock().unwrap();
io.as_ref().map(|io| Arc::new(io.clone()) as Arc<dyn std::any::Any + Send + Sync>)

View File

@@ -4,15 +4,11 @@ use core_types::{Ctx, ops::Convert, ops::ConvertAsync, transform::Footprint};
use std::marker::PhantomData;
/// Passes-through the input value without changing it. This is useful for rerouting wires for organization purposes.
#[node_macro::node(category("General"), skip_impl, extent(passthrough_extent))]
#[node_macro::node(category("General"), skip_impl)]
fn passthrough<T: Send>(_: impl Ctx, content: T) -> T {
content
}
fn passthrough_extent(content: core_types::extent::ExtentIn<'_>, level: core_types::extent::LevelIn) -> core_types::gpoll::GPoll<core_types::gpoll::Extent> {
content.at(level)
}
#[node_macro::node(category(""), skip_impl)]
fn into<T: Send + Into<O>, O: Send>(_: impl Ctx, value: T, #[data] _out_ty: PhantomData<O>) -> O {
value.into()