Implement CreateBufferMapped in dawn_native for MAP_WRITE buffers only.

This is the first command to return a struct. This patch also
updates the code generator to support structure return values.

Bug: dawn:7
Change-Id: Ie8acec895c0ec88429672138ffc900032fbbc447
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/4780
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng
2019-05-15 18:55:22 +00:00
committed by Commit Bot service account
parent 0195dbf908
commit 740995c0b1
22 changed files with 241 additions and 12 deletions

View File

@@ -35,6 +35,13 @@ namespace dawn_native { namespace opengl {
return mBuffer;
}
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
void* data = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
*mappedPointer = reinterpret_cast<uint8_t*>(data);
return {};
}
MaybeError Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) {
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
glBufferSubData(GL_ARRAY_BUFFER, start, count, data);

View File

@@ -31,12 +31,15 @@ namespace dawn_native { namespace opengl {
GLuint GetHandle() const;
private:
// Dawn API
MaybeError SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
void MapReadAsyncImpl(uint32_t serial) override;
void MapWriteAsyncImpl(uint32_t serial) override;
void UnmapImpl() override;
void DestroyImpl() override;
MaybeError MapAtCreationImpl(uint8_t** mappedPointer) override;
GLuint mBuffer = 0;
};