Skip to content

@tmrw-realityos/charmDocs


@tmrw-realityos/charm / WebGPUShader

Class: WebGPUShader

Constructors

new WebGPUShader()

new WebGPUShader(id, device, vertexSource, fragmentSource): WebGPUShader

Parameters

id: string

device: GPUDevice

vertexSource: string

fragmentSource: string

Returns

WebGPUShader

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:74

Properties

fragmentDesc

fragmentDesc: GPUShaderModuleDescriptor

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:68


id

id: string = ""

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:65


index

index: number = -1

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:66


quadBindGroup?

optional quadBindGroup: GPUBindGroup

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:63


vertexDesc

vertexDesc: GPUShaderModuleDescriptor

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:67


vertexInputs

vertexInputs: Map<string, number>

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:70


vertexInputsMask

vertexInputsMask: number = 0

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:71


wgslReflects_

wgslReflects_: WgslReflect[]

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:64

Accessors

pipeLineLayout

get pipeLineLayout(): GPUPipelineLayout

Returns

GPUPipelineLayout

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:127

Methods

bindResources()

bindResources(groupIndex, data, renderPass?): GPUBindGroup

Parameters

groupIndex: number

data: BindDataEntry[]

renderPass?: GPURenderPassEncoder

Returns

GPUBindGroup

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:449


checkBindGroupCompatibility()

checkBindGroupCompatibility(index, bindGroupLabel): boolean

If a bind group doesnt match a shader, use this method to compare The bindgroup must be created using the context.createSimpleBindGroup

Parameters

index: number

bindGroupLabel: string

Returns

boolean

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:192


createBindGroupLayoutDescriptors()

createBindGroupLayoutDescriptors(): GPUBindGroupLayoutDescriptor[]

Extracts groups from the shader code and creates a GPUBindGroupLayoutDescriptor that will be used by the pipeline

Returns

GPUBindGroupLayoutDescriptor[]

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:218


extractVertexInputs()

extractVertexInputs(): void

Returns

void

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:334


getBindGroupInfo()

getBindGroupInfo(index): string[]

Returns an array of strings showing every element in the bind group layout Helps debugs missmatch between bindgroup and pipeline layout

Parameters

index: number

Returns

string[]

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:141


getBindGroupLayoutDescriptors()

getBindGroupLayoutDescriptors(): GPUBindGroupLayoutDescriptor[]

Returns

GPUBindGroupLayoutDescriptor[]

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:135


getBindGroupLayouts()

getBindGroupLayouts(): GPUBindGroupLayout[]

Returns

GPUBindGroupLayout[]

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:131


getBindGroupSimple()

getBindGroupSimple(index): string

Returns a string with very similar structure as in the context.createSimpleBindGroup. Useful for debugging. It can be used to create bindgroups but you can already do that with bindGroupLayoutDescriptors

Parameters

index: number

Returns

string

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:165


getFragmentModule()

getFragmentModule(): GPUShaderModule

Returns

GPUShaderModule

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:370


getPipeline()

getPipeline(v): GPURenderPipeline

Parameters

v: PipelineInfo

Returns

GPURenderPipeline

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:438


getPipelineDescriptor()

getPipelineDescriptor(desc): GPURenderPipelineDescriptor

Parameters

desc: IPipelineSimpleDescriptor = {}

Returns

GPURenderPipelineDescriptor

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:400


getQuadPipeline()

getQuadPipeline(): GPURenderPipeline

Returns

GPURenderPipeline

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:492


getResourceBindingByName()

getResourceBindingByName(name): undefined | VariableInfo

Parameters

name: string

Returns

undefined | VariableInfo

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:374


getVertexModule()

getVertexModule(): GPUShaderModule

Returns

GPUShaderModule

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:366


reflectCode()

reflectCode(code): WgslReflect

Parameters

code: string

Returns

WgslReflect

Defined in

packages/charm/src/graphics/WebGPU/WebGPUShader.ts:323