1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-30 04:50:08 +00:00

Corrected for potential lost lines.

This commit is contained in:
Thomas Harte 2016-05-08 16:43:11 -04:00
parent a75259ce9f
commit ccdbec3ffc
3 changed files with 17 additions and 9 deletions

View File

@ -40,8 +40,8 @@ const GLsizei IntermediateBufferWidth = 2048;
const GLsizei IntermediateBufferHeight = 512; const GLsizei IntermediateBufferHeight = 512;
// Some internal buffer sizes // Some internal buffer sizes
const GLsizeiptr OutputVertexBufferDataSize = 44928; // a multiple of 6 * OutputVertexSize const GLsizeiptr OutputVertexBufferDataSize = 6 * 8 * 312 * 10; // a multiple of 6 * OutputVertexSize
const GLsizeiptr SourceVertexBufferDataSize = 29952; // a multiple of 2 * SourceVertexSize const GLsizeiptr SourceVertexBufferDataSize = 2 * 16 * 312 * 10; // a multiple of 2 * SourceVertexSize
} }
} }

View File

@ -49,16 +49,25 @@ void CRTInputBufferBuilder::allocate_write_area(size_t required_length)
void CRTInputBufferBuilder::release_write_pointer() void CRTInputBufferBuilder::release_write_pointer()
{ {
if(_should_reset) // if(_should_reset)
{ // {
_next_write_x_position = _next_write_y_position = 0; // _next_write_x_position = _next_write_y_position = 0;
} // }
} }
bool CRTInputBufferBuilder::reduce_previous_allocation_to(size_t actual_length) bool CRTInputBufferBuilder::reduce_previous_allocation_to(size_t actual_length)
{ {
if(_next_write_y_position == InputBufferBuilderHeight) return false; if(_next_write_y_position == InputBufferBuilderHeight) return false;
// correct if the writing cursor was reset while a client was writing
if(_next_write_x_position == 0 && _next_write_y_position == 0 && _write_target_pointer != 1)
{
memmove(&_image[1], &_image[_write_target_pointer], actual_length);
_write_target_pointer = 1;
_last_allocation_amount = actual_length;
_next_write_x_position = (uint16_t)(actual_length + 2);
}
// book end the allocation with duplicates of the first and last pixel, to protect // book end the allocation with duplicates of the first and last pixel, to protect
// against rounding errors when this run is drawn // against rounding errors when this run is drawn
memcpy( &_image[(_write_target_pointer - 1) * _bytes_per_pixel], memcpy( &_image[(_write_target_pointer - 1) * _bytes_per_pixel],
@ -82,9 +91,8 @@ uint8_t *CRTInputBufferBuilder::get_image_pointer()
uint16_t CRTInputBufferBuilder::get_and_finalise_current_line() uint16_t CRTInputBufferBuilder::get_and_finalise_current_line()
{ {
// TODO: we may have a vended allocate_write_area in play that'll be lost by this step; fix.
uint16_t result = _write_y_position + (_next_write_x_position ? 1 : 0); uint16_t result = _write_y_position + (_next_write_x_position ? 1 : 0);
_should_reset = (_next_write_y_position == InputBufferBuilderHeight); _next_write_x_position = _next_write_y_position = 0;
return result; return result;
} }

View File

@ -185,7 +185,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out
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; _composite_src_output_y %= IntermediateBufferHeight;
_source_buffer_data_pointer %= SourceVertexBufferDataSize; _source_buffer_data_pointer %= SourceVertexBufferDataSize;