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_PATH 10 #define SKC_ONCE_PATH 11 12 // 13 // 14 // 15 16 #include "block.h" 17 18 // 19 // 20 // 21 22 union skc_path_header 23 { 24 skc_uint4 u32v4; 25 26 struct { 27 skc_uint handle; // host handle 28 skc_uint blocks; // # of S-segment blocks in path 29 skc_uint nodes; // # of S-segment node blocks -- not including header 30 skc_uint prims; // # of path elements: lines, quads, cubics, rat-quads, rat-cubics 31 }; 32 }; 33 34 union skc_path_bounds 35 { 36 skc_float4 f32v4; 37 38 struct { 39 skc_float x0; 40 skc_float y0; 41 skc_float x1; 42 skc_float y1; 43 }; 44 }; 45 46 // 47 // This head structure aliases a block. 48 // 49 // Blocks are at least 16 words. 50 // 51 52 struct skc_path_head 53 { 54 union skc_path_header header; // 4 55 union skc_path_bounds bounds; // 4 56 union skc_tagged_block_id tag_ids[]; // 8+ ids 57 }; 58 59 #define SKC_PATH_HEAD_WORDS 8 60 61 #define SKC_PATH_HEAD_OFFSET_HANDLE 0 62 #define SKC_PATH_HEAD_OFFSET_BLOCKS 1 63 #define SKC_PATH_HEAD_OFFSET_NODES 2 64 #define SKC_PATH_HEAD_OFFSET_PRIMS 3 65 66 #define SKC_PATH_HEAD_OFFSET_IDS 8 67 68 #define SKC_PATH_HEAD_WORDS_CALC (sizeof(struct skc_path_head) / sizeof(skc_uint)) 69 #define SKC_PATH_HEAD_OFFSET_HANDLE_CALC (SKC_OFFSET_OF(struct skc_path_head,header.handle) / sizeof(skc_uint)) 70 #define SKC_PATH_HEAD_OFFSET_BLOCKS_CALC (SKC_OFFSET_OF(struct skc_path_head,header.blocks) / sizeof(skc_uint)) 71 #define SKC_PATH_HEAD_OFFSET_NODES_CALC (SKC_OFFSET_OF(struct skc_path_head,header.nodes) / sizeof(skc_uint)) 72 #define SKC_PATH_HEAD_OFFSET_PRIMS_CALC (SKC_OFFSET_OF(struct skc_path_head,header.prims) / sizeof(skc_uint)) 73 #define SKC_PATH_HEAD_OFFSET_IDS_CALC (SKC_OFFSET_OF(struct skc_path_head,tag_ids) / sizeof(skc_uint)) 74 75 // 76 // NOT ALL OPENCL PREPROCESSORS ARE HAPPY WITH CALCULATING OFFSET_OF() 77 // 78 // - Intel ioc compiler failed in the past 79 // 80 81 #if !defined(__OPENCL_C_VERSION__) 82 SKC_STATIC_ASSERT(SKC_PATH_HEAD_WORDS == SKC_PATH_HEAD_WORDS_CALC); 83 SKC_STATIC_ASSERT(SKC_PATH_HEAD_OFFSET_HANDLE == SKC_PATH_HEAD_OFFSET_HANDLE_CALC); 84 SKC_STATIC_ASSERT(SKC_PATH_HEAD_OFFSET_BLOCKS == SKC_PATH_HEAD_OFFSET_BLOCKS_CALC); 85 SKC_STATIC_ASSERT(SKC_PATH_HEAD_OFFSET_NODES == SKC_PATH_HEAD_OFFSET_NODES_CALC); 86 SKC_STATIC_ASSERT(SKC_PATH_HEAD_OFFSET_PRIMS == SKC_PATH_HEAD_OFFSET_PRIMS_CALC); 87 SKC_STATIC_ASSERT(SKC_PATH_HEAD_OFFSET_IDS == SKC_PATH_HEAD_OFFSET_IDS_CALC); 88 #endif 89 90 // 91 // This node structure aliases a block. 92 // 93 // Blocks are at least 16 words. 94 // 95 // The last word in the block points to the next block 96 // 97 // The tag indicating a 'next' pointer is zero. 98 // 99 100 #if !defined(__OPENCL_C_VERSION__) 101 struct skc_path_node 102 { 103 union skc_tagged_block_id tag_ids[]; 104 }; 105 #endif 106 107 // 108 // 109 // 110 111 #endif 112 113 // 114 // 115 // 116