273 Commits

Author SHA1 Message Date
sotaro
2cc8d30558 Bug 1957563 - Replace SurfaceDescriptorD3D10::fenceInfo with GpuProcessFencesHolderId r=gfx-reviewers,lsalzman
Remove FenceInfo. Instead use GpuProcessFencesHolderId and GpuProcessD3D11FencesHolderMap.

GpuProcessD3D11FencesHolderMap is changed to instantiate also in Parent process when GPU process does not exist. Then it seems better to change its name. The name change is going to be handled in Bug 1958752.

Differential Revision: https://phabricator.services.mozilla.com/D244539
2025-04-07 11:48:23 +00:00
sotaro
a3b1c3345a Bug 1951428 - Limit ExternalTextureDMABuf only to Linux r=webgpu-reviewers,teoxoy
Differential Revision: https://phabricator.services.mozilla.com/D240573
2025-03-06 23:51:37 +00:00
Alex Franchuk
ce069a465c Bug 1942129 pt4b - Remove use of RawShmem r=ipc-reviewers,nika,webgpu-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D236749
2025-03-04 22:11:11 +00:00
sotaro
1690845843 Bug 1920763 - Add VK_KHR_external_semaphore_fd handling for WebGPU r=gfx-reviewers,webgpu-reviewers,ErichDonGubler
It is necessary to wait external semaphore before consuming WebGPU output without readback.

Differential Revision: https://phabricator.services.mozilla.com/D227329
2025-03-04 00:58:03 +00:00
Butkovits Atila
2406ce261c Backed out 8 changesets (bug 1942129) for causing bustages at SharedMemoryMapping.h. CLOSED TREE
Backed out changeset 8d9053f1c203 (bug 1942129)
Backed out changeset 393e3c507c27 (bug 1942129)
Backed out changeset 8240d353d224 (bug 1942129)
Backed out changeset 8c4cd026b720 (bug 1942129)
Backed out changeset 742634b0d6e9 (bug 1942129)
Backed out changeset d16857f9812f (bug 1942129)
Backed out changeset 7ff7af041ee7 (bug 1942129)
Backed out changeset ef41d9e4c7de (bug 1942129)
2025-03-04 00:43:23 +02:00
Alex Franchuk
57e4ff560c Bug 1942129 pt4b - Remove use of RawShmem r=ipc-reviewers,nika,webgpu-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D236749
2025-03-03 19:53:19 +00:00
sotaro
9e1a2a0609 Bug 1948175 - Add byte stride delivery to PCanvasManagerChild::SendGetSnapshot() r=gfx-reviewers,lsalzman
On macOS, ComputeRGBStride() uses alignment of 32 bytes.

Differential Revision: https://phabricator.services.mozilla.com/D238150
2025-02-14 06:11:44 +00:00
sotaro
27f295f394 Bug 1945044 - Call VkImageHandle::destroy() only when its device is active r=webgpu-reviewers,gfx-reviewers,lsalzman,ErichDonGubler
When device is not valid, Global::device_as_hal() causes crash.

Differential Revision: https://phabricator.services.mozilla.com/D236507
2025-02-05 00:01:24 +00:00
sotaro
4532a91cce Bug 1945708 - Do readback by wgpu when ExternalTexture is still being used by wgpu r=gfx-reviewers,lsalzman
When ExternalExture is still being used by wgpu, ExternalTexture::GetSnapshot() does not work. In this case, do readback by wgpu.

Differential Revision: https://phabricator.services.mozilla.com/D236665
2025-02-04 07:49:39 +00:00
sotaro
cdcd9875e3 Bug 1944716 - Fix taking snapshot of WebGPU when no readback is enabled r=gfx-reviewers,lsalzman
Fix simple mistake of Bug 1940374 fix.

Differential Revision: https://phabricator.services.mozilla.com/D236074
2025-01-30 05:02:16 +00:00
sotaro
14e5d5dc22 Bug 1940374 - Readback snapshot when last submitted TextureId is valid r=gfx-reviewers,lsalzman
Store last submitted TextureId in PresentationData for getting front buffer snapshot.

WebGPUParent::RecvQueueSubmit() stores the latest TextureId in the swap chain in PresentationData::LastSubmittedTextureId. To do so, it retrieves the OwnerId from ExternalTexture. Next, get PresentationData from OwnerId.

If readback is required, it is performed synchronously. Its implementation is borrowed from WebGPUParent::RecvSwapChainPresent().

Differential Revision: https://phabricator.services.mozilla.com/D233473
2025-01-23 01:34:30 +00:00
Nicolas Silva
2c31a86582 Bug 1941731 - Bail out on the parent side if ForwardError finds a DeviceLost error. r=webgpu-reviewers,ErichDonGubler
A common pattern in WebGPUParent.cpp is to early return if ForwardError returns true which happens when it enconters an error other than DeviceLost. Teo suggested that DeviceLost should also cause the early-return which makes sense as far as I can tell so this patch implements the suggestion. As a result, a DeviceLost error while atempting a device will prevent us from continuing to run code that assumes the device has been successfully inserted in the registry.

In addition, some unnecessary code in RcvAdapterRequestDevice was removed. LoseDevice isn't needed since we haven't created the device in the first place, and the assertion was redundant with the code in ForwardError.

Differential Revision: https://phabricator.services.mozilla.com/D234473
2025-01-17 13:03:32 +00:00
sotaro
e26ad3bd5c Bug 1941485 - Change VkImageHandle::destroy() as to use Global and id::DeviceId r=webgpu-reviewers,gfx-reviewers,nical
To destroy vk::Image and vk::DeviceMemory, VkImageHandle::destroy() uses function pointers that were stored during allocating vk::Image and vk::DeviceMemory. But it caused crashes when they were destroyed after destroying Global.

The change stops to store the function pointers.

Differential Revision: https://phabricator.services.mozilla.com/D234133
2025-01-16 00:57:36 +00:00
Nicolas Silva
376f6268f9 Bug 1940671 - Fix command buffer id leak. r=webgpu-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D234023
2025-01-14 08:08:00 +00:00
sotaro
650e5995d7 Bug 1939213 - Call Global::device_poll() in WebGPUParent::GetFrontBufferSnapshot() when WebGPUParent::RecvSwapChainPresent() does readback r=gfx-reviewers,lsalzman
When WebGPUParent::RecvSwapChainPresent() does readback, there is still pending ReadbackPresentCallback() exists. Since the callback is going to be called by next wgpu_server_queue_submit() or next wgpu_server_poll_all_devices().

Global::device_poll() triggers the ReadbackPresentCallback() if the callback is pending state.

Differential Revision: https://phabricator.services.mozilla.com/D232915
2024-12-27 09:52:15 +00:00
sotaro
95ea53535b Bug 1910520 - Add Metal SharedEvent handling around WebRender for compositing IOSurface of WebGPU r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D228946
2024-12-11 02:00:23 +00:00
Sandor Molnar
e487c5d26c Backed out changeset e1bbcdd0dd97 (bug 1910520) for causing build bustages. CLOSED TREE 2024-12-11 02:27:17 +02:00
sotaro
c4f72671b1 Bug 1910520 - Add Metal SharedEvent handling around WebRender for compositing IOSurface of WebGPU r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D228946
2024-12-11 00:04:26 +00:00
Nicolas Silva
6227a35c17 Bug 1903302 - Ship dxcompiler.dll and dxil.dll. r=sylvestre,glandium,firefox-build-system-reviewers
This patch is the first step towards shipping dxcompiler.dll and
dxil.dll (also referred to as DXC) on Windows for WebGPU.

With this patch DXC is disabled by default at build time and can be enabled
on x86_64 by adding `ac_add_options --enable-dxcompiler` in the mozconfig
file.

Followup work will include in no particular order:
 - Enabling DXC by default.
 - Enabling DXC for Windows on x86 and arm architectures.
 - Using our own DXC builds instead of pulling the dlls from the Windows
   SDK.

Differential Revision: https://phabricator.services.mozilla.com/D216293
2024-12-09 13:07:17 +00:00
teoxoy
9111bf40ea Bug 1933492 - Update wgpu to revision 66d51b6059127b81c7385ec3f2d49c3e81f76f0e. r=webgpu-reviewers,supply-chain-reviewers,nical
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>

Differential Revision: https://phabricator.services.mozilla.com/D230946
2024-12-05 11:39:10 +00:00
Butkovits Atila
57d3668876 Backed out changeset 113850da1f80 (bug 1903302) for causing python failures. CLOSED TREE 2024-12-05 12:25:38 +02:00
Nicolas Silva
a374e4b165 Bug 1903302 - Ship dxcompiler.dll and dxil.dll. r=sylvestre,glandium,firefox-build-system-reviewers
This patch is the first step towards shipping dxcompiler.dll and
dxil.dll (also referred to as DXC) on Windows for WebGPU.

With this patch DXC is disabled by default at build time and can be enabled
on x86_64 by adding `ac_add_options --enable-dxcompiler` in the mozconfig
file.

Followup work will include in no particular order:
 - Enabling DXC by default.
 - Enabling DXC for Windows on x86 and arm architectures.
 - Using our own DXC builds instead of pulling the dlls from the Windows
   SDK.

Differential Revision: https://phabricator.services.mozilla.com/D216293
2024-12-05 09:39:55 +00:00
Goloman Adrian
d2a39124c7 Backed out changeset 9b662ae8100d (bug 1933492) for causing build bustages. CLOSED TREE 2024-12-04 13:09:07 +02:00
teoxoy
5698dd07fe Bug 1933492 - Update wgpu to revision 66d51b6059127b81c7385ec3f2d49c3e81f76f0e. r=webgpu-reviewers,supply-chain-reviewers,nical
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>

Differential Revision: https://phabricator.services.mozilla.com/D230946
2024-12-04 10:16:19 +00:00
Erich Gubler
5d60ca45a1 Bug 1930751 - build(webgpu): update WGPU to 47bfede63f82e09f5e50e9735c6d98dd19403d3c r=webgpu-reviewers,supply-chain-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D228713
2024-11-25 17:40:13 +00:00
Erich Gubler
c79ba13272 Bug 1932968 - replace manual static_case<bool>(externalTexture) in WebGPUParent::EnsureExternalTextureForSwapChain r=webgpu-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D229988
2024-11-24 19:13:30 +00:00
Erich Gubler
d637a92015 Bug 1932968 - remove useless std::move call in WebGPUParent::MapCallback r=webgpu-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D229987
2024-11-24 19:13:30 +00:00
Erich Gubler
871e2c1b20 Bug 1932968 - chore(webgpu): align arg. names in WebGPUParent::Recv{BindGroup,Pipeline}LayoutDrop r=webgpu-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D229986
2024-11-24 19:13:29 +00:00
sotaro
c32034340f Bug 1927658 - Add ExternalTextureMacIOSurface for handling Mac IO Surface for WebGPU r=webgpu-reviewers,nical
Add ExternalTextureMacIOSurface class and mac IO Surface handling to wgpu_bindings for no readback present on macos.

Differential Revision: https://phabricator.services.mozilla.com/D227136
2024-11-07 00:41:43 +00:00
Erich Gubler
16daa04f78 Bug 1838729, part 1 - feat(webgpu): add GPUQuerySet APIs r=webgpu-reviewers,webidl,nical,saschanaz
Expected outcomes from CTS have been adjusted in part 4: D227734

Differential Revision: https://phabricator.services.mozilla.com/D223787
2024-11-06 06:31:13 +00:00
sotaro
ffb80d2308 Bug 1921379 - Alloc DMA buffer in VKImage for WebGPU presentation on Linux r=webgpu-reviewers,nical
Allocate dmabuf  in VKImage, since direct dmabuf creation by gbm_bo_* is not reliable and comes with various issue.

Texture of swap chain uses vk::ImageCreateFlags::ALIAS(VK_IMAGE_CREATE_ALIAS_BIT).

wgpu_server_adapter_request_device() allocates vulkan device for enabling the following extensions that is necessary for dmabuf support.
- khr::external_memory_fd
- ext::external_memory_dma_buf
- ext::image_drm_format_modifier
- khr::external_semaphore_fd

Differential Revision: https://phabricator.services.mozilla.com/D223910
2024-10-29 01:58:48 +00:00
sotaro
d27765a943 Bug 1924042 - Fallback to readback when creating Texture with ExternalTextureD3D11 is failed r=webgpu-reviewers,nical
ExternalTexture usage does not handle a case that creating texture with ExternalTexture is failed. In this case, it seems better to fallback to readback.

Differential Revision: https://phabricator.services.mozilla.com/D225327
2024-10-24 01:30:36 +00:00
Brad Werth
6d67f3e74d Bug 1877330 Part 3: Make WebGPUParent swallow unreportable device lost callbacks. r=teoxoy
This changes both the parent and the child to clarify that some device
lost callbacks from wgpu should not resolve the lost promise. It also
adds an assert to detect when we are getting the lost callback after
we've already unregistered device, which is a possible cause of timeouts
in this test.

It restores the part of the test that checks that device drop is
unobservable, which it once again is.

Differential Revision: https://phabricator.services.mozilla.com/D225733
2024-10-21 20:08:28 +00:00
sotaro
d5c9a4e638 Bug 1920361 - Add ExternalTextureDMABuf for handling DMA buf for WebGPU r=webgpu-reviewers,stransky,nical
Add ExternalTextureDMABuf for handling DMA buf for WebGPU. Actual DMA buf allocation is going to be done in Vulkan by another bug.

Differential Revision: https://phabricator.services.mozilla.com/D223062
2024-09-24 16:19:35 +00:00
teoxoy
04696bebed Bug 1918739 - Update wgpu to revision c8beade1877251c494036fc3661b04ec6aad63a9. r=webgpu-reviewers,supply-chain-reviewers,jimb
Differential Revision: https://phabricator.services.mozilla.com/D222155
2024-09-17 21:44:15 +00:00
Norisz Fay
b6992edc1c Backed out changeset 128de7e126a3 (bug 1918739) for causing wgpu_bindings related bustages CLOSED TREE 2024-09-14 03:16:45 +03:00
teoxoy
9fd15cf9ae Bug 1918739 - Update wgpu to revision c8beade1877251c494036fc3661b04ec6aad63a9. r=webgpu-reviewers,supply-chain-reviewers,jimb
Differential Revision: https://phabricator.services.mozilla.com/D222155
2024-09-13 23:53:22 +00:00
Jim Blandy
c57ff07601 Bug 1913121: Update wgpu to c6a3d9273 (2024-08-13) r=webgpu-reviewers,supply-chain-reviewers,ErichDonGubler,teoxoy
Adapt `wgpu_server_queue_submit` to the new submission index
type.

Use corrected spelling `WGPUTextureFormat_Rg11b10UFloat`.

Assign queue ids explicitly, rather than deriving them from device ids:

- `wgpu_bindings::client::IdentityHub`: add an `IdentityManager` for queues.
  Initialize it in `IdentityHub::default`.

- `dom::webgpu::DeviceRequest`: hold separate `mDeviceId` and `mQueueId`
  members.

- `wgpu_client_make_device_id`: rename to `wgpu_client_make_device_queue_id`,
  and have it allocate both a device id and a queue id.

- `PWebGPU` protocol's `AdapterRequestDevice` request: explicitly pass
  an id for the new queue.

- `WebGPUChild::AdapterRequestDevice`: pass through the queue id from
  `wgpu_client_make_device_queue_id` through to `SendAdapterRequestDevice`,
  and also return it as `DeviceRequest::mQueueId`.

- `WebGPUParent::RecvAdapterRequestDevice`: accept a queue id, and pass
  it along to `ffi::wgpu_server_adapter_request_device`.

- `wgpu_server_adapter_request_device`: take a new argument specifying the
  new queue's id, and pass that along to `global.adapter_request_device`.

- `dom::webgpu::Adapter::RequestDevice`: given the `DeviceRequest` returned by
  `WebGPUChild::AdapterRequestDevice`, pass the ids for both the new device and
  the new queue to `dom::webgpu::Device::Device`.

- Let `dom::webgpu::Device::Device` take a new argument explicitly specifying
  the device's queue's id.

Differential Revision: https://phabricator.services.mozilla.com/D219356
2024-08-19 18:46:19 +00:00
sotaro
11955a763b Bug 1888341 - Remove MOZ_ASSERT_UNREACHABLE in WebGPUParent::CreateExternalTexture() r=gfx-reviewers,lsalzman
ExternalTexture allocation failure could happen when allocating size is too large or system does not have enough gpu memory. Then it seems better to remove the assert. ExternalTextureD3D11.cpp already has enough error logs.

Differential Revision: https://phabricator.services.mozilla.com/D205978
2024-03-28 10:54:06 +00:00
Erich Gubler
e6445c8a1c Bug 1879692: chore(webgpu): remove PresentationData::mBuffersLock r=webgpu-reviewers,jimb
This logic is in an IPDL actor, and doesn't spin up its own threads.
Therefore, all methods in `WebGPUParent` are called on the same thread,
all the time. There's no need for a synchronization mechanism here; it
only serves to confuse the mental model of newcomers to this code.

Differential Revision: https://phabricator.services.mozilla.com/D203709
2024-03-07 22:07:31 +00:00
Erich Gubler
dfd3817b71 Bug 1879692: refactor(webgpu): s/PresentationData*/RefPtr<PresentationData> r=webgpu-reviewers,nical
If we were in Rust, and I could extract a reference using only safe
code, I'd totally trust this, and be happy to avoid an atomic addition
on the strong ref-count. However, I think in our case for C++, it's
better to simply avoid the safety hazard altogether, and accept the
trivial performance hit.

Differential Revision: https://phabricator.services.mozilla.com/D203708
2024-03-07 22:07:31 +00:00
Erich Gubler
b62d49eca9 Bug 1879692: refactor(webgpu): clarify internal-ness of WGPU error logs in readback presentation r=webgpu-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D203713
2024-03-06 21:17:35 +00:00
Erich Gubler
4e35c1f913 Bug 1879692: fix(webgpu): bail readback presentation if get_mapped_range fails r=webgpu-reviewers,nical
Failing to `return` here yields a crash in the case where the device is
lost, which is the root cause of bug 1879692. Crashing seems like
a pretty severe consequence for something that users may invoke
themselves (i.e., via `device.destroy`), so let's bail out instead.

Differential Revision: https://phabricator.services.mozilla.com/D203710
2024-03-06 21:17:35 +00:00
Erich Gubler
f35a5a1e04 Bug 1879692: refactor(webgpu): always print WGPU errors in readback presentation r=webgpu-reviewers,nical
Differential Revision: https://phabricator.services.mozilla.com/D203712
2024-03-06 21:17:34 +00:00
Erich Gubler
6914f3de10 Bug 1879692: fix(webgpu): coerce valid. errors to internal in readback presentation r=webgpu-reviewers,nical
Validation errors are supposed to be errors that a WebGPU user are
solely responsible for. In cases where we encounter an error for
implementation internals, we should use
[`GPUInternalError`](https://gpuweb.github.io/gpuweb/#gpuinternalerror)
instead. If we encounter a validation error in our usage of `wgpu-core`
to implement presentation readback, coerce them to an internal error
before forwarding them to the applicable `GPUDevice`.

Differential Revision: https://phabricator.services.mozilla.com/D203711
2024-03-06 21:17:34 +00:00
Peter Van der Beken
9e9199880e Bug 1640839 - Stop generating a sentinel value at the end of WebIDL enums. r=mccr8,jgilbert,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D201344
2024-03-02 07:50:25 +00:00
Natalia Csoregi
10b9ceb789 Backed out 13 changesets (bug 1640839) for causing bustage on Element.cpp CLOSED TREE
Backed out changeset 179ceb82c9e5 (bug 1640839)
Backed out changeset 73f498a821f0 (bug 1640839)
Backed out changeset dc2d3d0e0365 (bug 1640839)
Backed out changeset ddc989ac0509 (bug 1640839)
Backed out changeset e595bb3feea8 (bug 1640839)
Backed out changeset c85aca04e27f (bug 1640839)
Backed out changeset 98e8e3a4047a (bug 1640839)
Backed out changeset 59ef180517db (bug 1640839)
Backed out changeset af2f5e293662 (bug 1640839)
Backed out changeset 89aa6d9dc598 (bug 1640839)
Backed out changeset 67b722a722f9 (bug 1640839)
Backed out changeset 24a9665c6ced (bug 1640839)
Backed out changeset d93f199385e9 (bug 1640839)
2024-03-01 18:23:08 +02:00
Peter Van der Beken
e0fa109cb0 Bug 1640839 - Stop generating a sentinel value at the end of WebIDL enums. r=mccr8,jgilbert,media-playback-reviewers,padenot
Differential Revision: https://phabricator.services.mozilla.com/D201344
2024-03-01 14:31:15 +00:00
Nicolas Silva
10f2d9133a Bug 1878308 - Move the compute pass remoting logic into wgpu bindings. r=webgpu-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D200460
2024-02-26 08:31:37 +00:00
Nicolas Silva
8fe46ddc7b Bug 1878308 - Move the render pass remoting logic into wgpu's bindings. r=webgpu-reviewers,ErichDonGubler
Differential Revision: https://phabricator.services.mozilla.com/D200444
2024-02-26 08:31:37 +00:00