module
Lapis::Docs::GENERAL::PIPELINE
Overview
Diorite Render Architecture & Zero-Alloc Pipeline
Architecture of Diorite's batch renderer, priority layering, immediate meshes, and zero-allocation memory recycling.
Overview
Diorite uses a decoupled architecture separating procedural command issuance from GPU batch dispatch. Commands submitted through the DSL or generated by nodes are aggregated into thread-safe queues and rendered efficiently using pre-allocated vertex arrays and immediate mesh buffers.
Key Topics
| Topic | Description |
|---|---|
| Visual Priority | 3D items use StandardMaterial3D with render_priority 127 and FlagDisableDepthTest. 2D items render in a dedicated CanvasLayer on layer 128 with z_index 4096. |
| ImmediateMesh Batching | All shapes are generated into unified continuous vertex arrays, dispatching to GPU in single draw calls per pass. |
| Lifetime Management | Commands specify a duration in seconds. Single-frame commands (duration <= 0.0) are consumed immediately; timed commands decay remaining_time until expiration. |
Code Examples
Configuring Render Priority
# Draw with on-top override disabled (obeys standard depth occlusion)
DebugDraw.box_3d(pos, size, Godot::Color.new(1, 1, 0), on_top: false)
Timed Persistence
# Retain hit spark for 0.75 seconds
DebugDraw.ray_hit_3d(origin, hit_point, hit_normal, duration: 0.75_f32)
Pitfalls & Best Practices
- Avoid modifying queue arrays directly; always use DebugDraw public methods to ensure thread safety.
- Reusing vertex buffer memory between frames minimizes garbage collection pressure during continuous telemetry recording.
Frequently Asked Questions
- Q: How many draw calls does Diorite issue per frame?
A: Typically only 2 to 3 draw calls: one for depth-disabled 3D shapes, one for depth-tested 3D shapes, and one for the 2D canvas overlay. - Q: What is the overhead of calling DebugDraw when no shapes are drawn?
A: Essentially zero; empty queues skip ImmediateMesh surface generation entirely.
Defined in:
docs/general/pipeline.crClass Method Summary
-
.example_01_configuring_render_priority : Nil
Example: Configuring Render Priority
-
.example_02_timed_persistence : Nil
Example: Timed Persistence
-
.topic_01_visual_priority : Nil
Visual Priority: 3D items use StandardMaterial3D with render_priority 127 and FlagDisableDepthTest.
-
.topic_02_immediate_mesh_batching : Nil
ImmediateMesh Batching: All shapes are generated into unified continuous vertex arrays, dispatching to GPU in single draw calls per pass.
-
.topic_03_lifetime_management : Nil
Lifetime Management: Commands specify a duration in seconds.
Class Method Detail
Example: Configuring Render Priority
DebugDraw.box_3d(pos, size, Godot::Color.new(1, 1, 0), on_top: false)
Example: Timed Persistence
DebugDraw.ray_hit_3d(origin, hit_point, hit_normal, duration: 0.75_f32)
Visual Priority: 3D items use StandardMaterial3D with render_priority 127 and FlagDisableDepthTest. 2D items render in a dedicated CanvasLayer on layer 128 with z_index 4096.
ImmediateMesh Batching: All shapes are generated into unified continuous vertex arrays, dispatching to GPU in single draw calls per pass.
Lifetime Management: Commands specify a duration in seconds. Single-frame commands (duration <= 0.0) are consumed immediately; timed commands decay remaining_time until expiration.