Bug 1011367: Add Direct3D 11 Gfx feature. r=bjacob

This commit is contained in:
Bas Schouten 2014-05-16 18:16:21 +02:00
parent 4fab0c05e9
commit 768b5f27ae
5 changed files with 30 additions and 0 deletions

View File

@ -106,6 +106,11 @@ CompositorD3D11::~CompositorD3D11()
bool
CompositorD3D11::Initialize()
{
if (!gfxPlatform::CanUseDirect3D11()) {
NS_WARNING("Direct3D 11-accelerated layers are not supported on this system.");
return false;
}
HRESULT hr;
mDevice = gfxWindowsPlatform::GetPlatform()->GetD3D11Device();

View File

@ -1998,6 +1998,7 @@ gfxPlatform::OptimalFormatForContent(gfxContentType aContent)
* not have any effect until we restart.
*/
static bool sLayersSupportsD3D9 = false;
static bool sLayersSupportsD3D11 = false;
static bool sBufferRotationCheckPref = true;
static bool sPrefBrowserTabsRemoteAutostart = false;
@ -2019,6 +2020,7 @@ InitLayersAccelerationPrefs()
#ifdef XP_WIN
if (gfxPrefs::LayersAccelerationForceEnabled()) {
sLayersSupportsD3D9 = true;
sLayersSupportsD3D11 = true;
} else {
nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
if (gfxInfo) {
@ -2028,6 +2030,11 @@ InitLayersAccelerationPrefs()
sLayersSupportsD3D9 = true;
}
}
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS, &status))) {
if (status == nsIGfxInfo::FEATURE_NO_INFO) {
sLayersSupportsD3D11 = true;
}
}
}
}
#endif
@ -2066,6 +2073,15 @@ gfxPlatform::CanUseDirect3D9()
return sLayersSupportsD3D9;
}
bool
gfxPlatform::CanUseDirect3D11()
{
// this function is called from the compositor thread, so it is not
// safe to init the prefs etc. from here.
MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
return sLayersSupportsD3D11;
}
bool
gfxPlatform::BufferRotationEnabled()
{

View File

@ -468,6 +468,7 @@ public:
*/
static bool GetPrefLayersOffMainThreadCompositionEnabled();
static bool CanUseDirect3D9();
static bool CanUseDirect3D11();
static bool OffMainThreadCompositionRequired();

View File

@ -81,6 +81,8 @@ interface nsIGfxInfo : nsISupports
const long FEATURE_STAGEFRIGHT = 9;
/* Whether Webrtc Hardware acceleration is supported */
const long FEATURE_WEBRTC_HW_ACCELERATION = 10;
/* Whether Direct3D 11 is supported for layers. */
const long FEATURE_DIRECT3D_11_LAYERS = 11;
/*
* A set of return values from GetFeatureStatus

View File

@ -112,6 +112,9 @@ GetPrefNameForFeature(int32_t aFeature)
case nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS:
name = BLACKLIST_PREF_BRANCH "layers.direct3d10-1";
break;
case nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS:
name = BLACKLIST_PREF_BRANCH "layers.direct3d11";
break;
case nsIGfxInfo::FEATURE_OPENGL_LAYERS:
name = BLACKLIST_PREF_BRANCH "layers.opengl";
break;
@ -270,6 +273,8 @@ BlacklistFeatureToGfxFeature(const nsAString& aFeature)
return nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS;
else if (aFeature == NS_LITERAL_STRING("DIRECT3D_10_1_LAYERS"))
return nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS;
else if (aFeature == NS_LITERAL_STRING("DIRECT3D_11_LAYERS"))
return nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS;
else if (aFeature == NS_LITERAL_STRING("OPENGL_LAYERS"))
return nsIGfxInfo::FEATURE_OPENGL_LAYERS;
else if (aFeature == NS_LITERAL_STRING("WEBGL_OPENGL"))
@ -804,6 +809,7 @@ GfxInfoBase::EvaluateDownloadedBlacklist(nsTArray<GfxDriverInfo>& aDriverInfo)
nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS,
nsIGfxInfo::FEATURE_DIRECT3D_10_LAYERS,
nsIGfxInfo::FEATURE_DIRECT3D_10_1_LAYERS,
nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS,
nsIGfxInfo::FEATURE_OPENGL_LAYERS,
nsIGfxInfo::FEATURE_WEBGL_OPENGL,
nsIGfxInfo::FEATURE_WEBGL_ANGLE,