Bug 1348320: Use UpdateSubResource on crashy intel device/OS version combinations. r=jrmuizel

MozReview-Commit-ID: EdDn4qy1ajP

--HG--
extra : rebase_source : fadec88a9586bc40e44d2f91aae5c9c5f8f59a5c
This commit is contained in:
Bas Schouten 2017-05-01 01:11:24 +00:00
parent 9b3fb791ae
commit 76892628f3
3 changed files with 31 additions and 1 deletions

View File

@ -428,6 +428,8 @@ D3D11TextureData::Create(IntSize aSize, SurfaceFormat aFormat, SourceSurface* aS
D3D11_SUBRESOURCE_DATA uploadData;
D3D11_SUBRESOURCE_DATA* uploadDataPtr = nullptr;
RefPtr<DataSourceSurface> srcSurf;
DataSourceSurface::MappedSurface sourceMap;
if (aSurface) {
srcSurf = aSurface->GetDataSurface();
@ -436,12 +438,13 @@ D3D11TextureData::Create(IntSize aSize, SurfaceFormat aFormat, SourceSurface* aS
return nullptr;
}
DataSourceSurface::MappedSurface sourceMap;
if (!srcSurf->Map(DataSourceSurface::READ, &sourceMap)) {
gfxCriticalError() << "Failed to map source surface for D3D11TextureData::Create";
return nullptr;
}
}
if (srcSurf && !DeviceManagerDx::Get()->HasCrashyInitData()) {
uploadData.pSysMem = sourceMap.mData;
uploadData.SysMemPitch = sourceMap.mStride;
uploadData.SysMemSlicePitch = 0; // unused
@ -451,6 +454,18 @@ D3D11TextureData::Create(IntSize aSize, SurfaceFormat aFormat, SourceSurface* aS
RefPtr<ID3D11Texture2D> texture11;
HRESULT hr = device->CreateTexture2D(&newDesc, uploadDataPtr, getter_AddRefs(texture11));
if (srcSurf && DeviceManagerDx::Get()->HasCrashyInitData()) {
D3D11_BOX box;
box.front = box.top = box.left = 0;
box.back = 1;
box.right = aSize.width;
box.bottom = aSize.height;
RefPtr<ID3D11DeviceContext> ctx;
device->GetImmediateContext(getter_AddRefs(ctx));
ctx->UpdateSubresource(texture11, 0, &box, sourceMap.mData, sourceMap.mStride, 0);
}
if (srcSurf) {
srcSurf->Unmap();
}

View File

@ -823,6 +823,17 @@ DeviceManagerDx::CanInitializeKeyedMutexTextures()
return (mDeviceStatus->adapter().VendorId != 0x8086 || gfxPrefs::Direct3D11AllowIntelMutex());
}
bool
DeviceManagerDx::HasCrashyInitData()
{
MutexAutoLock lock(mDeviceLock);
if (!mDeviceStatus) {
return false;
}
return (mDeviceStatus->adapter().VendorId == 0x8086 && !IsWin10OrLater());
}
bool
DeviceManagerDx::CheckRemotePresentSupport()
{

View File

@ -70,6 +70,10 @@ public:
// need to avoid it.
bool CanInitializeKeyedMutexTextures();
// Intel devices on older windows versions seem to occasionally have
// stability issues when supplying InitData to CreateTexture2D.
bool HasCrashyInitData();
bool CreateCompositorDevices();
void CreateContentDevices();