commit a32cef48493d96650f37cf8e2e623819efcbf97f
parent 28720f05016d6f5967ef55d53d61d348139e4cd9
Author: Sotaro Ikeda <sotaro.ikeda.g@gmail.com>
Date: Wed, 24 Dec 2025 00:15:31 +0000
Bug 2007481 - Add IDCompositionTexture support check to DeviceManagerDx r=gfx-reviewers,lsalzman
Preparation of Bug 1958603.
Differential Revision: https://phabricator.services.mozilla.com/D277415
Diffstat:
3 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/gfx/thebes/DeviceManagerDx.cpp b/gfx/thebes/DeviceManagerDx.cpp
@@ -60,7 +60,8 @@ void DeviceManagerDx::Shutdown() { sInstance = nullptr; }
DeviceManagerDx::DeviceManagerDx()
: mDeviceLock("gfxWindowsPlatform.mDeviceLock"),
- mCompositorDeviceSupportsVideo(false) {
+ mCompositorDeviceSupportsVideo(false),
+ mSupportsDCompositionTexture(false) {
// Set up the D3D11 feature levels we can ask for.
mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_11_1);
mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_11_0);
@@ -571,6 +572,32 @@ void DeviceManagerDx::CreateDirectCompositionDeviceLocked() {
return;
}
+ // Check if DCompositionTexture is supported
+ RefPtr<ID3D11Device> device = mCompositorDevice;
+ const bool supported = [device, compositionDevice] {
+ HRESULT hr;
+ RefPtr<IDCompositionDevice4> dcomp4;
+ hr = compositionDevice->QueryInterface(
+ (IDCompositionDevice4**)getter_AddRefs(dcomp4));
+ if (FAILED(hr)) {
+ return false;
+ }
+
+ BOOL supportCompositionTexture = FALSE;
+ hr = dcomp4->CheckCompositionTextureSupport(device,
+ &supportCompositionTexture);
+ if (FAILED(hr)) {
+ return false;
+ }
+
+ if (supportCompositionTexture == FALSE) {
+ return false;
+ }
+
+ return true;
+ }();
+
+ mSupportsDCompositionTexture = supported;
mDirectCompositionDevice = compositionDevice;
}
@@ -1425,6 +1452,11 @@ bool DeviceManagerDx::CanUseDComp() {
return !!mDirectCompositionDevice;
}
+bool DeviceManagerDx::CanUseDCompositionTexture() {
+ MutexAutoLock lock(mDeviceLock);
+ return mDirectCompositionDevice && mSupportsDCompositionTexture;
+}
+
void DeviceManagerDx::GetCompositorDevices(
RefPtr<ID3D11Device>* aOutDevice,
RefPtr<layers::DeviceAttachmentsD3D11>* aOutAttachments) {
diff --git a/gfx/thebes/DeviceManagerDx.h b/gfx/thebes/DeviceManagerDx.h
@@ -80,6 +80,7 @@ class DeviceManagerDx final {
bool CanUseP010();
bool CanUseP016();
bool CanUseDComp();
+ bool CanUseDCompositionTexture();
// Returns true if we can create a texture with
// D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX and also
@@ -209,6 +210,7 @@ class DeviceManagerDx final {
RefPtr<layers::DeviceAttachmentsD3D11> mCompositorAttachments
MOZ_GUARDED_BY(mDeviceLock);
bool mCompositorDeviceSupportsVideo MOZ_GUARDED_BY(mDeviceLock);
+ bool mSupportsDCompositionTexture MOZ_GUARDED_BY(mDeviceLock);
Maybe<D3D11DeviceStatus> mDeviceStatus MOZ_GUARDED_BY(mDeviceLock);
Maybe<DeviceResetReason> mDeviceResetReason MOZ_GUARDED_BY(mDeviceLock);
RefPtr<Runnable> mUpdateMonitorInfoRunnable MOZ_GUARDED_BY(mDeviceLock);
diff --git a/gfx/webrender_bindings/DCLayerTree.cpp b/gfx/webrender_bindings/DCLayerTree.cpp
@@ -1321,33 +1321,10 @@ bool DCLayerTree::SupportsSwapChainTearing() {
}
bool DCLayerTree::SupportsDCompositionTexture() {
- RefPtr<ID3D11Device> device = mDevice;
- RefPtr<IDCompositionDevice2> compositionDevice = mCompositionDevice;
- static const bool supported = [device, compositionDevice] {
- const auto dcomp4 = QI<IDCompositionDevice4>::From(compositionDevice.get());
- if (!dcomp4) {
- return false;
- }
-
- BOOL supportCompositionTexture = FALSE;
- HRESULT hr = dcomp4->CheckCompositionTextureSupport(
- device, &supportCompositionTexture);
- if (FAILED(hr)) {
- return false;
- }
-
- if (supportCompositionTexture == FALSE) {
- return false;
- }
-
- return true;
- }();
-
if (!gfx::gfxVars::WebRenderLayerCompositorDCompTexture()) {
return false;
}
-
- return supported;
+ return gfx::DeviceManagerDx::Get()->CanUseDCompositionTexture();
}
DXGI_FORMAT DCLayerTree::GetOverlayFormatForSDR() {