github.com/cybriq/giocore@v0.0.7-0.20210703034601-cfb9cb5f3900/gpu/shaders/setup.h (about) 1 // SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense 2 3 // Various constants for the sizes of groups and tiles. 4 5 // Much of this will be made dynamic in various ways, but for now it's easiest 6 // to hardcode and keep all in one place. 7 8 // A LG_WG_FACTOR of n scales workgroup sizes by 2^n. Use 0 for a 9 // maximum workgroup size of 128, or 1 for a maximum size of 256. 10 #define LG_WG_FACTOR 0 11 #define WG_FACTOR (1<<LG_WG_FACTOR) 12 13 #define TILE_WIDTH_PX 32 14 #define TILE_HEIGHT_PX 32 15 16 #define PTCL_INITIAL_ALLOC 1024 17 18 // These should probably be renamed and/or reworked. In the binning 19 // kernel, they represent the number of bins. Also, the workgroup size 20 // of that kernel is equal to the number of bins, but should probably 21 // be more flexible (it's 512 in the K&L paper). 22 #define N_TILE_X 16 23 #define N_TILE_Y (8 * WG_FACTOR) 24 #define N_TILE (N_TILE_X * N_TILE_Y) 25 #define LG_N_TILE (7 + LG_WG_FACTOR) 26 #define N_SLICE (N_TILE / 32) 27 28 struct Config { 29 uint n_elements; // paths 30 uint n_pathseg; 31 uint width_in_tiles; 32 uint height_in_tiles; 33 Alloc tile_alloc; 34 Alloc bin_alloc; 35 Alloc ptcl_alloc; 36 Alloc pathseg_alloc; 37 Alloc anno_alloc; 38 Alloc trans_alloc; 39 }; 40 41 // Fill modes. 42 #define MODE_NONZERO 0 43 #define MODE_STROKE 1 44 45 // Size of kernel4 clip state, in words. 46 #define CLIP_STATE_SIZE 2 47 48 // fill_mode_from_flags extracts the fill mode from tag flags. 49 uint fill_mode_from_flags(uint flags) { 50 return flags & 0x1; 51 }