]> git.sesse.net Git - narabu/commitdiff
Fix some off-by-ones in the tally shader.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 16 Oct 2017 20:16:27 +0000 (22:16 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 16 Oct 2017 20:16:27 +0000 (22:16 +0200)
narabu-encoder.cpp
tally.shader

index 6b1df4837ef5774bcb0a1c78d9a812f7ef70afbe..b1b86d847a3f2cc128430c22a975a36adc986618 100644 (file)
@@ -344,8 +344,8 @@ int main(int argc, char **argv)
                for (unsigned i = 0; i < 4; ++i) {
                        printf("writing table %d\n", i);
                        for (unsigned j = 0; j < NUM_SYMS; ++j) {
-                               printf("%d,%d: %d\n", i, j, rans_dist->ransdist[i * 256 + j].first);
-                               write_varint(rans_dist->ransdist[i * 256 + j].first, codedfp);
+                               printf("%d,%d: start=%d freq=%d\n", i, j, rans_dist->ransdist[i * 256 + j].first, rans_dist->ransdist[i * 256 + j].second);
+                               write_varint(rans_dist->ransdist[i * 256 + j].second, codedfp);
                        }
                }
        }
index 0d6d09ec70bd7d562313fabe98bdf6008d5ab366..fba526b96b6c29be33db626098a63a50b9ddab22 100644 (file)
@@ -145,6 +145,8 @@ void main()
        memoryBarrierShared();
        barrier();
 
+       new_val = new_dist[i];
+
        for (uint layer = 2; layer <= 256; layer *= 2) {
                if ((i & (layer - 1)) == layer - 1) {
                        new_dist[i] += new_dist[i - (layer / 2)];
@@ -159,5 +161,5 @@ void main()
                memoryBarrierShared();
                barrier();
        }
-       ransdist[base + i] = uvec2(new_val, new_dist[i]);
+       ransdist[base + i] = uvec2(new_dist[i] - new_val, new_val);
 }