Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::gpu::RenderPassEncoder Class Reference

Encodes commands inside an active render pass. More...

#include "donner/gpu/CommandEncoder.h"

Public Member Functions

 RenderPassEncoder (const RenderPassEncoder &)=delete
RenderPassEncoder & operator= (const RenderPassEncoder &)=delete
 RenderPassEncoder (RenderPassEncoder &&)=delete
RenderPassEncoder & operator= (RenderPassEncoder &&)=delete
Status setPipeline (const RenderPipeline &pipeline)
 Sets the active render pipeline.
Status setBindGroup (uint32_t index, const BindGroup &bindGroup)
 Binds bindGroup at index.
Status setVertexBuffer (uint32_t slot, const Buffer &buffer, uint64_t offsetBytes=0)
 Binds buffer as the vertex buffer for slot.
Status setIndexBuffer (const Buffer &buffer, IndexFormat format, uint64_t offsetBytes=0)
 Binds buffer as the index buffer for subsequent drawIndexed calls.
Status setScissorRect (uint32_t x, uint32_t y, uint32_t width, uint32_t height)
 Sets the scissor rectangle.
Status setViewport (float x, float y, float width, float height, float minDepth, float maxDepth)
 Sets the viewport.
Status draw (uint32_t vertexCount, uint32_t instanceCount=1, uint32_t firstVertex=0, uint32_t firstInstance=0)
 Records a draw.
Status drawIndexed (uint32_t indexCount, uint32_t instanceCount=1, uint32_t firstIndex=0, int32_t baseVertex=0, uint32_t firstInstance=0)
 Records an indexed draw.
Status end ()
 Ends the render pass. Further pass operations fail with GpuErrorType::InvalidState until a new pass begins.

Friends

class CommandEncoder

Detailed Description

Encodes commands inside an active render pass.

Obtained from CommandEncoder::beginRenderPass; owned by the encoder and valid until the encoder is destroyed (operations after end fail with GpuErrorType::InvalidState).

Member Function Documentation

◆ draw()

Status donner::gpu::RenderPassEncoder::draw ( uint32_t vertexCount,
uint32_t instanceCount = 1,
uint32_t firstVertex = 0,
uint32_t firstInstance = 0 )

Records a draw.

Fails closed unless a pipeline is set, every vertex buffer slot the pipeline declares is bound with enough bytes for the drawn range (checked arithmetic), and every bind group index the pipeline layout declares holds a bind group created against the same layout.

Parameters
vertexCountNumber of vertices.
instanceCountNumber of instances.
firstVertexFirst vertex index.
firstInstanceFirst instance index.

◆ drawIndexed()

Status donner::gpu::RenderPassEncoder::drawIndexed ( uint32_t indexCount,
uint32_t instanceCount = 1,
uint32_t firstIndex = 0,
int32_t baseVertex = 0,
uint32_t firstInstance = 0 )

Records an indexed draw.

For each of the indexCount indices starting at firstIndex in the bound index range, vertex-stepped attributes fetch element baseVertex + index value and instance-stepped attributes fetch element firstInstance + instance; the vertex stage sees the same sums as vertex_index and instance_index.

Fails closed unless a PrimitiveTopology::TriangleList pipeline is set (strips would need primitive-restart semantics the backends do not share, so they are refused with GpuErrorType::Unsupported), an index buffer is bound, the index range (firstIndex + indexCount) * indexWidth fits the bound range (checked 64-bit arithmetic), every declared vertex slot is bound, every instance-stepped slot covers firstInstance + instanceCount elements, and every bind group index the pipeline layout declares holds a group created against that layout.

Vertex-stepped ranges are NOT validated here: the element reached is baseVertex + index value, and index values live in GPU memory. Keeping every baseVertex + value inside the bound vertex buffers is the caller's responsibility; what an out-of-range vertex fetch returns, and whether the backend reports it, is backend-dependent and outside this contract.

A zero indexCount or instanceCount is recorded like draw records zero counts; the range checks still apply and backends issue no native draw for it.

Parameters
indexCountNumber of indices read.
instanceCountNumber of instances.
firstIndexFirst index read, relative to the bound offset.
baseVertexSigned value added to every index value before the vertex fetch.
firstInstanceFirst instance index.

◆ setBindGroup()

Status donner::gpu::RenderPassEncoder::setBindGroup ( uint32_t index,
const BindGroup & bindGroup )

Binds bindGroup at index.

Compatibility with the active pipeline's layout is checked at draw time, so bind groups may be set before the pipeline.

Parameters
indexBind group index; must be below kMaxBindGroups.
bindGroupBind group to bind; must be a live handle of the encoder's device.

◆ setIndexBuffer()

Status donner::gpu::RenderPassEncoder::setIndexBuffer ( const Buffer & buffer,
IndexFormat format,
uint64_t offsetBytes = 0 )

Binds buffer as the index buffer for subsequent drawIndexed calls.

The bound range runs from offsetBytes to the end of the buffer; binding exactly at the end is allowed and yields an empty range. Rebinding replaces the format and range for later draws only, and the binding does not survive end.

Fails closed with GpuErrorType::Unsupported when the device cannot honor the full unsigned range of format (see Device::supportsFullIndexRange), so a 32-bit index that a driver would silently truncate is refused before any GPU work is recorded.

Parameters
bufferBuffer to bind; needs BufferUsage::Index and must be a live handle of the encoder's device.
formatWidth of each index.
offsetBytesByte offset of the first index; must be a multiple of the index width and within the buffer.

◆ setPipeline()

Status donner::gpu::RenderPassEncoder::setPipeline ( const RenderPipeline & pipeline)

Sets the active render pipeline.

Parameters
pipelinePipeline to bind; must be a live handle of the encoder's device.

◆ setScissorRect()

Status donner::gpu::RenderPassEncoder::setScissorRect ( uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height )

Sets the scissor rectangle.

The rectangle must fit inside the pass attachment extent.

Parameters
xLeft edge in pixels.
yTop edge in pixels.
widthWidth in pixels.
heightHeight in pixels.

◆ setVertexBuffer()

Status donner::gpu::RenderPassEncoder::setVertexBuffer ( uint32_t slot,
const Buffer & buffer,
uint64_t offsetBytes = 0 )

Binds buffer as the vertex buffer for slot.

Parameters
slotVertex buffer slot; must be below kMaxVertexBuffers.
bufferBuffer to bind; needs BufferUsage::Vertex.
offsetBytesByte offset of the first element; must be within the buffer.

◆ setViewport()

Status donner::gpu::RenderPassEncoder::setViewport ( float x,
float y,
float width,
float height,
float minDepth,
float maxDepth )

Sets the viewport.

All values must be finite, with positive extent and 0 <= minDepth <= maxDepth <= 1.

Parameters
xLeft edge in pixels.
yTop edge in pixels.
widthWidth in pixels.
heightHeight in pixels.
minDepthMinimum depth of the viewport range.
maxDepthMaximum depth of the viewport range.

The documentation for this class was generated from the following file: