Skip to main content

GpuComputeLayoutEngine

Struct GpuComputeLayoutEngine 

Source
pub struct GpuComputeLayoutEngine { /* private fields */ }
Expand description

Persistent GPU compute layout and zero-readback indirect draw engine supporting Apple Metal hardware and bit-exact CPU parity.

Implementations§

Source§

impl GpuComputeLayoutEngine

Hardware initialization, persistent buffer management, and compute layout dispatch for GpuComputeLayoutEngine.

Source

pub fn probe() -> GpuComputeLayoutEngine

Probes physical Apple Metal compute pipelines when available, falling back cleanly to CPU reference parity.

§Returns
  • Self - Ready compute layout engine.
Source

pub fn cpu_reference_only() -> GpuComputeLayoutEngine

Creates a deterministic CPU reference compute parity engine that never invokes hardware GPU APIs.

§Returns
  • Self - CPU reference parity compute engine.
Source

pub fn is_hardware_compute_ready(&self) -> bool

Returns true when physical GPU compute pipelines are compiled and ready for dispatch.

§Returns
  • bool - true when executing on physical hardware compute pipelines.
Source

pub fn dispatch( &mut self, scene: &GpuComputeSceneInput, render_offscreen: bool, ) -> GpuComputeDispatchResult

Executes the 4-kernel GPU compute layout pipeline and optionally renders compacted primitives via indirect draw into an offscreen target.

§Arguments
  • &GpuComputeSceneInput - Flat BFS layout inputs, styles, and level offsets.
  • bool - When true, also executes hardware drawPrimitives:indirectBuffer: into an offscreen MTLTexture.
§Returns
  • GpuComputeDispatchResult - Resolved layout outputs, compacted primitives, indirect draw args, hit-test result, and GPU timing telemetry.
Source

pub fn dispatch_steady_indirect( &mut self, scene: &GpuComputeSceneInput, render_offscreen: bool, upload_buffers: bool, ) -> GpuComputeDispatchResult

Executes the steady-state zero-readback GPU compute layout and indirect render pipeline without copying outputs, primitives, or offscreen pixels back to CPU memory.

§Arguments
  • &GpuComputeSceneInput - Flat BFS scene descriptors (only root and uniform update when upload_buffers is false).
  • bool - When true, encodes hardware drawPrimitives:indirectBuffer: into the offscreen MTLTexture.
  • bool - When true, uploads full node and visual buffers; when false, reuses resident GPU buffers and updates only root + uniforms.
§Returns
  • GpuComputeDispatchResult - Hardware GPU timing, draw count, and indirect args with zero CPU readback allocations.
Source

pub fn begin_steady_indirect_async( &mut self, scene: &GpuComputeSceneInput, render_offscreen: bool, upload_buffers: bool, ) -> Option<(usize, usize, usize)>

Commits a zero-readback GPU compute layout and optional indirect render command buffer asynchronously so CPU worker threads can overlap concurrently (MixedCoExec).

§Arguments
  • &GpuComputeSceneInput - Flat BFS scene descriptors.
  • bool - When true, also encodes hardware drawPrimitives:indirectBuffer: into the offscreen MTLTexture.
  • bool - When true, uploads full node and visual buffers; when false, reuses resident GPU memory.
§Returns
  • Option<(usize, usize, usize)> - Retained in-flight command buffer tuple (cmd_buf_handle, draw_calls, uploaded_bytes) when submitted on hardware GPU, or None on CPU fallback.
Source

pub fn finish_steady_indirect_async( &mut self, in_flight: (usize, usize, usize), ) -> GpuComputeDispatchResult

Awaits completion of a command buffer previously committed by begin_steady_indirect_async and returns exact hardware GPU execution telemetry.

§Arguments
  • (usize, usize, usize) - In-flight tuple (cmd_buf_handle, draw_calls, uploaded_bytes) returned by begin_steady_indirect_async.
§Returns
  • GpuComputeDispatchResult - Hardware GPU execution duration, draw calls, and indirect draw arguments.
Source

pub fn upload_primitive_spans_metal( &mut self, primitives: &[GpuPrimitiveInstance], spans: &[DirtyBufferSpan], slot: usize, wait_sync: bool, ) -> Option<(usize, u64)>

Uploads coalesced DirtyBufferSpan byte ranges from primitives into a GPU-private MTLBuffer via a real Metal MTLBlitCommandEncoder, supporting both in_flight = 1 synchronous and in_flight = 2 ping-pong asynchronous pipelining.

§Arguments
  • &[GpuPrimitiveInstance] - Source frame primitive array (64 bytes per entry).
  • &[DirtyBufferSpan] - Coalesced dirty byte ranges produced by DirtySpanCoalescer.
  • usize - Ping-pong staging slot index (0 or 1).
  • bool - When true, blocks on waitUntilCompleted (in_flight = 1); when false, returns the retained command buffer for finish_upload_metal (in_flight = 2).
§Returns
  • Option<(usize, u64)> - Tuple (retained_cmd_buf_or_zero, gpu_exec_ns) on hardware Metal, or None on CPU fallback.
Source

pub fn finish_upload_metal(&self, cmd_handle: usize) -> u64

Awaits completion of an asynchronous Metal dirty-span blit command buffer returned by upload_primitive_spans_metal, returning hardware GPU execution nanoseconds.

§Arguments
  • usize - Retained id<MTLCommandBuffer> handle (0 is a no-op).
§Returns
  • u64 - Hardware GPU execution duration in nanoseconds.
Source§

impl GpuComputeLayoutEngine

Trait Implementations§

Source§

impl Debug for GpuComputeLayoutEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for GpuComputeLayoutEngine

Default initialization probing native hardware compute support with automatic CPU reference parity fallback.

Source§

fn default() -> GpuComputeLayoutEngine

Probes the active host for hardware compute pipelines and creates a ready GpuComputeLayoutEngine.

§Returns
  • Self - Initialized GPU compute layout engine.
Source§

impl Drop for GpuComputeLayoutEngine

Releases retained native Metal compute buffers and offscreen render textures cleanly on drop.

Source§

fn drop(&mut self)

Releases all retained GPU compute buffers, offscreen textures, queue, and device handles.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.