GPURenderPassEncoder¶
When executing encoded render pass commands as part of a GPUCommandBuffer, an internal RenderState object is used to track the current state required for rendering.
Properties¶
label¶
A developer-provided label which is used in an implementation-defined way. It can be used by the browser, OS, or other tools to help identify the underlying internal object to the developer. Examples include displaying the label in GPUError messages, console warnings, browser developer tools, and platform debugging utilities.
Functions¶
beginOcclusionQuery¶
abstract fun beginOcclusionQuery(queryIndex: GPUSize32)
Begins an occlusion query at queryIndex; endOcclusionQuery marks the end of the query.
draw¶
Draws primitives. See § 23.2 Rendering for the detailed specification.
**Parameters**
- vertexCount: The number of vertices to draw.
- instanceCount: The number of instances to draw.
- firstVertex: Offset into the vertex buffers, in vertices, to begin drawing from.
- firstInstance: First instance to draw.
drawIndexed¶
abstract fun drawIndexed(
indexCount: GPUSize32,
instanceCount: GPUSize32,
firstIndex: GPUSize32,
baseVertex: GPUSignedOffset32 = 0,
firstInstance: GPUSize32
)
Draws indexed primitives. See § 23.2 Rendering for the detailed specification.
**Parameters**
- indexCount: The number of indices to draw.
- instanceCount: The number of instances to draw.
- firstIndex: Offset into the index buffer, in indices, begin drawing from.
- baseVertex: Added to each index value before indexing into the vertex buffers.
- firstInstance: First instance to draw.
drawIndexedIndirect¶
abstract fun drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64)
Draws indexed primitives using parameters read from a GPUBuffer. See § 23.2 Rendering for the detailed specification. The indirect drawIndexed parameters encoded in the buffer must be a tightly packed block of five 32-bit values (20 bytes total), given in the same order as the arguments for drawIndexed(). The value corresponding to baseVertex is a signed 32-bit integer, and all others are unsigned 32-bit integers.
**Parameters**
- indirectBuffer: Buffer containing the indirect drawIndexed parameters.
- indirectOffset: Offset in bytes into indirectBuffer where the drawing data begins.
drawIndirect¶
abstract fun drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64)
Draws primitives using parameters read from a GPUBuffer. See § 23.2 Rendering for the detailed specification. The indirect draw parameters encoded in the buffer must be a tightly packed block of four 32-bit unsigned integer values (16 bytes total), given in the same order as the arguments for draw().
**Parameters**
- indirectBuffer: Buffer containing the indirect draw parameters.
- indirectOffset: Offset in bytes into indirectBuffer where the drawing data begins.
end¶
abstract fun end()
Completes recording of the render pass commands sequence.
endOcclusionQuery¶
abstract fun endOcclusionQuery()
Ends the occlusion query begun by beginOcclusionQuery.
executeBundles¶
abstract fun executeBundles(bundles: List<GPURenderBundle>)
Executes the commands previously recorded into the given GPURenderBundles as part of this render pass. When a GPURenderBundle is executed, it does not inherit the render pass’s pipeline, bind groups, immediate data, or vertex and index buffers. After a GPURenderBundle has executed, the render pass’s pipeline, bind group, immediate data, and vertex/index buffer state is cleared (to the initial, empty values).
**Parameters**
- bundles: List of render bundles to execute.
insertDebugMarker¶
abstract fun insertDebugMarker(markerLabel: String)
Marks a point in a stream of commands with a label.
**Parameters**
- markerLabel: The label to insert.
popDebugGroup¶
abstract fun popDebugGroup()
Ends the labeled debug group most recently started by pushDebugGroup().
pushDebugGroup¶
abstract fun pushDebugGroup(groupLabel: String)
Begins a labeled debug group containing subsequent commands.
**Parameters**
- groupLabel: The label for the command group.
setBindGroup¶
abstract fun setBindGroup(
index: GPUIndex32,
bindGroup: GPUBindGroup?,
dynamicOffsetsData: List<UInt> = emptyList()
)
Sets the current GPUBindGroup for the given index.
See [GPUBindingCommandsMixin.setBindGroup(index, bindGroup, dynamicOffsetsData) in the WebGPU specification](https://www.w3.org/TR/webgpu/#dom-gpubindingcommandsmixin-setbindgroup).
setBlendConstant¶
abstract fun setBlendConstant(color: GPUColor)
Sets the constant blend color and alpha values used with "constant" and "one-minus-constant" GPUBlendFactors.
**Parameters**
- color: The color to use when blending.
setImmediates¶
abstract fun setImmediates(
rangeOffset: GPUSize32,
data: ArrayBuffer,
dataOffset: GPUSize64,
dataSize: GPUSize64? = null
)
Sets immediate data for subsequent render or compute commands.
**Parameters**
- rangeOffset: Offset in bytes into the immediate data range to begin writing at.
- data: Data to write into the immediate data range.
- dataOffset: Offset into data to begin writing from. Given in elements if data is a TypedArray and bytes otherwise.
- dataSize: Size of content to write from data. Given in elements if data is a TypedArray and bytes otherwise.
setIndexBuffer¶
abstract fun setIndexBuffer(
buffer: GPUBuffer,
indexFormat: GPUIndexFormat,
offset: GPUSize64,
size: GPUSize64? = null
)
Sets the current index buffer.
**Parameters**
- buffer: Buffer containing index data to use for subsequent drawing commands.
- indexFormat: Format of the index data contained in buffer.
- offset: Offset in bytes into buffer where the index data begins. Defaults to 0.
- size: Size in bytes of the index data in buffer. Defaults to the size of the buffer minus the offset.
setPipeline¶
abstract fun setPipeline(pipeline: GPURenderPipeline)
Sets the current GPURenderPipeline.
**Parameters**
- pipeline: The render pipeline to use for subsequent drawing commands.
setScissorRect¶
abstract fun setScissorRect(
x: GPUIntegerCoordinate,
y: GPUIntegerCoordinate,
width: GPUIntegerCoordinate,
height: GPUIntegerCoordinate
)
Sets the scissor rectangle used during the rasterization stage. After transformation into viewport coordinates any fragments which fall outside the scissor rectangle will be discarded.
**Parameters**
- x: Minimum X value of the scissor rectangle in pixels.
- y: Minimum Y value of the scissor rectangle in pixels.
- width: Width of the scissor rectangle in pixels.
- height: Height of the scissor rectangle in pixels.
setStencilReference¶
abstract fun setStencilReference(reference: GPUStencilValue)
Sets the [stencilReference] value used during stencil tests with the "replace" GPUStencilOperation.
**Parameters**
- reference: The new stencil reference value.
setVertexBuffer¶
abstract fun setVertexBuffer(
slot: GPUIndex32,
buffer: GPUBuffer?,
offset: GPUSize64,
size: GPUSize64? = null
)
Sets the current vertex buffer for the given slot.
**Parameters**
- slot: The vertex buffer slot to set the vertex buffer for.
- buffer: Buffer containing vertex data to use for subsequent drawing commands.
- offset: Offset in bytes into buffer where the vertex data begins. Defaults to 0.
- size: Size in bytes of the vertex data in buffer. Defaults to the size of the buffer minus the offset.
setViewport¶
Sets the viewport used during the rasterization stage to linearly map from normalized device coordinates to viewport coordinates.
**Parameters**
- x: Minimum X value of the viewport in pixels.
- y: Minimum Y value of the viewport in pixels.
- width: Width of the viewport in pixels.
- height: Height of the viewport in pixels.
- minDepth: Minimum depth value of the viewport.
- maxDepth: Maximum depth value of the viewport.