From 0f9f747c8a6f9f5b2edd741cde6fbd159e1fc414 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 14 Jul 2017 17:38:17 -0400 Subject: [PATCH] OpenGL: implement a synchronous MapReadAsync Mapping OpenGL buffers persistently and unsynchronized isn't supported on OSX's OpenGL version where we want to run tests. --- src/backend/opengl/BufferGL.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/opengl/BufferGL.cpp b/src/backend/opengl/BufferGL.cpp index 3949b77ea1..b125ee5ac2 100644 --- a/src/backend/opengl/BufferGL.cpp +++ b/src/backend/opengl/BufferGL.cpp @@ -37,12 +37,17 @@ namespace opengl { glBufferSubData(GL_ARRAY_BUFFER, start * sizeof(uint32_t), count * sizeof(uint32_t), data); } - void Buffer::MapReadAsyncImpl(uint32_t, uint32_t, uint32_t) { - // TODO(cwallez@chromium.org): Implement Map Read for the GL backend + void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) { + // TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high + // version of OpenGL that would let us map the buffer unsynchronized. + glBindBuffer(GL_ARRAY_BUFFER, buffer); + void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_READ_BIT); + CallMapReadCallback(serial, NXT_BUFFER_MAP_READ_STATUS_SUCCESS, data); } void Buffer::UnmapImpl() { - // TODO(cwallez@chromium.org): Implement Map Read for the GL backend + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glUnmapBuffer(GL_ARRAY_BUFFER); } void Buffer::TransitionUsageImpl(nxt::BufferUsageBit, nxt::BufferUsageBit) {