|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Many vertex blocks laid out in one buffer, drawn as few runs. More...
#include <SliceSet.hpp>
Collaboration diagram for MayaFlux::Buffers::SliceSet:Classes | |
| struct | Slice |
Public Types | |
| using | SliceId = uint32_t |
Public Member Functions | |
| SliceId | add (std::span< const uint8_t > bytes, std::optional< Portal::Graphics::PrimitiveTopology > topology=std::nullopt) |
| Append a block at the end of memory and draw order. | |
| void | bring_to_front (SliceId id) |
| Draw a block after every other. | |
| bool | contains (SliceId id) const noexcept |
True when id names a live block. | |
| void | flush (const std::shared_ptr< VKBuffer > &target, std::shared_ptr< VKBuffer > &staging) |
| Upload what changed since the last flush. | |
| void | remove (SliceId id) |
| Remove a block; later blocks shift down. | |
| void | send_to_back (SliceId id) |
| Draw a block before every other. | |
| void | set_visible (SliceId id, bool visible) |
| Hide or show a block without moving its data. | |
| size_t | size () const noexcept |
| Number of live blocks. | |
| size_t | size_bytes () const noexcept |
| Bytes in the mirror. | |
| SliceSet (uint32_t stride_bytes, Portal::Graphics::PrimitiveTopology topology) | |
| std::optional< std::vector< Portal::Graphics::DrawRun > > | take_runs () |
| Runs for the visible blocks in draw order, if they changed. | |
| void | update (SliceId id, std::span< const uint8_t > bytes) |
| Replace a block's vertices. | |
| uint32_t | vertex_count () const noexcept |
| Vertices in the mirror, hidden blocks included. | |
Private Member Functions | |
| void | mark_dirty (size_t start, size_t end) |
| void | repack_from (size_t memory_index) |
Private Attributes | |
| bool | m_all_dirty { false } |
| std::vector< std::pair< size_t, size_t > > | m_dirty |
| std::vector< SliceId > | m_draw_order |
| std::vector< SliceId > | m_memory_order |
| std::vector< uint8_t > | m_mirror |
| SliceId | m_next_id { 1 } |
| bool | m_runs_changed { true } |
| std::unordered_map< SliceId, Slice > | m_slices |
| uint32_t | m_stride |
| Portal::Graphics::PrimitiveTopology | m_topology |
Many vertex blocks laid out in one buffer, drawn as few runs.
Holds a CPU mirror of the whole batch that shares offsets with the GPU buffer. Blocks are identified by id, placed contiguously in the order they were added, and share one stride. Each carries a topology, defaulting to the set's, so a render processor that triangulates can draw mixed spans as one batch; one that does not needs every slice to match its own topology. Draw order is independent of memory order: bring_to_front, send_to_back and set_visible only change the run list, never move vertex data. Runs adjacent in both memory and draw order and of the same topology are coalesced, so an in-order visible batch is a single run. Strip and fan topologies are never coalesced, since joining their runs would fabricate a primitive across the seam.
Same-size updates write into the mirror and mark one dirty range. Adding appends. Resizing or removing a block shifts the blocks after it, which are then uploaded as one range.
Apply runs with RenderProcessor::set_runs and pair them with set_vertex_range: a single run is not honoured by the multi-run draw, which otherwise draws the buffer's whole vertex count.
Not thread safe.
Definition at line 34 of file SliceSet.hpp.