From 0d2d6a452d4de160ec9469c277fd15771c5f20d4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 May 2016 19:55:34 -0400 Subject: [PATCH] Fixed some dangling buffer management issues. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 16 ++++------------ Outputs/CRT/Internals/CRTOpenGL.hpp | 11 +++-------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index d5cfed7cc..ecd1eb6f4 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -80,11 +80,9 @@ static int getCircularRanges(GLsizei *start_pointer, GLsizei *end_pointer, GLsiz } } -static GLsizei submitArrayData(GLuint buffer, uint8_t *source, GLsizei *length_pointer, GLsizei chunk_size) +static GLsizei submitArrayData(GLuint buffer, uint8_t *source, GLsizei *length_pointer) { GLsizei length = *length_pointer; - GLsizei residue = length % chunk_size; - length -= residue; glBindBuffer(GL_ARRAY_BUFFER, buffer); uint8_t *data = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, length, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); @@ -92,13 +90,7 @@ static GLsizei submitArrayData(GLuint buffer, uint8_t *source, GLsizei *length_p glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, length); glUnmapBuffer(GL_ARRAY_BUFFER); - if(residue) - { - memmove(source, &source[length], (size_t)residue); - *length_pointer = residue; - } - else - *length_pointer = 0; + *length_pointer = 0; return length; } @@ -204,10 +196,10 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out } // release the mapping, giving up on trying to draw if data has been lost - GLsizei submitted_output_data = submitArrayData(output_array_buffer, _output_buffer_data.get(), &_output_buffer_data_pointer, 6*OutputVertexSize); + GLsizei submitted_output_data = submitArrayData(output_array_buffer, _output_buffer_data.get(), &_output_buffer_data_pointer); // bind and flush the source array buffer - GLsizei submitted_source_data = submitArrayData(source_array_buffer, _source_buffer_data.get(), &_source_buffer_data_pointer, 2*SourceVertexSize); + GLsizei submitted_source_data = submitArrayData(source_array_buffer, _source_buffer_data.get(), &_source_buffer_data_pointer); // determine how many lines are newly reclaimed; they'll need to be cleared Range clearing_zones[2]; diff --git a/Outputs/CRT/Internals/CRTOpenGL.hpp b/Outputs/CRT/Internals/CRTOpenGL.hpp index 6da343c13..12c4c79eb 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.hpp +++ b/Outputs/CRT/Internals/CRTOpenGL.hpp @@ -107,12 +107,12 @@ class OpenGLOutputBuilder { inline uint8_t *get_next_source_run() { if(_source_buffer_data_pointer == SourceVertexBufferDataSize) return nullptr; - return &_source_buffer_data.get()[_source_buffer_data_pointer % SourceVertexBufferDataSize]; + return &_source_buffer_data.get()[_source_buffer_data_pointer]; } inline void complete_source_run() { - _source_buffer_data_pointer += 2 * SourceVertexSize; + _source_buffer_data_pointer += SourceVertexSize; } inline bool composite_output_run_has_room_for_vertex() @@ -123,7 +123,7 @@ class OpenGLOutputBuilder { inline uint8_t *get_next_output_run() { if(_output_buffer_data_pointer == OutputVertexBufferDataSize) return nullptr; - return &_output_buffer_data.get()[_output_buffer_data_pointer % OutputVertexBufferDataSize]; + return &_output_buffer_data.get()[_output_buffer_data_pointer]; } inline void complete_output_run() @@ -146,11 +146,6 @@ class OpenGLOutputBuilder { return _output_device; } - inline bool composite_output_buffer_has_room_for_vertices(GLsizei vertices_to_write) - { - return _composite_src_output_y <= _cleared_composite_output_y + IntermediateBufferHeight - vertices_to_write * OutputVertexSize; - } - inline uint16_t get_composite_output_y() { return _composite_src_output_y % IntermediateBufferHeight;