mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 04:31:30 +11:00
kernel4.comp: remove unused commands
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
parent
6a4e26ef2a
commit
b73eabf4eb
|
@ -3,15 +3,6 @@ use piet_gpu_derive::piet_gpu;
|
|||
piet_gpu! {
|
||||
#[gpu_write]
|
||||
mod ptcl {
|
||||
struct CmdCircle {
|
||||
center: [f32; 2],
|
||||
radius: f32,
|
||||
rgba_color: u32,
|
||||
}
|
||||
struct CmdLine {
|
||||
start: [f32; 2],
|
||||
end: [f32; 2],
|
||||
}
|
||||
struct CmdStroke {
|
||||
// This is really a Ref<Tile>, but we don't have cross-module
|
||||
// references.
|
||||
|
@ -41,23 +32,17 @@ piet_gpu! {
|
|||
struct CmdSolid {
|
||||
rgba_color: u32,
|
||||
}
|
||||
struct CmdSolidMask {
|
||||
mask: f32,
|
||||
}
|
||||
struct CmdJump {
|
||||
new_ref: u32,
|
||||
}
|
||||
enum Cmd {
|
||||
End,
|
||||
Circle(CmdCircle),
|
||||
Line(CmdLine),
|
||||
Fill(CmdFill),
|
||||
BeginClip(CmdBeginClip),
|
||||
BeginSolidClip(CmdBeginSolidClip),
|
||||
EndClip(CmdEndClip),
|
||||
Stroke(CmdStroke),
|
||||
Solid(CmdSolid),
|
||||
SolidMask(CmdSolidMask),
|
||||
Jump(CmdJump),
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -117,17 +117,6 @@ void main() {
|
|||
break;
|
||||
}
|
||||
switch (tag) {
|
||||
case Cmd_Circle:
|
||||
CmdCircle circle = Cmd_Circle_read(cmd_alloc, cmd_ref);
|
||||
vec4 fg_rgba = unpackUnorm4x8(circle.rgba_color).wzyx;
|
||||
for (uint i = 0; i < CHUNK; i++) {
|
||||
float dy = float(i * CHUNK_DY);
|
||||
float r = length(vec2(xy.x, xy.y + dy) + vec2(0.5, 0.5) - circle.center.xy);
|
||||
float alpha = clamp(0.5 + circle.radius - r, 0.0, 1.0);
|
||||
// TODO: sRGB
|
||||
rgb[i] = mix(rgb[i], fg_rgba.rgb, mask[i] * alpha * fg_rgba.a);
|
||||
}
|
||||
break;
|
||||
case Cmd_Stroke:
|
||||
// Calculate distance field from all the line segments in this tile.
|
||||
CmdStroke stroke = Cmd_Stroke_read(cmd_alloc, cmd_ref);
|
||||
|
@ -145,7 +134,7 @@ void main() {
|
|||
}
|
||||
tile_seg_ref = seg.next;
|
||||
} while (tile_seg_ref.offset != 0);
|
||||
fg_rgba = unpackUnorm4x8(stroke.rgba_color).wzyx;
|
||||
vec4 fg_rgba = unpackUnorm4x8(stroke.rgba_color).wzyx;
|
||||
for (uint k = 0; k < CHUNK; k++) {
|
||||
float alpha = clamp(stroke.half_width + 0.5 - df[k], 0.0, 1.0);
|
||||
rgb[k] = mix(rgb[k], fg_rgba.rgb, mask[k] * alpha * fg_rgba.a);
|
||||
|
@ -215,12 +204,6 @@ void main() {
|
|||
rgb[k] = mix(rgb[k], fg_rgba.rgb, mask[k] * fg_rgba.a);
|
||||
}
|
||||
break;
|
||||
case Cmd_SolidMask:
|
||||
CmdSolidMask solid_mask = Cmd_SolidMask_read(cmd_alloc, cmd_ref);
|
||||
for (uint k = 0; k < CHUNK; k++) {
|
||||
mask[k] = solid_mask.mask;
|
||||
}
|
||||
break;
|
||||
case Cmd_Jump:
|
||||
cmd_ref = CmdRef(Cmd_Jump_read(cmd_alloc, cmd_ref).new_ref);
|
||||
cmd_alloc.offset = cmd_ref.offset;
|
||||
|
|
Binary file not shown.
|
@ -2,14 +2,6 @@
|
|||
|
||||
// Code auto-generated by piet-gpu-derive
|
||||
|
||||
struct CmdCircleRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct CmdLineRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct CmdStrokeRef {
|
||||
uint offset;
|
||||
};
|
||||
|
@ -34,10 +26,6 @@ struct CmdSolidRef {
|
|||
uint offset;
|
||||
};
|
||||
|
||||
struct CmdSolidMaskRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct CmdJumpRef {
|
||||
uint offset;
|
||||
};
|
||||
|
@ -46,29 +34,6 @@ struct CmdRef {
|
|||
uint offset;
|
||||
};
|
||||
|
||||
struct CmdCircle {
|
||||
vec2 center;
|
||||
float radius;
|
||||
uint rgba_color;
|
||||
};
|
||||
|
||||
#define CmdCircle_size 16
|
||||
|
||||
CmdCircleRef CmdCircle_index(CmdCircleRef ref, uint index) {
|
||||
return CmdCircleRef(ref.offset + index * CmdCircle_size);
|
||||
}
|
||||
|
||||
struct CmdLine {
|
||||
vec2 start;
|
||||
vec2 end;
|
||||
};
|
||||
|
||||
#define CmdLine_size 16
|
||||
|
||||
CmdLineRef CmdLine_index(CmdLineRef ref, uint index) {
|
||||
return CmdLineRef(ref.offset + index * CmdLine_size);
|
||||
}
|
||||
|
||||
struct CmdStroke {
|
||||
uint tile_ref;
|
||||
float half_width;
|
||||
|
@ -134,16 +99,6 @@ CmdSolidRef CmdSolid_index(CmdSolidRef ref, uint index) {
|
|||
return CmdSolidRef(ref.offset + index * CmdSolid_size);
|
||||
}
|
||||
|
||||
struct CmdSolidMask {
|
||||
float mask;
|
||||
};
|
||||
|
||||
#define CmdSolidMask_size 4
|
||||
|
||||
CmdSolidMaskRef CmdSolidMask_index(CmdSolidMaskRef ref, uint index) {
|
||||
return CmdSolidMaskRef(ref.offset + index * CmdSolidMask_size);
|
||||
}
|
||||
|
||||
struct CmdJump {
|
||||
uint new_ref;
|
||||
};
|
||||
|
@ -155,63 +110,19 @@ CmdJumpRef CmdJump_index(CmdJumpRef ref, uint index) {
|
|||
}
|
||||
|
||||
#define Cmd_End 0
|
||||
#define Cmd_Circle 1
|
||||
#define Cmd_Line 2
|
||||
#define Cmd_Fill 3
|
||||
#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
|
||||
#define Cmd_Fill 1
|
||||
#define Cmd_BeginClip 2
|
||||
#define Cmd_BeginSolidClip 3
|
||||
#define Cmd_EndClip 4
|
||||
#define Cmd_Stroke 5
|
||||
#define Cmd_Solid 6
|
||||
#define Cmd_Jump 7
|
||||
#define Cmd_size 16
|
||||
|
||||
CmdRef Cmd_index(CmdRef ref, uint index) {
|
||||
return CmdRef(ref.offset + index * Cmd_size);
|
||||
}
|
||||
|
||||
CmdCircle CmdCircle_read(Alloc a, CmdCircleRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = read_mem(a, ix + 0);
|
||||
uint raw1 = read_mem(a, ix + 1);
|
||||
uint raw2 = read_mem(a, ix + 2);
|
||||
uint raw3 = read_mem(a, ix + 3);
|
||||
CmdCircle s;
|
||||
s.center = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
s.radius = uintBitsToFloat(raw2);
|
||||
s.rgba_color = raw3;
|
||||
return s;
|
||||
}
|
||||
|
||||
void CmdCircle_write(Alloc a, CmdCircleRef ref, CmdCircle s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
write_mem(a, ix + 0, floatBitsToUint(s.center.x));
|
||||
write_mem(a, ix + 1, floatBitsToUint(s.center.y));
|
||||
write_mem(a, ix + 2, floatBitsToUint(s.radius));
|
||||
write_mem(a, ix + 3, s.rgba_color);
|
||||
}
|
||||
|
||||
CmdLine CmdLine_read(Alloc a, CmdLineRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = read_mem(a, ix + 0);
|
||||
uint raw1 = read_mem(a, ix + 1);
|
||||
uint raw2 = read_mem(a, ix + 2);
|
||||
uint raw3 = read_mem(a, ix + 3);
|
||||
CmdLine s;
|
||||
s.start = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
s.end = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
||||
return s;
|
||||
}
|
||||
|
||||
void CmdLine_write(Alloc a, CmdLineRef ref, CmdLine s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
write_mem(a, ix + 0, floatBitsToUint(s.start.x));
|
||||
write_mem(a, ix + 1, floatBitsToUint(s.start.y));
|
||||
write_mem(a, ix + 2, floatBitsToUint(s.end.x));
|
||||
write_mem(a, ix + 3, floatBitsToUint(s.end.y));
|
||||
}
|
||||
|
||||
CmdStroke CmdStroke_read(Alloc a, CmdStrokeRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = read_mem(a, ix + 0);
|
||||
|
@ -305,19 +216,6 @@ void CmdSolid_write(Alloc a, CmdSolidRef ref, CmdSolid s) {
|
|||
write_mem(a, ix + 0, s.rgba_color);
|
||||
}
|
||||
|
||||
CmdSolidMask CmdSolidMask_read(Alloc a, CmdSolidMaskRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = read_mem(a, ix + 0);
|
||||
CmdSolidMask s;
|
||||
s.mask = uintBitsToFloat(raw0);
|
||||
return s;
|
||||
}
|
||||
|
||||
void CmdSolidMask_write(Alloc a, CmdSolidMaskRef ref, CmdSolidMask s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
write_mem(a, ix + 0, floatBitsToUint(s.mask));
|
||||
}
|
||||
|
||||
CmdJump CmdJump_read(Alloc a, CmdJumpRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = read_mem(a, ix + 0);
|
||||
|
@ -335,14 +233,6 @@ uint Cmd_tag(Alloc a, CmdRef ref) {
|
|||
return read_mem(a, ref.offset >> 2);
|
||||
}
|
||||
|
||||
CmdCircle Cmd_Circle_read(Alloc a, CmdRef ref) {
|
||||
return CmdCircle_read(a, CmdCircleRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
CmdLine Cmd_Line_read(Alloc a, CmdRef ref) {
|
||||
return CmdLine_read(a, CmdLineRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
CmdFill Cmd_Fill_read(Alloc a, CmdRef ref) {
|
||||
return CmdFill_read(a, CmdFillRef(ref.offset + 4));
|
||||
}
|
||||
|
@ -367,10 +257,6 @@ CmdSolid Cmd_Solid_read(Alloc a, CmdRef ref) {
|
|||
return CmdSolid_read(a, CmdSolidRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
CmdSolidMask Cmd_SolidMask_read(Alloc a, CmdRef ref) {
|
||||
return CmdSolidMask_read(a, CmdSolidMaskRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
CmdJump Cmd_Jump_read(Alloc a, CmdRef ref) {
|
||||
return CmdJump_read(a, CmdJumpRef(ref.offset + 4));
|
||||
}
|
||||
|
@ -379,16 +265,6 @@ void Cmd_End_write(Alloc a, CmdRef ref) {
|
|||
write_mem(a, ref.offset >> 2, Cmd_End);
|
||||
}
|
||||
|
||||
void Cmd_Circle_write(Alloc a, CmdRef ref, CmdCircle s) {
|
||||
write_mem(a, ref.offset >> 2, Cmd_Circle);
|
||||
CmdCircle_write(a, CmdCircleRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Cmd_Line_write(Alloc a, CmdRef ref, CmdLine s) {
|
||||
write_mem(a, ref.offset >> 2, Cmd_Line);
|
||||
CmdLine_write(a, CmdLineRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Cmd_Fill_write(Alloc a, CmdRef ref, CmdFill s) {
|
||||
write_mem(a, ref.offset >> 2, Cmd_Fill);
|
||||
CmdFill_write(a, CmdFillRef(ref.offset + 4), s);
|
||||
|
@ -419,11 +295,6 @@ void Cmd_Solid_write(Alloc a, CmdRef ref, CmdSolid s) {
|
|||
CmdSolid_write(a, CmdSolidRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Cmd_SolidMask_write(Alloc a, CmdRef ref, CmdSolidMask s) {
|
||||
write_mem(a, ref.offset >> 2, Cmd_SolidMask);
|
||||
CmdSolidMask_write(a, CmdSolidMaskRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Cmd_Jump_write(Alloc a, CmdRef ref, CmdJump s) {
|
||||
write_mem(a, ref.offset >> 2, Cmd_Jump);
|
||||
CmdJump_write(a, CmdJumpRef(ref.offset + 4), s);
|
||||
|
|
Loading…
Reference in a new issue