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
|
|
|
|
2021-04-03 12:59:07 +11:00
|
|
|
// This is now set in the ninja file during compilation
|
|
|
|
//#define ENABLE_IMAGE_INDICES
|
implement FillImage command and sRGB support
FillImage is like Fill, except that it takes its color from one or
more image atlases.
kernel4 uses a single image for non-Vulkan hosts, and the dynamic sized array
of image descriptors on Vulkan.
A previous version of this commit used textures. I think images are a better
choice for piet-gpu, for several reasons:
- Texture sampling, in particular textureGrad, is slow on lower spec devices
such as Google Pixel. Texture sampling is particularly slow and difficult to
implement for CPU fallbacks.
- Texture sampling need more parameters, in particular the full u,v
transformation matrix, leading to a large increase in the command size. Since
all commands use the same size, that memory penalty is paid by all scenes, not
just scenes with textures.
- It is unlikely that piet-gpu will support every kind of fill for every
client, because each kind must be added to kernel4.
With FillImage, a client will prepare the image(s) in separate shader stages,
sampling and applying transformations and special effects as needed. Textures
that align with the output pixel grid can be used directly, without
pre-processing.
Note that the pre-processing step can run concurrently with the piet-gpu pipeline;
Only the last stage, kernel4, needs the images.
Pre-processing most likely uses fixed function vertex/fragment programs,
which on some GPUs may run in parallel with piet-gpu's compute programs.
While here, fix a few validation errors:
- Explicitly enable EXT_descriptor_indexing, KHR_maintenance3,
KHR_get_physical_device_properties2.
- Specify a vkDescriptorSetVariableDescriptorCountAllocateInfo for
vkAllocateDescriptorSets. Otherwise, variable image2D arrays won't work (but
sampler2D arrays do, at least on my setup).
Updates #38
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-29 08:02:39 +11:00
|
|
|
|
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
|
|
|
|
|
|
|
struct Config {
|
|
|
|
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-03-15 22:28:04 +11:00
|
|
|
Alloc trans_alloc;
|
2020-12-12 04:30:20 +11:00
|
|
|
};
|
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.
|
|
|
|
#define CLIP_STATE_SIZE 2
|
|
|
|
|
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
|
|
|
}
|