From 5b37a651ac7b2dab9bf4170f758c14f74cfad684 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 18 Mar 2016 21:35:52 -0400 Subject: [PATCH] Made an attemp to deal with `glUnmapBuffer(GL_ARRAY_BUFFER) == GL_FALSE`. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index f1fe31b12..0ea951a22 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -206,7 +206,6 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out size_t first_size = InputVertexBufferDataSize - start; memcpy(&target[start], &_output_buffer_data[start], first_size); memcpy(target, _output_buffer_data, length - first_size); - glUnmapBuffer(GL_ARRAY_BUFFER); } } else @@ -215,10 +214,16 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out if(target) { memcpy(target, &_output_buffer_data[start], length); - glUnmapBuffer(GL_ARRAY_BUFFER); } } + while(glUnmapBuffer(GL_ARRAY_BUFFER) == GL_FALSE) + { + // "the data store contents are undefined. An application must detect this rare condition and reinitialize the data store." + uint8_t *target = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, InputVertexBufferDataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT); + memcpy(target, _output_buffer_data, InputVertexBufferDataSize); + } + _run_builders[run]->amount_of_uploaded_data = _run_builders[run]->amount_of_data; }