Spatialize
GPU rendering infrastructure for Vantle
This document describes the Spatialize system, a GPU rendering infrastructure built on wgpu.
Context
The render context manages GPU resources and pipeline state.
Assembler
Build a rendering context with the assembler pattern:
let renderer = pollster::block_on(render::Assembler::new()
.surface(surface)
.adapter(adapter)
.size(size.width, size.height)
.assemble())?;
| Field | Description |
|---|---|
surface
|
wgpu surface for presentation |
adapter
|
wgpu adapter for device creation |
size
|
Initial viewport dimensions |
Pipelines
Build GPU pipelines with the raster and compute assemblers:
let shader = Raster::assembler()
.shader(SHADER)
.vertex(Vertex::layout())
.bind(0, Binding::uniform(wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT))
.target(format, Some(wgpu::BlendState::ALPHA_BLENDING))
.target(wgpu::TextureFormat::Rg8Unorm, None)
.depth(wgpu::TextureFormat::Depth32Float, true, wgpu::CompareFunction::Less)
.cull(wgpu::Face::Back)
.assemble(device)?;