Skip to main content

GpuConfig

Struct GpuConfig 

Source
#[repr(C, align(16))]
pub struct GpuConfig { pub width: u32, pub height: u32, pub strip_height: u32, pub alphas_tex_width_bits: u32, pub encoded_paints_tex_width_bits: u32, pub strip_offset_x: i32, pub strip_offset_y: i32, pub negate_ndc: u32, }
Expand description

The uniform block the strip shaders read once per draw.

Laid out to match the reference renderer’s Config byte for byte: eight 4-byte scalars in a 16-byte-aligned block.

Fields§

§width: u32

Width of the render target in pixels.

§height: u32

Height of the render target in pixels.

§strip_height: u32

Height of one strip in pixels — always Tile::HEIGHT.

§alphas_tex_width_bits: u32

log2 of the alpha texture’s width in texels.

Pre-computed on the CPU because a downlevel (GLES 3.0 / WebGL2) target has no firstTrailingBit; the shader shifts by this instead of dividing.

§encoded_paints_tex_width_bits: u32

log2 of the encoded-paint texture’s width in texels, pre-computed for the same reason as Self::alphas_tex_width_bits.

§strip_offset_x: i32

Horizontal offset applied to every strip, in pixels.

§strip_offset_y: i32

Vertical offset applied to every strip, in pixels.

§negate_ndc: u32

Whether the shader negates the y component of its NDC position (non-zero) or leaves it alone (zero).

Kept for a future GLSL/WebGL backend: transpiling WGSL to GLSL applies a y-flip to reconcile WebGPU’s y-down clip space with a WebGL framebuffer’s y-up one. Rendering straight into a caller-provided framebuffer wants that flip undone rather than a second framebuffer allocated and blitted, and the rest of the strip pipeline (slot textures included) assumes y-down throughout. Every backend this crate drives today leaves it zero.

Implementations§

Source§

impl GpuConfig

Source

pub const SIZE: u64

The uniform’s size in bytes, for a buffer binding’s min_binding_size.

Source

pub fn new( width: u32, height: u32, alphas_tex_width: u32, encoded_paints_tex_width: u32, ) -> Self

A config for a width x height target sampling resource textures alphas_tex_width and encoded_paints_tex_width texels wide, with no strip offset and no NDC negation.

Both texture widths must be powers of two: the shader reconstructs them as 1 << bits (see tex_width_bits).

Source

pub const fn with_strip_offset(self, x: i32, y: i32) -> Self

The same config with strips offset by (x, y) pixels.

Source

pub const fn with_negate_ndc(self, negate: bool) -> Self

The same config with NDC y negation switched on or off (Self::negate_ndc).

Trait Implementations§

Source§

impl Clone for GpuConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for GpuConfig

Source§

impl Debug for GpuConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Pod for GpuConfig

Source§

impl Zeroable for GpuConfig

Source§

fn zeroed() -> Self

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,