1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Moved more of the circular logic inside getCircularRanges in order to eliminate one more potential source of error.

This commit is contained in:
Thomas Harte 2016-05-09 07:34:37 -04:00
parent ddfc9910e5
commit 45af963b9a
2 changed files with 11 additions and 15 deletions

View File

@ -41,8 +41,14 @@ struct Range {
GLsizei location, length; GLsizei location, length;
}; };
static int getCircularRanges(GLsizei start, GLsizei end, GLsizei buffer_length, GLsizei granularity, Range *ranges) static int getCircularRanges(GLsizei *start_pointer, GLsizei *end_pointer, GLsizei buffer_length, GLsizei granularity, Range *ranges)
{ {
GLsizei start = *start_pointer;
GLsizei end = *end_pointer;
*end_pointer %= buffer_length;
*start_pointer = *end_pointer;
start -= start%granularity; start -= start%granularity;
end -= end%granularity; end -= end%granularity;
@ -160,8 +166,6 @@ OpenGLOutputBuilder::OpenGLOutputBuilder(unsigned int buffer_depth) :
OpenGLOutputBuilder::~OpenGLOutputBuilder() OpenGLOutputBuilder::~OpenGLOutputBuilder()
{ {
// glUnmapBuffer(GL_ARRAY_BUFFER);
// glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glDeleteTextures(1, &textureName); glDeleteTextures(1, &textureName);
glDeleteBuffers(1, &output_array_buffer); glDeleteBuffers(1, &output_array_buffer);
glDeleteBuffers(1, &source_array_buffer); glDeleteBuffers(1, &source_array_buffer);
@ -193,19 +197,11 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
// determine how many lines are newly reclaimed; they'll need to be cleared // determine how many lines are newly reclaimed; they'll need to be cleared
Range clearing_zones[2], source_drawing_zones[2]; Range clearing_zones[2], source_drawing_zones[2];
Range output_drawing_zones[2]; Range output_drawing_zones[2];
int number_of_clearing_zones = getCircularRanges(_cleared_composite_output_y, _composite_src_output_y, IntermediateBufferHeight, 1, clearing_zones); int number_of_clearing_zones = getCircularRanges(&_cleared_composite_output_y, &_composite_src_output_y, IntermediateBufferHeight, 1, clearing_zones);
int number_of_source_drawing_zones = getCircularRanges(_drawn_source_buffer_data_pointer, _source_buffer_data_pointer, SourceVertexBufferDataSize, 2*SourceVertexSize, source_drawing_zones); int number_of_source_drawing_zones = getCircularRanges(&_drawn_source_buffer_data_pointer, &_source_buffer_data_pointer, SourceVertexBufferDataSize, 2*SourceVertexSize, source_drawing_zones);
int number_of_output_drawing_zones = getCircularRanges(_drawn_output_buffer_data_pointer, _output_buffer_data_pointer, OutputVertexBufferDataSize, 6*OutputVertexSize, output_drawing_zones); int number_of_output_drawing_zones = getCircularRanges(&_drawn_output_buffer_data_pointer, &_output_buffer_data_pointer, OutputVertexBufferDataSize, 6*OutputVertexSize, output_drawing_zones);
uint16_t completed_texture_y = _buffer_builder->get_and_finalise_current_line(); uint16_t completed_texture_y = _buffer_builder->get_and_finalise_current_line();
_composite_src_output_y %= IntermediateBufferHeight;
_source_buffer_data_pointer %= SourceVertexBufferDataSize;
_output_buffer_data_pointer %= OutputVertexBufferDataSize;
_cleared_composite_output_y = _composite_src_output_y;
_drawn_source_buffer_data_pointer = _source_buffer_data_pointer;
_drawn_output_buffer_data_pointer = _output_buffer_data_pointer;
if(_fence != nullptr) if(_fence != nullptr)
{ {
glClientWaitSync(_fence, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); glClientWaitSync(_fence, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);

View File

@ -60,7 +60,7 @@ class OpenGLOutputBuilder {
std::unique_ptr<std::mutex> _output_mutex; std::unique_ptr<std::mutex> _output_mutex;
// transient buffers indicating composite data not yet decoded // transient buffers indicating composite data not yet decoded
uint16_t _composite_src_output_y, _cleared_composite_output_y; GLsizei _composite_src_output_y, _cleared_composite_output_y;
std::unique_ptr<OpenGL::OutputShader> output_shader_program; std::unique_ptr<OpenGL::OutputShader> output_shader_program;
std::unique_ptr<OpenGL::IntermediateShader> composite_input_shader_program, composite_separation_filter_program, composite_y_filter_shader_program, composite_chrominance_filter_shader_program; std::unique_ptr<OpenGL::IntermediateShader> composite_input_shader_program, composite_separation_filter_program, composite_y_filter_shader_program, composite_chrominance_filter_shader_program;