Backed out changeset 54e35266f616 (bug 1866412) for causing bp-nu bustages in RenderD3D11TextureHost.cpp. CLOSED TREE

This commit is contained in:
Stanca Serban 2023-12-08 11:00:31 +02:00
parent 9790c3e9af
commit b57f879b5e
16 changed files with 14 additions and 473 deletions

View File

@ -85,7 +85,7 @@ Maybe<layers::SurfaceDescriptor> ExternalTextureD3D11::ToSurfaceDescriptor() {
/* gpuProcessTextureId */ Nothing(),
/* arrayIndex */ 0, format, gfx::IntSize(mWidth, mHeight),
gfx::ColorSpace2::SRGB, gfx::ColorRange::FULL,
/* hasKeyedMutex */ false, /* fenceInfo */ Nothing()));
/* hasKeyedMutex */ false));
}
void ExternalTextureD3D11::GetSnapshot(const ipc::Shmem& aDestShmem,

View File

@ -172,8 +172,7 @@ SharedSurface_ANGLEShareHandle::ToSurfaceDescriptor() {
return Some(layers::SurfaceDescriptorD3D10(
(WindowsHandle)mShareHandle, /* gpuProcessTextureId */ Nothing(),
/* arrayIndex */ 0, format, mDesc.size, mDesc.colorSpace,
gfx::ColorRange::FULL, /* hasKeyedMutex */ true,
/* fenceInfo */ Nothing()));
gfx::ColorRange::FULL, /* hasKeyedMutex */ true));
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -444,8 +444,7 @@ SharedSurface_D3D11Interop::ToSurfaceDescriptor() {
return Some(layers::SurfaceDescriptorD3D10(
WindowsHandle(mData.dxgiHandle), /* gpuProcessTextureId */ Nothing(),
/* arrayIndex */ 0, format, mDesc.size, mDesc.colorSpace,
gfx::ColorRange::FULL, /* hasKeyedMutex */ true,
/* fenceInfo */ Nothing()));
gfx::ColorRange::FULL, /* hasKeyedMutex */ true));
}
//////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,20 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FileHandleWrapper.h"
namespace mozilla::gfx {
FileHandleWrapper::FileHandleWrapper(mozilla::UniqueFileHandle&& aHandle)
: mHandle(std::move(aHandle)) {}
FileHandleWrapper::~FileHandleWrapper() {}
mozilla::detail::FileHandleType FileHandleWrapper::GetHandle() {
return mHandle.get();
}
} // namespace mozilla::gfx

View File

@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _include_gfx_ipc_FileHandleWrapper_h__
#define _include_gfx_ipc_FileHandleWrapper_h__
#include "mozilla/UniquePtrExtensions.h"
#include "nsISupportsImpl.h"
namespace mozilla {
namespace ipc {
template <typename T>
struct IPDLParamTraits;
} // namespace ipc
namespace gfx {
//
// A class for sharing file handle or shared handle among multiple clients.
//
// The file handles or the shared handles consume system resources. The class
// could reduce the number of shared handles in a process.
//
class FileHandleWrapper {
friend struct mozilla::ipc::IPDLParamTraits<gfx::FileHandleWrapper*>;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileHandleWrapper);
explicit FileHandleWrapper(mozilla::UniqueFileHandle&& aHandle);
mozilla::detail::FileHandleType GetHandle();
protected:
~FileHandleWrapper();
const mozilla::UniqueFileHandle mHandle;
};
struct FenceInfo {
FenceInfo() = default;
FenceInfo(FileHandleWrapper* aFenceHandle, uint64_t aFenceValue)
: mFenceHandle(aFenceHandle), mFenceValue(aFenceValue) {}
bool operator==(const FenceInfo& aOther) const {
return mFenceHandle == aOther.mFenceHandle &&
mFenceValue == aOther.mFenceValue;
}
RefPtr<FileHandleWrapper> mFenceHandle;
uint64_t mFenceValue = 0;
};
} // namespace gfx
} // namespace mozilla
#endif // _include_gfx_ipc_FileHandleWrapper_h__

View File

@ -21,7 +21,6 @@
#include "ipc/EnumSerializer.h"
#include "ipc/IPCMessageUtilsSpecializations.h"
#include "mozilla/gfx/CrossProcessPaint.h"
#include "mozilla/gfx/FileHandleWrapper.h"
#include "mozilla/gfx/Matrix.h"
#include "mozilla/gfx/ScaleFactor.h"
#include "mozilla/gfx/ScaleFactors2D.h"
@ -29,9 +28,7 @@
#include "nsRect.h"
#include "nsRegion.h"
#include "mozilla/Array.h"
#include "mozilla/ipc/FileDescriptor.h"
#include "mozilla/ipc/IPDLParamTraits.h"
#include "mozilla/ipc/ProtocolMessageUtils.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/ShmemMessageUtils.h"
@ -1189,24 +1186,6 @@ struct ParamTraits<mozilla::fontlist::Pointer> {
}
};
template <>
struct ParamTraits<mozilla::gfx::FenceInfo> {
typedef mozilla::gfx::FenceInfo paramType;
static void Write(MessageWriter* aWriter, const paramType& aParam) {
WriteParam(aWriter, aParam.mFenceHandle);
WriteParam(aWriter, aParam.mFenceValue);
}
static bool Read(MessageReader* aReader, paramType* aResult) {
if (!ReadParam(aReader, &aResult->mFenceHandle) ||
!ReadParam(aReader, &aResult->mFenceValue)) {
return false;
}
return true;
}
};
} // namespace IPC
namespace mozilla {
@ -1260,43 +1239,6 @@ struct IPDLParamTraits<gfx::PaintFragment> {
}
};
template <>
struct IPDLParamTraits<gfx::FileHandleWrapper*> {
static void Write(IPC::MessageWriter* aWriter, IProtocol* aActor,
gfx::FileHandleWrapper* aParam) {
if (!aParam) {
WriteIPDLParam(aWriter, aActor, false);
return;
}
WriteIPDLParam(aWriter, aActor, true);
mozilla::ipc::FileDescriptor desc(aParam->GetHandle());
WriteIPDLParam(aWriter, aActor, desc);
}
static bool Read(IPC::MessageReader* aReader, IProtocol* aActor,
RefPtr<gfx::FileHandleWrapper>* aResult) {
*aResult = nullptr;
bool notnull = false;
if (!ReadIPDLParam(aReader, aActor, &notnull)) {
return false;
}
if (!notnull) {
return true;
}
mozilla::ipc::FileDescriptor desc;
if (!ReadIPDLParam(aReader, aActor, &desc)) {
return false;
}
auto wrapper =
MakeRefPtr<gfx::FileHandleWrapper>(desc.TakePlatformHandle());
*aResult = std::move(wrapper);
return true;
}
};
} // namespace ipc
} // namespace mozilla

View File

@ -14,7 +14,6 @@ EXPORTS.mozilla.gfx += [
"CanvasManagerParent.h",
"CanvasRenderThread.h",
"CrossProcessPaint.h",
"FileHandleWrapper.h",
"GPUChild.h",
"GPUParent.h",
"GPUProcessHost.h",
@ -46,7 +45,6 @@ UNIFIED_SOURCES += [
"CompositorWidgetVsyncObserver.cpp",
"CrossProcessPaint.cpp",
"D3DMessageUtils.cpp",
"FileHandleWrapper.cpp",
"GPUChild.cpp",
"GPUProcessHost.cpp",
"GPUProcessImpl.cpp",

View File

@ -1,190 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FenceD3D11.h"
#include <d3d11.h>
#include <d3d11_3.h>
#include <d3d11_4.h>
#include "mozilla/gfx/Logging.h"
namespace mozilla {
namespace layers {
RefPtr<ID3D11Device> mDevice;
/* static */
RefPtr<FenceD3D11> FenceD3D11::Create(ID3D11Device* aDevice) {
MOZ_ASSERT(aDevice);
if (!aDevice) {
return nullptr;
}
RefPtr<ID3D11Device5> d3d11_5;
auto hr =
aDevice->QueryInterface(__uuidof(ID3D11Device5), getter_AddRefs(d3d11_5));
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Failed to get ID3D11Device5: " << gfx::hexa(hr);
return nullptr;
}
RefPtr<ID3D11Fence> fenceD3D11;
d3d11_5->CreateFence(0, D3D11_FENCE_FLAG_SHARED,
IID_PPV_ARGS((ID3D11Fence**)getter_AddRefs(fenceD3D11)));
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Fence creation failed: " << gfx::hexa(hr);
return nullptr;
}
HANDLE sharedHandle = nullptr;
hr = fenceD3D11->CreateSharedHandle(nullptr, GENERIC_ALL, nullptr,
&sharedHandle);
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Fence shared handle creation failed "
<< gfx::hexa(hr);
return nullptr;
}
RefPtr<gfx::FileHandleWrapper> handle =
new gfx::FileHandleWrapper(UniqueFileHandle(sharedHandle));
RefPtr<FenceD3D11> fence = new FenceD3D11(handle);
fence->mDevice = aDevice;
fence->mSignalFence = fenceD3D11;
return fence;
}
/* static */
RefPtr<FenceD3D11> FenceD3D11::CreateFromHandle(
RefPtr<gfx::FileHandleWrapper> aHandle) {
// Opening shared handle is deferred.
return new FenceD3D11(aHandle);
}
/* static */
bool FenceD3D11::IsSupported(ID3D11Device* aDevice) {
RefPtr<ID3D11Device5> d3d11_5;
auto hr =
aDevice->QueryInterface(__uuidof(ID3D11Device5), getter_AddRefs(d3d11_5));
if (FAILED(hr)) {
return false;
}
return true;
}
FenceD3D11::FenceD3D11(RefPtr<gfx::FileHandleWrapper>& aHandle)
: mHandle(aHandle) {
MOZ_ASSERT(mHandle);
}
FenceD3D11::~FenceD3D11() {}
gfx::FenceInfo FenceD3D11::GetFenceInfo() const {
return gfx::FenceInfo(mHandle, mFenceValue);
}
bool FenceD3D11::IncrementAndSignal() {
MOZ_ASSERT(mDevice);
MOZ_ASSERT(mSignalFence);
if (!mDevice || !mSignalFence) {
return false;
}
RefPtr<ID3D11DeviceContext> context;
mDevice->GetImmediateContext(getter_AddRefs(context));
RefPtr<ID3D11DeviceContext4> context4;
auto hr = context->QueryInterface(__uuidof(ID3D11DeviceContext4),
getter_AddRefs(context4));
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Failed to get D3D11DeviceContext4: "
<< gfx::hexa(hr);
return false;
}
hr = context4->Signal(mSignalFence, mFenceValue + 1);
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Signal fence failed: " << gfx::hexa(hr);
return false;
}
mFenceValue++;
return true;
}
void FenceD3D11::Update(uint64_t aFenceValue) {
MOZ_ASSERT(!mDevice);
MOZ_ASSERT(!mSignalFence);
if (mFenceValue > aFenceValue) {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
return;
}
mFenceValue = aFenceValue;
}
bool FenceD3D11::Wait(ID3D11Device* aDevice) {
MOZ_ASSERT(aDevice);
if (!aDevice) {
return false;
}
// Skip wait if passed device is the same as signaling device.
if (mDevice == aDevice) {
return true;
}
RefPtr<ID3D11Fence> fence;
auto it = mWaitFenceMap.find(aDevice);
if (it == mWaitFenceMap.end()) {
RefPtr<ID3D11Device5> d3d11_5;
auto hr = aDevice->QueryInterface(__uuidof(ID3D11Device5),
getter_AddRefs(d3d11_5));
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Failed to get ID3D11Device5: " << gfx::hexa(hr);
return false;
}
hr = d3d11_5->OpenSharedFence(mHandle->GetHandle(), __uuidof(ID3D11Fence),
(void**)(ID3D11Fence**)getter_AddRefs(fence));
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Opening fence shared handle failed "
<< gfx::hexa(hr);
return false;
}
mWaitFenceMap.emplace(aDevice, fence);
} else {
fence = it->second;
}
if (!fence) {
MOZ_ASSERT_UNREACHABLE("unexpected to be called");
return false;
}
RefPtr<ID3D11DeviceContext> context;
aDevice->GetImmediateContext(getter_AddRefs(context));
RefPtr<ID3D11DeviceContext4> context4;
auto hr = context->QueryInterface(__uuidof(ID3D11DeviceContext4),
getter_AddRefs(context4));
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Failed to get D3D11DeviceContext4: "
<< gfx::hexa(hr);
return false;
}
hr = context4->Wait(fence, mFenceValue);
if (FAILED(hr)) {
gfxCriticalNoteOnce << "Failed to wait fence: " << gfx::hexa(hr);
return false;
}
return true;
}
} // namespace layers
} // namespace mozilla

View File

@ -1,86 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_GFX_FenceD3D11_H
#define MOZILLA_GFX_FenceD3D11_H
#include <unordered_map>
#include "mozilla/gfx/FileHandleWrapper.h"
#include "nsISupportsImpl.h"
struct ID3D11Device;
struct ID3D11Fence;
namespace mozilla {
namespace layers {
//
// A class for wrapping ID3D11Fence.
//
// The class can be used for singaling fence and waiting fence. When the class
// is created by Create(), it can be used for singaling fence and waiting
// fence. When the class is created by CreateFromHandle() it can be used only
// for waiting fence.
//
// There is a case that ID3D12Fence is used for fence signaling. In this case,
// the class can be used for waitng fence by using CreateFromHandle().
//
// IncrementAndSignal() is used for signaling fence. The fence will be updated
// after all previous work has completed.
//
// For waiting fence, Update() is used to update the target value of the
// waiting. Wait() is then used to wait for the fence.
//
class FenceD3D11 final {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FenceD3D11);
static RefPtr<FenceD3D11> Create(ID3D11Device* aDevice);
static RefPtr<FenceD3D11> CreateFromHandle(
RefPtr<gfx::FileHandleWrapper> aHandle);
// Check if ID3D11Device suppors ID3D11Fence creation.
static bool IsSupported(ID3D11Device* aDevice);
// Updates mSignalFence to incremented value after all previous work has
// completed. Used only when FenceD3D11 is created by FenceD3D11::Create().
bool IncrementAndSignal();
// Update FenceValue to the specified value.
// Used only when FenceD3D11 is created by FenceD3D11::CreateFromHandle().
void Update(uint64_t aFenceValue);
// Wait for fence until it reaches or exceeds mFenceValue.
bool Wait(ID3D11Device* aDevice);
uint64_t GetFenceValue() const { return mFenceValue; }
gfx::FenceInfo GetFenceInfo() const;
const RefPtr<gfx::FileHandleWrapper> mHandle;
protected:
explicit FenceD3D11(RefPtr<gfx::FileHandleWrapper>& aHandle);
~FenceD3D11();
// Device that is used for creating mSignalFence.
RefPtr<ID3D11Device> mDevice;
// Fence that is used for updating fence value.
// Valid only when created with FenceD3D11::Create().
RefPtr<ID3D11Fence> mSignalFence;
uint64_t mFenceValue = 0;
// Fences that are used for waiting.
// They are opened for each D3D11 device that the fence is waited on.
// XXX change to LRU cache
std::unordered_map<const ID3D11Device*, RefPtr<ID3D11Fence>> mWaitFenceMap;
};
} // namespace layers
} // namespace mozilla
#endif // MOZILLA_GFX_FenceD3D11_H

View File

@ -403,8 +403,7 @@ bool D3D11TextureData::SerializeSpecific(
}
*aOutDesc = SurfaceDescriptorD3D10(
(WindowsHandle)sharedHandle, mGpuProcessTextureId, mArrayIndex, mFormat,
mSize, mColorSpace, mColorRange, /* hasKeyedMutex */ mHasKeyedMutex,
/* fenceInfo */ Nothing());
mSize, mColorSpace, mColorRange, /* hasKeyedMutex */ mHasKeyedMutex);
return true;
}
@ -762,9 +761,6 @@ DXGITextureHostD3D11::DXGITextureHostD3D11(
mHandle((HANDLE)aDescriptor.handle()),
mFormat(aDescriptor.format()),
mHasKeyedMutex(aDescriptor.hasKeyedMutex()),
mAcquireFenceInfo(aDescriptor.fenceInfo().isSome()
? aDescriptor.fenceInfo().ref()
: gfx::FenceInfo()),
mColorSpace(aDescriptor.colorSpace()),
mColorRange(aDescriptor.colorRange()),
mIsLocked(false) {}
@ -916,7 +912,7 @@ void DXGITextureHostD3D11::CreateRenderTexture(
RefPtr<wr::RenderDXGITextureHost> texture = new wr::RenderDXGITextureHost(
mHandle, mGpuProcessTextureId, mArrayIndex, mFormat, mColorSpace,
mColorRange, mSize, mHasKeyedMutex, mAcquireFenceInfo);
mColorRange, mSize, mHasKeyedMutex);
if (mFlags & TextureFlags::SOFTWARE_DECODED_VIDEO) {
texture->SetIsSoftwareDecodedVideo();
}

View File

@ -23,11 +23,6 @@
#include "mozilla/layers/TextureHost.h"
namespace mozilla {
namespace gfx {
struct FenceInfo;
}
namespace gl {
class GLBlitHelper;
}
@ -389,7 +384,6 @@ class DXGITextureHostD3D11 : public TextureHost {
HANDLE mHandle;
gfx::SurfaceFormat mFormat;
bool mHasKeyedMutex;
gfx::FenceInfo mAcquireFenceInfo;
public:
const gfx::ColorSpace2 mColorSpace;

View File

@ -244,10 +244,10 @@ RefPtr<TextureHost> TextureHostWrapperD3D11::CreateFromBufferTexture(
auto colorSpace = ToColorSpace2(bufferTexture->GetYUVColorSpace());
auto descD3D10 = SurfaceDescriptorD3D10(
WindowsHandle(nullptr), Some(id),
/* arrayIndex */ 0, gfx::SurfaceFormat::NV12, size, colorSpace,
colorRange, /* hasKeyedMutex */ false, /* fenceInfo */ Nothing());
auto descD3D10 =
SurfaceDescriptorD3D10(WindowsHandle(nullptr), Some(id),
/* arrayIndex */ 0, gfx::SurfaceFormat::NV12, size,
colorSpace, colorRange, /* hasKeyedMutex */ false);
RefPtr<DXGITextureHostD3D11> textureHostD3D11 =
new DXGITextureHostD3D11(flags, descD3D10);

View File

@ -20,7 +20,6 @@ using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
using mozilla::gfx::Matrix4x4 from "mozilla/gfx/Matrix.h";
using mozilla::gfx::FenceInfo from "mozilla/gfx/FileHandleWrapper.h";
[MoveOnly] using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasic.h";
using gfxImageFormat from "gfxTypes.h";
using mozilla::layers::MaybeVideoBridgeSource from "mozilla/layers/VideoBridgeUtils.h";
@ -40,7 +39,6 @@ namespace layers {
ColorSpace2 colorSpace;
ColorRange colorRange;
bool hasKeyedMutex;
FenceInfo? fenceInfo;
};
[Comparable] struct SurfaceDescriptorDXGIYCbCr {

View File

@ -38,7 +38,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
EXPORTS.mozilla.layers += [
"d3d11/CompositorD3D11.h",
"d3d11/DeviceAttachmentsD3D11.h",
"d3d11/FenceD3D11.h",
"d3d11/GpuProcessD3D11TextureMap.h",
"d3d11/HelpersD3D11.h",
"d3d11/ShaderDefinitionsD3D11.h",
@ -46,7 +45,6 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
"d3d11/TextureHostWrapperD3D11.h",
]
UNIFIED_SOURCES += [
"d3d11/FenceD3D11.cpp",
"d3d11/GpuProcessD3D11TextureMap.cpp",
"d3d11/TextureD3D11.cpp",
"d3d11/TextureHostWrapperD3D11.cpp",

View File

@ -15,7 +15,6 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/gfx/CanvasManagerParent.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/layers/FenceD3D11.h"
#include "mozilla/layers/GpuProcessD3D11TextureMap.h"
#include "mozilla/layers/TextureD3D11.h"
@ -26,7 +25,7 @@ RenderDXGITextureHost::RenderDXGITextureHost(
HANDLE aHandle, Maybe<layers::GpuProcessTextureId>& aGpuProcessTextureId,
uint32_t aArrayIndex, gfx::SurfaceFormat aFormat,
gfx::ColorSpace2 aColorSpace, gfx::ColorRange aColorRange,
gfx::IntSize aSize, bool aHasKeyedMutex, gfx::FenceInfo& aAcquireFenceInfo)
gfx::IntSize aSize, bool aHasKeyedMutex)
: mHandle(aHandle),
mGpuProcessTextureId(aGpuProcessTextureId),
mArrayIndex(aArrayIndex),
@ -38,7 +37,6 @@ RenderDXGITextureHost::RenderDXGITextureHost(
mColorRange(aColorRange),
mSize(aSize),
mHasKeyedMutex(aHasKeyedMutex),
mAcquireFenceInfo(aAcquireFenceInfo),
mLocked(false) {
MOZ_COUNT_CTOR_INHERITED(RenderDXGITextureHost, RenderTextureHost);
MOZ_ASSERT((mFormat != gfx::SurfaceFormat::NV12 &&
@ -358,20 +356,6 @@ wr::WrExternalImage RenderDXGITextureHost::Lock(uint8_t aChannelIndex,
bool RenderDXGITextureHost::LockInternal() {
if (!mLocked) {
if (mAcquireFenceInfo.mFenceHandle) {
if (!mAcquireFence) {
mAcquireFence = layers::FenceD3D11::CreateFromHandle(
mAcquireFenceInfo.mFenceHandle);
}
if (mAcquireFence) {
MOZ_ASSERT(mAcquireFenceInfo.mFenceHandle == mAcquireFence->mHandle);
mAcquireFence->Update(mAcquireFenceInfo.mFenceValue);
RefPtr<ID3D11Device> d3d11Device =
gfx::DeviceManagerDx::Get()->GetCompositorDevice();
mAcquireFence->Wait(d3d11Device);
}
}
if (mKeyedMutex) {
HRESULT hr = mKeyedMutex->AcquireSync(0, 10000);
if (hr != S_OK) {
@ -457,8 +441,7 @@ gfx::IntSize RenderDXGITextureHost::GetSize(uint8_t aChannelIndex) const {
}
bool RenderDXGITextureHost::SyncObjectNeeded() {
return mGpuProcessTextureId.isNothing() &&
(!mHasKeyedMutex || !mAcquireFenceInfo.mFenceHandle);
return mGpuProcessTextureId.isNothing() && !mHasKeyedMutex;
}
RenderDXGIYCbCrTextureHost::RenderDXGIYCbCrTextureHost(

View File

@ -7,21 +7,16 @@
#ifndef MOZILLA_GFX_RENDERD3D11TEXTUREHOST_H
#define MOZILLA_GFX_RENDERD3D11TEXTUREHOST_H
#include <d3d11.h>
#include "GLTypes.h"
#include "mozilla/gfx/FileHandleWrapper.h"
#include "RenderTextureHostSWGL.h"
#include <d3d11.h>
struct ID3D11Texture2D;
struct IDXGIKeyedMutex;
namespace mozilla {
namespace layers {
class FenceD3D11;
} // namespace layers
namespace wr {
class RenderDXGITextureHost final : public RenderTextureHostSWGL {
@ -29,8 +24,7 @@ class RenderDXGITextureHost final : public RenderTextureHostSWGL {
RenderDXGITextureHost(
HANDLE aHandle, Maybe<layers::GpuProcessTextureId>& aGpuProcessTextureId,
uint32_t aArrayIndex, gfx::SurfaceFormat aFormat, gfx::ColorSpace2,
gfx::ColorRange aColorRange, gfx::IntSize aSize, bool aHasKeyedMutex,
gfx::FenceInfo& aAcquireFenceInfo);
gfx::ColorRange aColorRange, gfx::IntSize aSize, bool aHasKeyedMutex);
wr::WrExternalImage Lock(uint8_t aChannelIndex, gl::GLContext* aGL) override;
void Unlock() override;
@ -119,15 +113,12 @@ class RenderDXGITextureHost final : public RenderTextureHostSWGL {
bool mIsSoftwareDecodedVideo = false;
RefPtr<layers::FenceD3D11> mAcquireFence;
public:
const gfx::SurfaceFormat mFormat;
const gfx::ColorSpace2 mColorSpace;
const gfx::ColorRange mColorRange;
const gfx::IntSize mSize;
const bool mHasKeyedMutex;
const gfx::FenceInfo mAcquireFenceInfo;
private:
bool mLocked;