glUseProgram(glsl_program_num);
+ // An SSBO for the rANS distributions.
+ GLuint ssbo;
+ glGenBuffers(1, &ssbo);
+ glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
+ glBufferData(GL_SHADER_STORAGE_BUFFER, 65536 * 4 * sizeof(uint32_t), nullptr, GL_DYNAMIC_COPY);
+ glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 9, ssbo);
+
// Upload luma.
GLuint y_tex;
glGenTextures(1, &y_tex);
check_error();
steady_clock::time_point start = steady_clock::now();
- unsigned num_iterations = 1000;
+ unsigned num_iterations = 100;
for (unsigned i = 0; i < num_iterations; ++i) {
glDispatchCompute(WIDTH_BLOCKS, HEIGHT_BLOCKS, 1);
}
printf("\n");
printf("Each iteration took %.3f ms (but note that is DCT only, no rANS).\n", 1e3 * duration<double>(now - start).count() / num_iterations);
+#if 1
+ glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
+ const uint32_t *dist = (const uint32_t *)glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY);
+ for (int i = 0; i < 1024; ++i) {
+ printf("%d,%d: %u\n", i / 256, i % 256, dist[i] / num_iterations);
+ }
+#endif
}