Bug 1780792 - Move the remaining buffer logic in Device.cpp into Buffer.cpp. r=jimb
Having the code in the same place makes it easier to follow. This made me realize that the validation of aMode in mapAsync has to move to the device side (fix coming in a followup). Depends on D151631 Differential Revision: https://phabricator.services.mozilla.com/D151632
This commit is contained in:
@@ -166,8 +166,21 @@ already_AddRefed<dom::Promise> Buffer::MapAsync(
|
||||
|
||||
RefPtr<Buffer> self(this);
|
||||
|
||||
ffi::WGPUHostMap mode;
|
||||
switch (aMode) {
|
||||
case dom::GPUMapMode_Binding::READ:
|
||||
mode = ffi::WGPUHostMap_Read;
|
||||
break;
|
||||
case dom::GPUMapMode_Binding::WRITE:
|
||||
mode = ffi::WGPUHostMap_Write;
|
||||
break;
|
||||
default:
|
||||
// TODO: This has to be validated on the device timeline.
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
auto mappingPromise =
|
||||
GetDevice().MapBufferAsync(mId, aMode, aOffset, size, aRv);
|
||||
GetDevice().GetBridge()->SendBufferMap(mId, mode, aOffset, size);
|
||||
MOZ_ASSERT(mappingPromise);
|
||||
|
||||
mMapRequest = promise;
|
||||
@@ -291,7 +304,10 @@ void Buffer::Unmap(JSContext* aCx, ErrorResult& aRv) {
|
||||
mShmem = ipc::Shmem();
|
||||
}
|
||||
|
||||
GetDevice().UnmapBuffer(mId, mMapped->mWritable);
|
||||
if (!GetDevice().IsLost()) {
|
||||
GetDevice().GetBridge()->SendBufferUnmap(mId, mMapped->mWritable);
|
||||
}
|
||||
|
||||
mMapped.reset();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user