![]() |
Lysa
0.0
Lysa 3D Engine
|
Device-only GPU memory array.
Uses a single persistent staging buffer (same capacity as the GPU buffer) shared across all concurrent write sessions. Each session tracks its own list of written regions; writes from different threads target disjoint MemoryBlocks, so they never overlap in the staging buffer.
Typical per-thread usage: auto session = array.beginWrites(); // creates a session token array.write(session, bloc1, ptr1); // memcpy into staging, records region array.write(session, bloc2, ptr2); array.flush(session, commandList); // ONE copy call for all regions, destroys token
Inheritance diagram for DeviceMemoryArray:Public Typedefs | |
| using | WriteSession = uint64 |
| Opaque handle returned by beginWrites() and consumed by flush(). More... | |
Public Member Functions | |
| DeviceMemoryArray (const std::shared_ptr< vireo::Vireo > &vireo, size_t instanceSize, size_t instanceCount, vireo::BufferType bufferType, const std::string &name) | |
| WriteSession | beginWrites () |
| void | write (WriteSession session, const MemoryBlock &destination, const void *source) |
| void | flush (WriteSession session, const vireo::CommandList &commandList) |
| void | barrier (const vireo::CommandList &commandList, vireo::ResourceState oldState, vireo::ResourceState newState) const |
| ~DeviceMemoryArray () override | |
Public Member Functions inherited from MemoryArray | |
| MemoryBlock | alloc (size_t instanceCount) |
| void | free (const MemoryBlock &bloc) |
| void | copyTo (const vireo::CommandList &commandList, const MemoryArray &destination) |
| auto | getBuffer () const |
| virtual | ~MemoryArray () |
| MemoryArray (MemoryArray &) = delete | |
| MemoryArray & | operator= (MemoryArray &) = delete |
Static Public Attributes | |
| static constexpr WriteSession | INVALID_WRITE_SESSION {0} |
Additional Inherited Members | |
Protected Member Functions inherited from MemoryArray | |
| MemoryArray (const std::shared_ptr< vireo::Vireo > &vireo, size_t instanceSize, size_t instanceCount, vireo::BufferType bufferType, const std::string &name) | |
Protected Attributes inherited from MemoryArray | |
| const std::shared_ptr< vireo::Vireo > | vireo |
| const std::string | name |
| const size_t | instanceSize |
| std::shared_ptr< vireo::Buffer > | buffer |
| std::list< MemoryBlock > | freeBlocs |
| std::mutex | mutex |
| using WriteSession = uint64 |
Opaque handle returned by beginWrites() and consumed by flush().
| DeviceMemoryArray | ( | const std::shared_ptr< vireo::Vireo > & | vireo, |
| size_t | instanceSize, | ||
| size_t | instanceCount, | ||
| vireo::BufferType | bufferType, | ||
| const std::string & | name | ||
| ) |
Creates a device-only GPU memory array.
| vireo | Vireo instance |
| instanceSize | Size in bytes of one element |
| instanceCount | Maximum number of elements |
| bufferType | Must be VERTEX, INDEX, INDIRECT, DEVICE_STORAGE or READWRITE_STORAGE |
| name | Name used for GPU-side debug labels |
|
override |
| void barrier | ( | const vireo::CommandList & | commandList, |
| vireo::ResourceState | oldState, | ||
| vireo::ResourceState | newState | ||
| ) | const |
Inserts a GPU pipeline/memory barrier for this buffer.
| WriteSession beginWrites | ( | ) |
Opens a new write session and returns its opaque handle. Multiple sessions may be open simultaneously from different threads.
| void flush | ( | WriteSession | session, |
| const vireo::CommandList & | commandList | ||
| ) |
Emits a single GPU copy covering all regions recorded in session, then destroys the session token.
| session | Handle returned by beginWrites() |
| commandList | Command list to record the copy into |
| void write | ( | WriteSession | session, |
| const MemoryBlock & | destination, | ||
| const void * | source | ||
| ) |
Copies source into the staging buffer at the offset described by destination and records the region in session. Thread-safe: concurrent writes to different MemoryBlocks are safe.
|
staticconstexpr |