Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::gpu::BufferMappingTable Class Reference

Tracks the host mappings a backend has open and answers the mapping hooks Device dispatches to it. More...

#include "donner/gpu/BufferMappingTable.h"

Public Member Functions

 BufferMappingTable (BufferMappingHost &host)
Status begin (uint32_t mappingSlotIndex, uint32_t bufferSlotIndex, uint64_t offsetBytes, uint64_t byteCount, uint64_t readySerial)
 Opens a mapping over byteCount bytes of bufferSlotIndex starting at offsetBytes.
MapSliceReport waitSlice (uint32_t mappingSlotIndex, double sliceSeconds)
 Waits up to sliceSeconds for one mapping, and reports what it found and how it waited.
Result< std::span< const uint8_t > > bytes (uint32_t mappingSlotIndex) const
 Bytes of a completed mapping, or a failure while it is pending, released, or invalidated.
void release (uint32_t mappingSlotIndex)
 Releases a mapping, so every remaining handle naming it reads as released.
void invalidateBuffer (uint32_t bufferSlotIndex)
 Invalidates every mapping of bufferSlotIndex, called when the buffer is retired so a mapping cannot outlive the allocation it points into.
size_t liveMappingCountForTest () const
 How many mappings are currently open, counting ones whose buffer was retired: those are still open handles that have to be released. Test accessor for leak checks.

Detailed Description

Tracks the host mappings a backend has open and answers the mapping hooks Device dispatches to it.

A mapping names a byte range of one buffer plus the submission that must complete before that range holds the bytes the caller asked for. Holding a mapping is not ownership of the buffer: destroying the buffer invalidates the mapping instead of keeping the allocation alive, so a read afterwards is a reported failure rather than a read of freed memory.

A mapping observes the work submitted before it was created. Writes still queued for a later submission are not part of it, because the submission that would carry them does not exist yet and waiting for it would be waiting for something the caller has not asked for.

Constructor & Destructor Documentation

◆ BufferMappingTable()

donner::gpu::BufferMappingTable::BufferMappingTable ( BufferMappingHost & host)
inlineexplicit
Parameters
hostSupplies the backend's buffer facts; must outlive this table.

Member Function Documentation

◆ begin()

Status donner::gpu::BufferMappingTable::begin ( uint32_t mappingSlotIndex,
uint32_t bufferSlotIndex,
uint64_t offsetBytes,
uint64_t byteCount,
uint64_t readySerial )

Opens a mapping over byteCount bytes of bufferSlotIndex starting at offsetBytes.

Parameters
mappingSlotIndexSlot the mapping occupies.
bufferSlotIndexSlot of the buffer being mapped.
offsetBytesByte offset of the mapped range.
byteCountLength of the mapped range.
readySerialSubmission whose completion makes the range hold the bytes the caller asked for. Zero when the buffer has no outstanding work, which is ready immediately.

◆ bytes()

Result< std::span< const uint8_t > > donner::gpu::BufferMappingTable::bytes ( uint32_t mappingSlotIndex) const

Bytes of a completed mapping, or a failure while it is pending, released, or invalidated.

The span aliases the backend's own allocation rather than a copy of it, so it is valid only until whichever of these comes first: the mapping is released, its buffer is retired, or the device is lost. Callers that outlive any of those copy the bytes out. The annotation states that contract to the compiler rather than enforcing it: the span is returned inside a Result, and the dangling diagnostic does not see through an unannotated class template.

Parameters
mappingSlotIndexSlot of the mapping.

◆ invalidateBuffer()

void donner::gpu::BufferMappingTable::invalidateBuffer ( uint32_t bufferSlotIndex)

Invalidates every mapping of bufferSlotIndex, called when the buffer is retired so a mapping cannot outlive the allocation it points into.

Parameters
bufferSlotIndexSlot of the buffer being retired.

◆ release()

void donner::gpu::BufferMappingTable::release ( uint32_t mappingSlotIndex)

Releases a mapping, so every remaining handle naming it reads as released.

Parameters
mappingSlotIndexSlot of the mapping.

◆ waitSlice()

MapSliceReport donner::gpu::BufferMappingTable::waitSlice ( uint32_t mappingSlotIndex,
double sliceSeconds )

Waits up to sliceSeconds for one mapping, and reports what it found and how it waited.

Parameters
mappingSlotIndexSlot of the mapping.
sliceSecondsLongest this call may block; zero polls without calling the host wait.

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