mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 1352016 - P3. Check if NV12 rendering is usable when allocating D3D11 surface. r=mattwoodrow
MozReview-Commit-ID: EgA6lEeIyBj --HG-- extra : rebase_source : cb3c4e5e864085fe76514096d6d9aa9b49d0a334
This commit is contained in:
parent
21b23b41d6
commit
66188b449c
@ -22,6 +22,7 @@ struct D3D11DeviceStatus
|
||||
uint32_t featureLevel;
|
||||
DxgiAdapterDesc adapter;
|
||||
int32_t sequenceNumber;
|
||||
bool useNV12;
|
||||
};
|
||||
|
||||
struct DevicePrefs
|
||||
|
@ -34,7 +34,8 @@ bool
|
||||
D3D11ShareHandleImage::AllocateTexture(D3D11RecycleAllocator* aAllocator, ID3D11Device* aDevice)
|
||||
{
|
||||
if (aAllocator) {
|
||||
if (gfxPrefs::PDMWMFUseNV12Format()) {
|
||||
if (gfxPrefs::PDMWMFUseNV12Format() &&
|
||||
gfx::DeviceManagerDx::Get()->CanUseNV12()) {
|
||||
mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::NV12, mSize);
|
||||
} else {
|
||||
mTextureClient = aAllocator->CreateOrRecycleClient(gfx::SurfaceFormat::B8G8R8A8, mSize);
|
||||
|
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "D3D11Checks.h"
|
||||
#include "DXVA2Manager.h"
|
||||
#include "gfxConfig.h"
|
||||
#include "GfxDriverInfo.h"
|
||||
#include "gfxPrefs.h"
|
||||
@ -409,5 +410,23 @@ D3D11Checks::DoesRemotePresentWork(IDXGIAdapter* adapter)
|
||||
return SUCCEEDED(hr) && check;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
D3D11Checks::DoesNV12Work(ID3D11Device* device)
|
||||
{
|
||||
DXGI_ADAPTER_DESC desc;
|
||||
PodZero(&desc);
|
||||
if (!GetDxgiDesc(device, &desc)) {
|
||||
// Failed to retrieve device information, assume it doesn't work
|
||||
return false;
|
||||
}
|
||||
|
||||
nsString version;
|
||||
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
||||
if (gfxInfo) {
|
||||
gfxInfo->GetAdapterDriverVersion(version);
|
||||
}
|
||||
return DXVA2Manager::IsNV12Supported(desc.VendorId, desc.DeviceId, version);
|
||||
}
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mozilla
|
||||
|
@ -17,11 +17,12 @@ struct D3D11Checks
|
||||
{
|
||||
static bool DoesRenderTargetViewNeedRecreating(ID3D11Device* aDevice);
|
||||
static bool DoesDeviceWork();
|
||||
static bool DoesTextureSharingWork(ID3D11Device *device);
|
||||
static bool DoesAlphaTextureSharingWork(ID3D11Device *device);
|
||||
static bool DoesTextureSharingWork(ID3D11Device* device);
|
||||
static bool DoesAlphaTextureSharingWork(ID3D11Device* device);
|
||||
static void WarnOnAdapterMismatch(ID3D11Device* device);
|
||||
static bool GetDxgiDesc(ID3D11Device* device, DXGI_ADAPTER_DESC* out);
|
||||
static bool DoesRemotePresentWork(IDXGIAdapter* adapter);
|
||||
static bool DoesNV12Work(ID3D11Device* device);
|
||||
};
|
||||
|
||||
} // namespace gfx
|
||||
|
@ -395,6 +395,7 @@ DeviceManagerDx::CreateCompositorDevice(FeatureState& d3d11)
|
||||
}
|
||||
|
||||
uint32_t featureLevel = device->GetFeatureLevel();
|
||||
bool useNV12 = D3D11Checks::DoesNV12Work(device);
|
||||
{
|
||||
MutexAutoLock lock(mDeviceLock);
|
||||
mCompositorDevice = device;
|
||||
@ -405,7 +406,8 @@ DeviceManagerDx::CreateCompositorDevice(FeatureState& d3d11)
|
||||
textureSharingWorks,
|
||||
featureLevel,
|
||||
DxgiAdapterDesc::From(desc),
|
||||
sequenceNumber));
|
||||
sequenceNumber,
|
||||
useNV12));
|
||||
}
|
||||
mCompositorDevice->SetExceptionMode(0);
|
||||
}
|
||||
@ -501,6 +503,8 @@ DeviceManagerDx::CreateWARPCompositorDevice()
|
||||
PodZero(&nullAdapter);
|
||||
|
||||
int featureLevel = device->GetFeatureLevel();
|
||||
|
||||
bool useNV12 = D3D11Checks::DoesNV12Work(device);
|
||||
{
|
||||
MutexAutoLock lock(mDeviceLock);
|
||||
mCompositorDevice = device;
|
||||
@ -511,7 +515,8 @@ DeviceManagerDx::CreateWARPCompositorDevice()
|
||||
textureSharingWorks,
|
||||
featureLevel,
|
||||
nullAdapter,
|
||||
sequenceNumber));
|
||||
sequenceNumber,
|
||||
useNV12));
|
||||
}
|
||||
mCompositorDevice->SetExceptionMode(0);
|
||||
|
||||
@ -1001,6 +1006,16 @@ DeviceManagerDx::IsWARP()
|
||||
return mDeviceStatus->isWARP();
|
||||
}
|
||||
|
||||
bool
|
||||
DeviceManagerDx::CanUseNV12()
|
||||
{
|
||||
MutexAutoLock lock(mDeviceLock);
|
||||
if (!mDeviceStatus) {
|
||||
return false;
|
||||
}
|
||||
return mDeviceStatus->useNV12();
|
||||
}
|
||||
|
||||
void
|
||||
DeviceManagerDx::InitializeDirectDraw()
|
||||
{
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
unsigned GetCompositorFeatureLevel() const;
|
||||
bool TextureSharingWorks();
|
||||
bool IsWARP();
|
||||
bool CanUseNV12();
|
||||
|
||||
// Returns true if we can create a texture with
|
||||
// D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX and also
|
||||
|
Loading…
x
Reference in New Issue
Block a user