From: Steinar H. Gunderson Date: Sun, 12 Nov 2017 10:00:09 +0000 (+0100) Subject: Fix some hardcoded resolutions in the encoder. X-Git-Url: https://git.sesse.net/?p=narabu;a=commitdiff_plain;h=67ba4e9e079527f90ebac9a1d99d66181071fb8a Fix some hardcoded resolutions in the encoder. --- diff --git a/narabu-encoder.cpp b/narabu-encoder.cpp index fe27064..ca81b2e 100644 --- a/narabu-encoder.cpp +++ b/narabu-encoder.cpp @@ -224,13 +224,13 @@ int main(int argc, char **argv) GLuint output_ssbo; glGenBuffers(1, &output_ssbo); glBindBuffer(GL_SHADER_STORAGE_BUFFER, output_ssbo); - glNamedBufferStorage(output_ssbo, 45 * 64 * 1024, nullptr, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT); + glNamedBufferStorage(output_ssbo, HEIGHT_BLOCKS * WIDTH_BLOCKS * 1024, nullptr, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT); check_error(); GLuint bytes_written_ssbo; glGenBuffers(1, &bytes_written_ssbo); glBindBuffer(GL_SHADER_STORAGE_BUFFER, bytes_written_ssbo); - glNamedBufferStorage(bytes_written_ssbo, 45 * 64 * sizeof(uint32_t), nullptr, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT); + glNamedBufferStorage(bytes_written_ssbo, HEIGHT_BLOCKS * WIDTH_BLOCKS * sizeof(uint32_t), nullptr, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT); check_error(); // Bind SSBOs. @@ -384,19 +384,19 @@ int main(int argc, char **argv) // Write out the actual data. - const uint32_t *bytes_written = (const uint32_t *)glMapNamedBufferRange(bytes_written_ssbo, 0, 45 * 64 * sizeof(uint32_t), GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT); + const uint32_t *bytes_written = (const uint32_t *)glMapNamedBufferRange(bytes_written_ssbo, 0, HEIGHT_BLOCKS * WIDTH_BLOCKS * sizeof(uint32_t), GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT); #if 0 - for (int i = 0; i < 45*64; ++i) { + for (int i = 0; i < HEIGHT_BLOCKS*64; ++i) { printf("%d,%d,%d: %u\n", i / 64, (i / 8) % 8, i % 8, 1024 * (i + 1) - offsets[i]); } #endif - const uint8_t *data = (const uint8_t *)glMapNamedBufferRange(output_ssbo, 0, 45 * 64 * 1024, GL_MAP_READ_BIT | GL_MAP_PERSISTENT_BIT); + const uint8_t *data = (const uint8_t *)glMapNamedBufferRange(output_ssbo, 0, HEIGHT_BLOCKS * WIDTH_BLOCKS * 1024, 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 < 45; ++stream_idx) { + 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; uint32_t num_rans_bytes = bytes_written[stream_idx * 64 + y * 8 + x]; const uint8_t *ptr = out_end - num_rans_bytes;