Allan MacKinnon | 4359d52 | 2018-06-19 13:57:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can |
| 5 | * be found in the LICENSE file. |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #ifndef SKC_ONCE_BLOCK |
| 10 | #define SKC_ONCE_BLOCK |
| 11 | |
| 12 | // |
| 13 | // |
| 14 | // |
| 15 | |
| 16 | #include "types.h" |
| 17 | #include "macros.h" |
| 18 | |
| 19 | // |
| 20 | // Hard requirements: |
| 21 | // |
| 22 | // - A TTXB "block pool" extent that is at least 1GB. |
| 23 | // |
| 24 | // - A virtual surface of at least 8K x 8K |
| 25 | // |
| 26 | // - A physical surface of __don't really care__ because it's |
| 27 | // advantageous to tile the physical surface into sub-surface |
| 28 | // rectangles so that multiple linear (smaller) TTCK sorts are |
| 29 | // simultaneously performed. |
| 30 | // |
| 31 | // |
| 32 | // EXTENT TTXB BITS |
| 33 | // SIZE (MB) +-------------------------------------+ |
| 34 | // | 22 23 24 25 26 * 27 * | |
| 35 | // +----+-------------------------------------+ |
| 36 | // | 8 | 128 256 512 1024 2048 4096 | |
| 37 | // TTXB | 16 | 256 512 1024 2048 4096 8192 | |
| 38 | // WORDS | 32 | 512 1024 2048 4096 8192 16384 | |
| 39 | // | 64 | 1024 2048 4096 8192 16384 32768 | |
| 40 | // +----+-------------------------------------+ |
| 41 | // |
| 42 | // |
| 43 | // SUB-SURFACE X/Y BITS |
| 44 | // TILE SIZE +------------------------------------------------------+ |
| 45 | // | 5 6 7 8 9 10 11 12 13 | |
| 46 | // +----+------------------------------------------------------+ |
| 47 | // | 3 | 256 512 1024 2048 4096 8192 16384 32768 65536 | |
| 48 | // TILE | 4 | 512 1024 2048 4096 8192 16384 32768 65536 128K | |
| 49 | // SIDE | 5 | 1024 2048 4096 8192 16384 32768 65536 128K 256K | |
| 50 | // BITS | 6 | 2048 4096 8192 16384 32768 65536 128K 256K 512K | |
| 51 | // | 7 | 4096 8192 16384 32768 65536 128K 256K 512K 1024K | |
| 52 | // +----+------------------------------------------------------+ |
| 53 | // TILES^2 | 1024 4096 16384 65536 256K 1M 4M 16M 64M | |
| 54 | // +------------------------------------------------------+ |
| 55 | // |
| 56 | // The following values should be pretty future-proof across all GPUs: |
| 57 | // |
| 58 | // - 27 bits of block id space implies a max of 4GB-32GB of |
| 59 | // rasterized paths depending on the size of the TTXB block. |
| 60 | // This could enable interesting use cases. |
| 61 | // |
| 62 | // - A minimum block size is 16 words (64 bytes) and a maximum of 32 |
| 63 | // words (128 bytes) greatly simplifies portability. It's unlikely |
| 64 | // that a large GPU can service a tile larger than 32x32 pixels. |
| 65 | // Additionally, on smaller devices, rectangular tiles will have a |
| 66 | // minimum height of 16 pixels. Note that a minimum subblock size |
| 67 | // is probably 8 words (32 bytes). |
| 68 | // |
| 69 | // - A virtual rasterization surface that's from +/-32768K to |
| 70 | // +/-128K depending on the target's rasterization tile size. |
| 71 | // |
| 72 | // - A physical sub-surface tile (or entire surface) from 4Kx4K to |
| 73 | // 16Kx16K depending on the target's rasterization tile size. |
| 74 | // |
| 75 | // - Support for a minimum of 256K layers. If necessary, this can |
| 76 | // convseratively raised to 1m or 2m layers by either implementing |
| 77 | // surface tiling or when the target supports large raster tiles. |
| 78 | // |
| 79 | // - Keys that (optionally) only require a 32-bit high word |
| 80 | // comparison. |
| 81 | // |
| 82 | // |
| 83 | // TAGGED BLOCK ID |
| 84 | // |
| 85 | // 0 5 31 |
| 86 | // | | ID | |
| 87 | // | TAG | SUBBLOCK | BLOCK | |
| 88 | // +-----+----------+--------+ |
| 89 | // | 5 | N | 27 - N | |
| 90 | // |
| 91 | // There are 27 bits of subblocks and 5 bits of tag. |
| 92 | // |
| 93 | // |
| 94 | // TTRK (64-bit COMPARE) |
| 95 | // |
| 96 | // 0 63 |
| 97 | // | TTSB ID | X | Y | RASTER COHORT ID | |
| 98 | // +---------+------+------+------------------+ |
| 99 | // | 27 | 12 | 12 | 13 | |
| 100 | // |
| 101 | // |
| 102 | // TTRK (32-BIT COMPARE) |
| 103 | // |
| 104 | // 0 63 |
| 105 | // | TTSB ID | N/A | X | Y | RASTER COHORT ID | |
| 106 | // +---------+-----+------+------+------------------+ |
| 107 | // | 27 | 5 | 12 | 12 | 8 | |
| 108 | // |
| 109 | // |
| 110 | // TTSK v2: |
| 111 | // |
| 112 | // 0 63 |
| 113 | // | TTSB ID | IS_PREFIX | N/A | X | Y | |
| 114 | // +---------+-----------+------+----+----+ |
| 115 | // | 27 | 1 (=0) | 12 | 12 | 12 | |
| 116 | // |
| 117 | // |
| 118 | // TTPK v2: |
| 119 | // |
| 120 | // 0 63 |
| 121 | // | TTPB ID | IS_PREFIX | SPAN | X | Y | |
| 122 | // +---------+-----------+------+-----+-----+ |
| 123 | // | 27 | 1 (=1) | 12 | 12 | 12 | |
| 124 | // |
| 125 | // |
| 126 | // TTCK (32-BIT COMPARE) v1: |
| 127 | // |
| 128 | // 0 63 |
| 129 | // | PAYLOAD/TTSB/TTPB ID | PREFIX | ESCAPE | LAYER | X | Y | |
| 130 | // +----------------------+--------+--------+-------+-----+-----+ |
| 131 | // | 30 | 1 | 1 | 18 | 7 | 7 | |
| 132 | // |
| 133 | // |
| 134 | // TTCK (32-BIT COMPARE) v2: |
| 135 | // |
| 136 | // 0 63 |
| 137 | // | PAYLOAD/TTSB/TTPB ID | PREFIX | ESCAPE | LAYER | X | Y | |
| 138 | // +----------------------+--------+--------+-------+-----+-----+ |
| 139 | // | 30 | 1 | 1 | 15 | 9 | 8 | |
| 140 | // |
| 141 | // |
| 142 | // TTCK (64-BIT COMPARE) -- achieves 4K x 4K with an 8x16 tile: |
| 143 | // |
| 144 | // 0 63 |
| 145 | // | PAYLOAD/TTSB/TTPB ID | PREFIX | ESCAPE | LAYER | X | Y | |
| 146 | // +----------------------+--------+--------+-------+-----+-----+ |
| 147 | // | 27 | 1 | 1 | 18 | 9 | 8 | |
| 148 | // |
| 149 | // |
| 150 | |
Allan MacKinnon | 4359d52 | 2018-06-19 13:57:04 -0700 | [diff] [blame] | 151 | #define SKC_TAGGED_BLOCK_ID_BITS_ID 27 // this size is cast in stone |
| 152 | #define SKC_TAGGED_BLOCK_ID_BITS_TAG 5 // which leaves 5 bits of tag |
| 153 | |
| 154 | // |
| 155 | // |
| 156 | // |
| 157 | |
| 158 | typedef enum skc_block_id_tag { |
| 159 | |
| 160 | SKC_BLOCK_ID_TAG_PATH_LINE, // 0 -- 4 segments |
| 161 | SKC_BLOCK_ID_TAG_PATH_QUAD, // 1 -- 6 segments |
| 162 | SKC_BLOCK_ID_TAG_PATH_CUBIC, // 2 -- 8 segments |
| 163 | SKC_BLOCK_ID_TAG_PATH_RAT_QUAD, // 3 -- 8 segments : 6 + w0 + na |
| 164 | SKC_BLOCK_ID_TAG_PATH_RAT_CUBIC, // 4 -- 10 segments : 8 + w0 + w1 |
Allan MacKinnon | 638ab5a | 2018-09-10 13:02:04 -0700 | [diff] [blame] | 165 | SKC_BLOCK_ID_TAG_PATH_COUNT, // 5 -- this represents the end of path tags |
| 166 | SKC_BLOCK_ID_TAG_PATH_NEXT = SKC_BLOCK_ID_TAG_PATH_COUNT, |
Allan MacKinnon | 4359d52 | 2018-06-19 13:57:04 -0700 | [diff] [blame] | 167 | |
| 168 | // |
| 169 | // TAGS [6-30] ARE AVAILABLE |
| 170 | // |
| 171 | |
| 172 | SKC_BLOCK_ID_TAG_INVALID = (1u << SKC_TAGGED_BLOCK_ID_BITS_TAG) - 1, // all 1's |
| 173 | SKC_BLOCK_ID_TAG_COUNT, |
| 174 | |
| 175 | } skc_block_id_tag; |
| 176 | |
| 177 | // |
| 178 | // |
| 179 | // |
| 180 | |
| 181 | #define SKC_TAGGED_BLOCK_ID_INVALID SKC_UINT_MAX // all 1's |
| 182 | |
| 183 | // |
| 184 | // |
| 185 | // |
| 186 | |
| 187 | typedef skc_uint skc_block_id_t; |
| 188 | |
| 189 | // |
| 190 | // |
| 191 | // |
| 192 | |
| 193 | typedef skc_uint skc_tagged_block_id_t; |
| 194 | |
| 195 | union skc_tagged_block_id |
| 196 | { |
| 197 | skc_uint u32; |
| 198 | |
| 199 | #if !defined(__OPENCL_C_VERSION__) |
| 200 | struct { |
| 201 | skc_uint tag : SKC_TAGGED_BLOCK_ID_BITS_TAG; |
| 202 | skc_uint id : SKC_TAGGED_BLOCK_ID_BITS_ID; |
| 203 | }; |
| 204 | #else |
| 205 | // |
| 206 | // OPENCL BIT-FIELD EXTRACT/INSERT |
| 207 | // |
| 208 | #endif |
| 209 | }; |
| 210 | |
| 211 | // |
| 212 | // |
| 213 | // |
| 214 | |
| 215 | #define SKC_TAGGED_BLOCK_ID_MASK_TAG SKC_BITS_TO_MASK(SKC_TAGGED_BLOCK_ID_BITS_TAG) |
| 216 | |
| 217 | #define SKC_TAGGED_BLOCK_ID_GET_TAG(bst) ((bst) & SKC_TAGGED_BLOCK_ID_MASK_TAG) |
| 218 | #define SKC_TAGGED_BLOCK_ID_GET_ID(bst) ((bst) >> SKC_TAGGED_BLOCK_ID_BITS_TAG) |
| 219 | |
| 220 | // |
| 221 | // |
| 222 | // |
| 223 | |
| 224 | #endif |
| 225 | |
| 226 | // |
| 227 | // |
| 228 | // |