Skip to content

Commit

Permalink
remove FillMask and FillMaskInv
Browse files Browse the repository at this point in the history
Obsoleted by BeginClip/EndClip.

Updates linebender#36

Signed-off-by: Elias Naur <[email protected]>
  • Loading branch information
eliasnaur committed Nov 29, 2020
1 parent bd450ef commit feeb459
Show file tree
Hide file tree
Showing 18 changed files with 12 additions and 238 deletions.
6 changes: 0 additions & 6 deletions piet-gpu-types/src/annotated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ piet_gpu! {
bbox: [f32; 4],
rgba_color: u32,
}
struct AnnoFillMask {
bbox: [f32; 4],
mask: f32,
}
struct AnnoStroke {
bbox: [f32; 4],
rgba_color: u32,
Expand All @@ -27,8 +23,6 @@ piet_gpu! {
Nop,
Stroke(AnnoStroke),
Fill(AnnoFill),
FillMask(AnnoFillMask),
FillMaskInv(AnnoFillMask),
BeginClip(AnnoClip),
EndClip(AnnoClip),
}
Expand Down
7 changes: 0 additions & 7 deletions piet-gpu-types/src/ptcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ piet_gpu! {
backdrop: i32,
rgba_color: u32,
}
struct CmdFillMask {
tile_ref: u32,
backdrop: i32,
mask: f32,
}
struct CmdBeginClip {
tile_ref: u32,
backdrop: i32,
Expand Down Expand Up @@ -57,8 +52,6 @@ piet_gpu! {
Circle(CmdCircle),
Line(CmdLine),
Fill(CmdFill),
FillMask(CmdFillMask),
FillMaskInv(CmdFillMask),
BeginClip(CmdBeginClip),
BeginSolidClip(CmdBeginSolidClip),
EndClip(CmdEndClip),
Expand Down
5 changes: 0 additions & 5 deletions piet-gpu-types/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ piet_gpu! {
struct Fill {
rgba_color: u32,
}
struct FillMask {
mask: f32,
}
struct Stroke {
rgba_color: u32,
}
Expand Down Expand Up @@ -59,8 +56,6 @@ piet_gpu! {
Fill(Fill),
SetLineWidth(SetLineWidth),
Transform(Transform),
FillMask(FillMask),
FillMaskInv(FillMask),
BeginClip(Clip),
EndClip(Clip),
}
Expand Down
61 changes: 2 additions & 59 deletions piet-gpu/shader/annotated.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ struct AnnoFillRef {
uint offset;
};

struct AnnoFillMaskRef {
uint offset;
};

struct AnnoStrokeRef {
uint offset;
};
Expand All @@ -31,17 +27,6 @@ AnnoFillRef AnnoFill_index(AnnoFillRef ref, uint index) {
return AnnoFillRef(ref.offset + index * AnnoFill_size);
}

struct AnnoFillMask {
vec4 bbox;
float mask;
};

#define AnnoFillMask_size 20

AnnoFillMaskRef AnnoFillMask_index(AnnoFillMaskRef ref, uint index) {
return AnnoFillMaskRef(ref.offset + index * AnnoFillMask_size);
}

struct AnnoStroke {
vec4 bbox;
uint rgba_color;
Expand All @@ -67,10 +52,8 @@ AnnoClipRef AnnoClip_index(AnnoClipRef ref, uint index) {
#define Annotated_Nop 0
#define Annotated_Stroke 1
#define Annotated_Fill 2
#define Annotated_FillMask 3
#define Annotated_FillMaskInv 4
#define Annotated_BeginClip 5
#define Annotated_EndClip 6
#define Annotated_BeginClip 3
#define Annotated_EndClip 4
#define Annotated_size 28

AnnotatedRef Annotated_index(AnnotatedRef ref, uint index) {
Expand Down Expand Up @@ -99,28 +82,6 @@ void AnnoFill_write(AnnoFillRef ref, AnnoFill s) {
annotated[ix + 4] = s.rgba_color;
}

AnnoFillMask AnnoFillMask_read(AnnoFillMaskRef ref) {
uint ix = ref.offset >> 2;
uint raw0 = annotated[ix + 0];
uint raw1 = annotated[ix + 1];
uint raw2 = annotated[ix + 2];
uint raw3 = annotated[ix + 3];
uint raw4 = annotated[ix + 4];
AnnoFillMask s;
s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));
s.mask = uintBitsToFloat(raw4);
return s;
}

void AnnoFillMask_write(AnnoFillMaskRef ref, AnnoFillMask s) {
uint ix = ref.offset >> 2;
annotated[ix + 0] = floatBitsToUint(s.bbox.x);
annotated[ix + 1] = floatBitsToUint(s.bbox.y);
annotated[ix + 2] = floatBitsToUint(s.bbox.z);
annotated[ix + 3] = floatBitsToUint(s.bbox.w);
annotated[ix + 4] = floatBitsToUint(s.mask);
}

AnnoStroke AnnoStroke_read(AnnoStrokeRef ref) {
uint ix = ref.offset >> 2;
uint raw0 = annotated[ix + 0];
Expand Down Expand Up @@ -177,14 +138,6 @@ AnnoFill Annotated_Fill_read(AnnotatedRef ref) {
return AnnoFill_read(AnnoFillRef(ref.offset + 4));
}

AnnoFillMask Annotated_FillMask_read(AnnotatedRef ref) {
return AnnoFillMask_read(AnnoFillMaskRef(ref.offset + 4));
}

AnnoFillMask Annotated_FillMaskInv_read(AnnotatedRef ref) {
return AnnoFillMask_read(AnnoFillMaskRef(ref.offset + 4));
}

AnnoClip Annotated_BeginClip_read(AnnotatedRef ref) {
return AnnoClip_read(AnnoClipRef(ref.offset + 4));
}
Expand All @@ -207,16 +160,6 @@ void Annotated_Fill_write(AnnotatedRef ref, AnnoFill s) {
AnnoFill_write(AnnoFillRef(ref.offset + 4), s);
}

void Annotated_FillMask_write(AnnotatedRef ref, AnnoFillMask s) {
annotated[ref.offset >> 2] = Annotated_FillMask;
AnnoFillMask_write(AnnoFillMaskRef(ref.offset + 4), s);
}

void Annotated_FillMaskInv_write(AnnotatedRef ref, AnnoFillMask s) {
annotated[ref.offset >> 2] = Annotated_FillMaskInv;
AnnoFillMask_write(AnnoFillMaskRef(ref.offset + 4), s);
}

void Annotated_BeginClip_write(AnnotatedRef ref, AnnoClip s) {
annotated[ref.offset >> 2] = Annotated_BeginClip;
AnnoClip_write(AnnoClipRef(ref.offset + 4), s);
Expand Down
2 changes: 0 additions & 2 deletions piet-gpu/shader/backdrop.comp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ void main() {
uint tag = Annotated_tag(ref);
switch (tag) {
case Annotated_Fill:
case Annotated_FillMask:
case Annotated_FillMaskInv:
case Annotated_BeginClip:
PathRef path_ref = PathRef(element_ix * Path_size);
Path path = Path_read(path_ref);
Expand Down
Binary file modified piet-gpu/shader/backdrop.spv
Binary file not shown.
2 changes: 0 additions & 2 deletions piet-gpu/shader/binning.comp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ void main() {
int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
switch (tag) {
case Annotated_Fill:
case Annotated_FillMask:
case Annotated_FillMaskInv:
case Annotated_Stroke:
case Annotated_BeginClip:
case Annotated_EndClip:
Expand Down
Binary file modified piet-gpu/shader/binning.spv
Binary file not shown.
27 changes: 1 addition & 26 deletions piet-gpu/shader/coarse.comp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ void main() {
uint tile_count;
switch (tag) {
case Annotated_Fill:
case Annotated_FillMask:
case Annotated_FillMaskInv:
case Annotated_Stroke:
case Annotated_BeginClip:
case Annotated_EndClip:
Expand Down Expand Up @@ -234,9 +232,7 @@ void main() {
// Include the path in the tile if
// - the tile contains at least a segment (tile offset non-zero)
// - the tile is completely covered (backdrop non-zero)
bool inside = tile.backdrop != 0;
bool fill = tag != Annotated_FillMaskInv;
include_tile = tile.tile.offset != 0 || inside == fill;
include_tile = tile.tile.offset != 0 || tile.backdrop != 0;
}
if (include_tile) {
uint el_slice = el_ix / 32;
Expand Down Expand Up @@ -312,27 +308,6 @@ void main() {
Cmd_EndClip_write(cmd_ref, CmdEndClip(1.0));
cmd_ref.offset += Cmd_size;
break;
case Annotated_FillMask:
case Annotated_FillMaskInv:
tile = Tile_read(TileRef(sh_tile_base[element_ref_ix]
+ (sh_tile_stride[element_ref_ix] * tile_y + tile_x) * Tile_size));
AnnoFillMask fill_mask = Annotated_FillMask_read(ref);
alloc_cmd(cmd_ref, cmd_limit);
if (tile.tile.offset != 0) {
CmdFillMask cmd_fill;
cmd_fill.tile_ref = tile.tile.offset;
cmd_fill.backdrop = tile.backdrop;
cmd_fill.mask = fill_mask.mask;
if (tag == Annotated_FillMask) {
Cmd_FillMask_write(cmd_ref, cmd_fill);
} else {
Cmd_FillMaskInv_write(cmd_ref, cmd_fill);
}
} else {
Cmd_SolidMask_write(cmd_ref, CmdSolidMask(fill_mask.mask));
}
cmd_ref.offset += Cmd_size;
break;
case Annotated_Stroke:
tile = Tile_read(TileRef(sh_tile_base[element_ref_ix]
+ (sh_tile_stride[element_ref_ix] * tile_y + tile_x) * Tile_size));
Expand Down
Binary file modified piet-gpu/shader/coarse.spv
Binary file not shown.
19 changes: 0 additions & 19 deletions piet-gpu/shader/elements.comp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ State map_element(ElementRef ref) {
c.pathseg_count = 1;
break;
case Element_Fill:
case Element_FillMask:
case Element_FillMaskInv:
case Element_Stroke:
case Element_BeginClip:
c.flags = FLAG_RESET_BBOX;
Expand Down Expand Up @@ -408,23 +406,6 @@ void main() {
out_ref = AnnotatedRef((st.path_count - 1) * Annotated_size);
Annotated_Fill_write(out_ref, anno_fill);
break;
case Element_FillMask:
FillMask fill_mask = Element_FillMask_read(this_ref);
AnnoFillMask anno_fill_mask;
anno_fill_mask.mask = fill_mask.mask;
anno_fill_mask.bbox = st.bbox;
out_ref = AnnotatedRef((st.path_count - 1) * Annotated_size);
Annotated_FillMask_write(out_ref, anno_fill_mask);
break;
case Element_FillMaskInv:
fill_mask = Element_FillMaskInv_read(this_ref);
anno_fill_mask.mask = fill_mask.mask;
// The inverse fill conceptually takes up the entire screen.
// TODO: Tighten bounds to contain only affected paths.
anno_fill_mask.bbox = vec4(0, 0, 1e9, 1e9);
out_ref = AnnotatedRef((st.path_count - 1) * Annotated_size);
Annotated_FillMaskInv_write(out_ref, anno_fill_mask);
break;
case Element_BeginClip:
Clip begin_clip = Element_BeginClip_read(this_ref);
AnnoClip anno_begin_clip = AnnoClip(begin_clip.bbox);
Expand Down
Binary file modified piet-gpu/shader/elements.spv
Binary file not shown.
14 changes: 0 additions & 14 deletions piet-gpu/shader/kernel4.comp
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,6 @@ void main() {
rgb[k] = mix(rgb[k], fg_rgba.rgb, mask[k] * area[k] * fg_rgba.a);
}
break;
case Cmd_FillMask:
CmdFillMask fill_mask = Cmd_FillMask_read(cmd_ref);
area = computeArea(xy, fill_mask.backdrop, fill_mask.tile_ref);
for (uint k = 0; k < CHUNK; k++) {
mask[k] = mix(mask[k], fill_mask.mask, area[k]);
}
break;
case Cmd_FillMaskInv:
fill_mask = Cmd_FillMask_read(cmd_ref);
area = computeArea(xy, fill_mask.backdrop, fill_mask.tile_ref);
for (uint k = 0; k < CHUNK; k++) {
mask[k] = mix(mask[k], fill_mask.mask, 1.0 - area[k]);
}
break;
case Cmd_BeginClip:
case Cmd_BeginSolidClip:
uint blend_slot = blend_sp % BLEND_STACK_SIZE;
Expand Down
Binary file modified piet-gpu/shader/kernel4.spv
Binary file not shown.
69 changes: 7 additions & 62 deletions piet-gpu/shader/ptcl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ struct CmdFillRef {
uint offset;
};

struct CmdFillMaskRef {
uint offset;
};

struct CmdBeginClipRef {
uint offset;
};
Expand Down Expand Up @@ -95,18 +91,6 @@ CmdFillRef CmdFill_index(CmdFillRef ref, uint index) {
return CmdFillRef(ref.offset + index * CmdFill_size);
}

struct CmdFillMask {
uint tile_ref;
int backdrop;
float mask;
};

#define CmdFillMask_size 12

CmdFillMaskRef CmdFillMask_index(CmdFillMaskRef ref, uint index) {
return CmdFillMaskRef(ref.offset + index * CmdFillMask_size);
}

struct CmdBeginClip {
uint tile_ref;
int backdrop;
Expand Down Expand Up @@ -172,15 +156,13 @@ CmdJumpRef CmdJump_index(CmdJumpRef ref, uint index) {
#define Cmd_Circle 1
#define Cmd_Line 2
#define Cmd_Fill 3
#define Cmd_FillMask 4
#define Cmd_FillMaskInv 5
#define Cmd_BeginClip 6
#define Cmd_BeginSolidClip 7
#define Cmd_EndClip 8
#define Cmd_Stroke 9
#define Cmd_Solid 10
#define Cmd_SolidMask 11
#define Cmd_Jump 12
#define Cmd_BeginClip 4
#define Cmd_BeginSolidClip 5
#define Cmd_EndClip 6
#define Cmd_Stroke 7
#define Cmd_Solid 8
#define Cmd_SolidMask 9
#define Cmd_Jump 10
#define Cmd_size 20

CmdRef Cmd_index(CmdRef ref, uint index) {
Expand Down Expand Up @@ -266,25 +248,6 @@ void CmdFill_write(CmdFillRef ref, CmdFill s) {
ptcl[ix + 2] = s.rgba_color;
}

CmdFillMask CmdFillMask_read(CmdFillMaskRef ref) {
uint ix = ref.offset >> 2;
uint raw0 = ptcl[ix + 0];
uint raw1 = ptcl[ix + 1];
uint raw2 = ptcl[ix + 2];
CmdFillMask s;
s.tile_ref = raw0;
s.backdrop = int(raw1);
s.mask = uintBitsToFloat(raw2);
return s;
}

void CmdFillMask_write(CmdFillMaskRef ref, CmdFillMask s) {
uint ix = ref.offset >> 2;
ptcl[ix + 0] = s.tile_ref;
ptcl[ix + 1] = uint(s.backdrop);
ptcl[ix + 2] = floatBitsToUint(s.mask);
}

CmdBeginClip CmdBeginClip_read(CmdBeginClipRef ref) {
uint ix = ref.offset >> 2;
uint raw0 = ptcl[ix + 0];
Expand Down Expand Up @@ -382,14 +345,6 @@ CmdFill Cmd_Fill_read(CmdRef ref) {
return CmdFill_read(CmdFillRef(ref.offset + 4));
}

CmdFillMask Cmd_FillMask_read(CmdRef ref) {
return CmdFillMask_read(CmdFillMaskRef(ref.offset + 4));
}

CmdFillMask Cmd_FillMaskInv_read(CmdRef ref) {
return CmdFillMask_read(CmdFillMaskRef(ref.offset + 4));
}

CmdBeginClip Cmd_BeginClip_read(CmdRef ref) {
return CmdBeginClip_read(CmdBeginClipRef(ref.offset + 4));
}
Expand Down Expand Up @@ -437,16 +392,6 @@ void Cmd_Fill_write(CmdRef ref, CmdFill s) {
CmdFill_write(CmdFillRef(ref.offset + 4), s);
}

void Cmd_FillMask_write(CmdRef ref, CmdFillMask s) {
ptcl[ref.offset >> 2] = Cmd_FillMask;
CmdFillMask_write(CmdFillMaskRef(ref.offset + 4), s);
}

void Cmd_FillMaskInv_write(CmdRef ref, CmdFillMask s) {
ptcl[ref.offset >> 2] = Cmd_FillMaskInv;
CmdFillMask_write(CmdFillMaskRef(ref.offset + 4), s);
}

void Cmd_BeginClip_write(CmdRef ref, CmdBeginClip s) {
ptcl[ref.offset >> 2] = Cmd_BeginClip;
CmdBeginClip_write(CmdBeginClipRef(ref.offset + 4), s);
Expand Down
Loading

0 comments on commit feeb459

Please sign in to comment.