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();
|
||||
}
|
||||
|
||||
|
||||
@@ -126,30 +126,6 @@ already_AddRefed<Buffer> Device::CreateBuffer(
|
||||
return Buffer::Create(this, mId, aDesc, aRv);
|
||||
}
|
||||
|
||||
RefPtr<MappingPromise> Device::MapBufferAsync(RawId aId, uint32_t aMode,
|
||||
uint64_t aOffset, uint64_t aSize,
|
||||
ErrorResult& aRv) {
|
||||
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:
|
||||
MOZ_CRASH("should have checked aMode in Buffer::MapAsync");
|
||||
}
|
||||
|
||||
return mBridge->SendBufferMap(aId, mode, aOffset, aSize);
|
||||
}
|
||||
|
||||
void Device::UnmapBuffer(RawId aId, bool aFlush) {
|
||||
if (mBridge->CanSend()) {
|
||||
mBridge->SendBufferUnmap(aId, aFlush);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<Texture> Device::CreateTexture(
|
||||
const dom::GPUTextureDescriptor& aDesc) {
|
||||
RawId id = 0;
|
||||
|
||||
@@ -100,10 +100,6 @@ class Device final : public DOMEventTargetHelper, public SupportsWeakPtr {
|
||||
static JSObject* CreateExternalArrayBuffer(JSContext* aCx, size_t aOffset,
|
||||
size_t aSize,
|
||||
const ipc::Shmem& aShmem);
|
||||
RefPtr<MappingPromise> MapBufferAsync(RawId aId, uint32_t aMode,
|
||||
uint64_t aOffset, uint64_t aSize,
|
||||
ErrorResult& aRv);
|
||||
void UnmapBuffer(RawId aId, bool aFlush);
|
||||
already_AddRefed<Texture> InitSwapChain(
|
||||
const dom::GPUCanvasConfiguration& aDesc,
|
||||
const layers::CompositableHandle& aHandle, gfx::SurfaceFormat aFormat,
|
||||
|
||||
Reference in New Issue
Block a user