Skip to main content

Module line_shader

Module line_shader 

Source
Expand description

The caller’s own shader code, spliced into the built-in line.wesl.

The built-in entry shader keeps three marks, each a comment naming the place it sits: one at module scope, one at the end of the vertex stage and one at the end of the fragment stage. A shader is spliced in at those marks while the module is still WESL, before anything is compiled, so each snippet is ordinary WESL: it sees every binding, flag and helper the place it lands in sees, it takes part in the conditional compilation, and its diagnostics point at the line it was written on rather than at a fragment of generated WGSL.

The marks sit where the stages still have something left to do, which is what keeps a snippet short:

  • The module mark is after every built-in binding and helper, so a snippet can declare the functions, types and constants the stages call.
  • The vertex mark is after the quad corner is built, before it is returned. The output is a var out there, so a snippet can rewrite any varying — the coverage color among them — in place.
  • The fragment mark is after the coverage is applied to the colour, before the hard-edge cut and the return. The colour is a var color there, so a snippet can rewrite it in place, and what it leaves is what the target receives — a snippet of its own may return instead, which is how a caller replaces the shading the stroke ends with.

The layouts, the instance record and the entry-point names stay the variant’s, exactly as they are for the built-in shader: a snippet changes what a stage computes, not what the pipeline reads. A snippet that declares a binding of its own therefore fails pipeline creation rather than drawing something else; one that declares functions, types or constants over the bindings every variant already declares works.

The label names the shader: it is the shader module’s label, and a composition error is reported under it.

Re-exports§

use std::sync::Arc; 🔒
use crate::specialize::PipelineDescriptor; 🔒
use crate::specialize::SurfaceTarget; 🔒

Structs§

LineOptions
The policy a caller decides about a built-in line pipeline.
LineShader
A caller’s own shader code, spliced into the built-in line.wesl.
LineVariant
The pipeline variant a line draw resolves to.

Constants§

SEGMENT_STRIDE
The byte width of one instance the line pipeline reads: the sum of the attribute sizes below.

Functions§

pipeline 🔒
The pipeline a line variant draws with.
segment_layout
The instance-step layout a line pipeline reads its segment records through.