Skip to content

Class: GPUContext

WebGPU api use context

Constructors

Properties

Methods

Constructors

constructor

new GPUContext(): GPUContext

Returns

GPUContext

Properties

lastGeometry

Static lastGeometry: GeometryBase

Defined in

src/gfx/renderJob/GPUContext.ts:15


lastPipeline

Static lastPipeline: GPURenderPipeline

Defined in

src/gfx/renderJob/GPUContext.ts:16


lastShader

Static lastShader: RenderShaderPass

Defined in

src/gfx/renderJob/GPUContext.ts:17


drawCount

Static drawCount: number = 0

Defined in

src/gfx/renderJob/GPUContext.ts:18


renderPassCount

Static renderPassCount: number = 0

Defined in

src/gfx/renderJob/GPUContext.ts:19


geometryCount

Static geometryCount: number = 0

Defined in

src/gfx/renderJob/GPUContext.ts:20


pipelineCount

Static pipelineCount: number = 0

Defined in

src/gfx/renderJob/GPUContext.ts:21


matrixCount

Static matrixCount: number = 0

Defined in

src/gfx/renderJob/GPUContext.ts:22


lastRenderPassState

Static lastRenderPassState: RendererPassState

Defined in

src/gfx/renderJob/GPUContext.ts:23


LastCommand

Static LastCommand: GPUCommandEncoder

Defined in

src/gfx/renderJob/GPUContext.ts:24

Methods

bindPipeline

bindPipeline(encoder, renderShader): boolean

renderPipeline before render need bind pipeline

Parameters

NameTypeDescription
encoderGPURenderPassEncoder | GPURenderBundleEncodercurrent GPURenderPassEncoder GPURenderPassEncoder GPURenderBundleEncoder
renderShaderRenderShaderPassrender pass shader RenderShaderPass

Returns

boolean

Defined in

src/gfx/renderJob/GPUContext.ts:32


bindCamera

bindCamera(encoder, camera): void

render before need make sure use camera

Parameters

NameTypeDescription
encoderGPURenderPassEncoder | GPURenderBundleEncodercurrent GPURenderPassEncoder GPURenderPassEncoder GPURenderBundleEncoder
cameraCamera3Duse camera Camera3D

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:58


bindGeometryBuffer

bindGeometryBuffer(encoder, geometry): void

bind geometry vertex buffer to current render pipeline

Parameters

NameTypeDescription
encoderGPURenderPassEncoder | GPURenderBundleEncodercurrent GPURenderPassEncoder GPURenderPassEncoder GPURenderBundleEncoder
geometryGeometryBaseengine geometry

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:70


cleanCache

cleanCache(): void

begin or end clean all use cache

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:89


createPipeline

createPipeline(gpuRenderPipeline): GPURenderPipeline

create a render pipeline

Parameters

NameTypeDescription
gpuRenderPipelineGPURenderPipelineDescriptorGPURenderPipelineDescriptor

Returns

GPURenderPipeline

Defined in

src/gfx/renderJob/GPUContext.ts:100


beginCommandEncoder

beginCommandEncoder(): GPUCommandEncoder

auto get webgpu commandEncoder and start a command encoder

Returns

GPUCommandEncoder

commandEncoder GPUCommandEncoder

Defined in

src/gfx/renderJob/GPUContext.ts:110


endCommandEncoder

endCommandEncoder(command): void

end CommandEncoder record and submit

Parameters

NameTypeDescription
commandGPUCommandEncoderGPUCommandEncoder

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:123


recordBundleEncoder

recordBundleEncoder(des): GPURenderBundleEncoder

create a renderBundle gpu object by GPURenderBundleEncoderDescriptor

Parameters

NameTypeDescription
desGPURenderBundleEncoderDescriptorGPURenderBundleEncoderDescriptor

Returns

GPURenderBundleEncoder

renderBundleEncoder GPURenderBundleEncoder

Defined in

src/gfx/renderJob/GPUContext.ts:136


beginRenderPass

beginRenderPass(command, renderPassState): GPURenderPassEncoder

render pass start return current use gpu renderPassEncoder

Parameters

NameTypeDescription
commandGPUCommandEncoderGPUCommandEncoder
renderPassStateRendererPassStateRendererPassState

Returns

GPURenderPassEncoder

encoder GPURenderPassEncoder

Defined in

src/gfx/renderJob/GPUContext.ts:147


drawIndexed

drawIndexed(encoder, indexCount, instanceCount?, firstIndex?, baseVertex?, firstInstance?): void

Start the rendering process to draw any pipes

Parameters

NameType
encoderGPURenderPassEncoder
indexCountnumber
instanceCount?number
firstIndex?number
baseVertex?number
firstInstance?number

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:190


draw

draw(encoder, vertexCount, instanceCount?, firstVertex?, firstInstance?): void

Parameters

NameType
encoderGPURenderPassEncoder
vertexCountnumber
instanceCount?number
firstVertex?number
firstInstance?number

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:199


endPass

endPass(encoder): void

The GPU must be informed of the end of encoder recording

Parameters

NameType
encoderGPURenderPassEncoder

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:211


computeCommand

computeCommand(command, computes): void

Perform the final calculation and submit the Shader to the GPU

Parameters

NameType
commandGPUCommandEncoder
computesComputeShader[]

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:221


copyTexture

copyTexture(command, source, dest): void

Parameters

NameType
commandGPUCommandEncoder
sourceTexture
destTexture

Returns

void

Defined in

src/gfx/renderJob/GPUContext.ts:230

Released under the MIT License