2020-04-22 10:55:17 +10:00
|
|
|
// Code auto-generated by piet-gpu-derive
|
|
|
|
|
|
|
|
struct CmdCircleRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CmdLineRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CmdStrokeRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CmdFillRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CmdFillEdgeRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CmdDrawFillRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CmdSolidRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
struct CmdJumpRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
2020-04-22 10:55:17 +10:00
|
|
|
struct CmdRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
2020-05-16 08:20:25 +10:00
|
|
|
struct SegmentRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SegChunkRef {
|
|
|
|
uint offset;
|
|
|
|
};
|
|
|
|
|
2020-04-22 10:55:17 +10:00
|
|
|
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 {
|
2020-05-26 02:08:21 +10:00
|
|
|
SegChunkRef seg_ref;
|
2020-04-29 04:02:19 +10:00
|
|
|
float half_width;
|
2020-04-22 10:55:17 +10:00
|
|
|
uint rgba_color;
|
|
|
|
};
|
|
|
|
|
2020-04-29 15:25:57 +10:00
|
|
|
#define CmdStroke_size 12
|
2020-04-22 10:55:17 +10:00
|
|
|
|
|
|
|
CmdStrokeRef CmdStroke_index(CmdStrokeRef ref, uint index) {
|
|
|
|
return CmdStrokeRef(ref.offset + index * CmdStroke_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct CmdFill {
|
2020-05-26 08:01:52 +10:00
|
|
|
SegChunkRef seg_ref;
|
2020-05-01 10:06:01 +10:00
|
|
|
int backdrop;
|
|
|
|
uint rgba_color;
|
2020-04-22 10:55:17 +10:00
|
|
|
};
|
|
|
|
|
2020-05-01 10:06:01 +10:00
|
|
|
#define CmdFill_size 12
|
2020-04-22 10:55:17 +10:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CmdSolid_size 4
|
|
|
|
|
|
|
|
CmdSolidRef CmdSolid_index(CmdSolidRef ref, uint index) {
|
|
|
|
return CmdSolidRef(ref.offset + index * CmdSolid_size);
|
|
|
|
}
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
struct CmdJump {
|
|
|
|
uint new_ref;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CmdJump_size 4
|
|
|
|
|
|
|
|
CmdJumpRef CmdJump_index(CmdJumpRef ref, uint index) {
|
|
|
|
return CmdJumpRef(ref.offset + index * CmdJump_size);
|
|
|
|
}
|
|
|
|
|
2020-04-22 10:55:17 +10:00
|
|
|
#define Cmd_End 0
|
|
|
|
#define Cmd_Circle 1
|
|
|
|
#define Cmd_Line 2
|
|
|
|
#define Cmd_Fill 3
|
|
|
|
#define Cmd_Stroke 4
|
|
|
|
#define Cmd_FillEdge 5
|
|
|
|
#define Cmd_DrawFill 6
|
|
|
|
#define Cmd_Solid 7
|
2020-04-26 03:15:22 +10:00
|
|
|
#define Cmd_Jump 8
|
|
|
|
#define Cmd_Bail 9
|
2020-04-22 10:55:17 +10:00
|
|
|
#define Cmd_size 20
|
|
|
|
|
|
|
|
CmdRef Cmd_index(CmdRef ref, uint index) {
|
|
|
|
return CmdRef(ref.offset + index * Cmd_size);
|
|
|
|
}
|
|
|
|
|
2020-05-16 08:20:25 +10:00
|
|
|
struct Segment {
|
|
|
|
vec2 start;
|
|
|
|
vec2 end;
|
2020-05-26 08:01:52 +10:00
|
|
|
float y_edge;
|
2020-05-16 08:20:25 +10:00
|
|
|
};
|
|
|
|
|
2020-05-26 08:01:52 +10:00
|
|
|
#define Segment_size 20
|
2020-05-16 08:20:25 +10:00
|
|
|
|
|
|
|
SegmentRef Segment_index(SegmentRef ref, uint index) {
|
|
|
|
return SegmentRef(ref.offset + index * Segment_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SegChunk {
|
|
|
|
uint n;
|
|
|
|
SegChunkRef next;
|
2020-05-26 02:08:21 +10:00
|
|
|
SegmentRef segs;
|
2020-05-16 08:20:25 +10:00
|
|
|
};
|
|
|
|
|
2020-05-26 02:08:21 +10:00
|
|
|
#define SegChunk_size 12
|
2020-05-16 08:20:25 +10:00
|
|
|
|
|
|
|
SegChunkRef SegChunk_index(SegChunkRef ref, uint index) {
|
|
|
|
return SegChunkRef(ref.offset + index * SegChunk_size);
|
|
|
|
}
|
|
|
|
|
2020-04-22 10:55:17 +10:00
|
|
|
CmdCircle CmdCircle_read(CmdCircleRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = ptcl[ix + 0];
|
|
|
|
uint raw1 = ptcl[ix + 1];
|
|
|
|
uint raw2 = ptcl[ix + 2];
|
|
|
|
uint raw3 = ptcl[ix + 3];
|
|
|
|
CmdCircle s;
|
|
|
|
s.center = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
|
|
|
s.radius = uintBitsToFloat(raw2);
|
|
|
|
s.rgba_color = raw3;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdCircle_write(CmdCircleRef ref, CmdCircle s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
ptcl[ix + 0] = floatBitsToUint(s.center.x);
|
|
|
|
ptcl[ix + 1] = floatBitsToUint(s.center.y);
|
|
|
|
ptcl[ix + 2] = floatBitsToUint(s.radius);
|
|
|
|
ptcl[ix + 3] = s.rgba_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdLine CmdLine_read(CmdLineRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = ptcl[ix + 0];
|
|
|
|
uint raw1 = ptcl[ix + 1];
|
|
|
|
uint raw2 = ptcl[ix + 2];
|
|
|
|
uint raw3 = ptcl[ix + 3];
|
|
|
|
CmdLine s;
|
|
|
|
s.start = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
|
|
|
s.end = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdLine_write(CmdLineRef ref, CmdLine s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
ptcl[ix + 0] = floatBitsToUint(s.start.x);
|
|
|
|
ptcl[ix + 1] = floatBitsToUint(s.start.y);
|
|
|
|
ptcl[ix + 2] = floatBitsToUint(s.end.x);
|
|
|
|
ptcl[ix + 3] = floatBitsToUint(s.end.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdStroke CmdStroke_read(CmdStrokeRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = ptcl[ix + 0];
|
|
|
|
uint raw1 = ptcl[ix + 1];
|
2020-04-29 04:02:19 +10:00
|
|
|
uint raw2 = ptcl[ix + 2];
|
2020-04-22 10:55:17 +10:00
|
|
|
CmdStroke s;
|
2020-05-26 02:08:21 +10:00
|
|
|
s.seg_ref = SegChunkRef(raw0);
|
2020-04-29 15:25:57 +10:00
|
|
|
s.half_width = uintBitsToFloat(raw1);
|
|
|
|
s.rgba_color = raw2;
|
2020-04-22 10:55:17 +10:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdStroke_write(CmdStrokeRef ref, CmdStroke s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
2020-05-26 02:08:21 +10:00
|
|
|
ptcl[ix + 0] = s.seg_ref.offset;
|
2020-04-29 15:25:57 +10:00
|
|
|
ptcl[ix + 1] = floatBitsToUint(s.half_width);
|
|
|
|
ptcl[ix + 2] = s.rgba_color;
|
2020-04-22 10:55:17 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
CmdFill CmdFill_read(CmdFillRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = ptcl[ix + 0];
|
|
|
|
uint raw1 = ptcl[ix + 1];
|
|
|
|
uint raw2 = ptcl[ix + 2];
|
|
|
|
CmdFill s;
|
2020-05-26 08:01:52 +10:00
|
|
|
s.seg_ref = SegChunkRef(raw0);
|
2020-05-01 10:06:01 +10:00
|
|
|
s.backdrop = int(raw1);
|
|
|
|
s.rgba_color = raw2;
|
2020-04-22 10:55:17 +10:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdFill_write(CmdFillRef ref, CmdFill s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
2020-05-26 08:01:52 +10:00
|
|
|
ptcl[ix + 0] = s.seg_ref.offset;
|
2020-05-01 10:06:01 +10:00
|
|
|
ptcl[ix + 1] = uint(s.backdrop);
|
|
|
|
ptcl[ix + 2] = s.rgba_color;
|
2020-04-22 10:55:17 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
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];
|
|
|
|
CmdSolid s;
|
|
|
|
s.rgba_color = raw0;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdSolid_write(CmdSolidRef ref, CmdSolid s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
ptcl[ix + 0] = s.rgba_color;
|
|
|
|
}
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
CmdJump CmdJump_read(CmdJumpRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = ptcl[ix + 0];
|
|
|
|
CmdJump s;
|
|
|
|
s.new_ref = raw0;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdJump_write(CmdJumpRef ref, CmdJump s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
ptcl[ix + 0] = s.new_ref;
|
|
|
|
}
|
|
|
|
|
2020-04-22 10:55:17 +10:00
|
|
|
uint Cmd_tag(CmdRef ref) {
|
|
|
|
return ptcl[ref.offset >> 2];
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdCircle Cmd_Circle_read(CmdRef ref) {
|
|
|
|
return CmdCircle_read(CmdCircleRef(ref.offset + 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdLine Cmd_Line_read(CmdRef ref) {
|
|
|
|
return CmdLine_read(CmdLineRef(ref.offset + 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdFill Cmd_Fill_read(CmdRef ref) {
|
|
|
|
return CmdFill_read(CmdFillRef(ref.offset + 4));
|
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
CmdJump Cmd_Jump_read(CmdRef ref) {
|
|
|
|
return CmdJump_read(CmdJumpRef(ref.offset + 4));
|
|
|
|
}
|
|
|
|
|
2020-04-22 10:55:17 +10:00
|
|
|
void Cmd_End_write(CmdRef ref) {
|
|
|
|
ptcl[ref.offset >> 2] = Cmd_End;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_Circle_write(CmdRef ref, CmdCircle s) {
|
|
|
|
ptcl[ref.offset >> 2] = Cmd_Circle;
|
|
|
|
CmdCircle_write(CmdCircleRef(ref.offset + 4), s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_Line_write(CmdRef ref, CmdLine s) {
|
|
|
|
ptcl[ref.offset >> 2] = Cmd_Line;
|
|
|
|
CmdLine_write(CmdLineRef(ref.offset + 4), s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_Fill_write(CmdRef ref, CmdFill s) {
|
|
|
|
ptcl[ref.offset >> 2] = Cmd_Fill;
|
|
|
|
CmdFill_write(CmdFillRef(ref.offset + 4), s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_Stroke_write(CmdRef ref, CmdStroke s) {
|
|
|
|
ptcl[ref.offset >> 2] = Cmd_Stroke;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-04-26 03:15:22 +10:00
|
|
|
void Cmd_Jump_write(CmdRef ref, CmdJump s) {
|
|
|
|
ptcl[ref.offset >> 2] = Cmd_Jump;
|
|
|
|
CmdJump_write(CmdJumpRef(ref.offset + 4), s);
|
|
|
|
}
|
|
|
|
|
2020-04-22 10:55:17 +10:00
|
|
|
void Cmd_Bail_write(CmdRef ref) {
|
|
|
|
ptcl[ref.offset >> 2] = Cmd_Bail;
|
|
|
|
}
|
|
|
|
|
2020-05-16 08:20:25 +10:00
|
|
|
Segment Segment_read(SegmentRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = ptcl[ix + 0];
|
|
|
|
uint raw1 = ptcl[ix + 1];
|
|
|
|
uint raw2 = ptcl[ix + 2];
|
|
|
|
uint raw3 = ptcl[ix + 3];
|
2020-05-26 08:01:52 +10:00
|
|
|
uint raw4 = ptcl[ix + 4];
|
2020-05-16 08:20:25 +10:00
|
|
|
Segment s;
|
|
|
|
s.start = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
|
|
|
s.end = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
2020-05-26 08:01:52 +10:00
|
|
|
s.y_edge = uintBitsToFloat(raw4);
|
2020-05-16 08:20:25 +10:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Segment_write(SegmentRef ref, Segment s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
ptcl[ix + 0] = floatBitsToUint(s.start.x);
|
|
|
|
ptcl[ix + 1] = floatBitsToUint(s.start.y);
|
|
|
|
ptcl[ix + 2] = floatBitsToUint(s.end.x);
|
|
|
|
ptcl[ix + 3] = floatBitsToUint(s.end.y);
|
2020-05-26 08:01:52 +10:00
|
|
|
ptcl[ix + 4] = floatBitsToUint(s.y_edge);
|
2020-05-16 08:20:25 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
SegChunk SegChunk_read(SegChunkRef ref) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
uint raw0 = ptcl[ix + 0];
|
|
|
|
uint raw1 = ptcl[ix + 1];
|
2020-05-26 02:08:21 +10:00
|
|
|
uint raw2 = ptcl[ix + 2];
|
2020-05-16 08:20:25 +10:00
|
|
|
SegChunk s;
|
|
|
|
s.n = raw0;
|
|
|
|
s.next = SegChunkRef(raw1);
|
2020-05-26 02:08:21 +10:00
|
|
|
s.segs = SegmentRef(raw2);
|
2020-05-16 08:20:25 +10:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SegChunk_write(SegChunkRef ref, SegChunk s) {
|
|
|
|
uint ix = ref.offset >> 2;
|
|
|
|
ptcl[ix + 0] = s.n;
|
|
|
|
ptcl[ix + 1] = s.next.offset;
|
2020-05-26 02:08:21 +10:00
|
|
|
ptcl[ix + 2] = s.segs.offset;
|
2020-05-16 08:20:25 +10:00
|
|
|
}
|
|
|
|
|