Commit graph

160 commits

Author SHA1 Message Date
Erich Gubler
260a0b100c Bug 1838694: fix(webgpu): impl. correct GPUError types r=jgilbert,webgpu-reviewers,webidl,peterv
Differential Revision: https://phabricator.services.mozilla.com/D181690
2023-07-06 20:50:52 +00:00
Iulian Moraru
8a0b708983 Backed out 3 changesets (bug 1838694) for causing webgpu failures. CLOSED TREE
Backed out changeset 8f7835cd7d0c (bug 1838694)
Backed out changeset 7fdcca116760 (bug 1838694)
Backed out changeset 83d3204888fd (bug 1838694)
2023-07-05 19:48:43 +03:00
Erich Gubler
cbbc72af6c Bug 1838694: fix(webgpu): only set PopErrorScopeResult::resultType in Device::PopErrorScope if an error was actually found r=webgpu-reviewers,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D181808
2023-07-05 14:16:41 +00:00
Erich Gubler
c005dbec80 Bug 1838694: fix(webgpu): impl. correct GPUError types r=jgilbert,webgpu-reviewers,webidl,peterv
Differential Revision: https://phabricator.services.mozilla.com/D181690
2023-07-05 14:16:40 +00:00
Stanca Serban
8b84555cc4 Backed out 3 changesets (bug 1838694) for causing mochitests failures in test_interfaces_secureContext.html. CLOSED TREE
Backed out changeset 892fed91da4e (bug 1838694)
Backed out changeset f6477420370e (bug 1838694)
Backed out changeset 109ebd10d0c3 (bug 1838694)
2023-06-29 00:46:26 +03:00
Erich Gubler
0c1fc363df Bug 1838694: fix(webgpu): only set PopErrorScopeResult::resultType in Device::PopErrorScope if an error was actually found r=webgpu-reviewers,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D181808
2023-06-28 19:29:17 +00:00
Erich Gubler
1953484601 Bug 1838694: fix(webgpu): impl. correct GPUError types r=jgilbert,webgpu-reviewers,webidl,peterv
Differential Revision: https://phabricator.services.mozilla.com/D181690
2023-06-28 19:29:17 +00:00
Kelsey Gilbert
8ce110a8e9 Bug 1837557 - Productionize webgpu pushErrorScope/popErrorScope. r=webgpu-reviewers,jimb
Differential Revision: https://phabricator.services.mozilla.com/D180456
2023-06-14 05:51:00 +00:00
Erich Gubler
d95cf633aa Bug 1829305: fix(webgpu): trade incorrect ImageCopyBuffer usage for exploded ID and FFI-friendly ImageDataLayout in wgpu_server_encoder_copy_texture_to_buffer r=webgpu-reviewers,jimb
Differential Revision: https://phabricator.services.mozilla.com/D176207
2023-04-25 20:59:51 +00:00
Nicolas Silva
1fe9277420 Bug 1827421 - wgpu api changes. r=webgpu-reviewers,webidl,teoxoy,smaug
Differential Revision: https://phabricator.services.mozilla.com/D175262
2023-04-19 21:53:19 +00:00
Randell Jesup
ae8888362e Bug 1207753 - dom/WebGPU thread-safety annotations r=webgpu-reviewers,jimb
Differential Revision: https://phabricator.services.mozilla.com/D130946
2023-04-10 20:26:23 +00:00
Jim Blandy
f4ff558293 Bug 1825449: Don't warn on mismatched WebGPU error scope push/pop. r=webgpu-reviewers,teoxoy
In the graphics process, don't warn on receipt of mismatched DevicePushErrorScope/DevicePopErrorScope messages, since these can be easily caused by ordinary content and do not indicate anything wrong with Firefox.

Differential Revision: https://phabricator.services.mozilla.com/D174045
2023-03-30 16:23:26 +00:00
Jim Blandy
eded4d5146 Bug 1824265: Clarify WebGPU mapAsync error messages. r=webgpu-reviewers,teoxoy
Calling `GPUBuffer.mapAsync` returns a `Promise` that is rejected if something goes wrong mapping the buffer, but Firefox's error message doesn't really say anything to indicate that mapping was involved: "Invalid buffer" is a bit mysterious.

Ideally we would attach call stacks to these promises - and I think there is a way to do that - but for now this patch just changes the error messages to mention mapping.

While we're in the neighborhood, improve some `NS_WARNING` messages.

Differential Revision: https://phabricator.services.mozilla.com/D173493
2023-03-24 20:08:09 +00:00
Jim Blandy
1e9e5f2198 Bug 1808602: Implement 'dom.webgpu.wgpu-backend' pref. r=jrmuizel
Add a new string-valued, Rust-visible pref, `dom.webgpu.wgpu-backend`, to `StaticPrefList.yaml` in `modules/libpref/init`. If this string is non-empty, use it to enable the indicated WebGPU backends when we create a `wgpu_core::Global` in `gfx/wgpu_bindings/src/server.rs`. See `StaticPrefList.yaml` for details.

As this is the first time we have exposed a `mirror: always`, `type: DataMutexString` pref to Rust, make the appropriate changes to `generate_static_pref_list.py` to generate the necessary C++ and Rust code to lock the value, make a string copy, and pass ownership back to Rust as an `nsstring::nsACString` (from the `xpcom/rust/nsstring` crate).

Differential Revision: https://phabricator.services.mozilla.com/D173335
2023-03-23 21:27:05 +00:00
Norisz Fay
3220100958 Backed out changeset 07b81afaa59e (bug 1808602) for causing python failure on test_generate_static_pref_list.py CLOSED TREE 2023-03-23 22:52:09 +02:00
Jim Blandy
46ff1ae846 Bug 1808602: Implement 'dom.webgpu.wgpu-backend' pref. r=jrmuizel
Add a new string-valued, Rust-visible pref, `dom.webgpu.wgpu-backend`, to `StaticPrefList.yaml` in `modules/libpref/init`. If this string is non-empty, use it to enable the indicated WebGPU backends when we create a `wgpu_core::Global` in `gfx/wgpu_bindings/src/server.rs`. See `StaticPrefList.yaml` for details.

As this is the first time we have exposed a `mirror: always`, `type: DataMutexString` pref to Rust, make the appropriate changes to `generate_static_pref_list.py` to generate the necessary C++ and Rust code to lock the value, make a string copy, and pass ownership back to Rust as an `nsstring::nsACString` (from the `xpcom/rust/nsstring` crate).

Differential Revision: https://phabricator.services.mozilla.com/D173335
2023-03-23 20:14:59 +00:00
sotaro
5789f6df62 Bug 1814533 - Add IsRegistered() check in PresentCallback() r=gfx-reviewers,lsalzman
There is a case that SwapChain is destroyed between wgpu_server_buffer_map() and PresentCallback().

Differential Revision: https://phabricator.services.mozilla.com/D168912
2023-02-06 05:32:55 +00:00
sotaro
954c16acec Bug 1805209 - Use RemoteTexture for WebGPU r=gfx-reviewers,lsalzman
WebGPU uses CompositableInProcessManager to push TextureHost directly from WebGPUParent to WebRender. But CompositableInProcessManager plumbing has a problem and caused Bug 1805209.

gecko already has a similar mechanism, called RemoteTextureMap. It is used in oop WebGL. If WebGPU uses RemoteTextureMap instead of CompositableInProcessManager, both WebGPU and oop WebGL use same mechanism.

WebGPUParent pushes a new texture to RemoteTextureMap. The RemoteTextureMap notifies the pushed texture to WebRenderImageHost.

Before the change, only one TextureHost is used for one swap chain. With the change, multiple TextureHosts are used for one swap chain with recycling.

The changes are followings.

- Use RemoteTextureMap instead of CompositableInProcessManager.
- Use RemoteTextureOwnerId instead of CompositableHandle.
- Use WebRenderCanvasData instead of WebRenderInProcessImageData.
- Add remote texture pushed callback functionality to RemoteTextureMap. With it, RemoteTextureMap notifies a new pushed remote texture to WebRenderImageHost.
- Remove CompositableInProcessManager.

Differential Revision: https://phabricator.services.mozilla.com/D164890
2022-12-23 20:41:02 +00:00
Nicolas Silva
4c5b1d34d3 Bug 1800430 - Port PWebGPU::QueueWriteAction to the new shmem classes. r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D162002
2022-12-20 10:34:28 +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
62d1d7906a Bug 1794406 - Report more specific error messages when buffer.mapAsync fails. r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D158959
2022-10-12 17:09:01 +00:00
Nicolas Silva
39c0ae30ae Bug 1780792 - Remove unnecessary MapRequest constructor. r=jimb
Differential Revision: https://phabricator.services.mozilla.com/D152521
2022-08-10 15:55:11 +00:00
Nicolas Silva
b59239fdc3 Bug 1777535 - Ensure WebGPUParent outlives the map callback. r=jimb
Depends on D152081

Differential Revision: https://phabricator.services.mozilla.com/D152082
2022-08-10 15:55:10 +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
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
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
b7a49dfc3f Bug 1777535 - Map only the required buffer range on the Parent side. r=jimb
Depends on D151617

Differential Revision: https://phabricator.services.mozilla.com/D151618
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
74e928ab94 Bug 1777535 - Return pointer and length in wgpu_server_buffer_get_mapped_range. r=jimb
Also return an empty slice instead of crashing in case of errors.
This is a small piece split off of the buffer mapping rework. Most of the call sites are completely rewritten in followup patches, and error reporting will also come in followups.

Depends on D151374

Differential Revision: https://phabricator.services.mozilla.com/D151615
2022-08-10 15:55:03 +00:00
Nicolas Silva
fc3cb0c578 Bug 1778713 - Give the raw IDs in WebGPUParent useful names. r=jimb
Depends on D149892

Differential Revision: https://phabricator.services.mozilla.com/D151374
2022-08-10 15:55:02 +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
27252fe925 Bug 1780792 - Remove unnecessary MapRequest constructor. r=jimb
Differential Revision: https://phabricator.services.mozilla.com/D152521
2022-08-10 11:38:59 +00:00
Nicolas Silva
7d890096eb Bug 1777535 - Ensure WebGPUParent outlives the map callback. r=jimb
Depends on D152081

Differential Revision: https://phabricator.services.mozilla.com/D152082
2022-08-10 11:38:58 +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
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
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
f6a7711e72 Bug 1777535 - Map only the required buffer range on the Parent side. r=jimb
Depends on D151617

Differential Revision: https://phabricator.services.mozilla.com/D151618
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
9e85a03e2e Bug 1777535 - Return pointer and length in wgpu_server_buffer_get_mapped_range. r=jimb
Also return an empty slice instead of crashing in case of errors.
This is a small piece split off of the buffer mapping rework. Most of the call sites are completely rewritten in followup patches, and error reporting will also come in followups.

Depends on D151374

Differential Revision: https://phabricator.services.mozilla.com/D151615
2022-08-10 11:38:52 +00:00
Nicolas Silva
0da0ba9dcf Bug 1778713 - Give the raw IDs in WebGPUParent useful names. r=jimb
Depends on D149892

Differential Revision: https://phabricator.services.mozilla.com/D151374
2022-08-10 11:38:52 +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
Christian Holler
ded7ccf616 Bug 1782703 - Add missing check to RecvSwapChainDestroy. r=nical
Differential Revision: https://phabricator.services.mozilla.com/D153459
2022-08-05 17:24:05 +00:00
Jim Blandy
cda20112e7 Bug 1780643: Fully initialize ffi::WGPUIdentityRecyclerFactory. r=nical
Differential Revision: https://phabricator.services.mozilla.com/D152450
2022-07-26 06:28:12 +00:00
Nicolas Silva
ba23af9d48 Bug 1750576 - Avoid passing raw strings in a couple of wgpu bindings entry points. r=emilio
Inspired by emilio's suggestion in the shader module API patch. This tries to be the most straightforward way to go from the strings coming from IPC to the ones consumed by wgpu.

Differential Revision: https://phabricator.services.mozilla.com/D151024
2022-07-08 08:11:39 +00:00
Nicolas Silva
1d6db74e44 Bug 1750576 - WebGPU shader module asynchronous CompilationInfo API. r=aosmond,emilio
This patch is a lot of plumbing for not that much functionality. The goal is to align CreateShaderModule's error reporting with the spec.
Creating a shader module is now a dedicated async IPDL message returning the compilation info so that it can be exposed as a promise by the WebGPU API.

Differential Revision: https://phabricator.services.mozilla.com/D146817
2022-07-08 08:11:39 +00:00