Define a new function, `wgpu_server_buffer_map_blocking` that maps a
wgpu buffer and blocks the calling thread until its contents are ready
for access by the CPU.
Use this function in `WebGPUParent::GetFrontBufferSnapshot`, rather
than calling `wgpu_server_poll_all_devices` explicitly to wait for the
buffer to be ready.
Differential Revision: https://phabricator.services.mozilla.com/D285397
There is no need to call `wgpu_server_poll_all_devices` from
`mozilla::webgpu::WebGPUParent::ActorDestroy`, as the normal wgpu-core
shutdown handling will take care of giving all devices a final poll.
The `Drop` implementation for `wgpu_core::resource::queue::Queue`
tries to clean everything up while still tolerating a hung device.
Differential Revision: https://phabricator.services.mozilla.com/D277472
When importing an external texture in the content process, call
BuildSurfaceDescriptorGPUVideoOrBuffer() instead of
BuildSurfaceDescriptorBuffer(), in order to avoid a readback of GPUVideo
images into a shmem.
In the GPU process, handle GPUVideo surface descriptors. For Tnull_t, if
the remote texture host is a BufferTextureHost we can use the existing
CreateFromBufferDesc() path to create the required wgpu textures. For
TSurfaceDescriptorD3D10 and TSurfaceDescriptorDXGIYCbCr we add new paths
to import the textures directly into wgpu via their shared
handles. SurfaceDescriptorDXGIYCbCr always requires 3 textures and
views: for Y, Cb, and Cr planes respectively. SurfaceDescriptorD3D10 can
come in a variety of formats, which we attempt to handle.
If a CompositeProcessFencesHolderId is provided we must ensure we wait
on the appropriate write fence prior to reading from the texture. To
ensure this occurs, we make the ExternalTextureSourceHost hold on to its
fences holder ID. When submitting command buffers, we pass the list of
used external texture sources to the host side, then on the host side
for each source we call OnBeforeQueueSubmit(). This obtains the write
fence's shared handle and the value which must be waited for from the
CompositeProcessD3D11FencesHolderMap, then imports the fence from the
shared handle and inserts a wait for the specified value into the
command queue.
If available, we request wgpu's TEXTURE_FORMAT_NV12,
TEXTURE_FORMAT_P010, and TEXTURE_FORMAT_16BIT_NORM features. The first
is required for NV12 format textures, and the latter 2 are required for
P010. If unavailable, we will gracefully fail to create these textures
but other content will continue to work. It would be surprising,
however, if the decoder were to provide us with textures in these
formats when they are not supported.
Differential Revision: https://phabricator.services.mozilla.com/D261424
When importing an external texture in the content process, call
BuildSurfaceDescriptorGPUVideoOrBuffer() instead of
BuildSurfaceDescriptorBuffer(), in order to avoid a readback of GPUVideo
images into a shmem.
In the GPU process, handle GPUVideo surface descriptors. For Tnull_t, if
the remote texture host is a BufferTextureHost we can use the existing
CreateFromBufferDesc() path to create the required wgpu textures. For
TSurfaceDescriptorD3D10 and TSurfaceDescriptorDXGIYCbCr we add new paths
to import the textures directly into wgpu via their shared
handles. SurfaceDescriptorDXGIYCbCr always requires 3 textures and
views: for Y, Cb, and Cr planes respectively. SurfaceDescriptorD3D10 can
come in a variety of formats, which we attempt to handle.
If a CompositeProcessFencesHolderId is provided we must ensure we wait
on the appropriate write fence prior to reading from the texture. To
ensure this occurs, we make the ExternalTextureSourceHost hold on to its
fences holder ID. When submitting command buffers, we pass the list of
used external texture sources to the host side, then on the host side
for each source we call OnBeforeQueueSubmit(). This obtains the write
fence's shared handle and the value which must be waited for from the
CompositeProcessD3D11FencesHolderMap, then imports the fence from the
shared handle and inserts a wait for the specified value into the
command queue.
If available, we request wgpu's TEXTURE_FORMAT_NV12,
TEXTURE_FORMAT_P010, and TEXTURE_FORMAT_16BIT_NORM features. The first
is required for NV12 format textures, and the latter 2 are required for
P010. If unavailable, we will gracefully fail to create these textures
but other content will continue to work. It would be surprising,
however, if the decoder were to provide us with textures in these
formats when they are not supported.
Differential Revision: https://phabricator.services.mozilla.com/D261424
Adds pref dom.webgpu.external-texture.enabled, which is false by
default, to control whether external texture support is enabled.
Additionally, adds a gfx blocklist entry which can override the pref to
disable on platforms with known issues. Block on non-Windows for now.
When support is disabled, either via the pref or blocklist, ensure the
Device.importExternalTexture() function is hidden. Add an additional
check to the C++ implementation as a precaution.
When support is enabled, enable the required wgpu feature.
Differential Revision: https://phabricator.services.mozilla.com/D260991
Adds pref dom.webgpu.external-texture.enabled, which is false by
default, to control whether external texture support is enabled.
Additionally, adds a gfx blocklist entry which can override the pref to
disable on platforms with known issues. Block on non-Windows for now.
When support is disabled, either via the pref or blocklist, ensure the
Device.importExternalTexture() function is hidden. Add an additional
check to the C++ implementation as a precaution.
When support is enabled, enable the required wgpu feature.
Differential Revision: https://phabricator.services.mozilla.com/D260991
Adds pref dom.webgpu.external-texture.enabled, which is false by
default, to control whether external texture support is enabled.
Additionally, adds a gfx blocklist entry which can override the pref to
disable on platforms with known issues. Block on non-Windows for now.
When support is disabled, either via the pref or blocklist, ensure the
Device.importExternalTexture() function is hidden. Add an additional
check to the C++ implementation as a precaution.
When support is enabled, enable the required wgpu feature.
Differential Revision: https://phabricator.services.mozilla.com/D260991
First we create an ExternalTextureSource using the infrastructure added
in the previous patch, and from that we create an ExternalTexture.
In order to create the external texture the client side passes an
`ExternalTextureDescriptor` to the host side, which encodes the
source as a optional ID. On the host side additional information is
queried from the ExternalTextureSourceHost, which is combined with the
`ExternalTextureDescriptor` provided by the client in order to call
wgpu's create_external_texture().
If there was an error importing the source on the client side the
source ID will be `None`. If there was an error importing the source
on the host side, it will return an empty slice of texture views as its
planes. In either case this indicates we should propagate the error
state to the external texture.
Subsequent patches will allow for creating multiple external textures
from the same source, and returning previously imported external
textures rather than always creating a new one.
Note that for now we have not requested Features::EXTERNAL_TEXTURE when
creating the wgpu device, meaning that any attempts to actually create
an external texture will result in an error.
Differential Revision: https://phabricator.services.mozilla.com/D259820
In order to support webgpu's GPUExternalTexture we must first be able
to import video frames into wgpu. To do so we introduce the concept of
an external texture "source". This consists of between 1 and 3
textures and texture views, in order to support single-plane RGBA or
multiplanar YCbCr data. The source is implemented as a distinct
concept from the external texture itself so that multiple external
textures can be created from the same source.
An external texture source has both a client-side and host-side
representation. The client side is responsible for managing the
lifecycle of the host side. It obtains a SurfaceDescriptor from the
current layers::Image of the video element or frame it was imported
from, and sends this to the host side. The host side is responsible
for creating the wgpu Textures and TextureViews it needs from the
SurfaceDescriptor. It also holds various pieces of information derived
from the imported frames that will be required to construct the
wgpu::ExternalTextureDescriptor required to create a
wgpu::ExternalTexture.
For now, we always call Image::BuildSurfaceDescriptorBuffer to obtain
the surface descriptor, and therefore only have to handle
SurfaceDescriptorBuffers. In subsequent patches we will handle
GPUVideo surface descriptors to directly import hardware decoded video
frames without requiring a readback.
Differential Revision: https://phabricator.services.mozilla.com/D259819
Upcoming patches implementing WebGPU external textures will perform
work on the parent side and require the ability to raise errors, but
we wish to keep the implementation in a separate file.
Differential Revision: https://phabricator.services.mozilla.com/D259818
First we create an ExternalTextureSource using the infrastructure added
in the previous patch, and from that we create an ExternalTexture.
In order to create the external texture the client side passes an
`ExternalTextureDescriptor` to the host side, which encodes the
source as a optional ID. On the host side additional information is
queried from the ExternalTextureSourceHost, which is combined with the
`ExternalTextureDescriptor` provided by the client in order to call
wgpu's create_external_texture().
If there was an error importing the source on the client side the
source ID will be `None`. If there was an error importing the source
on the host side, it will return an empty slice of texture views as its
planes. In either case this indicates we should propagate the error
state to the external texture.
Subsequent patches will allow for creating multiple external textures
from the same source, and returning previously imported external
textures rather than always creating a new one.
Note that for now we have not requested Features::EXTERNAL_TEXTURE when
creating the wgpu device, meaning that any attempts to actually create
an external texture will result in an error.
Differential Revision: https://phabricator.services.mozilla.com/D259820
In order to support webgpu's GPUExternalTexture we must first be able
to import video frames into wgpu. To do so we introduce the concept of
an external texture "source". This consists of between 1 and 3
textures and texture views, in order to support single-plane RGBA or
multiplanar YCbCr data. The source is implemented as a distinct
concept from the external texture itself so that multiple external
textures can be created from the same source.
An external texture source has both a client-side and host-side
representation. The client side is responsible for managing the
lifecycle of the host side. It obtains a SurfaceDescriptor from the
current layers::Image of the video element or frame it was imported
from, and sends this to the host side. The host side is responsible
for creating the wgpu Textures and TextureViews it needs from the
SurfaceDescriptor. It also holds various pieces of information derived
from the imported frames that will be required to construct the
wgpu::ExternalTextureDescriptor required to create a
wgpu::ExternalTexture.
For now, we always call Image::BuildSurfaceDescriptorBuffer to obtain
the surface descriptor, and therefore only have to handle
SurfaceDescriptorBuffers. In subsequent patches we will handle
GPUVideo surface descriptors to directly import hardware decoded video
frames without requiring a readback.
Differential Revision: https://phabricator.services.mozilla.com/D259819
Upcoming patches implementing WebGPU external textures will perform
work on the parent side and require the ability to raise errors, but
we wish to keep the implementation in a separate file.
Differential Revision: https://phabricator.services.mozilla.com/D259818
This reverts commit 22fb6f2691.
Revert "Bug 1975714 - Update backlog expectations. r=webgpu-reviewers,nical"
This reverts commit 72b4644a09.
Revert "Bug 1975714 - Use `MOZ_CAN_RUN_SCRIPT_BOUNDARY` for `reportCompilationMessagesToConsole`. r=webgpu-reviewers,ErichDonGubler"
This reverts commit 4394625f93.
Revert "Bug 1975714 - Assert that the IDs in server messages are the same as the ones the `WebGPUChild` actor expects. r=webgpu-reviewers,nical"
This reverts commit 5ce8cf9b12.
Revert "Bug 1978369 - Stop leaking queues. r=webgpu-reviewers,nical"
This reverts commit 32ab875eab.
Revert "Bug 1975714 - Move remaining ID creation/destruction into resource creation/destruction functions. r=webgpu-reviewers,nical"
This reverts commit 122e1a6529.
Revert "Bug 1975714 - Replace uses of `make_slice` with `FfiSlice`. r=webgpu-reviewers,ErichDonGubler"
This reverts commit 62add844bf.
Revert "Bug 1975714 - Use `FfiSlice` in remaining places. r=webgpu-reviewers,ErichDonGubler"
This reverts commit 3812af72dd.
Revert "Bug 1975714 - Use an opaque pointer for `WebGPUParent`. r=webgpu-reviewers,ErichDonGubler"
This reverts commit bf83ea6553.
Revert "Bug 1975714 - Remove unneeded `#[allow(dead_code)]`. r=webgpu-reviewers,ErichDonGubler"
This reverts commit a84b40d4b8.
Revert "Bug 1977861 - Stop leaking BGLs returned by GPUPipelineBase.getBindGroupLayout(). r=webgpu-reviewers,ErichDonGubler"
This reverts commit b5ec027bf9.
Revert "Bug 1975714 - Turn function pointers into extern fns. r=webgpu-reviewers,nical"
This reverts commit d3681b7012.
Revert "Bug 1975714 - Make sure to resolve/reject all pending promises in `ClearActorState`. r=webgpu-reviewers,nical"
This reverts commit 2f607174ce.
Revert "Bug 1975714 - Do not immediately resolve the lost promise on `device.destroy()`. r=webgpu-reviewers,nical"
This reverts commit 1c10e1f698.
Revert "Bug 1960399 - Reject async pipeline creation with `GPUPipelineError`. r=webgpu-reviewers,nical"
This reverts commit ee47165e63.
Revert "Bug 1975714 - Correct comments. r=webgpu-reviewers,nical"
This reverts commit 9e0aabda0e.
An ExternalTexture is a texture that is created and owned by gecko,
but shared with the webgpu implementation. It is used for webgpu
presentation. While this name describes the class well, it is
confusing due to webgpu having an entirely unrelated concept of
GPUExternalTexture.
This patch renames ExternalTexture, and all of its subclasses and
uses, to SharedTexture. This still describes the purpose accurately,
and has similarities to gl::SharedSurface which serves a similar
purpose for our webgl implementation.
Differential Revision: https://phabricator.services.mozilla.com/D255976