]> git.sesse.net Git - narabu/commitdiff
Parametrize STREAM_BUF_SIZE in the .cpp file.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 12 Nov 2017 10:07:14 +0000 (11:07 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 12 Nov 2017 10:07:14 +0000 (11:07 +0100)
narabu-encoder.cpp

index ca81b2e687fac1a30ad7c4d91b1ef2a6ee8f5f0a..b1d0d1f18e02d3ff805e469a596fb20a19b53c25 100644 (file)
@@ -32,6 +32,7 @@
 #define NUM_SYMS 256
 #define ESCAPE_LIMIT (NUM_SYMS - 1)
 #define BLOCKS_PER_STREAM 320
+#define STREAM_BUF_SIZE 1024  // In bytes.
 
 static constexpr uint32_t prob_bits = 12;
 static constexpr uint32_t prob_scale = 1 << prob_bits;
@@ -224,7 +225,7 @@ int main(int argc, char **argv)
        GLuint output_ssbo;
        glGenBuffers(1, &output_ssbo);
        glBindBuffer(GL_SHADER_STORAGE_BUFFER, output_ssbo);
-       glNamedBufferStorage(output_ssbo, HEIGHT_BLOCKS * WIDTH_BLOCKS * 1024, nullptr, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT);
+       glNamedBufferStorage(output_ssbo, HEIGHT_BLOCKS * WIDTH_BLOCKS * STREAM_BUF_SIZE, nullptr, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT);
        check_error();
 
        GLuint bytes_written_ssbo;
@@ -391,16 +392,16 @@ int main(int argc, char **argv)
        }
 #endif
 
-       const uint8_t *data = (const uint8_t *)glMapNamedBufferRange(output_ssbo, 0, HEIGHT_BLOCKS * WIDTH_BLOCKS * 1024, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT);
+       const uint8_t *data = (const uint8_t *)glMapNamedBufferRange(output_ssbo, 0, HEIGHT_BLOCKS * WIDTH_BLOCKS * STREAM_BUF_SIZE, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT);
 
        string last_block;
        for (unsigned y = 0; y < 8; ++y) {
                for (unsigned x = 0; x < 8; ++x) {
                        for (unsigned int stream_idx = 0; stream_idx < HEIGHT_BLOCKS; ++stream_idx) {
-                               const uint8_t *out_end = data + (stream_idx * 64 + y * 8 + x + 1) * 1024;
+                               const uint8_t *out_end = data + (stream_idx * 64 + y * 8 + x + 1) * STREAM_BUF_SIZE;
                                uint32_t num_rans_bytes = bytes_written[stream_idx * 64 + y * 8 + x];
                                const uint8_t *ptr = out_end - num_rans_bytes;
-                               assert(num_rans_bytes <= 1024);
+                               assert(num_rans_bytes <= STREAM_BUF_SIZE);
 
                                if (num_rans_bytes == last_block.size() &&
                                    memcmp(last_block.data(), ptr, last_block.size()) == 0) {