Граф коммитов

91 Коммитов

Автор SHA1 Сообщение Дата
Brad Werth 987879b702 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
2023-10-23 15:48:55 +00:00
Brad Werth 872b8a500d Bug 1838693 Part 3: Make GPUDevice::Destroy() trigger wgpu device_destroy, then device_drop. r=webgpu-reviewers,nical
This treats destroy as a 2-step process: wait on the destroy, then drop.

Differential Revision: https://phabricator.services.mozilla.com/D190238
2023-10-16 15:32:00 +00:00
Brad Werth 20f995376c Bug 1838693 Part 2: Rationalize GPUDevice lost promise handling. r=webgpu-reviewers,nical
This ensures that both internal and external triggers of "lose the
device" resolve the lost promise using the same code path.

Differential Revision: https://phabricator.services.mozilla.com/D190129
2023-10-16 15:32:00 +00:00
Nicolas Silva 89dc0e7e55 Bug 1780084 - Sanity-check for mValid before mapping the buffer. r=webgpu-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D189105
2023-09-26 15:19:21 +00:00
Erich Gubler c963e2560a Bug 1828123: refactor(webgpu)!: make `GPUDeviceDescriptor` inherit from `GPUObjectDescriptorBase` r=webgpu-reviewers,webidl,peterv,teoxoy
Depends on D185097

Differential Revision: https://phabricator.services.mozilla.com/D185098
2023-08-11 17:07:06 +00:00
Nicolas Silva c8a91b557d Bug 1843296 - Better handle shm allocation failure when creating buffers. r=gfx-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D184220
2023-08-08 10:32:09 +00:00
Narcis Beleuzu 72983cc276 Backed out changeset 969534e11452 (bug 1843296) for webgpu crash 2023-08-08 01:14:00 +03:00
Nicolas Silva d7317a4d43 Bug 1843296 - Better handle shm allocation failure when creating buffers. r=gfx-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D184220
2023-08-07 16:43:56 +00:00
Erich Gubler 1f2b372ff7 Bug 1842020: fix(webgpu): s/AbortError/RangeError on OOM in `GPUDevice.createBuffer` r=webgpu-reviewers,nical
Depends on D181691

Differential Revision: https://phabricator.services.mozilla.com/D182909
2023-07-07 16:43:32 +00:00
André Bargull 675e99e376 Bug 1841314 - Part 2: Prefer JS::NewExternalArrayBuffer with UniquePtr. r=sfink
Replace the existing callers of `JS::NewExternalArrayBuffer` with the new `UniquePtr`
alternative.

The old `JS::NewExternalArrayBuffer` function is still used in tests when the
free-function is `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D182587
2023-07-06 20:50:59 +00:00
Sandor Molnar a6c121377b Backed out 7 changesets (bug 1841314) for causing hazard failures. CLOSED TREE
Backed out changeset 82a53d6ea95a (bug 1841314)
Backed out changeset 524607b471a2 (bug 1841314)
Backed out changeset ce128e10bddb (bug 1841314)
Backed out changeset cdae4fbbdaff (bug 1841314)
Backed out changeset f1035b6c08fe (bug 1841314)
Backed out changeset 5897ad8ef181 (bug 1841314)
Backed out changeset 09618a767080 (bug 1841314)
2023-07-06 16:59:47 +03:00
André Bargull 100430c91f Bug 1841314 - Part 2: Prefer JS::NewExternalArrayBuffer with UniquePtr. r=sfink
Replace the existing callers of `JS::NewExternalArrayBuffer` with the new `UniquePtr`
alternative.

The old `JS::NewExternalArrayBuffer` function is still used in tests when the
free-function is `nullptr`.

Differential Revision: https://phabricator.services.mozilla.com/D182587
2023-07-06 12:26:53 +00:00
Cristina Horotan f77c6f3e48 Backed out 7 changesets (bug 1841314) for causing hazard failures at js.cpp CLOSED TREE
Backed out changeset becc2fa2c186 (bug 1841314)
Backed out changeset e5b723317177 (bug 1841314)
Backed out changeset 61ae850b25e5 (bug 1841314)
Backed out changeset 9ff320c779b8 (bug 1841314)
Backed out changeset debf1172f794 (bug 1841314)
Backed out changeset 8ac4fa317006 (bug 1841314)
Backed out changeset eccacbb3b620 (bug 1841314)
2023-07-06 15:11:47 +03:00
André Bargull 33e67df734 Bug 1841314 - Part 2: Prefer JS::NewExternalArrayBuffer with UniquePtr. r=sfink
Replace the existing callers of `JS::NewExternalArrayBuffer` with the new `UniquePtr`
alternative.

The old `JS::NewExternalArrayBuffer` function is still used in tests when the
free-function is `nullptr`.

Depends on D182586

Differential Revision: https://phabricator.services.mozilla.com/D182587
2023-07-06 11:41:17 +00:00
Erich Gubler 62082f2284 Bug 1831120: feat(webgpu): add `GPUBuffer` attributes r=webgpu-reviewers,webidl,saschanaz,jimb
Differential Revision: https://phabricator.services.mozilla.com/D177055
2023-05-09 17:29:56 +00:00
Andrew McCreight ce28c41da0 Bug 1805931, part 2 - Automated removal of uses of ROOT and UNROOT CC macros. r=smaug
As of the prior patch, these are no longer needed. I removed
these with a script, then ran clang-format on the files, then
manually reverted a few unrelated changed from the formatter.

Differential Revision: https://phabricator.services.mozilla.com/D164829
2022-12-15 19:45:01 +00:00
Nicolas Silva 84411fce11 Bug 1795311 - Use the new shmem classes in the WebGPU buffer impl. r=jgilbert
Depends on D159398

Differential Revision: https://phabricator.services.mozilla.com/D159399
2022-11-10 15:52:32 +00:00
Cristian Tuns 239d775bde Backed out 2 changesets (bug 1795311) for causing build bustages on WebGPUParent.cpp CLOSED TREE
Backed out changeset 71697f876d88 (bug 1795311)
Backed out changeset 60b9bfda2e8b (bug 1795311)
2022-11-09 11:17:43 -05:00
Nicolas Silva ce2cb5783c Bug 1795311 - Use the new shmem classes in the WebGPU buffer impl. r=jgilbert
Depends on D159398

Differential Revision: https://phabricator.services.mozilla.com/D159399
2022-11-09 14:30:16 +00:00
Nicolas Silva 6a27b6fc7f Bug 1777535 - Mapped at creation implies write access. r=jimb
Differential Revision: https://phabricator.services.mozilla.com/D152520
2022-08-10 15:55:11 +00:00
Nicolas Silva 76a812fef7 Bug 1777535 - Differentiate between destroying and dropping a buffer. r=jimb
The former frees resources but keeps the handle. It can be called multiple times. The latter destroys the handle. Any subsequent reference to the same buffer is a bug and will cause the GPU process to crash.

Depends on D152080

Differential Revision: https://phabricator.services.mozilla.com/D152081
2022-08-10 15:55:09 +00:00
Nicolas Silva dc27dd1a81 Bug 1771254 - Work around zero-sized shmems. r=jimb
Depends on D151703

Differential Revision: https://phabricator.services.mozilla.com/D152080
2022-08-10 15:55:09 +00:00
Nicolas Silva 4052fb5b08 Bug 1777535 - Don't crash when buffer_unmap returns an error. r=jimb
Depends on D151702

Differential Revision: https://phabricator.services.mozilla.com/D151703
2022-08-10 15:55:09 +00:00
Nicolas Silva aa764f309f Bug 1777535 - Validate mapAync mode on the parent side. r=jimb
Depends on D151632

Differential Revision: https://phabricator.services.mozilla.com/D151701
2022-08-10 15:55:08 +00:00
Nicolas Silva 971548a974 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
2022-08-10 15:55:08 +00:00
Nicolas Silva ea11e14b00 Bug 1780792 - use Buffer::GetDevice instead of mParent. r=jimb
Another cosmetic change. I've dabbled with IPDL actors too much to not think about WebGPUParent when reading "mParent". Also the parent-child relationship between Device and Buffer is not very obvious to me (nor is it part of the specification).
So I find that wrapping mParent in a GetDevice method to make the code easier to understand. It also makes it explicit that the parent pointer cannot be null.

Depends on D151630

Differential Revision: https://phabricator.services.mozilla.com/D151631
2022-08-10 15:55:07 +00:00
Nicolas Silva 15f2edabb7 Bug 1780792 - Remove Buffer::Mappable(). r=jimb
It is not used anywhere.

Depends on D151629

Differential Revision: https://phabricator.services.mozilla.com/D151630
2022-08-10 15:55:07 +00:00
Nicolas Silva 89ae7cbb9e Bug 1777535 - Simplify Buffer::Cleanup. r=jimb
Make sure to always clean up any potential content-side state and only avoid sending Destroy each time.

Depends on D151621

Differential Revision: https://phabricator.services.mozilla.com/D151629
2022-08-10 15:55:07 +00:00
Nicolas Silva 92f2f9d376 Bug 1777535 - Unmap the buffer in Destroy. r=jimb,emilio
Per spec, if a buffer is mapped in destory(), unmap() must be called.

Depends on D151620

Differential Revision: https://phabricator.services.mozilla.com/D151621
2022-08-10 15:55:06 +00:00
Nicolas Silva 2247de33ba Bug 1777535 - Validate getMappedRange against the actually mapped range. r=jimb
Depends on D151619

Differential Revision: https://phabricator.services.mozilla.com/D151620
2022-08-10 15:55:06 +00:00
Nicolas Silva cafc323604 Bug 1777535 - Track the buffer mapAsync promise. r=jimb
Per spec (and discussion with someone on the chromium side where spec is vague), the correct behavior should be:
 - MapAsync validation happens on the device timeline, so we should reject the promise in mapAsync on the content side if we run into an internal error not described by the spec.
 - Unmap immediately rejects all pending mapping promises on the content side (there can be multiple of them since we have to catch that error on the device timeline).

This patch tracks a single mapping promise at a time and immediately rejects on the content side any subseqent mapping
request made until unmap is called. This means our current implementation deviates slightly from the current state of
the spec in that:
 - The promise is rejected earlier on the content timeline,
 - If the first request fails, all subsequent requests will fail until either unmap or when the content side receives and processes the rejected
   promise, whereas Dawn's implementation would allow the first valid request to succed.

There was some confusion around the the use of uint64_t and size_t which probably originated at point where this code was working differently. This patch uses uint64_t (=BufferAddress) more consistently removing the need for some of the casting and overflow checks.
One notable change in the overall logic is that SetMapped is now called when the buffer is actually in the mapped state (before this patch it was called as soon as the buffer had a pending map request).

Depends on D151618

Differential Revision: https://phabricator.services.mozilla.com/D151619
2022-08-10 15:55:05 +00:00
Nicolas Silva 8829006db0 Bug 1780792 - Move the buffer creation code in Buffer.cpp. r=jimb
No funcitonal change here, I like to have the code maintaining and depending on the same invariants to be in the same place.

Depends on D151616

Differential Revision: https://phabricator.services.mozilla.com/D151617
2022-08-10 15:55:05 +00:00
Nicolas Silva 6c728ff882 Bug 1777535 - Use unsafe shmems. r=jimb
This commit makes WebGPU buffers use unsafe shmems.
Instead of relying on moving the shmem back and forth between the two processes to ensure thread safety, we instead rely on the validation done on both sides. The upside is that it makes it much easier to implement said validation correctly.

In the interest of splitting the buffer mapping rework into small-ish commits, this one puts some structural pieces in place but doesn't necessarily do justice to the final implementation:
 - The validation itself is coming in subsequent patches in this series.
 - Mapping sub-ranges of the buffer was somewhat implemented in some parts of the parent code and not in others, and was fairly broken as a whole. This commit always maps the entire buffer and proper logic for sub-ranges is coming in another commit.

The main things this commit does put in place:
 - Each mappable buffer is associated with a Shmem that is accessible to both sides.
 - On the child side, if a buffer is not mappable, then Buffer::mShmem is in its default state (it doesn't point to any shared memory segment).
 - On the parent side, if a buffer is not mappable it does not have an entry in mSharedMemoryMap.
 - The shmem is always created by the child and destroyed by the parent.

Depends on D151615

Differential Revision: https://phabricator.services.mozilla.com/D151616
2022-08-10 15:55:03 +00:00
Nicolas Silva 29159ae421 Bug 1771254 - Add MaybeShmem. r=jimb,aosmond
Most operations maniplating shmems in WebGPU are fallible, we'll have to handle passing them conditionally in most messages.

This commit starts with BufferMap, to avoid crashing when map is called on an invalid buffer.

Differential Revision: https://phabricator.services.mozilla.com/D149892
2022-08-10 15:55:02 +00:00
Marian-Vasile Laza 1c166e5dae Backed out 22 changesets (bug 1780792, bug 1778713, bug 1771254, bug 1777535) for causing bustages on WebGPUParent.h. CLOSED TREE
Backed out changeset 84974dbb4d3f (bug 1780792)
Backed out changeset 5bef755ea09b (bug 1777535)
Backed out changeset 6de84921e7d0 (bug 1780792)
Backed out changeset 89450745f60b (bug 1777535)
Backed out changeset de8da0f89c50 (bug 1777535)
Backed out changeset 24707519fe7b (bug 1771254)
Backed out changeset fe75bdc54a31 (bug 1777535)
Backed out changeset aa8e1c7f727f (bug 1777535)
Backed out changeset f674057a477f (bug 1777535)
Backed out changeset b4210142bf82 (bug 1780792)
Backed out changeset 326511661875 (bug 1780792)
Backed out changeset 6178c6dd5c31 (bug 1780792)
Backed out changeset 219760e8c20e (bug 1777535)
Backed out changeset e312cdad1fee (bug 1777535)
Backed out changeset 446e62674d9d (bug 1777535)
Backed out changeset d2f4d878d51f (bug 1777535)
Backed out changeset 85ac57add037 (bug 1777535)
Backed out changeset 4c512a0c05a9 (bug 1780792)
Backed out changeset 6f732421a0b4 (bug 1777535)
Backed out changeset 0da5289fe5a9 (bug 1777535)
Backed out changeset c19a35a62ed4 (bug 1778713)
Backed out changeset 61e4e8e63a3e (bug 1771254)
2022-08-10 15:04:12 +03:00
Nicolas Silva 86b9718b34 Bug 1777535 - Mapped at creation implies write access. r=jimb
Differential Revision: https://phabricator.services.mozilla.com/D152520
2022-08-10 11:38:59 +00:00
Nicolas Silva 0f1f96bcd1 Bug 1777535 - Differentiate between destroying and dropping a buffer. r=jimb
The former frees resources but keeps the handle. It can be called multiple times. The latter destroys the handle. Any subsequent reference to the same buffer is a bug and will cause the GPU process to crash.

Depends on D152080

Differential Revision: https://phabricator.services.mozilla.com/D152081
2022-08-10 11:38:58 +00:00
Nicolas Silva c48f4c8b0c Bug 1771254 - Work around zero-sized shmems. r=jimb
Depends on D151703

Differential Revision: https://phabricator.services.mozilla.com/D152080
2022-08-10 11:38:57 +00:00
Nicolas Silva 10ba2bff18 Bug 1777535 - Don't crash when buffer_unmap returns an error. r=jimb
Depends on D151702

Differential Revision: https://phabricator.services.mozilla.com/D151703
2022-08-10 11:38:57 +00:00
Nicolas Silva 93f4ab10fc Bug 1777535 - Validate mapAync mode on the parent side. r=jimb
Depends on D151632

Differential Revision: https://phabricator.services.mozilla.com/D151701
2022-08-10 11:38:56 +00:00
Nicolas Silva 627f38e04e 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
2022-08-10 11:38:56 +00:00
Nicolas Silva 1a98d9e824 Bug 1780792 - use Buffer::GetDevice instead of mParent. r=jimb
Another cosmetic change. I've dabbled with IPDL actors too much to not think about WebGPUParent when reading "mParent". Also the parent-child relationship between Device and Buffer is not very obvious to me (nor is it part of the specification).
So I find that wrapping mParent in a GetDevice method to make the code easier to understand. It also makes it explicit that the parent pointer cannot be null.

Depends on D151630

Differential Revision: https://phabricator.services.mozilla.com/D151631
2022-08-10 11:38:55 +00:00
Nicolas Silva 1e4e43530c Bug 1780792 - Remove Buffer::Mappable(). r=jimb
It is not used anywhere.

Depends on D151629

Differential Revision: https://phabricator.services.mozilla.com/D151630
2022-08-10 11:38:55 +00:00
Nicolas Silva 466aec98aa Bug 1777535 - Simplify Buffer::Cleanup. r=jimb
Make sure to always clean up any potential content-side state and only avoid sending Destroy each time.

Depends on D151621

Differential Revision: https://phabricator.services.mozilla.com/D151629
2022-08-10 11:38:55 +00:00
Nicolas Silva c87019923a Bug 1777535 - Unmap the buffer in Destroy. r=jimb,emilio
Per spec, if a buffer is mapped in destory(), unmap() must be called.

Depends on D151620

Differential Revision: https://phabricator.services.mozilla.com/D151621
2022-08-10 11:38:54 +00:00
Nicolas Silva 2efa36bbda Bug 1777535 - Validate getMappedRange against the actually mapped range. r=jimb
Depends on D151619

Differential Revision: https://phabricator.services.mozilla.com/D151620
2022-08-10 11:38:54 +00:00
Nicolas Silva 90aab927a5 Bug 1777535 - Track the buffer mapAsync promise. r=jimb
Per spec (and discussion with someone on the chromium side where spec is vague), the correct behavior should be:
 - MapAsync validation happens on the device timeline, so we should reject the promise in mapAsync on the content side if we run into an internal error not described by the spec.
 - Unmap immediately rejects all pending mapping promises on the content side (there can be multiple of them since we have to catch that error on the device timeline).

This patch tracks a single mapping promise at a time and immediately rejects on the content side any subseqent mapping
request made until unmap is called. This means our current implementation deviates slightly from the current state of
the spec in that:
 - The promise is rejected earlier on the content timeline,
 - If the first request fails, all subsequent requests will fail until either unmap or when the content side receives and processes the rejected
   promise, whereas Dawn's implementation would allow the first valid request to succed.

There was some confusion around the the use of uint64_t and size_t which probably originated at point where this code was working differently. This patch uses uint64_t (=BufferAddress) more consistently removing the need for some of the casting and overflow checks.
One notable change in the overall logic is that SetMapped is now called when the buffer is actually in the mapped state (before this patch it was called as soon as the buffer had a pending map request).

Depends on D151618

Differential Revision: https://phabricator.services.mozilla.com/D151619
2022-08-10 11:38:54 +00:00
Nicolas Silva 148b56eef8 Bug 1780792 - Move the buffer creation code in Buffer.cpp. r=jimb
No funcitonal change here, I like to have the code maintaining and depending on the same invariants to be in the same place.

Depends on D151616

Differential Revision: https://phabricator.services.mozilla.com/D151617
2022-08-10 11:38:53 +00:00
Nicolas Silva 1dae6e0bba Bug 1777535 - Use unsafe shmems. r=jimb
This commit makes WebGPU buffers use unsafe shmems.
Instead of relying on moving the shmem back and forth between the two processes to ensure thread safety, we instead rely on the validation done on both sides. The upside is that it makes it much easier to implement said validation correctly.

In the interest of splitting the buffer mapping rework into small-ish commits, this one puts some structural pieces in place but doesn't necessarily do justice to the final implementation:
 - The validation itself is coming in subsequent patches in this series.
 - Mapping sub-ranges of the buffer was somewhat implemented in some parts of the parent code and not in others, and was fairly broken as a whole. This commit always maps the entire buffer and proper logic for sub-ranges is coming in another commit.

The main things this commit does put in place:
 - Each mappable buffer is associated with a Shmem that is accessible to both sides.
 - On the child side, if a buffer is not mappable, then Buffer::mShmem is in its default state (it doesn't point to any shared memory segment).
 - On the parent side, if a buffer is not mappable it does not have an entry in mSharedMemoryMap.
 - The shmem is always created by the child and destroyed by the parent.

Depends on D151615

Differential Revision: https://phabricator.services.mozilla.com/D151616
2022-08-10 11:38:53 +00:00
Nicolas Silva 860c138181 Bug 1771254 - Add MaybeShmem. r=jimb,aosmond
Most operations maniplating shmems in WebGPU are fallible, we'll have to handle passing them conditionally in most messages.

This commit starts with BufferMap, to avoid crashing when map is called on an invalid buffer.

Differential Revision: https://phabricator.services.mozilla.com/D149892
2022-08-10 11:38:51 +00:00