Trait kas_wgpu::draw::CustomPipe[][src]

pub trait CustomPipe: 'static {
    type Window: CustomWindow;
    fn new_window(&self, device: &Device) -> Self::Window;

    fn resize(
        &self,
        window: &mut Self::Window,
        device: &Device,
        queue: &Queue,
        size: Size
    ) { ... }
fn prepare(
        &self,
        window: &mut Self::Window,
        device: &Device,
        staging_belt: &mut StagingBelt,
        encoder: &mut CommandEncoder
    ) { ... }
fn render_pass<'a>(
        &'a self,
        window: &'a mut Self::Window,
        device: &Device,
        pass: usize,
        rpass: &mut RenderPass<'a>,
        bg_common: &'a BindGroup
    ) { ... }
fn render_final<'a>(
        &'a self,
        window: &'a mut Self::Window,
        device: &Device,
        encoder: &mut CommandEncoder,
        frame_view: &TextureView,
        size: Size
    ) { ... } }
Expand description

A custom draw pipe

A “draw pipe” consists of draw primitives (usually triangles), resources (textures), shaders, and pipe configuration (e.g. blending mode). A custom pipe allows direct use of the WebGPU graphics stack.

To use this, pass the corresponding CustomPipeBuilder to crate::Toolkit::new_custom.

Note that kas-wgpu accepts only a single custom pipe. To use more than one custom graphics pipeline, you must implement your own multiplexer.

Associated Types

Associated per-window state for the custom pipe

Required methods

Construct a window associated with this pipeline

Note: Self::resize will be called before usage.

Provided methods

Called whenever the window is resized

Per-frame updates

This is called once per frame before rendering operations, and may for example be used to prepare uniform and buffers.

This method is optional; by default it does nothing.

Render (pass)

Each item drawn is associated with a clip region, and each of these with a pass. This method will be called once for each clip region in use (possibly also for other clip regions). Drawing uses an existing texture and occurs after most other draw operations, but before text.

The “common” bind group supplies window scaling and theme lighting information may optionally be set (see CustomPipeBuilder::build).

This method is optional; by default it does nothing.

Render (final)

This method is the last step in drawing a frame except for text rendering. Depending on the application, it may make more sense to draw in CustomPipe::render_pass or in this method.

This method is optional; by default it does nothing.

Implementations on Foreign Types

A dummy implementation (does nothing)

Implementors