1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-11 04:28:58 +00:00

Some cleaning.

This commit is contained in:
Thomas Harte 2016-03-16 22:52:33 -04:00
parent 0d27d3bb7f
commit c8ecfb89d8
2 changed files with 37 additions and 71 deletions

View File

@ -91,8 +91,8 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer);
glBufferData(GL_ARRAY_BUFFER, buffer_size, NULL, GL_STREAM_DRAW);
_output_buffer_data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, buffer_size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
glBufferData(GL_ARRAY_BUFFER, InputVertexBufferDataSize, NULL, GL_STREAM_DRAW);
_output_buffer_data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, InputVertexBufferDataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
_output_buffer_data_pointer = 0;
glBindVertexArray(output_vertex_array);
prepare_output_vertex_array();
@ -111,10 +111,6 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
filteredTexture = std::unique_ptr<OpenGL::TextureTarget>(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight));
}
// glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *)&_openGL_state->defaultFramebuffer);
//
// printf("%d", glIsFramebuffer(_openGL_state->defaultFramebuffer));
// lock down any further work on the current frame
_output_mutex->lock();
@ -159,26 +155,6 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
// glBindTexture(GL_TEXTURE_2D, _openGL_state->textureName);
// glGetIntegerv(GL_VIEWPORT, results);
// ensure array buffer is up to date
// glBindBuffer(GL_ARRAY_BUFFER, output_array_buffer);
// size_t max_number_of_vertices = 0;
// for(int c = 0; c < NumberOfFields; c++)
// {
// max_number_of_vertices = std::max(max_number_of_vertices, _run_builders[c]->number_of_vertices);
// }
// if(output_vertices_per_slice < max_number_of_vertices)
// {
// output_vertices_per_slice = max_number_of_vertices;
// glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(max_number_of_vertices * OutputVertexSize * OutputVertexSize), NULL, GL_STREAM_DRAW);
//
// for(unsigned int c = 0; c < NumberOfFields; c++)
// {
// uint8_t *data = &_run_builders[c]->_runs[0];
// glBufferSubData(GL_ARRAY_BUFFER, (GLsizeiptr)(c * output_vertices_per_slice * OutputVertexSize), (GLsizeiptr)(_run_builders[c]->number_of_vertices * OutputVertexSize), data);
// _run_builders[c]->uploaded_vertices = _run_builders[c]->number_of_vertices;
// }
// }
// switch to the output shader
if(rgb_shader_program)
{
@ -195,7 +171,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
// draw all sitting frames
unsigned int run = (unsigned int)_run_write_pointer;
// printf("%d: %zu v %zu\n", run, _run_builders[run]->uploaded_vertices, _run_builders[run]->number_of_vertices);
// printf("%d: %zu v %zu\n", run, _run_builders[run]->uploaded_vertices, _run_builders[run]->number_of_vertices);
GLint total_age = 0;
for(int c = 0; c < NumberOfFields; c++)
{
@ -206,20 +182,9 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
{
glUniform1f(timestampBaseUniform, (GLfloat)total_age);
// if(_run_builders[run]->uploaded_vertices != _run_builders[run]->number_of_vertices)
// {
// uint8_t *data = &_run_builders[run]->_runs[_run_builders[run]->uploaded_vertices * OutputVertexSize];
// glBufferSubData(GL_ARRAY_BUFFER,
// (GLsizeiptr)(((run * output_vertices_per_slice) + _run_builders[run]->uploaded_vertices) * OutputVertexSize),
// (GLsizeiptr)((_run_builders[run]->number_of_vertices - _run_builders[run]->uploaded_vertices) * OutputVertexSize), data);
// _run_builders[run]->uploaded_vertices = _run_builders[run]->number_of_vertices;
// }
// draw this frame
// glDrawArrays(GL_TRIANGLE_STRIP, (GLint)(run * output_vertices_per_slice), (GLsizei)_run_builders[run]->number_of_vertices);
GLsizei count = (GLsizei)_run_builders[run]->number_of_vertices;
GLsizei max_count = (GLsizei)((buffer_size - _run_builders[run]->start) / InputVertexSize);
GLsizei max_count = (GLsizei)((InputVertexBufferDataSize - _run_builders[run]->start) / InputVertexSize);
if(count < max_count)
{
glDrawArrays(GL_TRIANGLE_STRIP, (GLint)(_run_builders[run]->start / InputVertexSize), count);

View File

@ -47,7 +47,8 @@ const int InputBufferBuilderHeight = 1024;
const int IntermediateBufferWidth = 2048;
const int IntermediateBufferHeight = 2048;
const GLsizeiptr buffer_size = (GLsizeiptr)(312 * 6 * 6 * OutputVertexSize);
// Some internal
const GLsizeiptr InputVertexBufferDataSize = 256 * 1024;
// Runs are divided discretely by vertical syncs in order to put a usable bounds on the uniform used to track
@ -139,7 +140,7 @@ class OpenGLOutputBuilder {
inline uint8_t *get_next_input_run()
{
if (_output_buffer_data_pointer + 6 * InputVertexSize > buffer_size) _output_buffer_data_pointer = 0;
if (_output_buffer_data_pointer + 6 * InputVertexSize > InputVertexBufferDataSize) _output_buffer_data_pointer = 0;
uint8_t *pointer = &_output_buffer_data[_output_buffer_data_pointer];
_output_buffer_data_pointer += 6 * InputVertexSize;
return pointer;