MCPcopy Create free account
hub / github.com/TheRealMJP/SHforHLSL / computeHistogram

Function computeHistogram

SHTest/Externals/meshoptimizer/spatialorder.cpp:65–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65static void computeHistogram(unsigned int (&hist)[1024][3], const unsigned int* data, size_t count)
66{
67 memset(hist, 0, sizeof(hist));
68
69 // compute 3 10-bit histograms in parallel
70 for (size_t i = 0; i < count; ++i)
71 {
72 unsigned int id = data[i];
73
74 hist[(id >> 0) & 1023][0]++;
75 hist[(id >> 10) & 1023][1]++;
76 hist[(id >> 20) & 1023][2]++;
77 }
78
79 unsigned int sumx = 0, sumy = 0, sumz = 0;
80
81 // replace histogram data with prefix histogram sums in-place
82 for (int i = 0; i < 1024; ++i)
83 {
84 unsigned int hx = hist[i][0], hy = hist[i][1], hz = hist[i][2];
85
86 hist[i][0] = sumx;
87 hist[i][1] = sumy;
88 hist[i][2] = sumz;
89
90 sumx += hx;
91 sumy += hy;
92 sumz += hz;
93 }
94
95 assert(sumx == count && sumy == count && sumz == count);
96}
97
98static void radixPass(unsigned int* destination, const unsigned int* source, const unsigned int* keys, size_t count, unsigned int (&hist)[1024][3], int pass)
99{

Callers 1

meshopt_spatialSortRemapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected