зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1859825: Ensure that WebGPU Buffers are only dropped once. r=webgpu-reviewers,nical
In addition to moving the valid check earlier in Buffer::Drop, this patch also ensures that Device clears the tracked buffers set after they have been unmapped, and cleans up the error handling in Device::GetLost. Differential Revision: https://phabricator.services.mozilla.com/D191565
This commit is contained in:
Родитель
76cb7950f2
Коммит
987879b702
|
@ -133,6 +133,12 @@ already_AddRefed<Buffer> Buffer::Create(Device* aDevice, RawId aDeviceId,
|
|||
}
|
||||
|
||||
void Buffer::Drop() {
|
||||
if (!mValid) {
|
||||
return;
|
||||
}
|
||||
|
||||
mValid = false;
|
||||
|
||||
AbortMapRequest();
|
||||
|
||||
if (mMapped && !mMapped->mArrayBuffers.IsEmpty()) {
|
||||
|
@ -146,13 +152,11 @@ void Buffer::Drop() {
|
|||
}
|
||||
mMapped.reset();
|
||||
|
||||
if (mValid && GetDevice().IsBridgeAlive()) {
|
||||
GetDevice().GetBridge()->SendBufferDrop(mId);
|
||||
}
|
||||
|
||||
GetDevice().UntrackBuffer(this);
|
||||
|
||||
mValid = false;
|
||||
if (GetDevice().IsBridgeAlive()) {
|
||||
GetDevice().GetBridge()->SendBufferDrop(mId);
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::SetMapped(BufferAddress aOffset, BufferAddress aSize,
|
||||
|
|
|
@ -105,6 +105,7 @@ void Device::GetLabel(nsAString& aValue) const { aValue = mLabel; }
|
|||
void Device::SetLabel(const nsAString& aLabel) { mLabel = aLabel; }
|
||||
|
||||
dom::Promise* Device::GetLost(ErrorResult& aRv) {
|
||||
aRv = NS_OK;
|
||||
if (!mLostPromise) {
|
||||
mLostPromise = dom::Promise::Create(GetParentObject(), aRv);
|
||||
if (mLostPromise && !mBridge->CanSend()) {
|
||||
|
@ -118,7 +119,7 @@ dom::Promise* Device::GetLost(ErrorResult& aRv) {
|
|||
|
||||
void Device::ResolveLost(Maybe<dom::GPUDeviceLostReason> aReason,
|
||||
const nsAString& aMessage) {
|
||||
ErrorResult rv;
|
||||
IgnoredErrorResult rv;
|
||||
dom::Promise* lostPromise = GetLost(rv);
|
||||
if (!lostPromise) {
|
||||
// Promise doesn't exist? Maybe out of memory.
|
||||
|
@ -374,6 +375,8 @@ void Device::Destroy() {
|
|||
for (const auto& buffer : mTrackedBuffers) {
|
||||
buffer->Unmap(jsapi.cx(), rv);
|
||||
}
|
||||
|
||||
mTrackedBuffers.Clear();
|
||||
}
|
||||
|
||||
mBridge->SendDeviceDestroy(mId);
|
||||
|
|
Загрузка…
Ссылка в новой задаче