зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 45136034045a (bug 1285692)
This commit is contained in:
Родитель
80839e9ddd
Коммит
7b77101203
|
@ -245,6 +245,13 @@ SharedSurface_D3D11Interop::Create(const RefPtr<DXGLDevice>& dxgl,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<IDXGIKeyedMutex> keyedMutex;
|
||||
hr = textureD3D->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(keyedMutex));
|
||||
if (FAILED(hr)) {
|
||||
NS_WARNING("Failed to obtained keyed mutex from texture!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HANDLE sharedHandle;
|
||||
textureDXGI->GetSharedHandle(&sharedHandle);
|
||||
|
||||
|
@ -261,7 +268,7 @@ SharedSurface_D3D11Interop::Create(const RefPtr<DXGLDevice>& dxgl,
|
|||
|
||||
typedef SharedSurface_D3D11Interop ptrT;
|
||||
UniquePtr<ptrT> ret ( new ptrT(gl, size, hasAlpha, renderbufferGL, dxgl, objectWGL,
|
||||
textureD3D, sharedHandle) );
|
||||
textureD3D, sharedHandle, keyedMutex) );
|
||||
return Move(ret);
|
||||
}
|
||||
|
||||
|
@ -272,7 +279,8 @@ SharedSurface_D3D11Interop::SharedSurface_D3D11Interop(GLContext* gl,
|
|||
const RefPtr<DXGLDevice>& dxgl,
|
||||
HANDLE objectWGL,
|
||||
const RefPtr<ID3D11Texture2D>& textureD3D,
|
||||
HANDLE sharedHandle)
|
||||
HANDLE sharedHandle,
|
||||
const RefPtr<IDXGIKeyedMutex>& keyedMutex)
|
||||
: SharedSurface(SharedSurfaceType::DXGLInterop2,
|
||||
AttachmentType::GLRenderbuffer,
|
||||
gl,
|
||||
|
@ -285,11 +293,13 @@ SharedSurface_D3D11Interop::SharedSurface_D3D11Interop(GLContext* gl,
|
|||
, mTextureD3D(textureD3D)
|
||||
, mNeedsFinish(gfxPrefs::WebGLDXGLNeedsFinish())
|
||||
, mSharedHandle(sharedHandle)
|
||||
, mKeyedMutex(keyedMutex)
|
||||
, mLockedForGL(false)
|
||||
{ }
|
||||
|
||||
SharedSurface_D3D11Interop::~SharedSurface_D3D11Interop()
|
||||
{
|
||||
MOZ_ASSERT(!IsProducerAcquired());
|
||||
MOZ_ASSERT(!mLockedForGL);
|
||||
|
||||
if (!mDXGL->UnregisterObject(mObjectWGL)) {
|
||||
NS_WARNING("Failed to release a DXGL object, possibly leaking it.");
|
||||
|
@ -306,15 +316,39 @@ SharedSurface_D3D11Interop::~SharedSurface_D3D11Interop()
|
|||
void
|
||||
SharedSurface_D3D11Interop::ProducerAcquireImpl()
|
||||
{
|
||||
MOZ_ASSERT(!mLockedForGL);
|
||||
|
||||
if (mKeyedMutex) {
|
||||
const uint64_t keyValue = 0;
|
||||
const DWORD timeoutMs = 10000;
|
||||
HRESULT hr = mKeyedMutex->AcquireSync(keyValue, timeoutMs);
|
||||
if (hr == WAIT_TIMEOUT) {
|
||||
// Doubt we should do this? Maybe Wait for ever?
|
||||
MOZ_CRASH("GFX: d3d11Interop timeout");
|
||||
}
|
||||
}
|
||||
|
||||
// Now we have the mutex, we can lock for GL.
|
||||
MOZ_ALWAYS_TRUE(mDXGL->LockObject(mObjectWGL));
|
||||
|
||||
mLockedForGL = true;
|
||||
}
|
||||
|
||||
void
|
||||
SharedSurface_D3D11Interop::ProducerReleaseImpl()
|
||||
{
|
||||
MOZ_ASSERT(mLockedForGL);
|
||||
|
||||
mGL->fFlush();
|
||||
MOZ_ALWAYS_TRUE(mDXGL->UnlockObject(mObjectWGL));
|
||||
|
||||
mLockedForGL = false;
|
||||
|
||||
// Now we have unlocked for GL, we can release to consumer.
|
||||
if (mKeyedMutex) {
|
||||
mKeyedMutex->ReleaseSync(0);
|
||||
}
|
||||
|
||||
if (mNeedsFinish) {
|
||||
mGL->fFinish();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ public:
|
|||
const RefPtr<ID3D11Texture2D> mTextureD3D;
|
||||
const bool mNeedsFinish;
|
||||
|
||||
protected:
|
||||
RefPtr<IDXGIKeyedMutex> mKeyedMutex;
|
||||
bool mLockedForGL;
|
||||
|
||||
public:
|
||||
static UniquePtr<SharedSurface_D3D11Interop> Create(const RefPtr<DXGLDevice>& dxgl,
|
||||
GLContext* gl,
|
||||
|
@ -50,7 +54,8 @@ protected:
|
|||
const RefPtr<DXGLDevice>& dxgl,
|
||||
HANDLE objectWGL,
|
||||
const RefPtr<ID3D11Texture2D>& textureD3D,
|
||||
HANDLE sharedHandle);
|
||||
HANDLE sharedHandle,
|
||||
const RefPtr<IDXGIKeyedMutex>& keyedMutex);
|
||||
|
||||
public:
|
||||
virtual ~SharedSurface_D3D11Interop();
|
||||
|
|
Загрузка…
Ссылка в новой задаче