[][src]Crate web_glitz

WebGlitz is a low level graphics framework for the web build on top of WebGL 2 through wasm-bindgen. It intends to be easier to use by providing a more declarative interface (as opposed to WebGL's very procedural and stateful interface) that is memory safe and does not expose undefined behaviour.

Execution model

WebGlitz uses a stateless computation-as-data model, where rather than calling functions that directly cause an effect, you instead construct "task" values. Only when this task is submitted will it produce its effects. See the documentation for the task module for details on how tasks are constructed by combining commands and on how tasks are submitted to a runtime.

Runtimes

WebGlitz currently only implements a single threaded runtime, see runtime::single_threaded. With this runtime, tasks may only be submitted from the same thread as the thread in which the runtime was initialized. Submitting a task to the single threaded runtime typically does not result in dynamic dispatch (unless the task involves waiting on a GPU fence), which should mostly make the task model a zero/low cost abstraction when used with this runtime.

The task model should also make is possible to implement a thread-safe runtime, where tasks may also be submitted from other threads/(web-)workers. This is currently not yet implemented pending further details on WASM threads/workers and their implementation in wasm-bindgen. Submitting a task to this runtime will always involve dynamic dispatch, which may impose a (slight) performance cost on a task. However, it may also allow you to spread the work involved in task construction across multiple threads. How this trade-off affects overall performance will depend on your application.

Modules

buffer
derive
image

This module provides data types and traits for the allocation and manipulation of GPU-accessible image data.

pipeline
render_pass
render_target

A render pass (see render_pass) needs a render target: zero or more color images and zero or one depth-stencil image (see also image) into which the output of the render pass may be stored when the render pass completes. These images are said to be "attached" to the render target and are referred to as the "attached images" or simply the "attachments".

runtime

WebGlitz currently only provides a single threaded runtime that can run on the main WASM thread, see the documentation for the [single_threaded] module for details.

sampler
std140

This module contains types that may be used to define Rust struct types that match the std140 memory layout.

task

WebGlitz's execution model centers around the concepts of "tasks" and "commands". A "task" is a unit of work that is to be executed on a graphical processing unit (GPU). A "command" is an atomic task; a task may composed of multiple commands. There is not a specific type that represents a command in this library, both tasks and commands are represented by the [GpuTask] trait. The term "command" is only used by convention for the atomic task building blocks provided by WebGlitz that you may combine into more complex tasks.