2020-12-12 01:01:48 +11:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
|
|
|
|
|
2020-04-25 06:06:47 +10:00
|
|
|
// Various constants for the sizes of groups and tiles.
|
|
|
|
|
|
|
|
// Much of this will be made dynamic in various ways, but for now it's easiest
|
|
|
|
// to hardcode and keep all in one place.
|
|
|
|
|
2020-09-13 20:58:47 +10:00
|
|
|
// A LG_WG_FACTOR of n scales workgroup sizes by 2^n. Use 0 for a
|
|
|
|
// maximum workgroup size of 128, or 1 for a maximum size of 256.
|
|
|
|
#define LG_WG_FACTOR 1
|
|
|
|
#define WG_FACTOR (1<<LG_WG_FACTOR)
|
|
|
|
|
2020-04-25 06:06:47 +10:00
|
|
|
#define TILE_WIDTH_PX 16
|
|
|
|
#define TILE_HEIGHT_PX 16
|
|
|
|
|
2020-08-29 23:02:45 +10:00
|
|
|
#define PTCL_INITIAL_ALLOC 1024
|
2020-05-14 08:35:19 +10:00
|
|
|
|
|
|
|
// These should probably be renamed and/or reworked. In the binning
|
|
|
|
// kernel, they represent the number of bins. Also, the workgroup size
|
|
|
|
// of that kernel is equal to the number of bins, but should probably
|
|
|
|
// be more flexible (it's 512 in the K&L paper).
|
|
|
|
#define N_TILE_X 16
|
2020-09-13 20:58:47 +10:00
|
|
|
#define N_TILE_Y (8 * WG_FACTOR)
|
2020-05-14 08:35:19 +10:00
|
|
|
#define N_TILE (N_TILE_X * N_TILE_Y)
|
2020-09-13 20:58:47 +10:00
|
|
|
#define LG_N_TILE (7 + LG_WG_FACTOR)
|
2020-05-14 08:35:19 +10:00
|
|
|
#define N_SLICE (N_TILE / 32)
|
2020-12-12 04:30:20 +11:00
|
|
|
|
2021-06-24 04:50:51 +10:00
|
|
|
#define GRADIENT_WIDTH 512
|
|
|
|
|
2022-05-17 04:01:03 +10:00
|
|
|
// We allocate this many blend stack entries in registers, and spill
|
|
|
|
// to memory for the overflow.
|
|
|
|
#define BLEND_STACK_SPLIT 4
|
|
|
|
|
2022-06-24 01:48:26 +10:00
|
|
|
#ifdef MALLOC_FAILED
|
2020-12-12 04:30:20 +11:00
|
|
|
struct Config {
|
2022-06-24 01:48:26 +10:00
|
|
|
uint mem_size; // in bytes
|
2020-12-12 04:30:20 +11:00
|
|
|
uint n_elements; // paths
|
|
|
|
uint n_pathseg;
|
2020-12-18 10:55:21 +11:00
|
|
|
uint width_in_tiles;
|
|
|
|
uint height_in_tiles;
|
2020-12-24 22:00:53 +11:00
|
|
|
Alloc tile_alloc;
|
|
|
|
Alloc bin_alloc;
|
|
|
|
Alloc ptcl_alloc;
|
|
|
|
Alloc pathseg_alloc;
|
|
|
|
Alloc anno_alloc;
|
2021-11-24 02:28:50 +11:00
|
|
|
// new element pipeline stuff follows
|
|
|
|
|
2021-11-25 11:26:45 +11:00
|
|
|
// Bounding boxes of paths, stored as int (so atomics work)
|
2022-03-03 09:44:03 +11:00
|
|
|
Alloc path_bbox_alloc;
|
2021-12-03 03:41:41 +11:00
|
|
|
// Monoid for draw objects
|
|
|
|
Alloc drawmonoid_alloc;
|
2021-11-25 11:26:45 +11:00
|
|
|
|
2022-02-18 11:25:41 +11:00
|
|
|
// BeginClip(path_ix) / EndClip
|
|
|
|
Alloc clip_alloc;
|
|
|
|
// Intermediate bicyclic semigroup
|
|
|
|
Alloc clip_bic_alloc;
|
|
|
|
// Intermediate stack
|
|
|
|
Alloc clip_stack_alloc;
|
|
|
|
// Clip processing results (path_ix + bbox)
|
|
|
|
Alloc clip_bbox_alloc;
|
2022-03-03 09:44:03 +11:00
|
|
|
// Bounding box per draw object
|
|
|
|
Alloc draw_bbox_alloc;
|
|
|
|
// Info computed in draw stage, per draw object
|
|
|
|
Alloc drawinfo_alloc;
|
2022-02-18 11:25:41 +11:00
|
|
|
|
2021-11-24 02:28:50 +11:00
|
|
|
// Number of transforms in scene
|
2021-11-25 11:26:45 +11:00
|
|
|
// This is probably not needed.
|
2021-11-24 02:28:50 +11:00
|
|
|
uint n_trans;
|
2022-02-18 11:25:41 +11:00
|
|
|
// This *should* count only actual paths, but in the current
|
|
|
|
// implementation is redundant with n_elements.
|
2021-12-03 10:07:33 +11:00
|
|
|
uint n_path;
|
2022-02-18 11:25:41 +11:00
|
|
|
// Total number of BeginClip and EndClip draw objects.
|
|
|
|
uint n_clip;
|
2022-03-03 09:44:03 +11:00
|
|
|
|
|
|
|
// Note: one of these offsets *could* be hardcoded to zero (as was the
|
|
|
|
// original element stream), but for now retain flexibility.
|
|
|
|
|
2021-11-24 02:28:50 +11:00
|
|
|
// Offset (in bytes) of transform stream in scene buffer
|
|
|
|
uint trans_offset;
|
2021-11-25 11:26:45 +11:00
|
|
|
// Offset (in bytes) of linewidth stream in scene
|
|
|
|
uint linewidth_offset;
|
2021-12-03 10:07:33 +11:00
|
|
|
// Offset (in bytes) of path tag stream in scene
|
|
|
|
uint pathtag_offset;
|
2021-11-25 11:26:45 +11:00
|
|
|
// Offset (in bytes) of path segment stream in scene
|
|
|
|
uint pathseg_offset;
|
2022-03-03 09:44:03 +11:00
|
|
|
// Offset (in bytes) of draw object tag stream in scene; see drawtag.h
|
|
|
|
uint drawtag_offset;
|
|
|
|
// Offset (in bytes) of draw payload stream in scene
|
|
|
|
uint drawdata_offset;
|
2020-12-12 04:30:20 +11:00
|
|
|
};
|
2021-12-09 05:42:35 +11:00
|
|
|
#endif
|
2021-03-17 21:08:28 +11:00
|
|
|
|
|
|
|
// Fill modes.
|
|
|
|
#define MODE_NONZERO 0
|
|
|
|
#define MODE_STROKE 1
|
|
|
|
|
2021-03-23 02:13:39 +11:00
|
|
|
// Size of kernel4 clip state, in words.
|
2022-05-17 04:01:03 +10:00
|
|
|
#define CLIP_STATE_SIZE 1
|
2021-03-23 02:13:39 +11:00
|
|
|
|
2021-03-17 21:08:28 +11:00
|
|
|
// fill_mode_from_flags extracts the fill mode from tag flags.
|
|
|
|
uint fill_mode_from_flags(uint flags) {
|
2021-03-23 02:13:39 +11:00
|
|
|
return flags & 0x1;
|
2021-03-17 21:08:28 +11:00
|
|
|
}
|