Bug 1843891 - Enable to present WebGPU without readback with DX12 on Windows r=webgpu-reviewers,nical

Differential Revision: https://phabricator.services.mozilla.com/D190250
This commit is contained in:
sotaro 2024-03-22 04:13:28 +00:00
parent 36b74f7869
commit 22fa535fac
5 changed files with 17 additions and 7 deletions

View file

@ -126,6 +126,9 @@ void CanvasContext::Configure(const dom::GPUCanvasConfiguration& aConfig) {
mUseExternalTextureInSwapChain =
wgpu_client_use_external_texture_in_swapChain(
aConfig.mDevice->mId, ConvertTextureFormat(aConfig.mFormat));
if (!gfx::gfxVars::AllowWebGPUPresentWithoutReadback()) {
mUseExternalTextureInSwapChain = false;
}
#ifdef XP_WIN
// When WebRender does not use hardware acceleration, disable external texture
// in swap chain. Since compositor device might not exist.

View file

@ -101,7 +101,8 @@ class gfxVarReceiver;
_(AllowSoftwareWebRenderOGL, bool, false) \
_(WebglUseHardware, bool, true) \
_(WebRenderOverlayVpAutoHDR, bool, false) \
_(WebRenderOverlayVpSuperResolution, bool, false)
_(WebRenderOverlayVpSuperResolution, bool, false) \
_(AllowWebGPUPresentWithoutReadback, bool, false)
/* Add new entries above this line. */

View file

@ -3162,6 +3162,13 @@ void gfxPlatform::InitWebGPUConfig() {
#endif
gfxVars::SetAllowWebGPU(feature.IsEnabled());
#if XP_WIN
if (IsWin10CreatorsUpdateOrLater() &&
StaticPrefs::dom_webgpu_allow_present_without_readback()) {
gfxVars::SetAllowWebGPUPresentWithoutReadback(true);
}
#endif
}
#ifdef XP_WIN

View file

@ -1346,10 +1346,6 @@ pub extern "C" fn wgpu_client_use_external_texture_in_swapChain(
return false;
}
if !static_prefs::pref!("dom.webgpu.swap-chain.external-texture-dx12") {
return false;
}
let supported = match format {
wgt::TextureFormat::Bgra8Unorm => true,
_ => false,

View file

@ -4637,11 +4637,14 @@
mirror: always
rust: true
- name: dom.webgpu.swap-chain.external-texture-dx12
- name: dom.webgpu.allow-present-without-readback
type: RelaxedAtomicBool
#if defined(XP_WIN)
value: true
#else
value: false
#endif
mirror: always
rust: true
# For testing purposes, crash if we don't get a hardware adapter.
- name: dom.webgpu.testing.assert-hardware-adapter