blob: c2b95834b47553a63c9a902a9c8d586b7b604bcd [file] [log] [blame]
Allan MacKinnon4359d522018-06-19 13:57:04 -07001/*
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_RASTER
10#define SKC_ONCE_RASTER
11
12//
13//
14//
15
16#include "block.h"
17
18//
19// The raster "head" structure aliases a block.
20//
21// Blocks are guaranteed to be at least 16 words.
22//
23// Note that the end of the ttsk key sequence and beginning of the
24// ttpk key sequence may share a node.
25//
26// Note that keys are 64-bits and the "next" id is only a 32-bit
27// (27-bit tagged block id) so there is room for another next id or a
28// key/node countdown. For now we'll leave the second to last word
29// empty/unused.
30//
31
32typedef skc_uint2 skc_ttsk_t;
33typedef skc_uint2 skc_ttpk_t;
34typedef skc_uint2 skc_ttxk_t;
35
36union skc_raster_node_next
37{
38 skc_uint2 u32v2;
39
40 struct {
41 skc_block_id_t node; // low word
42 skc_uint na;
43 };
44};
45
46//
47//
48//
49
50union skc_raster_node_elem
51{
52 skc_uint2 u32v2;
53 skc_ttsk_t sk;
54 skc_ttpk_t pk;
55 skc_ttxk_t xk;
56 union skc_raster_node_next next;
57};
58
59//
60//
61//
62
63union skc_raster_header
64{
65 skc_uint4 u32v4;
66
67 struct {
68 skc_uint blocks; // # of blocks -- head+node+skb+pkb -- uint2.lo
69 skc_uint na; // unused -- uint2.hi
70 skc_uint nodes; // # of nodes -- not including header -- uint2.lo
71 skc_uint keys; // # of sk+pk keys -- uint2.hi
72 };
73};
74
75//
76//
77//
78
79struct skc_raster_head
80{
81 union skc_raster_header header; // 3 counters and a spare
82 skc_int4 bounds; // sub-pixel resolution bounds
83 union skc_raster_node_elem elems[]; // 64-bit keys and index of next node
84};
85
86//
87//
88//
89
90#define SKC_RASTER_HEAD_WORDS 8
91
92#define SKC_RASTER_HEAD_OFFSET_COUNTS_BLOCKS 0
93#define SKC_RASTER_HEAD_OFFSET_COUNTS_NA 1
94#define SKC_RASTER_HEAD_OFFSET_COUNTS_NODES 2
95#define SKC_RASTER_HEAD_OFFSET_COUNTS_KEYS 3
96
97#define SKC_RASTER_HEAD_OFFSET_BOUNDS 4
98#define SKC_RASTER_HEAD_OFFSET_ELEMS 8
99
100//
101//
102//
103
104#define SKC_RASTER_HEAD_WORDS_CALC (sizeof(struct skc_raster_head) / sizeof(skc_uint))
105
106#define SKC_RASTER_HEAD_OFFSET_COUNTS_BLOCKS_CALC (SKC_OFFSET_OF(struct skc_raster_head,header.blocks) / sizeof(skc_uint))
107#define SKC_RASTER_HEAD_OFFSET_COUNTS_NODES_CALC (SKC_OFFSET_OF(struct skc_raster_head,header.nodes) / sizeof(skc_uint))
108#define SKC_RASTER_HEAD_OFFSET_COUNTS_KEYS_CALC (SKC_OFFSET_OF(struct skc_raster_head,header.keys) / sizeof(skc_uint))
109
110#define SKC_RASTER_HEAD_OFFSET_BOUNDS_CALC (SKC_OFFSET_OF(struct skc_raster_head,bounds) / sizeof(skc_uint))
111#define SKC_RASTER_HEAD_OFFSET_ELEMS_CALC (SKC_OFFSET_OF(struct skc_raster_head,elems) / sizeof(skc_uint))
112
113//
114// NOT ALL OPENCL PREPROCESSORS ARE HAPPY WITH CALCULATING OFFSET_OF()
115//
116// - Intel ioc compiler failed in the past
117//
118
119#if !defined(__OPENCL_C_VERSION__)
120SKC_STATIC_ASSERT(SKC_RASTER_HEAD_WORDS == SKC_RASTER_HEAD_WORDS_CALC);
121SKC_STATIC_ASSERT(SKC_RASTER_HEAD_OFFSET_COUNTS_BLOCKS == SKC_RASTER_HEAD_OFFSET_COUNTS_BLOCKS_CALC);
122SKC_STATIC_ASSERT(SKC_RASTER_HEAD_OFFSET_COUNTS_NODES == SKC_RASTER_HEAD_OFFSET_COUNTS_NODES_CALC);
123SKC_STATIC_ASSERT(SKC_RASTER_HEAD_OFFSET_COUNTS_KEYS == SKC_RASTER_HEAD_OFFSET_COUNTS_KEYS_CALC);
124SKC_STATIC_ASSERT(SKC_RASTER_HEAD_OFFSET_BOUNDS == SKC_RASTER_HEAD_OFFSET_BOUNDS_CALC);
125SKC_STATIC_ASSERT(SKC_RASTER_HEAD_OFFSET_ELEMS == SKC_RASTER_HEAD_OFFSET_ELEMS_CALC);
126#endif
127
128//
129//
130//
131
132#if 0
133#if !defined(__OPENCL_C_VERSION__)
134struct skc_raster_node
135{
136 union skc_raster_node_elem elems[];
137};
138#endif
139#endif
140
141//
142//
143//
144
145#define SKC_RASTER_HEAD_DWORDS (SKC_RASTER_HEAD_WORDS / 2)
146#define SKC_RASTER_NODE_DWORDS SKC_DEVICE_BLOCK_DWORDS
147
148//
149//
150
151#define SKC_RASTER_NODE_COUNT_KEYS (SKC_DEVICE_BLOCK_DWORDS - 1)
152#define SKC_RASTER_HEAD_COUNT_KEYS (SKC_RASTER_NODE_COUNT_KEYS - SKC_RASTER_HEAD_DWORDS)
153
154//
155// these are the most possible keys that could be produced by a node
156//
157
158#define SKC_RASTER_HEAD_MAX_TTSK SKC_RASTER_HEAD_COUNT_KEYS
159#define SKC_RASTER_HEAD_MAX_TTPK ((SKC_DEVICE_BLOCK_DWORDS - SKC_RASTER_HEAD_DWORDS) / 2)
160
161#define SKC_RASTER_NODE_MAX_TTSK SKC_RASTER_NODE_COUNT_KEYS // a node could be all TTSK keys minus next pointer
162#define SKC_RASTER_NODE_MAX_TTPK (SKC_RASTER_NODE_DWORDS / 2) // a node could be at most half TTPK keys and (half-1) TTSK keys
163
164#define SKC_RASTER_HEAD_MIN_TTSK (SKC_RASTER_HEAD_MAX_TTSK - SKC_RASTER_NODE_MAX_TTPK)
165#define SKC_RASTER_HEAD_MIN_TTPK 0
166
167#define SKC_RASTER_NODE_MIN_TTSK (SKC_RASTER_NODE_MAX_TTSK - SKC_RASTER_NODE_MAX_TTPK)
168#define SKC_RASTER_NODE_MIN_TTPK 0
169
170//
171//
172//
173
174#endif
175
176//
177//
178//