Skip to main content

build_material

Function build_material 

Source
pub fn build_material(
    backend: &WGPUBackend,
    desc: &Material,
    pool: &GlobalLayoutPool,
) -> Option<(RenderPipeline, BindGroupLayout)>
Expand description

Builds a render pipeline and its own bind group layout from desc.

Returns None — not a panic — if desc.entries contains a GroupEntry::Global not yet registered in pool; the caller (GPUMaterial::upload) treats that exactly like any other unmet Deps and retries next tick.

Panics if the one GroupEntry::Own in desc.entries (if any) is visible to the compute stage — BindingKind is shared with Compute, and this is the check that catches a compute-only entry accidentally reused in a material instead of letting it fail deep inside wgpu with a less specific error. The bind group layout itself comes from binding::BindGroupLayoutBuilder. The pipeline layout is assembled directly from desc.entries, in order — position is the @group(N) index — panicking if desc.entries contains more than one GroupEntry::Own, or needs more bind groups than the device’s max_bind_groups allows, turning either mistake into an immediate, specific error instead of an opaque wgpu validation failure at draw time.