|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
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 |
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).
| 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.
| vertexCount | Number of vertices. |
| instanceCount | Number of instances. |
| firstVertex | First vertex index. |
| firstInstance | First instance index. |
| 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.
| indexCount | Number of indices read. |
| instanceCount | Number of instances. |
| firstIndex | First index read, relative to the bound offset. |
| baseVertex | Signed value added to every index value before the vertex fetch. |
| firstInstance | First instance index. |
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.
| index | Bind group index; must be below kMaxBindGroups. |
| bindGroup | Bind group to bind; must be a live handle of the encoder's device. |
| 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.
| buffer | Buffer to bind; needs BufferUsage::Index and must be a live handle of the encoder's device. |
| format | Width of each index. |
| offsetBytes | Byte offset of the first index; must be a multiple of the index width and within the buffer. |
| Status donner::gpu::RenderPassEncoder::setPipeline | ( | const RenderPipeline & | pipeline | ) |
Sets the active render pipeline.
| pipeline | Pipeline to bind; must be a live handle of the encoder's device. |
| 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.
| x | Left edge in pixels. |
| y | Top edge in pixels. |
| width | Width in pixels. |
| height | Height in pixels. |
| Status donner::gpu::RenderPassEncoder::setVertexBuffer | ( | uint32_t | slot, |
| const Buffer & | buffer, | ||
| uint64_t | offsetBytes = 0 ) |
Binds buffer as the vertex buffer for slot.
| slot | Vertex buffer slot; must be below kMaxVertexBuffers. |
| buffer | Buffer to bind; needs BufferUsage::Vertex. |
| offsetBytes | Byte offset of the first element; must be within the buffer. |
| 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.
| x | Left edge in pixels. |
| y | Top edge in pixels. |
| width | Width in pixels. |
| height | Height in pixels. |
| minDepth | Minimum depth of the viewport range. |
| maxDepth | Maximum depth of the viewport range. |