mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-11 04:51:32 +11:00
acb3933d94
This patch switches to a variable size encoding of draw objects. In addition to the CPU-side scene encoding, it changes the representation of intermediate per draw object state from the `Annotated` struct to a variable "info" encoding. In addition, the bounding boxes are moved to a separate array (for a more "structure of "arrays" approach). Data that's unchanged from the scene encoding is not copied. Rather, downstream stages can access the data from the scene buffer (reducing allocation and copying). Prefix sums, computed in `DrawMonoid` track the offset of both scene and intermediate data. The tags for the CPU-side encoding have been split into their own stream (again a change from AoS to SoA style). This is not necessarily the final form. There's some stuff (including at least one piet-gpu-derive type) that can be deleted. In addition, the linewidth field should probably move from the info to path-specific. Also, the 1:1 correspondence between draw object and path has not yet been broken. Closes #152
41 lines
1.1 KiB
GLSL
41 lines
1.1 KiB
GLSL
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
|
|
|
|
// Common data structures and functions for the draw tag stream.
|
|
|
|
// Design of draw tag: & 0x1c gives scene size in bytes
|
|
// & 1 gives clip
|
|
// (tag >> 4) & 0x1c is info size in bytes
|
|
|
|
#define Drawtag_Nop 0
|
|
#define Drawtag_FillColor 0x44
|
|
#define Drawtag_FillLinGradient 0x114
|
|
#define Drawtag_FillImage 0x48
|
|
#define Drawtag_BeginClip 0x05
|
|
#define Drawtag_EndClip 0x25
|
|
|
|
struct DrawMonoid {
|
|
uint path_ix;
|
|
uint clip_ix;
|
|
uint scene_offset;
|
|
uint info_offset;
|
|
};
|
|
|
|
DrawMonoid draw_monoid_identity() {
|
|
return DrawMonoid(0, 0, 0, 0);
|
|
}
|
|
|
|
DrawMonoid combine_draw_monoid(DrawMonoid a, DrawMonoid b) {
|
|
DrawMonoid c;
|
|
c.path_ix = a.path_ix + b.path_ix;
|
|
c.clip_ix = a.clip_ix + b.clip_ix;
|
|
c.scene_offset = a.scene_offset + b.scene_offset;
|
|
c.info_offset = a.info_offset + b.info_offset;
|
|
return c;
|
|
}
|
|
|
|
DrawMonoid map_tag(uint tag_word) {
|
|
// TODO: at some point, EndClip should not generate a path
|
|
uint has_path = uint(tag_word != Drawtag_Nop);
|
|
return DrawMonoid(has_path, tag_word & 1, tag_word & 0x1c, (tag_word >> 4) & 0x1c);
|
|
}
|