mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
af0a1af8e1
The backdrop propagation is slow but it does work.
110 lines
2.4 KiB
C
110 lines
2.4 KiB
C
// Code auto-generated by piet-gpu-derive
|
|
|
|
struct PathRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct TileRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct TileSegRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct Path {
|
|
uvec4 bbox;
|
|
TileRef tiles;
|
|
};
|
|
|
|
#define Path_size 12
|
|
|
|
PathRef Path_index(PathRef ref, uint index) {
|
|
return PathRef(ref.offset + index * Path_size);
|
|
}
|
|
|
|
struct Tile {
|
|
TileSegRef tile;
|
|
int backdrop;
|
|
};
|
|
|
|
#define Tile_size 8
|
|
|
|
TileRef Tile_index(TileRef ref, uint index) {
|
|
return TileRef(ref.offset + index * Tile_size);
|
|
}
|
|
|
|
struct TileSeg {
|
|
vec2 start;
|
|
vec2 end;
|
|
float y_edge;
|
|
TileSegRef next;
|
|
};
|
|
|
|
#define TileSeg_size 24
|
|
|
|
TileSegRef TileSeg_index(TileSegRef ref, uint index) {
|
|
return TileSegRef(ref.offset + index * TileSeg_size);
|
|
}
|
|
|
|
Path Path_read(PathRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = tile[ix + 0];
|
|
uint raw1 = tile[ix + 1];
|
|
uint raw2 = tile[ix + 2];
|
|
Path s;
|
|
s.bbox = uvec4(raw0 & 0xffff, raw0 >> 16, raw1 & 0xffff, raw1 >> 16);
|
|
s.tiles = TileRef(raw2);
|
|
return s;
|
|
}
|
|
|
|
void Path_write(PathRef ref, Path s) {
|
|
uint ix = ref.offset >> 2;
|
|
tile[ix + 0] = s.bbox.x | (s.bbox.y << 16);
|
|
tile[ix + 1] = s.bbox.z | (s.bbox.w << 16);
|
|
tile[ix + 2] = s.tiles.offset;
|
|
}
|
|
|
|
Tile Tile_read(TileRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = tile[ix + 0];
|
|
uint raw1 = tile[ix + 1];
|
|
Tile s;
|
|
s.tile = TileSegRef(raw0);
|
|
s.backdrop = int(raw1);
|
|
return s;
|
|
}
|
|
|
|
void Tile_write(TileRef ref, Tile s) {
|
|
uint ix = ref.offset >> 2;
|
|
tile[ix + 0] = s.tile.offset;
|
|
tile[ix + 1] = uint(s.backdrop);
|
|
}
|
|
|
|
TileSeg TileSeg_read(TileSegRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = tile[ix + 0];
|
|
uint raw1 = tile[ix + 1];
|
|
uint raw2 = tile[ix + 2];
|
|
uint raw3 = tile[ix + 3];
|
|
uint raw4 = tile[ix + 4];
|
|
uint raw5 = tile[ix + 5];
|
|
TileSeg s;
|
|
s.start = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
|
s.end = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
|
s.y_edge = uintBitsToFloat(raw4);
|
|
s.next = TileSegRef(raw5);
|
|
return s;
|
|
}
|
|
|
|
void TileSeg_write(TileSegRef ref, TileSeg s) {
|
|
uint ix = ref.offset >> 2;
|
|
tile[ix + 0] = floatBitsToUint(s.start.x);
|
|
tile[ix + 1] = floatBitsToUint(s.start.y);
|
|
tile[ix + 2] = floatBitsToUint(s.end.x);
|
|
tile[ix + 3] = floatBitsToUint(s.end.y);
|
|
tile[ix + 4] = floatBitsToUint(s.y_edge);
|
|
tile[ix + 5] = s.next.offset;
|
|
}
|
|
|