Class WebGPUDrawContext
Implements
Constructors
constructor
-
new WebGPUDrawContext(
bufferManager: WebGPUBufferManager,
_dummyIndexBuffer: WebGPUDataBuffer,
): WebGPUDrawContextCreates a new WebGPUDrawContext.
Parameters
- bufferManager: WebGPUBufferManager
The buffer manager used to manage WebGPU buffers.
- _dummyIndexBuffer: WebGPUDataBuffer
A dummy index buffer to be bound as the "indices" storage buffer when no index buffer is provided.
Returns WebGPUDrawContext
- bufferManager: WebGPUBufferManager
Properties
Optionalbind Groups
Cache of the bind groups. Will be reused for the next draw if isDirty==false (and materialContext.isDirty==false)
buffers
Buffers (uniform / storage) used for the draw call
Optionalfast Bundle
Bundle used in fast mode (when compatibilityMode==false)
Optionalindirect Draw Buffer
Buffer used for the indirect draw call when enableIndirectDraw is true.
unique Id
Unique identifier for the draw context.
Accessors
enable Indirect Draw
-
get enableIndirectDraw(): boolean
Indicates if the draw should be an indirect draw.
Returns boolean
-
set enableIndirectDraw(enable: boolean): void
Indicates if the draw should be an indirect draw.
Parameters
- enable: boolean
Returns void
use Instancing
-
get useInstancing(): boolean
True if instances are used in the draw calls
Returns boolean
-
set useInstancing(use: boolean): void
True if instances are used in the draw calls
Parameters
- use: boolean
Returns void
Methods
dispose
-
Disposes the draw context and its resources.
Returns void
is Dirty
-
Checks if the draw context is dirty.
Parameters
- materialContextUpdateId: number
The update ID of the material context associated with the draw context.
Returns boolean
True if the draw or material context is dirty, false otherwise.
- materialContextUpdateId: number
reset
-
Resets the draw context to its initial state.
Returns void
reset Is Dirty
-
Resets the dirty state of the draw context.
Parameters
- materialContextUpdateId: number
The update ID of the material context associated with the draw context.
Returns void
- materialContextUpdateId: number
set Buffer
-
Associates a buffer to the draw context.
Parameters
- name: string
The name of the buffer.
- buffer: Nullable<WebGPUDataBuffer>
The buffer to set.
Returns void
- name: string
set Indirect Data
-
setIndirectData(
indexOrVertexCount: number,
instanceCount: number,
firstIndexOrVertex: number,
forceUpdate?: boolean,
): voidData for the indirect draw call (only used when enableIndirectDraw is true).
Parameters
- indexOrVertexCount: number
The number of indices (if indexed draw) or vertices (if non-indexed draw).
- instanceCount: number
The number of instances to draw.
- firstIndexOrVertex: number
The index (if indexed draw) or vertex (if non-indexed draw) offset to start drawing from.
- forceUpdate: boolean = false
If true, forces the update of the indirect draw data even if instanceCount is the same as in the previous call.
Returns void
- indexOrVertexCount: number
set Vertex Pulling
-
setVertexPulling(
useVertexPulling: boolean,
webgpuPipelineContext: WebGPUPipelineContext,
vertexBuffers: { [key: string]: Nullable<VertexBuffer> },
indexBuffer: Nullable<DataBuffer>,
overrideVertexBuffers: Nullable<{ [kind: string]: Nullable<VertexBuffer> }>,
): voidSetup or disable vertex pulling as needed.
Parameters
- useVertexPulling: boolean
Use vertex pulling or not
- webgpuPipelineContext: WebGPUPipelineContext
The WebGPU pipeline context
- vertexBuffers: { [key: string]: Nullable<VertexBuffer> }
The current vertex buffers
- indexBuffer: Nullable<DataBuffer>
The current index buffer
- overrideVertexBuffers: Nullable<{ [kind: string]: Nullable<VertexBuffer> }>
The vertex buffers to override
Returns void
- useVertexPulling: boolean
WebGPU implementation of the IDrawContext interface. This class manages the draw context for WebGPU, including buffers and indirect draw data.