vello/piet-gpu/shader/bins.h
Raph Levien d14895b107 Continuing work on clips
I realized there's a problem with encoding clip bboxes relative to the
current transform (see #36 for a more detailed explanation), so this is
changing it to absolute bboxes.

This more or less gets clips working. There are optimization
opportunities (all-clear and all-opaque mask tiles), and it doesn't deal
with overflow of the blend stack, but it seems to basically work.
2020-11-20 18:25:27 -08:00

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;
}