15 #ifndef NANOVDB_PNANOVDB_VALIDATE_STRIDES_H_HAS_BEEN_INCLUDED 16 #define NANOVDB_PNANOVDB_VALIDATE_STRIDES_H_HAS_BEEN_INCLUDED 20 static pnanovdb_uint32_t
allocate(pnanovdb_uint32_t* poffset, pnanovdb_uint32_t size, pnanovdb_uint32_t alignment)
24 (*poffset) = alignment * (((*poffset) + (alignment - 1)) / alignment);
26 pnanovdb_uint32_t ret = (*poffset);
32 pnanovdb_uint32_t grid_type,
33 pnanovdb_uint32_t* background_off,
34 pnanovdb_uint32_t* min_off, pnanovdb_uint32_t* max_off,
35 pnanovdb_uint32_t* ave_off, pnanovdb_uint32_t* stddev_off,
36 pnanovdb_uint32_t* total_size)
38 pnanovdb_uint32_t offset = 0u;
45 *background_off =
allocate(&offset, minmaxStride, minmaxAlign);
46 *min_off =
allocate(&offset, minmaxStride, minmaxAlign);
47 *max_off =
allocate(&offset, minmaxStride, minmaxAlign);
48 *ave_off =
allocate(&offset, statStride, statStride);
49 *stddev_off =
allocate(&offset, statStride, statStride);
50 *total_size =
allocate(&offset, 0u, 32u);
53 static void compute_tile_strides(pnanovdb_uint32_t grid_type, pnanovdb_uint32_t* value_off, pnanovdb_uint32_t* total_size)
55 pnanovdb_uint32_t offset = 0u;
61 *value_off =
allocate(&offset, valueStride, valueAlign);
62 *total_size =
allocate(&offset, 0u, 32u);
66 pnanovdb_uint32_t grid_type,
67 pnanovdb_uint32_t nodeLevel,
68 pnanovdb_uint32_t* min_off, pnanovdb_uint32_t* max_off,
69 pnanovdb_uint32_t* ave_off, pnanovdb_uint32_t* stddev_off,
70 pnanovdb_uint32_t* table_off,
71 pnanovdb_uint32_t* total_size)
75 pnanovdb_uint32_t offset = 0u;
76 allocate(&offset, node_size[nodeLevel], 32u);
80 pnanovdb_uint32_t tableAlign = 32u;
81 pnanovdb_uint32_t tableFullStride = (tableStrideBits * node_elements[nodeLevel]) / 8u;
86 pnanovdb_uint32_t indexMaskStride = 0u;
110 tableFullStride = 8u;
118 tableFullStride = 8u;
119 indexMaskStride = 64u;
127 tableFullStride = (16u * node_elements[nodeLevel]) / 8u;
130 *min_off =
allocate(&offset, minmaxStride, minmaxAlign);
131 *max_off =
allocate(&offset, minmaxStride, minmaxAlign);
132 *ave_off =
allocate(&offset, statStride, statStride);
133 *stddev_off =
allocate(&offset, statStride, statStride);
134 *table_off =
allocate(&offset, tableFullStride, tableAlign);
135 allocate(&offset, indexMaskStride, tableAlign);
136 *total_size =
allocate(&offset, 0u, 32u);
146 pnanovdb_uint32_t root_background, root_min, root_max, root_ave, root_stddev, root_size;
147 compute_root_strides(idx, &root_background, &root_min, &root_max, &root_ave, &root_stddev, &root_size);
149 pnanovdb_uint32_t tile_value, tile_size;
152 pnanovdb_uint32_t upper_min, upper_max, upper_ave, upper_stddev, upper_table, upper_size;
153 compute_node_strides(idx, 2, &upper_min, &upper_max, &upper_ave, &upper_stddev, &upper_table, &upper_size);
155 pnanovdb_uint32_t lower_min, lower_max, lower_ave, lower_stddev, lower_table, lower_size;
156 compute_node_strides(idx, 1, &lower_min, &lower_max, &lower_ave, &lower_stddev, &lower_table, &lower_size);
158 pnanovdb_uint32_t leaf_min, leaf_max, leaf_ave, leaf_stddev, leaf_table, leaf_size;
159 compute_node_strides(idx, 0, &leaf_min, &leaf_max, &leaf_ave, &leaf_stddev, &leaf_table, &leaf_size);
163 pnanovdb_uint32_t tableStride = tableStrideBits / 8u;
168 valueStrideBits = 0u;
172 root_background, root_min, root_max, root_ave, root_stddev, root_size,
173 valueStrideBits, tableStride, tile_value, tile_size,
174 upper_min, upper_max, upper_ave, upper_stddev, upper_table, upper_size,
175 lower_min, lower_max, lower_ave, lower_stddev, lower_table, lower_size,
176 leaf_min, leaf_max, leaf_ave, leaf_stddev, leaf_table, leaf_size
178 constants[idx] = local_constants;
181 bool mismatch =
false;
193 local_printf(
"Error: Mismatch between constant tables.\n");
194 for (pnanovdb_uint32_t pass = 0u; pass < 2u; pass++)
198 local_printf(
"Printing expected values:\n");
202 local_printf(
"Printing current header values:\n");
207 local_printf(
"{%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d},\n",
220 #endif// end of NANOVDB_PNANOVDB_VALIDATE_STRIDES_H_HAS_BEEN_INCLUDED #define PNANOVDB_GRID_TYPE_END
Definition: PNanoVDB.h:966
pnanovdb_uint32_t root_tile_size
Definition: PNanoVDB.h:1619
static pnanovdb_uint32_t allocate(pnanovdb_uint32_t *poffset, pnanovdb_uint32_t size, pnanovdb_uint32_t alignment)
Definition: pnanovdb_validate_strides.h:20
Definition: PNanoVDB.h:1608
pnanovdb_uint32_t lower_off_max
Definition: PNanoVDB.h:1627
pnanovdb_uint32_t value_stride_bits
Definition: PNanoVDB.h:1616
pnanovdb_uint32_t root_off_max
Definition: PNanoVDB.h:1612
pnanovdb_uint32_t root_size
Definition: PNanoVDB.h:1615
pnanovdb_uint32_t lower_off_min
Definition: PNanoVDB.h:1626
#define PNANOVDB_LOWER_TABLE_COUNT
Definition: PNanoVDB.h:1526
#define PNANOVDB_UPPER_BASE_SIZE
Definition: PNanoVDB.h:1472
pnanovdb_uint32_t leaf_off_max
Definition: PNanoVDB.h:1633
#define PNANOVDB_ROOT_BASE_SIZE
Definition: PNanoVDB.h:1393
#define PNANOVDB_UPPER_TABLE_COUNT
Definition: PNanoVDB.h:1471
pnanovdb_uint32_t upper_off_table
Definition: PNanoVDB.h:1624
PNANOVDB_STATIC_CONST pnanovdb_grid_type_constants_t pnanovdb_grid_type_constants[27]
Definition: PNanoVDB.h:1642
pnanovdb_uint32_t leaf_size
Definition: PNanoVDB.h:1637
pnanovdb_uint32_t upper_size
Definition: PNanoVDB.h:1625
pnanovdb_uint32_t root_off_stddev
Definition: PNanoVDB.h:1614
static void compute_tile_strides(pnanovdb_uint32_t grid_type, pnanovdb_uint32_t *value_off, pnanovdb_uint32_t *total_size)
Definition: pnanovdb_validate_strides.h:53
#define PNANOVDB_LEAF_TYPE_LITE
Definition: PNanoVDB.h:989
pnanovdb_uint32_t lower_off_ave
Definition: PNanoVDB.h:1628
pnanovdb_uint32_t leaf_off_min
Definition: PNanoVDB.h:1632
pnanovdb_uint32_t upper_off_min
Definition: PNanoVDB.h:1620
pnanovdb_uint32_t table_stride
Definition: PNanoVDB.h:1617
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_stat_strides_bits[27]
Definition: PNanoVDB.h:1005
pnanovdb_uint32_t upper_off_max
Definition: PNanoVDB.h:1621
#define PNANOVDB_LEAF_TABLE_COUNT
Definition: PNanoVDB.h:1579
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_value_strides_bits[27]
Definition: PNanoVDB.h:997
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_minmax_strides_bits[27]
Definition: PNanoVDB.h:1001
pnanovdb_uint32_t lower_off_table
Definition: PNanoVDB.h:1630
#define PNANOVDB_LEAF_TYPE_POINTINDEX
Definition: PNanoVDB.h:993
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_leaf_type[27]
Definition: PNanoVDB.h:1007
#define PNANOVDB_LEAF_TYPE_INDEX
Definition: PNanoVDB.h:991
#define PNANOVDB_LEAF_TYPE_FP
Definition: PNanoVDB.h:990
#define PNANOVDB_LOWER_BASE_SIZE
Definition: PNanoVDB.h:1527
pnanovdb_uint32_t leaf_off_table
Definition: PNanoVDB.h:1636
pnanovdb_uint32_t root_off_background
Definition: PNanoVDB.h:1610
This file is a portable (e.g. pointer-less) C99/GLSL/HLSL port of NanoVDB.h, which is compatible with...
pnanovdb_uint32_t upper_off_stddev
Definition: PNanoVDB.h:1623
pnanovdb_uint32_t root_tile_off_value
Definition: PNanoVDB.h:1618
#define PNANOVDB_ROOT_TILE_BASE_SIZE
Definition: PNanoVDB.h:1431
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_table_strides_bits[27]
Definition: PNanoVDB.h:999
#define PNANOVDB_LEAF_BASE_SIZE
Definition: PNanoVDB.h:1580
static void compute_root_strides(pnanovdb_uint32_t grid_type, pnanovdb_uint32_t *background_off, pnanovdb_uint32_t *min_off, pnanovdb_uint32_t *max_off, pnanovdb_uint32_t *ave_off, pnanovdb_uint32_t *stddev_off, pnanovdb_uint32_t *total_size)
Definition: pnanovdb_validate_strides.h:31
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_minmax_aligns_bits[27]
Definition: PNanoVDB.h:1003
pnanovdb_uint32_t upper_off_ave
Definition: PNanoVDB.h:1622
pnanovdb_uint32_t root_off_min
Definition: PNanoVDB.h:1611
static void compute_node_strides(pnanovdb_uint32_t grid_type, pnanovdb_uint32_t nodeLevel, pnanovdb_uint32_t *min_off, pnanovdb_uint32_t *max_off, pnanovdb_uint32_t *ave_off, pnanovdb_uint32_t *stddev_off, pnanovdb_uint32_t *table_off, pnanovdb_uint32_t *total_size)
Definition: pnanovdb_validate_strides.h:65
pnanovdb_uint32_t leaf_off_stddev
Definition: PNanoVDB.h:1635
pnanovdb_uint32_t lower_off_stddev
Definition: PNanoVDB.h:1629
#define PNANOVDB_LEAF_TYPE_INDEXMASK
Definition: PNanoVDB.h:992
static bool validate_strides(int(*local_printf)(const char *format,...))
Definition: pnanovdb_validate_strides.h:139
pnanovdb_uint32_t leaf_off_ave
Definition: PNanoVDB.h:1634
pnanovdb_uint32_t root_off_ave
Definition: PNanoVDB.h:1613
pnanovdb_uint32_t lower_size
Definition: PNanoVDB.h:1631