Commit 11103795 authored by sotaro's avatar sotaro
Browse files

Bug 1835984 - Add Add KnowsCompositor::SupportsD3D11NV12() r=gfx-reviewers,lsalzman

DeviceManagerDx::Get()->CanUseNV12() needs D3D11Device in current process. The SupportsD3D11NV12() could be used without D3D11Device in current process.

It is preparation for Bug 1834039.

Differential Revision: https://phabricator.services.mozilla.com/D179532
parent ddce2746
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ struct TextureFactoryIdentifier {
  bool mSupportsTextureBlitting;
  bool mSupportsPartialUploads;
  bool mSupportsComponentAlpha;
  bool mSupportsD3D11NV12;
  SyncHandle mSyncHandle;

  explicit TextureFactoryIdentifier(
@@ -175,7 +176,7 @@ struct TextureFactoryIdentifier {
      bool aCompositorUseDComp = false, bool aUseCompositorWnd = false,
      bool aSupportsTextureBlitting = false,
      bool aSupportsPartialUploads = false, bool aSupportsComponentAlpha = true,
      SyncHandle aSyncHandle = 0)
      bool aSupportsD3D11NV12 = false, SyncHandle aSyncHandle = 0)
      : mParentBackend(aLayersBackend),
        mWebRenderBackend(WebRenderBackend::HARDWARE),
        mWebRenderCompositor(WebRenderCompositor::DRAW),
@@ -187,6 +188,7 @@ struct TextureFactoryIdentifier {
        mSupportsTextureBlitting(aSupportsTextureBlitting),
        mSupportsPartialUploads(aSupportsPartialUploads),
        mSupportsComponentAlpha(aSupportsComponentAlpha),
        mSupportsD3D11NV12(aSupportsD3D11NV12),
        mSyncHandle(aSyncHandle) {}

  explicit TextureFactoryIdentifier(
@@ -197,7 +199,7 @@ struct TextureFactoryIdentifier {
      bool aCompositorUseDComp = false, bool aUseCompositorWnd = false,
      bool aSupportsTextureBlitting = false,
      bool aSupportsPartialUploads = false, bool aSupportsComponentAlpha = true,
      SyncHandle aSyncHandle = 0)
      bool aSupportsD3D11NV12 = false, SyncHandle aSyncHandle = 0)
      : mParentBackend(LayersBackend::LAYERS_WR),
        mWebRenderBackend(aWebRenderBackend),
        mWebRenderCompositor(aWebRenderCompositor),
@@ -209,6 +211,7 @@ struct TextureFactoryIdentifier {
        mSupportsTextureBlitting(aSupportsTextureBlitting),
        mSupportsPartialUploads(aSupportsPartialUploads),
        mSupportsComponentAlpha(aSupportsComponentAlpha),
        mSupportsD3D11NV12(aSupportsD3D11NV12),
        mSyncHandle(aSyncHandle) {}

  bool operator==(const TextureFactoryIdentifier& aOther) const {
@@ -223,6 +226,7 @@ struct TextureFactoryIdentifier {
           mSupportsTextureBlitting == aOther.mSupportsTextureBlitting &&
           mSupportsPartialUploads == aOther.mSupportsPartialUploads &&
           mSupportsComponentAlpha == aOther.mSupportsComponentAlpha &&
           mSupportsD3D11NV12 == aOther.mSupportsD3D11NV12 &&
           mSyncHandle == aOther.mSyncHandle;
  }
};
+5 −0
Original line number Diff line number Diff line
@@ -113,6 +113,11 @@ class KnowsCompositor {
    return lock.ref().mTextureFactoryIdentifier.mSupportsComponentAlpha;
  }

  bool SupportsD3D11NV12() const {
    auto lock = mData.Lock();
    return lock.ref().mTextureFactoryIdentifier.mSupportsD3D11NV12;
  }

  bool SupportsD3D11() const {
    auto lock = mData.Lock();
    return lock.ref().mTextureFactoryIdentifier.mParentBackend ==
+2 −0
Original line number Diff line number Diff line
@@ -636,6 +636,7 @@ struct ParamTraits<mozilla::layers::TextureFactoryIdentifier> {
    WriteParam(aWriter, aParam.mSupportsTextureBlitting);
    WriteParam(aWriter, aParam.mSupportsPartialUploads);
    WriteParam(aWriter, aParam.mSupportsComponentAlpha);
    WriteParam(aWriter, aParam.mSupportsD3D11NV12);
    WriteParam(aWriter, aParam.mSyncHandle);
  }

@@ -651,6 +652,7 @@ struct ParamTraits<mozilla::layers::TextureFactoryIdentifier> {
                  ReadParam(aReader, &aResult->mSupportsTextureBlitting) &&
                  ReadParam(aReader, &aResult->mSupportsPartialUploads) &&
                  ReadParam(aReader, &aResult->mSupportsComponentAlpha) &&
                  ReadParam(aReader, &aResult->mSupportsD3D11NV12) &&
                  ReadParam(aReader, &aResult->mSyncHandle);
    return result;
  }
+8 −1
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#include "mozilla/widget/CompositorWidget.h"

#ifdef XP_WIN
#  include "mozilla/gfx/DeviceManagerDx.h"
#  include "mozilla/widget/WinCompositorWidget.h"
#endif
#if defined(MOZ_WIDGET_GTK)
@@ -2825,11 +2826,17 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvReleaseCompositable(
TextureFactoryIdentifier WebRenderBridgeParent::GetTextureFactoryIdentifier() {
  MOZ_ASSERT(mApi);

#ifdef XP_WIN
  const bool supportsD3D11NV12 = gfx::DeviceManagerDx::Get()->CanUseNV12();
#else
  const bool supportsD3D11NV12 = false;
#endif

  TextureFactoryIdentifier ident(
      mApi->GetBackendType(), mApi->GetCompositorType(), XRE_GetProcessType(),
      mApi->GetMaxTextureSize(), mApi->GetUseANGLE(), mApi->GetUseDComp(),
      mAsyncImageManager->UseCompositorWnd(), false, false, false,
      mApi->GetSyncHandle());
      supportsD3D11NV12, mApi->GetSyncHandle());
  return ident;
}