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

@@ -266,7 +266,7 @@ namespace dawn_native { namespace null {
struct BufferMapOperation : PendingOperation {
virtual void Execute() {
buffer->MapOperationCompleted(serial, ptr, isWrite);
buffer->OnMapCommandSerialFinished(serial, isWrite);
}
Ref<Buffer> buffer;
@@ -296,14 +296,6 @@ namespace dawn_native { namespace null {
return {};
}
void Buffer::MapOperationCompleted(uint32_t serial, void* ptr, bool isWrite) {
if (isWrite) {
CallMapWriteCallback(serial, WGPUBufferMapAsyncStatus_Success, ptr, GetSize());
} else {
CallMapReadCallback(serial, WGPUBufferMapAsyncStatus_Success, ptr, GetSize());
}
}
void Buffer::CopyFromStaging(StagingBufferBase* staging,
uint64_t sourceOffset,
uint64_t destinationOffset,
@@ -341,6 +333,10 @@ namespace dawn_native { namespace null {
ToBackend(GetDevice())->AddPendingOperation(std::move(operation));
}
void* Buffer::GetMappedPointerImpl() {
return mBackingData.get();
}
void Buffer::UnmapImpl() {
}

View File

@@ -182,7 +182,6 @@ namespace dawn_native { namespace null {
public:
Buffer(Device* device, const BufferDescriptor* descriptor);
void MapOperationCompleted(uint32_t serial, void* ptr, bool isWrite);
void CopyFromStaging(StagingBufferBase* staging,
uint64_t sourceOffset,
uint64_t destinationOffset,
@@ -201,6 +200,7 @@ namespace dawn_native { namespace null {
bool IsMapWritable() const override;
MaybeError MapAtCreationImpl(uint8_t** mappedPointer) override;
void MapAsyncImplCommon(uint32_t serial, bool isWrite);
void* GetMappedPointerImpl() override;
std::unique_ptr<uint8_t[]> mBackingData;
};