tessera_ui/renderer/compute.rs
1//! A unified system for GPU-based computation.
2//!
3//! This module provides a structured way to define and dispatch compute shaders
4//! as part of a sequential rendering and computation workflow. It integrates
5//! seamlessly with the unified command system to enable mixed graphics and
6//! compute workloads.
7//!
8//! # Key Components
9//!
10//! * [`ComputeCommand`]: A trait marking a command as a compute operation with
11//! optional barrier support.
12//! * [`ComputablePipeline`]: A trait for a specific compute task that processes
13//! a command within a `wgpu::ComputePass`.
14//! * [`ComputePipelineRegistry`]: The central dispatcher that manages all
15//! registered pipelines.
16//!
17//! # Workflow
18//!
19//! 1. **Define a Command:** Create a struct that implements `ComputeCommand`.
20//! 2. **Implement a Pipeline:** Create a struct that implements
21//! `ComputablePipeline<YourCommand>`. This involves setting up the
22//! `wgpu::ComputePipeline` and defining the `dispatch` method.
23//! 3. **Register the Pipeline:** During application startup, register an
24//! instance of your pipeline with the `ComputePipelineRegistry`.
25//! 4. **Submit Commands:** Components submit `ComputeCommand`s, which are then
26//! dispatched by the renderer to the appropriate pipeline through the
27//! unified command system.
28//!
29//! # Barrier Support
30//!
31//! Compute commands can specify barrier requirements to ensure proper
32//! synchronization with previous rendering operations, enabling post-processing
33//! effects and multi-pass algorithms.
34
35pub mod command;
36pub mod pipeline;
37pub mod resource;
38
39pub use command::ComputeCommand;
40pub use pipeline::{
41 ComputablePipeline, ComputeBatchItem, ComputePipelineRegistry, ErasedComputeBatchItem,
42};
43pub use resource::{ComputeResource, ComputeResourceManager, ComputeResourceRef};