mod generic_skybox;
pub use generic_skybox::{GenericSkyboxDrawData, GenericSkyboxType};
mod lines;
pub use lines::{LineBatchInfo, LineDrawData, LineDrawDataError, LineStripFlags};
mod point_cloud;
pub use point_cloud::{
PointCloudBatchFlags, PointCloudBatchInfo, PointCloudDrawData, PointCloudDrawDataError,
};
mod depth_cloud;
pub use self::depth_cloud::{DepthCloud, DepthCloudDrawData, DepthCloudRenderer, DepthClouds};
mod test_triangle;
pub use test_triangle::TestTriangleDrawData;
mod rectangles;
pub use rectangles::{
ColorMapper, ColormappedTexture, RectangleDrawData, RectangleOptions, ShaderDecoding,
TextureFilterMag, TextureFilterMin, TexturedRect,
};
mod mesh_renderer;
pub(crate) use mesh_renderer::MeshRenderer;
pub use mesh_renderer::{GpuMeshInstance, MeshDrawData};
mod compositor;
pub(crate) use compositor::CompositorDrawData;
mod debug_overlay;
pub use debug_overlay::{DebugOverlayDrawData, DebugOverlayError, DebugOverlayRenderer};
pub mod gpu_data {
pub use super::lines::gpu_data::{LineStripInfo, LineVertex};
pub use super::point_cloud::gpu_data::PositionRadius;
}
use crate::{
context::RenderContext,
draw_phases::DrawPhase,
include_shader_module,
wgpu_resources::{GpuRenderPipelinePoolAccessor, PoolError},
};
pub trait DrawData {
type Renderer: Renderer<RendererDrawData = Self> + Send + Sync;
}
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
pub enum DrawError {
#[error(transparent)]
Pool(#[from] PoolError),
}
pub trait Renderer {
type RendererDrawData: DrawData;
fn create_renderer(ctx: &RenderContext) -> Self;
fn draw(
&self,
render_pipelines: &GpuRenderPipelinePoolAccessor<'_>,
phase: DrawPhase,
pass: &mut wgpu::RenderPass<'_>,
draw_data: &Self::RendererDrawData,
) -> Result<(), DrawError>;
fn participated_phases() -> &'static [DrawPhase];
}
pub fn screen_triangle_vertex_shader(
ctx: &RenderContext,
) -> crate::wgpu_resources::GpuShaderModuleHandle {
ctx.gpu_resources.shader_modules.get_or_create(
ctx,
&include_shader_module!("../../shader/screen_triangle.wgsl"),
)
}