Expand description
Astrelis Render - Modular rendering framework for Astrelis
This crate provides:
- Graphics context management
- Window rendering contexts
- Frame and render pass management
- Compute pass management
- Framebuffer abstraction for offscreen rendering
- Render target abstraction (Surface/Framebuffer)
- Blend mode presets for common scenarios
- GPU feature detection and management
- Indirect draw buffer support for GPU-driven rendering
- Texture blitting for fullscreen quad rendering
- Sprite sheet support for animations
- Low-level extensible Renderer for WGPU resource management
- Building blocks for higher-level renderers (TextRenderer, SceneRenderer, etc.)
§Error Handling
This crate uses consistent error handling patterns:
§Result Types
- Creation methods return
Result<T, GraphicsError>for GPU initialization- Example:
GraphicsContext::new_owned_sync()returnsResult<Arc<Self>, GraphicsError>
- Example:
- Fallible operations return
Result<T, E>with specific error types- Example:
Readback::read()returnsResult<Vec<u8>, ReadbackError>
- Example:
- Use
.expect()for examples/tests where error handling isn’t critical- Example:
let ctx = GraphicsContext::new_owned_sync().expect("GPU required")
- Example:
§Option Types
- Optional resources return
Option<&T>for possibly-missing values- Example:
WindowManager::get_window(id)returnsOption<&RenderWindow>
- Example:
- Hit testing returns
Option<T>for no-hit scenarios- Example:
hit_test(point)returnsOption<WidgetId>
- Example:
§Panicking vs Fallible
- Avoid panic-suffixed methods - Use
.expect()at call sites instead- ❌ Bad:
resource_or_panic()method - ✅ Good:
resource().expect("Resource required")at call site
- ❌ Bad:
- Provide both variants for common operations
resource()- Panics if unavailable (use when required)try_resource()- ReturnsOption(use when optional)
Re-exports§
pub use capability::GpuRequirements;pub use capability::RenderCapability;pub use transform::DataRangeParams;pub use transform::DataTransform;pub use wgpu;
Modules§
- batched
- Batched deferred indirect renderer.
- capability
- Render capability system for declaring GPU feature/limit requirements.
- gpu_
profiling - GPU profiling via
wgpu-profilerwith puffin visualization. - transform
- Shared data-to-screen coordinate transformation for instanced renderers.
Macros§
- gpu_
profile_ scope - Execute a block of code within a GPU profiling scope on a
Frame.
Structs§
- Atlas
Entry - An entry in the texture atlas.
- Atlas
Key - Unique key for an atlas entry.
- Atlas
Rect - Rectangle for atlas packing (not coordinate-space aware).
- Atomic
Frame Stats - Thread-safe atomic frame statistics.
- Blit
Options - Options for configuring the blit renderer.
- Blit
Renderer - Camera
- A camera with view and projection matrices.
- Camera
Uniform - Camera uniform buffer data for shaders.
- Color
- An RGBA color with
f32components in the0.0..=1.0range. - Compute
Pass - A compute pass wrapper that automatically returns the command buffer to the frame.
- Compute
Pass Builder - Builder for creating compute passes.
- Compute
Pipeline Builder - Builder for creating a compute pipeline with common defaults.
- Depth
Texture - A depth texture with Arc-wrapped view for cheap, lifetime-free sharing.
- Dispatch
Indirect - Indirect dispatch command.
- Draw
Indexed Indirect - Indirect draw command for indexed geometry.
- Draw
Indirect - Indirect draw command for non-indexed geometry.
- Execution
Plan - Execution plan for the render graph.
- Frame
- Context for a single frame of rendering.
- Frame
Stats - Per-frame rendering statistics.
- Framebuffer
- An offscreen render target with optional depth and MSAA attachments.
- Framebuffer
Builder - Builder for creating framebuffers with optional attachments.
- GpuFeatures
- GPU features that can be requested or required.
- GpuProfiler
- GpuReadback
- GPU readback handle for async data retrieval.
- GpuTexture
- A GPU texture with cached view and metadata.
- Graphics
Context - A globally shared graphics context.
- Graphics
Context Descriptor - Descriptor for configuring graphics context creation.
- Indirect
Buffer - A type-safe GPU buffer for indirect draw commands.
- Line
Renderer - Fast batched line renderer using GPU instancing.
- Line
Segment - A line segment for batch rendering.
- Material
- A material manages shader parameters, textures, and pipeline state.
- Material
Builder - Builder for creating materials with a fluent API.
- Material
Texture - Texture binding information for a material.
- Mesh
- A mesh containing vertex and optional index data.
- Mesh
Builder - Builder for creating meshes.
- PassId
- Pass identifier in the render graph.
- Pipeline
State - Pipeline state configuration for a material.
- Point
- A point for batch rendering.
- Point
Renderer - Fast batched point renderer using GPU instancing.
- Profile
Region - A handle to a profiling region.
- Quad
- A quad (axis-aligned rectangle) for batch rendering.
- Quad
Renderer - Fast batched quad renderer using GPU instancing.
- Query
Result Buffer - Buffer for storing and reading query results.
- Query
Set - A wrapper around wgpu::QuerySet with metadata.
- Render
Context - Render context passed to pass execution functions.
- Render
Graph - Render graph managing passes and resources.
- Render
Graph Pass - A render pass in the graph.
- Render
Pass - A render pass that owns its encoder.
- Render
Pass Builder - Builder for creating render passes with fluent API.
- Render
Pipeline Builder - Builder for creating a render pipeline with sensible defaults.
- Render
Window - A renderable window that combines a winit
Windowwith aWindowContext. - Render
Window Builder - Builder for configuring a
RenderWindow. - Renderer
- Low-level extensible renderer that simplifies WGPU resource management.
- Resource
Id - Resource identifier in the render graph.
- Resource
Info - Resource information in the render graph.
- Ring
Buffer - A ring buffer for streaming per-frame data.
- Ring
Buffer Allocation - A region allocated from a ring buffer.
- Sampler
Cache - A thread-safe cache of GPU samplers.
- Sampler
Key - A hashable key for sampler descriptors.
- Sprite
Animation - Animation state for cycling through sprite sheet frames.
- Sprite
Sheet - A sprite sheet containing uniformly-sized sprites in a grid layout.
- Sprite
Sheet Descriptor - Descriptor for creating a sprite sheet.
- SpriteUV
- UV coordinates for a sprite (normalized 0-1 range).
- Staging
Buffer - A staging buffer for CPU-to-GPU transfers.
- Staging
Buffer Pool - A pool of staging buffers for reuse.
- Storage
Texture - A texture for compute shader read/write access.
- Surface
- The acquired surface texture and its view for the current frame.
- Texture
Atlas - Texture atlas with dynamic rectangle packing.
- Texture
Uploader - Helper to upload texture data from CPU to GPU.
- Typed
Buffer - A GPU buffer with type-safe element tracking.
- Viewport
- Viewport definition for rendering.
- Window
Context - Manages a wgpu
Surfaceand its configuration for a single window. - Window
Context Descriptor - Descriptor for configuring a window’s rendering context.
- Window
Manager - Manages multiple renderable windows with automatic event handling.
Enums§
- Blend
Mode - Predefined blend modes for common use cases.
- ClearOp
- Clear operation for a render pass.
- ColorOp
- Color operation for render pass.
- Color
Target - Target for color attachment in render passes.
- Depth
Clear Op - Depth clear operation for a render pass.
- Depth
Config - Configuration for how to handle depth in a render pass.
- DepthOp
- Depth operation for render pass.
- Feature
Support Result - Result of checking feature support.
- Graphics
Error - Errors that can occur during graphics context creation.
- Image
Sampling - Sampling mode for image textures.
- Material
Parameter - A material parameter value that can be bound to a shader.
- Projection
Mode - Projection mode for a camera.
- Query
Type - Types of GPU queries.
- Readback
Error - GPU readback error.
- Render
Graph Error - Render graph error.
- Render
Target - A render target that can be either a window surface or an offscreen framebuffer.
- Resource
Type - Resource type in the render graph.
- Storage
Texture Access - Access mode for storage textures in compute shaders.
- Vertex
Format - Vertex format specification.
Constants§
- DEFAULT_
DEPTH_ FORMAT - Default depth format used for depth textures.
- DEPTH_
FORMAT - Depth format used by framebuffers.
Traits§
- AsWgpu
- Access the underlying wgpu type (immutable).
- AsWgpu
Mut - Access the underlying wgpu type (mutable).
- Indirect
Command - Marker trait for indirect draw command types.
- Into
Wgpu - Consume and return the underlying wgpu type.
- Readback
Ext - Extension trait for convenient screenshot capture.
- Render
Pass Indirect Ext - Extension trait for render passes to use indirect buffers.
- Render
Pass Multi Draw Indirect Ext - Extension trait for multi-draw indirect operations.
Type Aliases§
- Uniform
Buffer - A uniform buffer for shader uniforms.