Commit Graph

235 Commits

Author SHA1 Message Date
Nicolas Silva
ff6fa22c05 Bug 1860958 - Implement Texture::Destroy. r=webgpu-reviewers,jimb
Differential Revision: https://phabricator.services.mozilla.com/D192080
2023-11-21 18:16:24 +00:00
Nicolas Silva
d71febc53e Bug 1865311 - Fix inconsistent destroy/drop naming in webgpu IPC. r=webgpu-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D193894
2023-11-17 20:11:22 +00:00
Brad Werth
ad675e8c0a Bug 1816731 Part 1: Prevent configuration of a WebGPU context for a too-big canvas. r=webgpu-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D193567
2023-11-17 16:11:40 +00:00
sotaro
a81fc25c0a Bug 1863106 - Set D3D11_BIND_UNORDERED_ACCESS if texture usage has STORAGE_BINDING r=lsalzman
wgpu dx12 requests to Texture that if its usage has STORAGE_BINDING, D3D12 resource needs to have D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS.

The equivalent of D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS in D3D11 is D3D11_BIND_UNORDERED_ACCESS. Therefore, D3D11 textures in ExternalTextureD3D11 also require D3D11_BIND_UNORDERED_ACCESS if STORAGE_BINDING is used.

Differential Revision: https://phabricator.services.mozilla.com/D192976
2023-11-09 00:42:41 +00:00
sotaro
6449563437 Bug 1860801 - Remove caching d3d12::Resource in TextureRaw r=lsalzman
Delete d3d12::Resource caching for now because it crashes when d3d12::Resource is deleted after wgpu_server_delete().

Differential Revision: https://phabricator.services.mozilla.com/D192953
2023-11-08 00:12:34 +00:00
sotaro
8803debcdf Bug 1859969 - Implement WebGPUParent::GetFrontBufferSnapshot() during presenting WebGPU without readback on Window r=gfx-reviewers,lsalzman
RemoteTextureMap::GetLatestBufferSnapshot() is changed to get snapshot from wegpu::ExternalTexture if it exists.

Actual snapshot from wegpu::ExternalTexture is implemented in ExternalTextureD3D11::GetSnapshot().

Differential Revision: https://phabricator.services.mozilla.com/D191937
2023-10-29 17:31:16 +00:00
sotaro
1c7a3ecd2e Bug 1845853 - Use the same DXGI adapter as WebRender with DX12 r=webgpu-reviewers,nical
By selecting an adapter with the same LUID as the compositor device, the same adapter is selected as the compositor device used by WebRender.

Differential Revision: https://phabricator.services.mozilla.com/D190905
2023-10-25 05:14:34 +00:00
sotaro
b8aa658666 Bug 1856787 - Add a capability to present WebGPU without readback on Windows r=webgpu-reviewers,nical
For presenting WebGPU without readback, wgpu does rendering to ExternalTexture. Then the ExternalTexture is pushed to RemoteTextureMap for present.

With DX12, ExternalTextureD3D11 is implemented for gecko side implementation. ExternalTextureWgpu holds necessary resource that is necessary by wgpu. ExternalTextureWgpu is created and destroyed by gecko side's ExternalTexture.

Presenting current texture starts at CanvasContext::SwapChainPresent(). CanvasContext::SwapChainPresent() posts current texture for present. And the current texture is set invalid, since the texture is going to be posted to WebRender. Next CanvasContext::GetCurrentTexture() call creates a new texture of swap chain.

WebGPUParent::RecvSwapChainPresent() receives present request. It pushes to RemoteTextureMap for presenting.

TextureRaw is recycled with ExternalTexture recycling.

Differential Revision: https://phabricator.services.mozilla.com/D190249
2023-10-24 04:04:07 +00:00
Brad Werth
aa33328ada Bug 1838693 Part 4: Ensure that each Device is sent DeviceLost only once. r=webgpu-reviewers,nical
This tracks DeviceIds that have been sent DeviceLost in a hashmap that
is pruned when the Device is dropped. This reduces IPC traffic with the
expected use case of many calls returning after a device loss.

Differential Revision: https://phabricator.services.mozilla.com/D190962
2023-10-16 15:32:01 +00:00
Brad Werth
c61c8a63d2 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
50e117837a Bug 1838693 Part 1: Stub in 'lose the device' and trigger it on device lost errors. r=webgpu-reviewers,nical
This creates a WebGPUParent::LoseDevice entry point, which informs the
WebGPUChild that the device has been lost. The child side is largely a
stub, as a later part will rationalize the handling of the device.lost
promise in the child.

This also expands ErrorBufferType with a DeviceLost value. The
LoseDevice function is triggered for any error where webgpu_bindings
HasErrorBufferType error_type returns ErrorBufferType::DeviceLost.

Differential Revision: https://phabricator.services.mozilla.com/D188388
2023-10-16 15:31:59 +00:00
sotaro
162407e36c Bug 1854541 - Add webgpu::ExternalTexture handling to RemoteTextureMap r=gfx-reviewers,lsalzman
It is a preparation for Bug 1843891.
RemoteTextureMap needs to handle webgpu::ExternalTexture.

Differential Revision: https://phabricator.services.mozilla.com/D188928
2023-09-26 07:17:54 +00:00
sotaro
71ca0a896c Bug 1852485 - Present WebGPU by using DX11 texture in swap chain with readback on Windows r=webgpu-reviewers,nical
The change is preparation for Bug 1843891.
Current gecko uses a internal texture for SwapChain's texture. This bug changes as to use external dx11 texture for WebGPU dx12 backend on Windows.

WebGPUParent allocates dx11 texture for SwapChain's texture of dx12 backend WebGPU. wgpu uses the dx11 texture as ID3D12Resource. The readback for presenting to WebRender still exists.
The change handles only RBGA format.

Differential Revision: https://phabricator.services.mozilla.com/D187870
2023-09-17 18:42:07 +00:00
Cosmin Sabou
da23f82150 Backed out changeset ba49d9bdc665 (bug 1852485) for causing non-unified build bustages at ExternalTextureD3D11.cpp. 2023-09-15 16:21:08 +03:00
sotaro
c2ac1fd434 Bug 1852485 - Present WebGPU by using DX11 texture in swap chain with readback on Windows r=webgpu-reviewers,nical
The change is preparation for Bug 1843891.
Current gecko uses a internal texture for SwapChain's texture. This bug changes as to use external dx11 texture for WebGPU dx12 backend on Windows.

WebGPUParent allocates dx11 texture for SwapChain's texture of dx12 backend WebGPU. wgpu uses the dx11 texture as ID3D12Resource. The readback for presenting to WebRender still exists.
The change handles only RBGA format.

Differential Revision: https://phabricator.services.mozilla.com/D187870
2023-09-15 11:14:51 +00:00
sotaro
f553ba47ff Bug 1851547 - Rename PresentRequest to ReadbackPresentRequest r=webgpu-reviewers,jimb
PresentRequest is used only for WebGPU present with readback. It seems better to rename it to ReadbackPresentRequest. mCanvasMap is also changed to mPresentationDataMap.
Preparation for Bug 1843891.

Differential Revision: https://phabricator.services.mozilla.com/D187427
2023-09-06 01:43:03 +00:00
Erich Gubler
e9f569ed34 Bug 1814088: feat(webgpu): implement GPUQueue.onSubmittedWorkDone r=webgpu-reviewers,webidl,smaug,nical
Differential Revision: https://phabricator.services.mozilla.com/D186175
2023-08-17 14:34:42 +00:00
Nicolas Silva
842015f5d5 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
cf3007f322 Backed out changeset 969534e11452 (bug 1843296) for webgpu crash 2023-08-08 01:14:00 +03:00
Nicolas Silva
540688c723 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
a423927a2c Bug 1846558: build(webgpu): bump wgpu to f71a1bc736fde37509262ca03e91d8f56a13aeb5 r=webgpu-reviewers,supply-chain-reviewers,jimb
Note that while WGPU's adapter option for a power preference has added
a new `None` variant as the new default, we preserve previous behavior
of specifying `LowPower` by default. This is because we're not sure we
want this behavior yet. See
[[https://bugzilla.mozilla.org/show_bug.cgi?id=1841840#c3 | bug 1841840,
comment 3]].

Depends on D185058

Differential Revision: https://phabricator.services.mozilla.com/D185059
2023-08-07 15:40:14 +00:00
Erich Gubler
44a202d302 Bug 1840179: refactor(webgpu): align Rust ErrorBuffer member names w/ C++ definition r=webgpu-reviewers,teoxoy
Differential Revision: https://phabricator.services.mozilla.com/D182102
2023-07-12 22:16:59 +00:00
Erich Gubler
51b0c33f8c Bug 1840179: refactor(webgpu): DRY b/w RecvDeviceAction{,WithAck} r=webgpu-reviewers,teoxoy
Differential Revision: https://phabricator.services.mozilla.com/D182100
2023-07-12 22:16:59 +00:00
Erich Gubler
a00a67aba0 Bug 1840179: fix(webgpu): classify WGPU errors into GPUErrors r=webgpu-reviewers,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D181912
2023-07-12 22:16:58 +00:00
Erich Gubler
e7c99d073f 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-06 20:50:53 +00:00
Erich Gubler
fdb35e5902 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
92d7bc5e11 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
9501ca79fc 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
40bf83dc2c 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
f38d9850c7 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
94dc4143c4 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
5e01577dfa 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
c1af6e3f5b 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
3fdad0d937 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
11e70ca834 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
8982c67749 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
1485dcdb62 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
46fc9a415d 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
5f0f28f2fe 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
93aba41563 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
0fc56ac1a4 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
3c434ffc74 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
623e2cb358 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
b9228971be 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
71997c8154 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
11403d75ae 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
121eaa5f9a 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
b31833822e 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
bdf9f3c272 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
68b87454c0 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