Refactor MapRequestTracker to be its own class file.

All the buffer backend files had basically the same implemenations
of MapRequestTracker and the tracker was owned by device backends.
This refactor puts MapRequestTracker into its own file
and has the tracker be owned by DeviceBase and BufferBase.

Bug: dawn:400
Change-Id: Id28422b575e9c04d4435d5f119e0ffe08c2d1ce8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/21760
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Natasha Lee
2020-05-19 01:29:32 +00:00
committed by Commit Bot service account
parent 2ae84e9461
commit 949f1e45f1
25 changed files with 176 additions and 237 deletions

View File

@@ -45,8 +45,8 @@ namespace dawn_native { namespace opengl {
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
*mappedPointer = reinterpret_cast<uint8_t*>(data);
mMappedData = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
*mappedPointer = reinterpret_cast<uint8_t*>(mMappedData);
return {};
}
@@ -64,8 +64,7 @@ namespace dawn_native { namespace opengl {
// 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.
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
CallMapReadCallback(serial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
mMappedData = gl.MapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY);
return {};
}
@@ -75,16 +74,20 @@ namespace dawn_native { namespace opengl {
// 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.
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
void* data = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
CallMapWriteCallback(serial, WGPUBufferMapAsyncStatus_Success, data, GetSize());
mMappedData = gl.MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
return {};
}
void* Buffer::GetMappedPointerImpl() {
return mMappedData;
}
void Buffer::UnmapImpl() {
const OpenGLFunctions& gl = ToBackend(GetDevice())->gl;
gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer);
gl.UnmapBuffer(GL_ARRAY_BUFFER);
mMappedData = nullptr;
}
void Buffer::DestroyImpl() {

View File

@@ -40,8 +40,10 @@ namespace dawn_native { namespace opengl {
bool IsMapWritable() const override;
MaybeError MapAtCreationImpl(uint8_t** mappedPointer) override;
void* GetMappedPointerImpl() override;
GLuint mBuffer = 0;
void* mMappedData = nullptr;
};
}} // namespace dawn_native::opengl

View File

@@ -153,6 +153,11 @@ namespace dawn_native { namespace opengl {
MaybeError Device::TickImpl() {
CheckPassedSerials();
if (GetCompletedCommandSerial() == GetLastSubmittedCommandSerial()) {
// If there's no GPU work in flight we still need to artificially increment the serial
// so that CPU operations waiting on GPU completion can know they don't have to wait.
ArtificiallyIncrementSerials();
}
return {};
}