/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- * 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/. */
usingnamespace mozilla::widget; using mozilla::layers::AutoTextureLock;
/* static */ bool D3D11Checks::DoesRenderTargetViewNeedRecreating(ID3D11Device* aDevice) { bool result = false; // CreateTexture2D is known to crash on lower feature levels, see bugs // 1170211 and 1089413. if (aDevice->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0) { returntrue;
}
RefPtr<ID3D11DeviceContext> deviceContext;
aDevice->GetImmediateContext(getter_AddRefs(deviceContext)); int backbufferWidth = 32; int backbufferHeight = 32;
RefPtr<ID3D11Texture2D> offscreenTexture;
RefPtr<IDXGIKeyedMutex> keyedMutex;
// XXX on some drivers resultColor will not have changed to // match the clear if (resultColor != 0xffffff00) {
gfxCriticalNote << "RenderTargetViewNeedsRecreating";
result = true;
}
} return result;
}
if (StaticPrefs::gfx_direct2d_force_enabled_AtStartup() ||
gfxConfig::IsForcedOnByUser(Feature::HW_COMPOSITING)) {
result = true; returntrue;
}
if (GetModuleHandleW(L"igd10umd32.dll")) { constwchar_t* checkModules[] = {L"dlumd32.dll", L"dlumd11.dll",
L"dlumd10.dll"}; for (size_t i = 0; i < PR_ARRAY_SIZE(checkModules); i += 1) { if (GetModuleHandleW(checkModules[i])) {
nsString displayLinkModuleVersionString;
gfxWindowsPlatform::GetDLLVersion(checkModules[i],
displayLinkModuleVersionString);
uint64_t displayLinkModuleVersion; if (!ParseDriverVersion(displayLinkModuleVersionString,
&displayLinkModuleVersion)) {
gfxCriticalError()
<< "DisplayLink: could not parse version " << checkModules[i]; returnfalse;
} if (displayLinkModuleVersion <= V(8, 6, 1, 36484)) {
NS_ConvertUTF16toUTF8 version(displayLinkModuleVersionString);
gfxCriticalError(CriticalLog::DefaultOptions(false))
<< "DisplayLink: too old version " << version.get(); returnfalse;
}
}
}
}
result = true; returntrue;
}
staticbool TryCreateTexture2D(ID3D11Device* device, D3D11_TEXTURE2D_DESC* desc,
D3D11_SUBRESOURCE_DATA* data,
RefPtr<ID3D11Texture2D>& texture) { // Older Intel driver version (see bug 1221348 for version #s) crash when // creating a texture with shared keyed mutex and data.
MOZ_SEH_TRY { return !FAILED(
device->CreateTexture2D(desc, data, getter_AddRefs(texture)));
}
MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { // For now we want to aggregrate all the crash signature to a known crash.
gfxDevCrash(LogReason::TextureCreation)
<< "Crash creating texture. See bug 1221348."; returnfalse;
}
}
// See bug 1083071. On some drivers, Direct3D 11 CreateShaderResourceView fails // with E_OUTOFMEMORY. staticbool DoesTextureSharingWorkInternal(ID3D11Device* device,
DXGI_FORMAT format, UINT bindflags) { // CreateTexture2D is known to crash on lower feature levels, see bugs // 1170211 and 1089413. if (device->GetFeatureLevel() < D3D_FEATURE_LEVEL_10_0) { returnfalse;
}
if (StaticPrefs::gfx_direct2d_force_enabled_AtStartup() ||
gfxConfig::IsForcedOnByUser(Feature::HW_COMPOSITING)) { returntrue;
}
if (GetModuleHandleW(L"atidxx32.dll")) {
nsCOMPtr<nsIGfxInfo> gfxInfo = components::GfxInfo::Service(); if (gfxInfo) {
nsString vendorID, vendorID2;
gfxInfo->GetAdapterVendorID(vendorID);
gfxInfo->GetAdapterVendorID2(vendorID2); if (vendorID.EqualsLiteral("0x8086") && vendorID2.IsEmpty()) { if (!StaticPrefs::layers_amd_switchable_gfx_enabled_AtStartup()) { returnfalse;
}
gfxCriticalError(CriticalLog::DefaultOptions(false))
<< "PossiblyBrokenSurfaceSharing_UnexpectedAMDGPU";
}
}
}
uint32_t color[texture_size * texture_size]; for (size_t i = 0; i < sizeof(color) / sizeof(color[0]); i++) {
color[i] = 0xff00ffff;
} // XXX If we pass the data directly at texture creation time we // get a crash on Intel 8.5.10.[18xx-1994] drivers. // We can work around this issue by doing UpdateSubresource. if (!TryCreateTexture2D(device, &desc, nullptr, texture)) {
gfxCriticalNote << "DoesD3D11TextureSharingWork_TryCreateTextureFailure"; returnfalse;
}
RefPtr<IDXGIKeyedMutex> sourceSharedMutex;
texture->QueryInterface(__uuidof(IDXGIKeyedMutex),
(void**)getter_AddRefs(sourceSharedMutex)); if (FAILED(sourceSharedMutex->AcquireSync(0, 30 * 1000))) {
gfxCriticalError() << "DoesD3D11TextureSharingWork_SourceMutexTimeout"; // only wait for 30 seconds returnfalse;
}
auto handle = ipc::FileDescriptor(UniqueFileHandle(sharedHandle));
RefPtr<ID3D11Device1> device1;
device->QueryInterface((ID3D11Device1**)getter_AddRefs(device1)); if (!device1) {
gfxCriticalNoteOnce << "Failed to get ID3D11Device1"; returnfalse;
}
RefPtr<ID3D11Resource> sharedResource;
RefPtr<ID3D11Texture2D> sharedTexture; auto raw = handle.TakePlatformHandle(); if (FAILED(device1->OpenSharedResource1(raw.get(), __uuidof(ID3D11Resource),
getter_AddRefs(sharedResource)))) {
gfxCriticalError(CriticalLog::DefaultOptions(false))
<< "OpenSharedResource failed for format " << format; returnfalse;
}
if (FAILED(sharedResource->QueryInterface(__uuidof(ID3D11Texture2D),
getter_AddRefs(sharedTexture)))) {
gfxCriticalError() << "DoesD3D11TextureSharingWork_GetSharedTextureFailure"; returnfalse;
}
// check that the color we put in is the color we get out if (resultColor != color[0]) { // Shared surfaces seem to be broken on dual AMD & Intel HW when using the // AMD GPU
gfxCriticalNote << "DoesD3D11TextureSharingWork_ColorMismatch"; returnfalse;
}
RefPtr<ID3D11ShaderResourceView> sharedView;
// This if(FAILED()) is the one that actually fails on systems affected by bug // 1083071. if (FAILED(device->CreateShaderResourceView(sharedTexture, NULL,
getter_AddRefs(sharedView)))) {
gfxCriticalNote << "CreateShaderResourceView failed for format" << format; returnfalse;
}
/* static */ bool D3D11Checks::DoesRemotePresentWork(IDXGIAdapter* adapter) { // Remote presentation was added in DXGI 1.2, for Windows 8 and the Platform // Update to Windows 7.
RefPtr<IDXGIAdapter2> check;
HRESULT hr =
adapter->QueryInterface(__uuidof(IDXGIAdapter2), getter_AddRefs(check)); return SUCCEEDED(hr) && check;
}
/* static */ D3D11Checks::VideoFormatOptionSet D3D11Checks::FormatOptions(
ID3D11Device* device) { auto doesNV12Work = [&]() { if (gfxVars::DXNV12Blocked()) { returnfalse;
}
DXGI_ADAPTER_DESC desc;
PodZero(&desc); if (!GetDxgiDesc(device, &desc)) { // Failed to retrieve device information, assume it doesn't work returnfalse;
}
VideoFormatOptionSet options; if (!doesNV12Work()) { // If the device doesn't support NV12, there's really no point testing for // P010 and P016. return options;
}
options += VideoFormatOption::NV12; if (doesP010Work()) {
options += VideoFormatOption::P010;
} if (doesP016Work()) {
options += VideoFormatOption::P016;
} return options;
}
} // namespace gfx
} // namespace mozilla
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.