Skip to content

Documentation / device / PBShaderExp

Class: PBShaderExp

Defined in: libs/device/src/builder/base.ts:148

Base class for a expression in the shader

Extends

Indexable

[name: string]: any

Accessors

$thisProxy

Get Signature

get $thisProxy(): T

Defined in: libs/device/src/builder/base.ts:133

Returns

T

Inherited from

Proxiable.$thisProxy


$group

Get Signature

get $group(): number

Defined in: libs/device/src/builder/base.ts:229

Returns

number

Set Signature

set $group(val): void

Defined in: libs/device/src/builder/base.ts:232

Parameters
val

number

Returns

void

Methods

uniform()

uniform(group): PBShaderExp

Defined in: libs/device/src/builder/base.ts:240

Point out that the variable should be in uniform address space

Parameters

group

number

The bind group index

Returns

PBShaderExp

self


uniformBuffer()

uniformBuffer(group, bindingSize?): PBShaderExp

Defined in: libs/device/src/builder/base.ts:251

Point out that the variable should be an uniform buffer

Parameters

group

number

The bind group index

bindingSize?

number = 0

Returns

PBShaderExp

self


workgroup()

workgroup(): PBShaderExp

Defined in: libs/device/src/builder/base.ts:276

Point out that the variable should be in workgroup address space

Returns

PBShaderExp

self

Remarks

WebGPU device only


storage()

storage(group): PBShaderExp

Defined in: libs/device/src/builder/base.ts:285

Point out that the variable should be in storage address space

Parameters

group

number

The bind group index

Returns

PBShaderExp

self


storageReadonly()

storageReadonly(group): PBShaderExp

Defined in: libs/device/src/builder/base.ts:306

Point out that the variable is read-only and should be in storage address space

Parameters

group

number

The bind group index

Returns

PBShaderExp

self


storageBuffer()

storageBuffer(group, bindingSize?): PBShaderExp

Defined in: libs/device/src/builder/base.ts:316

Point out that the variable should be a storage buffer

Parameters

group

number

The bind group index

bindingSize?

number = 0

Returns

PBShaderExp

self


storageBufferReadonly()

storageBufferReadonly(group, bindingSize?): PBShaderExp

Defined in: libs/device/src/builder/base.ts:341

Point out that the variable is read-only and should be a storage buffer

Parameters

group

number

The bind group index

bindingSize?

number = 0

Returns

PBShaderExp

self


inout()

inout(): PBShaderExp

Defined in: libs/device/src/builder/base.ts:346

Returns

PBShaderExp


out()

out(): PBShaderExp

Defined in: libs/device/src/builder/base.ts:350

Returns

PBShaderExp


attrib()

attrib(attr): PBShaderExp

Defined in: libs/device/src/builder/base.ts:359

Point out that the variable is a input vertex attribute

Parameters

attr

VertexSemantic

The vertex semantic

Returns

PBShaderExp

self


tag()

tag(...args): PBShaderExp

Defined in: libs/device/src/builder/base.ts:369

Create tags for the variable

Parameters

args

...ShaderExpTagValue[]

tags

Returns

PBShaderExp

self


sampleType()

sampleType(type): PBShaderExp

Defined in: libs/device/src/builder/base.ts:382

Set sample type for the variable if the variable is of type texture

Parameters

type

"float" | "unfilterable-float" | "depth" | "sint" | "uint"

sample type

Returns

PBShaderExp

self


noSampler()

noSampler(): PBShaderExp

Defined in: libs/device/src/builder/base.ts:402

Declares that this texture uniform is never sampled with a regular (non-comparison) sampler — it is only accessed with textureLoad, or, for depth textures, only with comparison sampling.

Returns

PBShaderExp

self

Remarks

On WebGPU every texture uniform gets an automatically bound sampler that counts against the per-stage sampler limit; use this on load-only textures (and comparison-only depth textures) to suppress it. The declaration-level hint keeps bind group layouts consistent between programs that share bind groups, which usage analysis could not guarantee.


withSampler()

withSampler(options): PBShaderExp

Defined in: libs/device/src/builder/base.ts:423

Declares that this texture uniform is always sampled with the given static sampler configuration.

Parameters

options

SamplerOptions

The static sampler configuration

Returns

PBShaderExp

self

Remarks

On WebGPU, textures declared with the same static configuration within the same bind group share a single auto-bound sampler binding instead of each taking one, keeping heavy shaders below the per-stage sampler limit. The shared sampler is created from the given options when the bind group is built; any sampler passed to setTexture() at runtime is ignored for this texture on WebGPU. On WebGL/WebGL2 behavior is unchanged — keep passing the matching sampler to setTexture(). Comparison samplers are not supported here; depth textures keep their auto-bound comparison sampler.


at()

at(index): PBShaderExp

Defined in: libs/device/src/builder/base.ts:435

Get element in the array by index

Parameters

index

number | PBShaderExp

index of the element

Returns

PBShaderExp

the element variable


setAt()

setAt(index, val): void

Defined in: libs/device/src/builder/base.ts:484

Set element in the array by index

Parameters

index

number | PBShaderExp

index of the element

val

number | boolean | PBShaderExp

value to set

Returns

void


highp()

highp(): PBShaderExp

Defined in: libs/device/src/builder/base.ts:515

Point out that the variable should be in high precision

Returns

PBShaderExp

self


mediump()

mediump(): PBShaderExp

Defined in: libs/device/src/builder/base.ts:523

Points out that the variable should be in medium precision

Returns

PBShaderExp

self


lowp()

lowp(): PBShaderExp

Defined in: libs/device/src/builder/base.ts:531

Points out that the variable should be in low precision

Returns

PBShaderExp

self


isConstructor()

isConstructor(): boolean

Defined in: libs/device/src/builder/base.ts:539

Whether this is a constructor

Returns

boolean

true if this is a constructor


isVector()

isVector(): boolean

Defined in: libs/device/src/builder/base.ts:546

Determine if this variable is of vector type

Returns

boolean

true if the variable is of vector type, otherwise false


numComponents()

numComponents(): number

Defined in: libs/device/src/builder/base.ts:554

Get vector component count of the variable if this variable is of vector type

Returns

number

the vector component count


getTypeName()

getTypeName(): string

Defined in: libs/device/src/builder/base.ts:562

Get type name of this variable

Returns

string

The type name of this variable

Released under the MIT License.