зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1465306 - Make D3D11YCbCrRecycleAllocator handle device reset r=nical
This commit is contained in:
Родитель
e76059bf98
Коммит
b0fbe12bd3
|
@ -7,6 +7,7 @@
|
|||
#include "D3D11YCbCrImage.h"
|
||||
#include "YCbCrUtils.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/gfx/DeviceManagerDx.h"
|
||||
#include "mozilla/layers/CompositableClient.h"
|
||||
#include "mozilla/layers/CompositableForwarder.h"
|
||||
#include "mozilla/layers/TextureD3D11.h"
|
||||
|
@ -56,8 +57,13 @@ D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
|
|||
return false;
|
||||
}
|
||||
|
||||
RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetImageDevice();
|
||||
if (!device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
DXGIYCbCrTextureAllocationHelper helper(aData, TextureFlags::DEFAULT, allocator->GetDevice());
|
||||
DXGIYCbCrTextureAllocationHelper helper(aData, TextureFlags::DEFAULT, device);
|
||||
mTextureClient = allocator->CreateOrRecycle(helper);
|
||||
}
|
||||
|
||||
|
@ -73,7 +79,7 @@ D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
|
|||
ID3D11Texture2D* textureCr = data->GetD3D11Texture(2);
|
||||
|
||||
RefPtr<ID3D10Multithread> mt;
|
||||
HRESULT hr = allocator->GetDevice()->QueryInterface(
|
||||
HRESULT hr = device->QueryInterface(
|
||||
(ID3D10Multithread**)getter_AddRefs(mt));
|
||||
|
||||
if (FAILED(hr) || !mt) {
|
||||
|
@ -89,7 +95,7 @@ D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
|
|||
D3D11MTAutoEnter mtAutoEnter(mt.forget());
|
||||
|
||||
RefPtr<ID3D11DeviceContext> ctx;
|
||||
allocator->GetDevice()->GetImmediateContext(getter_AddRefs(ctx));
|
||||
device->GetImmediateContext(getter_AddRefs(ctx));
|
||||
if (!ctx) {
|
||||
gfxCriticalError() << "Failed to get immediate context.";
|
||||
return false;
|
||||
|
@ -323,6 +329,14 @@ DXGIYCbCrTextureAllocationHelper::IsCompatible(TextureClient* aTextureClient)
|
|||
dxgiData->GetYUVColorSpace() != mData.mYUVColorSpace) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<ID3D11Texture2D> texY = dxgiData->GetD3D11Texture(0);
|
||||
RefPtr<ID3D11Device> device;
|
||||
texY->GetDevice(getter_AddRefs(device));
|
||||
if (!device || device != gfx::DeviceManagerDx::Get()->GetImageDevice()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,14 +25,11 @@ class DXGIYCbCrTextureData;
|
|||
class D3D11YCbCrRecycleAllocator : public TextureClientRecycleAllocator
|
||||
{
|
||||
public:
|
||||
explicit D3D11YCbCrRecycleAllocator(KnowsCompositor* aAllocator,
|
||||
ID3D11Device* aDevice)
|
||||
explicit D3D11YCbCrRecycleAllocator(KnowsCompositor* aAllocator)
|
||||
: TextureClientRecycleAllocator(aAllocator)
|
||||
, mDevice(aDevice)
|
||||
{
|
||||
}
|
||||
|
||||
ID3D11Device* GetDevice() const { return mDevice; }
|
||||
KnowsCompositor* GetAllocator() const { return mSurfaceAllocator; }
|
||||
|
||||
protected:
|
||||
|
@ -42,8 +39,6 @@ protected:
|
|||
BackendSelector aSelector,
|
||||
TextureFlags aTextureFlags,
|
||||
TextureAllocationFlags aAllocFlags) override;
|
||||
|
||||
RefPtr<ID3D11Device> mDevice;
|
||||
};
|
||||
|
||||
class D3D11YCbCrImage : public Image
|
||||
|
|
|
@ -472,26 +472,13 @@ ImageContainer::GetD3D11YCbCrRecycleAllocator(KnowsCompositor* aAllocator)
|
|||
return mD3D11YCbCrRecycleAllocator;
|
||||
}
|
||||
|
||||
RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetContentDevice();
|
||||
if (!device) {
|
||||
device = gfx::DeviceManagerDx::Get()->GetCompositorDevice();
|
||||
}
|
||||
|
||||
if (!device || !aAllocator->SupportsD3D11()) {
|
||||
if (!aAllocator->SupportsD3D11() ||
|
||||
!gfx::DeviceManagerDx::Get()->GetImageDevice()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ID3D10Multithread> multi;
|
||||
HRESULT hr =
|
||||
device->QueryInterface((ID3D10Multithread**)getter_AddRefs(multi));
|
||||
if (FAILED(hr) || !multi) {
|
||||
gfxWarning() << "Multithread safety interface not supported. " << hr;
|
||||
return nullptr;
|
||||
}
|
||||
multi->SetMultithreadProtected(TRUE);
|
||||
|
||||
mD3D11YCbCrRecycleAllocator =
|
||||
new D3D11YCbCrRecycleAllocator(aAllocator, device);
|
||||
new D3D11YCbCrRecycleAllocator(aAllocator);
|
||||
return mD3D11YCbCrRecycleAllocator;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -867,6 +867,7 @@ DeviceManagerDx::ResetDevices()
|
|||
mMLGDevice = nullptr;
|
||||
mCompositorDevice = nullptr;
|
||||
mContentDevice = nullptr;
|
||||
mImageDevice = nullptr;
|
||||
mDeviceStatus = Nothing();
|
||||
mDeviceResetReason = Nothing();
|
||||
Factory::SetDirect3D11Device(nullptr);
|
||||
|
@ -1053,6 +1054,37 @@ DeviceManagerDx::GetContentDevice()
|
|||
return mContentDevice;
|
||||
}
|
||||
|
||||
RefPtr<ID3D11Device>
|
||||
DeviceManagerDx::GetImageDevice()
|
||||
{
|
||||
MutexAutoLock lock(mDeviceLock);
|
||||
if (mImageDevice) {
|
||||
return mImageDevice;
|
||||
}
|
||||
|
||||
RefPtr<ID3D11Device> device = mContentDevice;
|
||||
if (!device) {
|
||||
device = mCompositorDevice;
|
||||
}
|
||||
|
||||
if (!device) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ID3D10Multithread> multi;
|
||||
HRESULT hr =
|
||||
device->QueryInterface((ID3D10Multithread**)getter_AddRefs(multi));
|
||||
if (FAILED(hr) || !multi) {
|
||||
gfxWarning() << "Multithread safety interface not supported. " << hr;
|
||||
return nullptr;
|
||||
}
|
||||
multi->SetMultithreadProtected(TRUE);
|
||||
|
||||
mImageDevice = device;
|
||||
|
||||
return mImageDevice;
|
||||
}
|
||||
|
||||
RefPtr<ID3D11Device>
|
||||
DeviceManagerDx::GetVRDevice()
|
||||
{
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
|
||||
RefPtr<ID3D11Device> GetCompositorDevice();
|
||||
RefPtr<ID3D11Device> GetContentDevice();
|
||||
RefPtr<ID3D11Device> GetImageDevice();
|
||||
RefPtr<IDCompositionDevice> GetDirectCompositionDevice();
|
||||
RefPtr<ID3D11Device> GetVRDevice();
|
||||
RefPtr<ID3D11Device> CreateDecoderDevice();
|
||||
|
@ -163,6 +164,7 @@ private:
|
|||
RefPtr<IDXGIAdapter1> mAdapter;
|
||||
RefPtr<ID3D11Device> mCompositorDevice;
|
||||
RefPtr<ID3D11Device> mContentDevice;
|
||||
RefPtr<ID3D11Device> mImageDevice;
|
||||
RefPtr<ID3D11Device> mVRDevice;
|
||||
RefPtr<ID3D11Device> mDecoderDevice;
|
||||
RefPtr<IDCompositionDevice> mDirectCompositionDevice;
|
||||
|
|
Загрузка…
Ссылка в новой задаче