mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
Allocate segment chunks in slabs
Another speedup might be to special-case when the number of chunks in a stroke or fill command is 1, then the segment header doesn't need allocation and memory traffic is reduced. But right now we'll avoid the complexity.
This commit is contained in:
parent
8eaf49a04d
commit
3d422d9243
|
@ -69,9 +69,20 @@ void alloc_cmd(inout CmdRef cmd_ref, inout uint cmd_limit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: aggregate rather than doing an atomic every time
|
#define CHUNK_ALLOC_SLAB 16
|
||||||
|
|
||||||
|
uint alloc_chunk_remaining;
|
||||||
|
uint alloc_chunk_offset;
|
||||||
|
|
||||||
SegChunkRef alloc_seg_chunk() {
|
SegChunkRef alloc_seg_chunk() {
|
||||||
return SegChunkRef(atomicAdd(alloc, SegChunk_size));
|
if (alloc_chunk_remaining == 0) {
|
||||||
|
alloc_chunk_offset = atomicAdd(alloc, CHUNK_ALLOC_SLAB * SegChunk_size);
|
||||||
|
alloc_chunk_remaining = CHUNK_ALLOC_SLAB;
|
||||||
|
}
|
||||||
|
uint offset = alloc_chunk_offset;
|
||||||
|
alloc_chunk_offset += SegChunk_size;
|
||||||
|
alloc_chunk_remaining--;
|
||||||
|
return SegChunkRef(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accumulate delta to backdrop.
|
// Accumulate delta to backdrop.
|
||||||
|
@ -101,6 +112,7 @@ void main() {
|
||||||
SegChunkRef last_chunk_ref = SegChunkRef(0);
|
SegChunkRef last_chunk_ref = SegChunkRef(0);
|
||||||
uint last_chunk_n = 0;
|
uint last_chunk_n = 0;
|
||||||
SegmentRef last_chunk_segs = SegmentRef(0);
|
SegmentRef last_chunk_segs = SegmentRef(0);
|
||||||
|
alloc_chunk_remaining = 0;
|
||||||
|
|
||||||
uint wr_ix = 0;
|
uint wr_ix = 0;
|
||||||
uint rd_ix = 0;
|
uint rd_ix = 0;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue