mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 12:41:30 +11:00
Merge pull request #33 from eliasnaur/master
piet-gpu-types: remove unused types
This commit is contained in:
commit
db6172d811
|
@ -3,35 +3,6 @@ use piet_gpu_derive::piet_gpu;
|
|||
piet_gpu! {
|
||||
#[gpu_write]
|
||||
mod annotated {
|
||||
// Note: path segments have moved to pathseg, delete these.
|
||||
struct AnnoFillLineSeg {
|
||||
p0: [f32; 2],
|
||||
p1: [f32; 2],
|
||||
path_ix: u32,
|
||||
// A note: the layout of this struct is shared with
|
||||
// AnnoStrokeLineSeg. In that case, we actually write
|
||||
// [0.0, 0.0] as the stroke field, to minimize divergence.
|
||||
}
|
||||
struct AnnoStrokeLineSeg {
|
||||
p0: [f32; 2],
|
||||
p1: [f32; 2],
|
||||
path_ix: u32,
|
||||
// halfwidth in both x and y for binning
|
||||
stroke: [f32; 2],
|
||||
}
|
||||
struct AnnoQuadSeg {
|
||||
p0: [f32; 2],
|
||||
p1: [f32; 2],
|
||||
p2: [f32; 2],
|
||||
stroke: [f32; 2],
|
||||
}
|
||||
struct AnnoCubicSeg {
|
||||
p0: [f32; 2],
|
||||
p1: [f32; 2],
|
||||
p2: [f32; 2],
|
||||
p3: [f32; 2],
|
||||
stroke: [f32; 2],
|
||||
}
|
||||
struct AnnoFill {
|
||||
rgba_color: u32,
|
||||
bbox: [f32; 4],
|
||||
|
@ -45,10 +16,6 @@ piet_gpu! {
|
|||
}
|
||||
enum Annotated {
|
||||
Nop,
|
||||
FillLine(AnnoFillLineSeg),
|
||||
StrokeLine(AnnoStrokeLineSeg),
|
||||
Quad(AnnoQuadSeg),
|
||||
Cubic(AnnoCubicSeg),
|
||||
Stroke(AnnoStroke),
|
||||
Fill(AnnoFill),
|
||||
}
|
||||
|
|
|
@ -25,15 +25,6 @@ piet_gpu! {
|
|||
backdrop: i32,
|
||||
rgba_color: u32,
|
||||
}
|
||||
struct CmdFillEdge {
|
||||
// The sign is only one bit.
|
||||
sign: i32,
|
||||
y: f32,
|
||||
}
|
||||
struct CmdDrawFill {
|
||||
backdrop: i32,
|
||||
rgba_color: u32,
|
||||
}
|
||||
struct CmdSolid {
|
||||
rgba_color: u32,
|
||||
}
|
||||
|
@ -46,11 +37,8 @@ piet_gpu! {
|
|||
Line(CmdLine),
|
||||
Fill(CmdFill),
|
||||
Stroke(CmdStroke),
|
||||
FillEdge(CmdFillEdge),
|
||||
DrawFill(CmdDrawFill),
|
||||
Solid(CmdSolid),
|
||||
Jump(CmdJump),
|
||||
Bail,
|
||||
}
|
||||
|
||||
// TODO: strongly consider using f16. If so, these would be
|
||||
|
|
|
@ -1,60 +1,10 @@
|
|||
use piet_gpu_derive::piet_gpu;
|
||||
|
||||
pub use self::scene::{
|
||||
Bbox, PietCircle, PietFill, PietItem, PietStrokeLine, PietStrokePolyLine, Point, SimpleGroup,
|
||||
};
|
||||
|
||||
pub use self::scene::{CubicSeg, Element, Fill, LineSeg, QuadSeg, SetLineWidth, Stroke, Transform};
|
||||
|
||||
piet_gpu! {
|
||||
#[rust_encode]
|
||||
mod scene {
|
||||
struct Bbox {
|
||||
bbox: [i16; 4],
|
||||
}
|
||||
struct Point {
|
||||
xy: [f32; 2],
|
||||
}
|
||||
struct SimpleGroup {
|
||||
n_items: u32,
|
||||
// Note: both of the following items are actually arrays
|
||||
items: Ref<PietItem>,
|
||||
bboxes: Ref<Bbox>,
|
||||
offset: Point,
|
||||
}
|
||||
struct PietCircle {
|
||||
rgba_color: u32,
|
||||
center: Point,
|
||||
radius: f32,
|
||||
}
|
||||
struct PietStrokeLine {
|
||||
flags: u32,
|
||||
rgba_color: u32,
|
||||
width: f32,
|
||||
start: Point,
|
||||
end: Point,
|
||||
}
|
||||
struct PietFill {
|
||||
flags: u32,
|
||||
rgba_color: u32,
|
||||
n_points: u32,
|
||||
points: Ref<Point>,
|
||||
}
|
||||
struct PietStrokePolyLine {
|
||||
rgba_color: u32,
|
||||
width: f32,
|
||||
n_points: u32,
|
||||
points: Ref<Point>,
|
||||
}
|
||||
enum PietItem {
|
||||
Group(SimpleGroup),
|
||||
Circle(PietCircle),
|
||||
Line(PietStrokeLine),
|
||||
Fill(PietFill),
|
||||
Poly(PietStrokePolyLine),
|
||||
}
|
||||
|
||||
// New approach follows (above to be deleted)
|
||||
struct LineSeg {
|
||||
p0: [f32; 2],
|
||||
p1: [f32; 2],
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
// Code auto-generated by piet-gpu-derive
|
||||
|
||||
struct AnnoFillLineSegRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct AnnoStrokeLineSegRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct AnnoQuadSegRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct AnnoCubicSegRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct AnnoFillRef {
|
||||
uint offset;
|
||||
};
|
||||
|
@ -28,58 +12,6 @@ struct AnnotatedRef {
|
|||
uint offset;
|
||||
};
|
||||
|
||||
struct AnnoFillLineSeg {
|
||||
vec2 p0;
|
||||
vec2 p1;
|
||||
uint path_ix;
|
||||
};
|
||||
|
||||
#define AnnoFillLineSeg_size 20
|
||||
|
||||
AnnoFillLineSegRef AnnoFillLineSeg_index(AnnoFillLineSegRef ref, uint index) {
|
||||
return AnnoFillLineSegRef(ref.offset + index * AnnoFillLineSeg_size);
|
||||
}
|
||||
|
||||
struct AnnoStrokeLineSeg {
|
||||
vec2 p0;
|
||||
vec2 p1;
|
||||
uint path_ix;
|
||||
vec2 stroke;
|
||||
};
|
||||
|
||||
#define AnnoStrokeLineSeg_size 28
|
||||
|
||||
AnnoStrokeLineSegRef AnnoStrokeLineSeg_index(AnnoStrokeLineSegRef ref, uint index) {
|
||||
return AnnoStrokeLineSegRef(ref.offset + index * AnnoStrokeLineSeg_size);
|
||||
}
|
||||
|
||||
struct AnnoQuadSeg {
|
||||
vec2 p0;
|
||||
vec2 p1;
|
||||
vec2 p2;
|
||||
vec2 stroke;
|
||||
};
|
||||
|
||||
#define AnnoQuadSeg_size 32
|
||||
|
||||
AnnoQuadSegRef AnnoQuadSeg_index(AnnoQuadSegRef ref, uint index) {
|
||||
return AnnoQuadSegRef(ref.offset + index * AnnoQuadSeg_size);
|
||||
}
|
||||
|
||||
struct AnnoCubicSeg {
|
||||
vec2 p0;
|
||||
vec2 p1;
|
||||
vec2 p2;
|
||||
vec2 p3;
|
||||
vec2 stroke;
|
||||
};
|
||||
|
||||
#define AnnoCubicSeg_size 40
|
||||
|
||||
AnnoCubicSegRef AnnoCubicSeg_index(AnnoCubicSegRef ref, uint index) {
|
||||
return AnnoCubicSegRef(ref.offset + index * AnnoCubicSeg_size);
|
||||
}
|
||||
|
||||
struct AnnoFill {
|
||||
uint rgba_color;
|
||||
vec4 bbox;
|
||||
|
@ -104,134 +36,14 @@ AnnoStrokeRef AnnoStroke_index(AnnoStrokeRef ref, uint index) {
|
|||
}
|
||||
|
||||
#define Annotated_Nop 0
|
||||
#define Annotated_FillLine 1
|
||||
#define Annotated_StrokeLine 2
|
||||
#define Annotated_Quad 3
|
||||
#define Annotated_Cubic 4
|
||||
#define Annotated_Stroke 5
|
||||
#define Annotated_Fill 6
|
||||
#define Annotated_size 44
|
||||
#define Annotated_Stroke 1
|
||||
#define Annotated_Fill 2
|
||||
#define Annotated_size 28
|
||||
|
||||
AnnotatedRef Annotated_index(AnnotatedRef ref, uint index) {
|
||||
return AnnotatedRef(ref.offset + index * Annotated_size);
|
||||
}
|
||||
|
||||
AnnoFillLineSeg AnnoFillLineSeg_read(AnnoFillLineSegRef 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];
|
||||
AnnoFillLineSeg s;
|
||||
s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
||||
s.path_ix = raw4;
|
||||
return s;
|
||||
}
|
||||
|
||||
void AnnoFillLineSeg_write(AnnoFillLineSegRef ref, AnnoFillLineSeg s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
annotated[ix + 0] = floatBitsToUint(s.p0.x);
|
||||
annotated[ix + 1] = floatBitsToUint(s.p0.y);
|
||||
annotated[ix + 2] = floatBitsToUint(s.p1.x);
|
||||
annotated[ix + 3] = floatBitsToUint(s.p1.y);
|
||||
annotated[ix + 4] = s.path_ix;
|
||||
}
|
||||
|
||||
AnnoStrokeLineSeg AnnoStrokeLineSeg_read(AnnoStrokeLineSegRef 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];
|
||||
uint raw5 = annotated[ix + 5];
|
||||
uint raw6 = annotated[ix + 6];
|
||||
AnnoStrokeLineSeg s;
|
||||
s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
||||
s.path_ix = raw4;
|
||||
s.stroke = vec2(uintBitsToFloat(raw5), uintBitsToFloat(raw6));
|
||||
return s;
|
||||
}
|
||||
|
||||
void AnnoStrokeLineSeg_write(AnnoStrokeLineSegRef ref, AnnoStrokeLineSeg s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
annotated[ix + 0] = floatBitsToUint(s.p0.x);
|
||||
annotated[ix + 1] = floatBitsToUint(s.p0.y);
|
||||
annotated[ix + 2] = floatBitsToUint(s.p1.x);
|
||||
annotated[ix + 3] = floatBitsToUint(s.p1.y);
|
||||
annotated[ix + 4] = s.path_ix;
|
||||
annotated[ix + 5] = floatBitsToUint(s.stroke.x);
|
||||
annotated[ix + 6] = floatBitsToUint(s.stroke.y);
|
||||
}
|
||||
|
||||
AnnoQuadSeg AnnoQuadSeg_read(AnnoQuadSegRef 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];
|
||||
uint raw5 = annotated[ix + 5];
|
||||
uint raw6 = annotated[ix + 6];
|
||||
uint raw7 = annotated[ix + 7];
|
||||
AnnoQuadSeg s;
|
||||
s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
||||
s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
|
||||
s.stroke = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7));
|
||||
return s;
|
||||
}
|
||||
|
||||
void AnnoQuadSeg_write(AnnoQuadSegRef ref, AnnoQuadSeg s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
annotated[ix + 0] = floatBitsToUint(s.p0.x);
|
||||
annotated[ix + 1] = floatBitsToUint(s.p0.y);
|
||||
annotated[ix + 2] = floatBitsToUint(s.p1.x);
|
||||
annotated[ix + 3] = floatBitsToUint(s.p1.y);
|
||||
annotated[ix + 4] = floatBitsToUint(s.p2.x);
|
||||
annotated[ix + 5] = floatBitsToUint(s.p2.y);
|
||||
annotated[ix + 6] = floatBitsToUint(s.stroke.x);
|
||||
annotated[ix + 7] = floatBitsToUint(s.stroke.y);
|
||||
}
|
||||
|
||||
AnnoCubicSeg AnnoCubicSeg_read(AnnoCubicSegRef 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];
|
||||
uint raw5 = annotated[ix + 5];
|
||||
uint raw6 = annotated[ix + 6];
|
||||
uint raw7 = annotated[ix + 7];
|
||||
uint raw8 = annotated[ix + 8];
|
||||
uint raw9 = annotated[ix + 9];
|
||||
AnnoCubicSeg s;
|
||||
s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
||||
s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
|
||||
s.p3 = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7));
|
||||
s.stroke = vec2(uintBitsToFloat(raw8), uintBitsToFloat(raw9));
|
||||
return s;
|
||||
}
|
||||
|
||||
void AnnoCubicSeg_write(AnnoCubicSegRef ref, AnnoCubicSeg s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
annotated[ix + 0] = floatBitsToUint(s.p0.x);
|
||||
annotated[ix + 1] = floatBitsToUint(s.p0.y);
|
||||
annotated[ix + 2] = floatBitsToUint(s.p1.x);
|
||||
annotated[ix + 3] = floatBitsToUint(s.p1.y);
|
||||
annotated[ix + 4] = floatBitsToUint(s.p2.x);
|
||||
annotated[ix + 5] = floatBitsToUint(s.p2.y);
|
||||
annotated[ix + 6] = floatBitsToUint(s.p3.x);
|
||||
annotated[ix + 7] = floatBitsToUint(s.p3.y);
|
||||
annotated[ix + 8] = floatBitsToUint(s.stroke.x);
|
||||
annotated[ix + 9] = floatBitsToUint(s.stroke.y);
|
||||
}
|
||||
|
||||
AnnoFill AnnoFill_read(AnnoFillRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = annotated[ix + 0];
|
||||
|
@ -283,22 +95,6 @@ uint Annotated_tag(AnnotatedRef ref) {
|
|||
return annotated[ref.offset >> 2];
|
||||
}
|
||||
|
||||
AnnoFillLineSeg Annotated_FillLine_read(AnnotatedRef ref) {
|
||||
return AnnoFillLineSeg_read(AnnoFillLineSegRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
AnnoStrokeLineSeg Annotated_StrokeLine_read(AnnotatedRef ref) {
|
||||
return AnnoStrokeLineSeg_read(AnnoStrokeLineSegRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
AnnoQuadSeg Annotated_Quad_read(AnnotatedRef ref) {
|
||||
return AnnoQuadSeg_read(AnnoQuadSegRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
AnnoCubicSeg Annotated_Cubic_read(AnnotatedRef ref) {
|
||||
return AnnoCubicSeg_read(AnnoCubicSegRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
AnnoStroke Annotated_Stroke_read(AnnotatedRef ref) {
|
||||
return AnnoStroke_read(AnnoStrokeRef(ref.offset + 4));
|
||||
}
|
||||
|
@ -311,26 +107,6 @@ void Annotated_Nop_write(AnnotatedRef ref) {
|
|||
annotated[ref.offset >> 2] = Annotated_Nop;
|
||||
}
|
||||
|
||||
void Annotated_FillLine_write(AnnotatedRef ref, AnnoFillLineSeg s) {
|
||||
annotated[ref.offset >> 2] = Annotated_FillLine;
|
||||
AnnoFillLineSeg_write(AnnoFillLineSegRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Annotated_StrokeLine_write(AnnotatedRef ref, AnnoStrokeLineSeg s) {
|
||||
annotated[ref.offset >> 2] = Annotated_StrokeLine;
|
||||
AnnoStrokeLineSeg_write(AnnoStrokeLineSegRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Annotated_Quad_write(AnnotatedRef ref, AnnoQuadSeg s) {
|
||||
annotated[ref.offset >> 2] = Annotated_Quad;
|
||||
AnnoQuadSeg_write(AnnoQuadSegRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Annotated_Cubic_write(AnnotatedRef ref, AnnoCubicSeg s) {
|
||||
annotated[ref.offset >> 2] = Annotated_Cubic;
|
||||
AnnoCubicSeg_write(AnnoCubicSegRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Annotated_Stroke_write(AnnotatedRef ref, AnnoStroke s) {
|
||||
annotated[ref.offset >> 2] = Annotated_Stroke;
|
||||
AnnoStroke_write(AnnoStrokeRef(ref.offset + 4), s);
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -7,8 +7,6 @@ glslang_validator = glslangValidator
|
|||
rule glsl
|
||||
command = $glslang_validator -V -o $out $in
|
||||
|
||||
build image.spv: glsl image.comp | scene.h
|
||||
|
||||
|
||||
build elements.spv: glsl elements.comp | scene.h state.h annotated.h
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,54 +0,0 @@
|
|||
// A simple kernel to create an image.
|
||||
|
||||
// Right now, this kernel stores the image in a buffer, but a better
|
||||
// plan is to use a texture. This is because of limited support.
|
||||
|
||||
#version 450
|
||||
#extension GL_GOOGLE_include_directive : enable
|
||||
|
||||
layout(local_size_x = 16, local_size_y = 16) in;
|
||||
|
||||
layout(set = 0, binding = 0) readonly buffer SceneBuf {
|
||||
uint[] scene;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1) buffer ImageBuf {
|
||||
uint[] image;
|
||||
};
|
||||
|
||||
#include "scene.h"
|
||||
|
||||
// TODO: make the image size dynamic.
|
||||
#define IMAGE_WIDTH 2048
|
||||
#define IMAGE_HEIGHT 1535
|
||||
|
||||
void main() {
|
||||
uvec2 xy_uint = gl_GlobalInvocationID.xy;
|
||||
vec2 xy = vec2(xy_uint);
|
||||
vec2 uv = xy * vec2(1.0 / IMAGE_WIDTH, 1.0 / IMAGE_HEIGHT);
|
||||
vec3 rgb = uv.xyy;
|
||||
|
||||
// Render the scene. Right now, every pixel traverses the scene graph,
|
||||
// which is horribly wasteful, but the goal is to get *some* output and
|
||||
// then optimize.
|
||||
|
||||
SimpleGroup group = PietItem_Group_read(PietItemRef(0));
|
||||
for (uint i = 0; i < group.n_items; i++) {
|
||||
PietItemRef item_ref = PietItem_index(group.items, i);
|
||||
uint tag = PietItem_tag(item_ref);
|
||||
tag = PietItem_Circle;
|
||||
if (tag == PietItem_Circle) {
|
||||
PietCircle circle = PietItem_Circle_read(item_ref);
|
||||
float r = length(xy + vec2(0.5, 0.5) - circle.center.xy);
|
||||
float alpha = clamp(0.5 + circle.radius - r, 0.0, 1.0);
|
||||
vec4 fg_rgba = unpackUnorm4x8(circle.rgba_color);
|
||||
// TODO: sRGB
|
||||
rgb = mix(rgb, fg_rgba.rgb, alpha * fg_rgba.a);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: sRGB
|
||||
uvec4 s = uvec4(round(vec4(rgb, 1.0) * 255.0));
|
||||
uint rgba_packed = s.r | (s.g << 8) | (s.b << 16) | (s.a << 24);
|
||||
image[xy_uint.y * IMAGE_WIDTH + xy_uint.x] = rgba_packed;
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -16,14 +16,6 @@ struct CmdFillRef {
|
|||
uint offset;
|
||||
};
|
||||
|
||||
struct CmdFillEdgeRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct CmdDrawFillRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct CmdSolidRef {
|
||||
uint offset;
|
||||
};
|
||||
|
@ -91,28 +83,6 @@ CmdFillRef CmdFill_index(CmdFillRef ref, uint index) {
|
|||
return CmdFillRef(ref.offset + index * CmdFill_size);
|
||||
}
|
||||
|
||||
struct CmdFillEdge {
|
||||
int sign;
|
||||
float y;
|
||||
};
|
||||
|
||||
#define CmdFillEdge_size 8
|
||||
|
||||
CmdFillEdgeRef CmdFillEdge_index(CmdFillEdgeRef ref, uint index) {
|
||||
return CmdFillEdgeRef(ref.offset + index * CmdFillEdge_size);
|
||||
}
|
||||
|
||||
struct CmdDrawFill {
|
||||
int backdrop;
|
||||
uint rgba_color;
|
||||
};
|
||||
|
||||
#define CmdDrawFill_size 8
|
||||
|
||||
CmdDrawFillRef CmdDrawFill_index(CmdDrawFillRef ref, uint index) {
|
||||
return CmdDrawFillRef(ref.offset + index * CmdDrawFill_size);
|
||||
}
|
||||
|
||||
struct CmdSolid {
|
||||
uint rgba_color;
|
||||
};
|
||||
|
@ -138,11 +108,8 @@ CmdJumpRef CmdJump_index(CmdJumpRef ref, uint index) {
|
|||
#define Cmd_Line 2
|
||||
#define Cmd_Fill 3
|
||||
#define Cmd_Stroke 4
|
||||
#define Cmd_FillEdge 5
|
||||
#define Cmd_DrawFill 6
|
||||
#define Cmd_Solid 7
|
||||
#define Cmd_Jump 8
|
||||
#define Cmd_Bail 9
|
||||
#define Cmd_Solid 5
|
||||
#define Cmd_Jump 6
|
||||
#define Cmd_size 20
|
||||
|
||||
CmdRef Cmd_index(CmdRef ref, uint index) {
|
||||
|
@ -252,38 +219,6 @@ void CmdFill_write(CmdFillRef ref, CmdFill s) {
|
|||
ptcl[ix + 2] = s.rgba_color;
|
||||
}
|
||||
|
||||
CmdFillEdge CmdFillEdge_read(CmdFillEdgeRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = ptcl[ix + 0];
|
||||
uint raw1 = ptcl[ix + 1];
|
||||
CmdFillEdge s;
|
||||
s.sign = int(raw0);
|
||||
s.y = uintBitsToFloat(raw1);
|
||||
return s;
|
||||
}
|
||||
|
||||
void CmdFillEdge_write(CmdFillEdgeRef ref, CmdFillEdge s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
ptcl[ix + 0] = uint(s.sign);
|
||||
ptcl[ix + 1] = floatBitsToUint(s.y);
|
||||
}
|
||||
|
||||
CmdDrawFill CmdDrawFill_read(CmdDrawFillRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = ptcl[ix + 0];
|
||||
uint raw1 = ptcl[ix + 1];
|
||||
CmdDrawFill s;
|
||||
s.backdrop = int(raw0);
|
||||
s.rgba_color = raw1;
|
||||
return s;
|
||||
}
|
||||
|
||||
void CmdDrawFill_write(CmdDrawFillRef ref, CmdDrawFill s) {
|
||||
uint ix = ref.offset >> 2;
|
||||
ptcl[ix + 0] = uint(s.backdrop);
|
||||
ptcl[ix + 1] = s.rgba_color;
|
||||
}
|
||||
|
||||
CmdSolid CmdSolid_read(CmdSolidRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = ptcl[ix + 0];
|
||||
|
@ -330,14 +265,6 @@ CmdStroke Cmd_Stroke_read(CmdRef ref) {
|
|||
return CmdStroke_read(CmdStrokeRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
CmdFillEdge Cmd_FillEdge_read(CmdRef ref) {
|
||||
return CmdFillEdge_read(CmdFillEdgeRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
CmdDrawFill Cmd_DrawFill_read(CmdRef ref) {
|
||||
return CmdDrawFill_read(CmdDrawFillRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
CmdSolid Cmd_Solid_read(CmdRef ref) {
|
||||
return CmdSolid_read(CmdSolidRef(ref.offset + 4));
|
||||
}
|
||||
|
@ -370,16 +297,6 @@ void Cmd_Stroke_write(CmdRef ref, CmdStroke s) {
|
|||
CmdStroke_write(CmdStrokeRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Cmd_FillEdge_write(CmdRef ref, CmdFillEdge s) {
|
||||
ptcl[ref.offset >> 2] = Cmd_FillEdge;
|
||||
CmdFillEdge_write(CmdFillEdgeRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Cmd_DrawFill_write(CmdRef ref, CmdDrawFill s) {
|
||||
ptcl[ref.offset >> 2] = Cmd_DrawFill;
|
||||
CmdDrawFill_write(CmdDrawFillRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Cmd_Solid_write(CmdRef ref, CmdSolid s) {
|
||||
ptcl[ref.offset >> 2] = Cmd_Solid;
|
||||
CmdSolid_write(CmdSolidRef(ref.offset + 4), s);
|
||||
|
@ -390,10 +307,6 @@ void Cmd_Jump_write(CmdRef ref, CmdJump s) {
|
|||
CmdJump_write(CmdJumpRef(ref.offset + 4), s);
|
||||
}
|
||||
|
||||
void Cmd_Bail_write(CmdRef ref) {
|
||||
ptcl[ref.offset >> 2] = Cmd_Bail;
|
||||
}
|
||||
|
||||
Segment Segment_read(SegmentRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = ptcl[ix + 0];
|
||||
|
|
|
@ -1,37 +1,5 @@
|
|||
// Code auto-generated by piet-gpu-derive
|
||||
|
||||
struct BboxRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct PointRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct SimpleGroupRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct PietCircleRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct PietStrokeLineRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct PietFillRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct PietStrokePolyLineRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct PietItemRef {
|
||||
uint offset;
|
||||
};
|
||||
|
||||
struct LineSegRef {
|
||||
uint offset;
|
||||
};
|
||||
|
@ -64,102 +32,6 @@ struct ElementRef {
|
|||
uint offset;
|
||||
};
|
||||
|
||||
struct Bbox {
|
||||
ivec4 bbox;
|
||||
};
|
||||
|
||||
#define Bbox_size 8
|
||||
|
||||
BboxRef Bbox_index(BboxRef ref, uint index) {
|
||||
return BboxRef(ref.offset + index * Bbox_size);
|
||||
}
|
||||
|
||||
struct Point {
|
||||
vec2 xy;
|
||||
};
|
||||
|
||||
#define Point_size 8
|
||||
|
||||
PointRef Point_index(PointRef ref, uint index) {
|
||||
return PointRef(ref.offset + index * Point_size);
|
||||
}
|
||||
|
||||
struct SimpleGroup {
|
||||
uint n_items;
|
||||
PietItemRef items;
|
||||
BboxRef bboxes;
|
||||
Point offset;
|
||||
};
|
||||
|
||||
#define SimpleGroup_size 20
|
||||
|
||||
SimpleGroupRef SimpleGroup_index(SimpleGroupRef ref, uint index) {
|
||||
return SimpleGroupRef(ref.offset + index * SimpleGroup_size);
|
||||
}
|
||||
|
||||
struct PietCircle {
|
||||
uint rgba_color;
|
||||
Point center;
|
||||
float radius;
|
||||
};
|
||||
|
||||
#define PietCircle_size 16
|
||||
|
||||
PietCircleRef PietCircle_index(PietCircleRef ref, uint index) {
|
||||
return PietCircleRef(ref.offset + index * PietCircle_size);
|
||||
}
|
||||
|
||||
struct PietStrokeLine {
|
||||
uint flags;
|
||||
uint rgba_color;
|
||||
float width;
|
||||
Point start;
|
||||
Point end;
|
||||
};
|
||||
|
||||
#define PietStrokeLine_size 28
|
||||
|
||||
PietStrokeLineRef PietStrokeLine_index(PietStrokeLineRef ref, uint index) {
|
||||
return PietStrokeLineRef(ref.offset + index * PietStrokeLine_size);
|
||||
}
|
||||
|
||||
struct PietFill {
|
||||
uint flags;
|
||||
uint rgba_color;
|
||||
uint n_points;
|
||||
PointRef points;
|
||||
};
|
||||
|
||||
#define PietFill_size 16
|
||||
|
||||
PietFillRef PietFill_index(PietFillRef ref, uint index) {
|
||||
return PietFillRef(ref.offset + index * PietFill_size);
|
||||
}
|
||||
|
||||
struct PietStrokePolyLine {
|
||||
uint rgba_color;
|
||||
float width;
|
||||
uint n_points;
|
||||
PointRef points;
|
||||
};
|
||||
|
||||
#define PietStrokePolyLine_size 16
|
||||
|
||||
PietStrokePolyLineRef PietStrokePolyLine_index(PietStrokePolyLineRef ref, uint index) {
|
||||
return PietStrokePolyLineRef(ref.offset + index * PietStrokePolyLine_size);
|
||||
}
|
||||
|
||||
#define PietItem_Group 0
|
||||
#define PietItem_Circle 1
|
||||
#define PietItem_Line 2
|
||||
#define PietItem_Fill 3
|
||||
#define PietItem_Poly 4
|
||||
#define PietItem_size 32
|
||||
|
||||
PietItemRef PietItem_index(PietItemRef ref, uint index) {
|
||||
return PietItemRef(ref.offset + index * PietItem_size);
|
||||
}
|
||||
|
||||
struct LineSeg {
|
||||
vec2 p0;
|
||||
vec2 p1;
|
||||
|
@ -254,114 +126,6 @@ ElementRef Element_index(ElementRef ref, uint index) {
|
|||
return ElementRef(ref.offset + index * Element_size);
|
||||
}
|
||||
|
||||
Bbox Bbox_read(BboxRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = scene[ix + 0];
|
||||
uint raw1 = scene[ix + 1];
|
||||
Bbox s;
|
||||
s.bbox = ivec4(int(raw0 << 16) >> 16, int(raw0) >> 16, int(raw1 << 16) >> 16, int(raw1) >> 16);
|
||||
return s;
|
||||
}
|
||||
|
||||
Point Point_read(PointRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = scene[ix + 0];
|
||||
uint raw1 = scene[ix + 1];
|
||||
Point s;
|
||||
s.xy = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
||||
return s;
|
||||
}
|
||||
|
||||
SimpleGroup SimpleGroup_read(SimpleGroupRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = scene[ix + 0];
|
||||
uint raw1 = scene[ix + 1];
|
||||
uint raw2 = scene[ix + 2];
|
||||
SimpleGroup s;
|
||||
s.n_items = raw0;
|
||||
s.items = PietItemRef(raw1);
|
||||
s.bboxes = BboxRef(raw2);
|
||||
s.offset = Point_read(PointRef(ref.offset + 12));
|
||||
return s;
|
||||
}
|
||||
|
||||
PietCircle PietCircle_read(PietCircleRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = scene[ix + 0];
|
||||
uint raw3 = scene[ix + 3];
|
||||
PietCircle s;
|
||||
s.rgba_color = raw0;
|
||||
s.center = Point_read(PointRef(ref.offset + 4));
|
||||
s.radius = uintBitsToFloat(raw3);
|
||||
return s;
|
||||
}
|
||||
|
||||
PietStrokeLine PietStrokeLine_read(PietStrokeLineRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = scene[ix + 0];
|
||||
uint raw1 = scene[ix + 1];
|
||||
uint raw2 = scene[ix + 2];
|
||||
PietStrokeLine s;
|
||||
s.flags = raw0;
|
||||
s.rgba_color = raw1;
|
||||
s.width = uintBitsToFloat(raw2);
|
||||
s.start = Point_read(PointRef(ref.offset + 12));
|
||||
s.end = Point_read(PointRef(ref.offset + 20));
|
||||
return s;
|
||||
}
|
||||
|
||||
PietFill PietFill_read(PietFillRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = scene[ix + 0];
|
||||
uint raw1 = scene[ix + 1];
|
||||
uint raw2 = scene[ix + 2];
|
||||
uint raw3 = scene[ix + 3];
|
||||
PietFill s;
|
||||
s.flags = raw0;
|
||||
s.rgba_color = raw1;
|
||||
s.n_points = raw2;
|
||||
s.points = PointRef(raw3);
|
||||
return s;
|
||||
}
|
||||
|
||||
PietStrokePolyLine PietStrokePolyLine_read(PietStrokePolyLineRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = scene[ix + 0];
|
||||
uint raw1 = scene[ix + 1];
|
||||
uint raw2 = scene[ix + 2];
|
||||
uint raw3 = scene[ix + 3];
|
||||
PietStrokePolyLine s;
|
||||
s.rgba_color = raw0;
|
||||
s.width = uintBitsToFloat(raw1);
|
||||
s.n_points = raw2;
|
||||
s.points = PointRef(raw3);
|
||||
return s;
|
||||
}
|
||||
|
||||
uint PietItem_tag(PietItemRef ref) {
|
||||
return scene[ref.offset >> 2];
|
||||
}
|
||||
|
||||
SimpleGroup PietItem_Group_read(PietItemRef ref) {
|
||||
return SimpleGroup_read(SimpleGroupRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
PietCircle PietItem_Circle_read(PietItemRef ref) {
|
||||
return PietCircle_read(PietCircleRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
PietStrokeLine PietItem_Line_read(PietItemRef ref) {
|
||||
return PietStrokeLine_read(PietStrokeLineRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
PietFill PietItem_Fill_read(PietItemRef ref) {
|
||||
return PietFill_read(PietFillRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
PietStrokePolyLine PietItem_Poly_read(PietItemRef ref) {
|
||||
return PietStrokePolyLine_read(PietStrokePolyLineRef(ref.offset + 4));
|
||||
}
|
||||
|
||||
LineSeg LineSeg_read(LineSegRef ref) {
|
||||
uint ix = ref.offset >> 2;
|
||||
uint raw0 = scene[ix + 0];
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue