Skip to main content

Module gpu

Module gpu 

Source
Expand description

GPU-side data layouts the strip shaders read.

Every type in this module is byte-compatible with the sparse-strip reference renderer’s own layouts, so the ported WGSL reads them unchanged. Layout drift is a silent mis-render rather than a compile error, so each struct carries a compile-time size assertion beside it and the integration tests pin the exact bytes.

Nothing here touches a wgpu::Device: sizing, addressing and packing are pure functions over plain values, host-testable with no GPU in the loop — the same pure-decision split frust-gpu follows. The one live-GPU input these functions need is frust_gpu::TierCaps::resource_texture_dim, which the caller passes in as a plain u32.

Two resource textures are described here, both Rgba32Uint:

  1. the alpha texture, holding the strip renderer’s 1-byte coverage values 16 to a texel (4 per channel), and
  2. the encoded-paint texture (paint_texture), holding 16-byte-aligned paint records back to back.

Both are sized resource_texture_dim texels wide so the shader can turn a flat index into a texel coordinate with a shift, and both grow in height only — never shrink — up to the same dimension, past which the frame path returns an error instead of asserting.

Re-exports§

pub use atlas::ATLAS_FORMAT;
pub use atlas::ATLAS_USAGES;
pub use atlas::AtlasArray;
pub use atlas::lower_encoded_image;
pub use bindings::ExternalRuns;
pub use bindings::ExternalTextures;
pub use bindings::lower_encoded_external;
pub use config::GpuConfig;
pub use config::tex_width_bits;
pub use depth::DepthAttachment;
pub use depth::DepthTexture;
pub use paint_texture::GpuBlurredRoundedRect;
pub use paint_texture::GpuEncodedImage;
pub use paint_texture::GpuEncodedPaint;
pub use paint_texture::GpuLinearGradient;
pub use paint_texture::GpuRadialGradient;
pub use paint_texture::GpuSweepGradient;
pub use pipelines::EnginePipeline;
pub use pipelines::EngineShaderModule;
pub use pipelines::EngineShaders;
pub use strips::GpuStrip;
pub use strips::StripDraw;
pub use targets::IntermediateTargets;
pub use targets::IntermediateTexture;

Modules§

atlas
The image atlas array, and the encoded-image record the strip shader reads it through.
bindings
The registry of caller-owned textures a frame’s strip passes sample, and the per-frame batching that binds each of them in turn.
config
The Config uniform every strip shader binds.
depth
The depth attachment the opaque strip pass establishes and the alpha pass tests against.
paint_texture
The encoded-paint records the fragment shader samples, and the Rgba32Uint texture they are serialized into.
pipelines
The nine render pipelines the engine draws with, as plain values.
present
The present pass: the engine’s premultiplied frame, converted for a swapchain that stores STRAIGHT alpha.
shader_src
The engine’s WGSL sources, assembled at compile time.
strips
The strip instance the vertex shader steps over, and the conversion into it from a rasterized Strip.
targets
The per-renderer pool the engine draws its off-screen intermediates from.

Structs§

AlphaAddress
Where one alpha value lives in an alpha texture: its texel, the channel within that texel, and the byte within that channel.

Constants§

ALPHAS_PER_CHANNEL
1-byte alpha values packed into one texel channel.
ALPHAS_PER_TEXEL
1-byte alpha values packed into one texel.
MIN_RESOURCE_TEXTURE_HEIGHT
The height a resource texture starts at, before any content forces it to grow.
RESOURCE_TEXTURE_FORMAT
The texture format both resource textures (alphas, encoded paints) use.
RESOURCE_TEXTURE_USAGES
The usages both resource textures are created with: sampled by the strip shaders, written by a queue upload, never a render attachment.
TEXEL_BYTES
Bytes in one Rgba32Uint texel: four channels of four bytes.
TEXEL_BYTES_SHIFT
log2 of TEXEL_BYTES, so a byte count is a shift away from a texel count (the shader does the same, since a downlevel target has no firstTrailingBit).

Functions§

alpha_address
The address of alpha value alpha_idx in an alpha texture width texels wide.
alpha_texture_descriptor
The descriptor for an alpha texture of width x height texels.
alpha_texture_height
The alpha-texture height needed to hold alphas_len coverage bytes in a texture resource_texture_dim texels wide.
grow_alpha_texture_height
The height an alpha texture currently current_height tall must be recreated at to hold alphas_len coverage bytes, or None when the existing texture already fits.
resource_bytes_per_row
The bytes_per_row of a resource texture width texels wide.
resource_texture_bytes
The total byte footprint of a resource texture of width x height texels — the size an upload buffer is padded to.
resource_texture_descriptor
A resource-texture descriptor: Rgba32Uint, single mip, single sample, sampled-and-uploadable.
with_padded_alphas
Runs upload over alphas padded with zeroes to the full byte footprint of a width x height alpha texture, then truncates it back to its original length.