Backed out changeset 8a39622aa24a (bug 1087270) for bustage

This commit is contained in:
Carsten "Tomcat" Book 2014-10-23 13:12:16 +02:00
Родитель 340b8a427e
Коммит 8e79075d89
2 изменённых файлов: 48 добавлений и 102 удалений

Просмотреть файл

@ -414,8 +414,9 @@ CompositorD3D11::CreateRenderTarget(const gfx::IntRect& aRect,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
RefPtr<ID3D11Texture2D> texture;
HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture));
if (Failed(hr) || !texture) {
mDevice->CreateTexture2D(&desc, nullptr, byRef(texture));
NS_ASSERTION(texture, "Could not create texture");
if (!texture) {
return nullptr;
}
@ -446,9 +447,9 @@ CompositorD3D11::CreateRenderTargetFromSource(const gfx::IntRect &aRect,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
RefPtr<ID3D11Texture2D> texture;
HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture));
mDevice->CreateTexture2D(&desc, nullptr, byRef(texture));
NS_ASSERTION(texture, "Could not create texture");
if (Failed(hr) || !texture) {
if (!texture) {
return nullptr;
}
@ -600,12 +601,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
}
RefPtr<ID3D11ShaderResourceView> view;
HRESULT hr = mDevice->CreateShaderResourceView(source->GetD3D11Texture(), nullptr, byRef(view));
if (Failed(hr)) {
// XXX - There's a chance we won't be able to render anything, should we
// just crash release builds?
return;
}
mDevice->CreateShaderResourceView(source->GetD3D11Texture(), nullptr, byRef(view));
ID3D11ShaderResourceView* srView = view;
mContext->PSSetShaderResources(3, 1, &srView);
@ -658,12 +654,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, texturedEffect->mTexture->GetFormat());
RefPtr<ID3D11ShaderResourceView> view;
HRESULT hr = mDevice->CreateShaderResourceView(source->GetD3D11Texture(), nullptr, byRef(view));
if (Failed(hr)) {
// XXX - There's a chance we won't be able to render anything, should we
// just crash release builds?
return;
}
mDevice->CreateShaderResourceView(source->GetD3D11Texture(), nullptr, byRef(view));
ID3D11ShaderResourceView* srView = view;
mContext->PSSetShaderResources(0, 1, &srView);
@ -695,7 +686,7 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
SetPSForEffect(aEffectChain.mPrimaryEffect, maskType, ycbcrEffect->mTexture->GetFormat());
if (!source->GetSubSource(Y) || !source->GetSubSource(Cb) || !source->GetSubSource(Cr)) {
// This can happen if we Failed to upload the textures, most likely
// This can happen if we failed to upload the textures, most likely
// because of unsupported dimensions (we don't tile YCbCr textures).
return;
}
@ -704,27 +695,13 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
TextureSourceD3D11* sourceCb = source->GetSubSource(Cb)->AsSourceD3D11();
TextureSourceD3D11* sourceCr = source->GetSubSource(Cr)->AsSourceD3D11();
HRESULT hr;
RefPtr<ID3D11ShaderResourceView> views[3];
hr = mDevice->CreateShaderResourceView(sourceY->GetD3D11Texture(),
mDevice->CreateShaderResourceView(sourceY->GetD3D11Texture(),
nullptr, byRef(views[0]));
if (Failed(hr)) {
return;
}
hr = mDevice->CreateShaderResourceView(sourceCb->GetD3D11Texture(),
mDevice->CreateShaderResourceView(sourceCb->GetD3D11Texture(),
nullptr, byRef(views[1]));
if (Failed(hr)) {
return;
}
hr = mDevice->CreateShaderResourceView(sourceCr->GetD3D11Texture(),
mDevice->CreateShaderResourceView(sourceCr->GetD3D11Texture(),
nullptr, byRef(views[2]));
if (Failed(hr)) {
return;
}
ID3D11ShaderResourceView* srViews[3] = { views[0], views[1], views[2] };
mContext->PSSetShaderResources(0, 3, srViews);
@ -751,17 +728,8 @@ CompositorD3D11::DrawQuad(const gfx::Rect& aRect,
mVSConstants.textureCoords = effectComponentAlpha->mTextureCoords;
RefPtr<ID3D11ShaderResourceView> views[2];
HRESULT hr;
mDevice->CreateShaderResourceView(sourceOnBlack->GetD3D11Texture(), nullptr, byRef(views[0]));
if (Failed(hr)) {
return;
}
mDevice->CreateShaderResourceView(sourceOnWhite->GetD3D11Texture(), nullptr, byRef(views[1]));
if (Failed(hr)) {
return;
}
ID3D11ShaderResourceView* srViews[2] = { views[0], views[1] };
mContext->PSSetShaderResources(0, 2, srViews);
@ -937,7 +905,7 @@ CompositorD3D11::UpdateRenderTarget()
nsRefPtr<ID3D11Texture2D> backBuf;
hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)backBuf.StartAssignment());
if (Failed(hr)) {
if (FAILED(hr)) {
return;
}
@ -1004,6 +972,29 @@ CompositorD3D11::CreateShaders()
return true;
}
static
bool ShouldRecoverFromMapFailure(HRESULT hr, ID3D11Device* device)
{
// XXX - it would be nice to use gfxCriticalError, but it needs to
// be made to work off the main thread first.
if (SUCCEEDED(hr)) {
return true;
}
if (hr == DXGI_ERROR_DEVICE_REMOVED) {
switch (device->GetDeviceRemovedReason()) {
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
return true;
case DXGI_ERROR_INVALID_CALL:
default:
return false;
}
}
return false;
}
bool
CompositorD3D11::UpdateConstantBuffers()
{
@ -1011,16 +1002,22 @@ CompositorD3D11::UpdateConstantBuffers()
D3D11_MAPPED_SUBRESOURCE resource;
hr = mContext->Map(mAttachments->mVSConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
if (Failed(hr)) {
if (FAILED(hr)) {
if (ShouldRecoverFromMapFailure(hr, GetDevice())) {
return false;
}
MOZ_CRASH();
}
*(VertexShaderConstants*)resource.pData = mVSConstants;
mContext->Unmap(mAttachments->mVSConstantBuffer, 0);
hr = mContext->Map(mAttachments->mPSConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
if (Failed(hr)) {
if (FAILED(hr)) {
if (ShouldRecoverFromMapFailure(hr, GetDevice())) {
return false;
}
MOZ_CRASH();
}
*(PixelShaderConstants*)resource.pData = mPSConstants;
mContext->Unmap(mAttachments->mPSConstantBuffer, 0);
@ -1085,46 +1082,5 @@ CompositorD3D11::PaintToTarget()
mContext->Unmap(readTexture, 0);
}
void
CompositorD3D11::HandleError(HRESULT hr, Severity aSeverity)
{
// XXX - It would be nice to use gfxCriticalError, but it needs to
// be made to work off the main thread first.
MOZ_ASSERT(aSeverity != DebugAssert);
if (aSeverity == Critical) {
MOZ_CRASH("Unrecoverable D3D11 error");
}
if (mDevice && hr == DXGI_ERROR_DEVICE_REMOVED) {
hr = mDevice->GetDeviceRemovedReason();
}
// Always crash if we are making invalid calls
if (hr == DXGI_ERROR_INVALID_CALL) {
MOZ_CRASH("Invalid D3D11 api call");
}
if (aSeverity == Recoverable) {
NS_WARNING("Encountered a recoverable D3D11 error");
}
}
bool
CompositorD3D11::Failed(HRESULT hr, Severity aSeverity)
{
if (FAILED(hr)) {
HandleError(hr, aSeverity);
return true;
}
return false;
}
bool
CompositorD3D11::Succeeded(HRESULT hr, Severity aSeverity)
{
return !Failed(hr, aSeverity);
}
}
}

Просмотреть файл

@ -143,16 +143,6 @@ public:
ID3D11DeviceContext* GetDC() { return mContext; }
private:
enum Severity {
Recoverable,
DebugAssert,
Critical,
};
void HandleError(HRESULT hr, Severity aSeverity);
bool Failed(HRESULT hr, Severity aSeverity = DebugAssert);
bool Succeeded(HRESULT hr, Severity aSeverity = DebugAssert);
// ensure mSize is up to date with respect to mWidget
void EnsureSize();
void VerifyBufferSize();