Implement MapWrite except in the wire.

Also this MapWrite doesn't zero out memory yet.
This commit is contained in:
Corentin Wallez
2018-03-20 20:56:39 -04:00
committed by Corentin Wallez
parent 8565e0056a
commit cc0a54dbdb
25 changed files with 521 additions and 102 deletions

View File

@@ -38,13 +38,19 @@ namespace backend { namespace opengl {
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.
// TODO(cwallez@chromium.org): this crashes on Mac NVIDIA, use GetBufferSubData there
// instead?
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_READ_BIT);
CallMapReadCallback(serial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
}
void Buffer::MapWriteAsyncImpl(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, mBuffer);
void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_WRITE_BIT);
CallMapWriteCallback(serial, NXT_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
}
void Buffer::UnmapImpl() {
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glUnmapBuffer(GL_ARRAY_BUFFER);

View File

@@ -32,6 +32,7 @@ namespace backend { namespace opengl {
private:
void SetSubDataImpl(uint32_t start, uint32_t count, const uint32_t* data) override;
void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
void UnmapImpl() override;
void TransitionUsageImpl(nxt::BufferUsageBit currentUsage,
nxt::BufferUsageBit targetUsage) override;