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
This commit is contained in:
sotaro
2025-01-23 01:34:30 +00:00
parent fbf390897c
commit 14e5d5dc22
12 changed files with 388 additions and 25 deletions

View File

@@ -1414,6 +1414,17 @@ extern "C" {
usage: wgt::TextureUsages,
) -> bool;
#[allow(dead_code)]
fn wgpu_server_ensure_external_texture_for_readback(
param: *mut c_void,
swap_chain_id: SwapChainId,
device_id: id::DeviceId,
texture_id: id::TextureId,
width: u32,
height: u32,
format: wgt::TextureFormat,
usage: wgt::TextureUsages,
);
#[allow(dead_code)]
fn wgpu_server_get_external_texture_handle(
param: *mut c_void,
id: id::TextureId,
@@ -2035,6 +2046,21 @@ impl Global {
};
}
if let Some(swap_chain_id) = swap_chain_id {
unsafe {
wgpu_server_ensure_external_texture_for_readback(
self.owner,
swap_chain_id,
self_id,
id,
desc.size.width,
desc.size.height,
desc.format,
desc.usage,
)
};
}
let (_, error) = self.device_create_texture(self_id, &desc, Some(id));
if let Some(err) = error {
error_buf.init(err);