mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
343e4c3075
Adds a binning stage. This is a first draft, and a number of loose ends exist.
61 lines
1.2 KiB
C
61 lines
1.2 KiB
C
// Code auto-generated by piet-gpu-derive
|
|
|
|
struct BinInstanceRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct BinChunkRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct BinInstance {
|
|
uint element_ix;
|
|
};
|
|
|
|
#define BinInstance_size 4
|
|
|
|
BinInstanceRef BinInstance_index(BinInstanceRef ref, uint index) {
|
|
return BinInstanceRef(ref.offset + index * BinInstance_size);
|
|
}
|
|
|
|
struct BinChunk {
|
|
uint n;
|
|
BinChunkRef next;
|
|
};
|
|
|
|
#define BinChunk_size 8
|
|
|
|
BinChunkRef BinChunk_index(BinChunkRef ref, uint index) {
|
|
return BinChunkRef(ref.offset + index * BinChunk_size);
|
|
}
|
|
|
|
BinInstance BinInstance_read(BinInstanceRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = bins[ix + 0];
|
|
BinInstance s;
|
|
s.element_ix = raw0;
|
|
return s;
|
|
}
|
|
|
|
void BinInstance_write(BinInstanceRef ref, BinInstance s) {
|
|
uint ix = ref.offset >> 2;
|
|
bins[ix + 0] = s.element_ix;
|
|
}
|
|
|
|
BinChunk BinChunk_read(BinChunkRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = bins[ix + 0];
|
|
uint raw1 = bins[ix + 1];
|
|
BinChunk s;
|
|
s.n = raw0;
|
|
s.next = BinChunkRef(raw1);
|
|
return s;
|
|
}
|
|
|
|
void BinChunk_write(BinChunkRef ref, BinChunk s) {
|
|
uint ix = ref.offset >> 2;
|
|
bins[ix + 0] = s.n;
|
|
bins[ix + 1] = s.next.offset;
|
|
}
|
|
|