From 1b256d4382071381c512db37b0105b6a85edd350 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 11 Jan 2015 22:15:15 +0000 Subject: [PATCH] Fix case of buffer maps in idle writing state - don't generate chunks * If we generate an unmap chunk on a buffer while idle, it contains 'dangerous' data set at that point - it means that if we fetch the buffer initial contents at frame start, these are actually saved *before* the unmap chunk, in the initialisation/creation chunk which contains the shadow copy. Then the unmap overwrites with older data. * When mapping buffers, we should always either update the initial chunk or mark the buffer dirty so the initial chunk is refreshed on capture. * This was changed in commit 99c671992850346b1e52b8d87a2958e5b5e9e5d1 and was probably ok before then (although going into the serialise function was unnecessary and did some redundant copies into a chunk we were going to throw away). I'm not sure why I made that change, if it was to fix a bug I can't understand how. I guess I'll see if anything breaks. --- renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp index 9e841809a..ee8e7ede6 100644 --- a/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp @@ -1650,9 +1650,11 @@ GLboolean WrappedOpenGL::glUnmapNamedBufferEXT(GLuint buffer) } else { - SCOPED_SERIALISE_CONTEXT(UNMAP); - Serialise_glUnmapNamedBufferEXT(buffer); - record->AddChunk(scope.Get()); + // if we are here for WRITING_IDLE, the app wrote directly into our backing + // store memory. Just need to copy the data across to GL, no other work needed + void *ptr = m_Real.glMapNamedBufferRangeEXT(buffer, (GLintptr)record->Map.offset, GLsizeiptr(record->Map.length), GL_MAP_WRITE_BIT); + memcpy(ptr, record->Map.ptr, record->Map.length); + m_Real.glUnmapNamedBufferEXT(buffer); } break;