Bug 1167332 - Pass failures out of SetBufferData. r=jgilbert, a=lizzard
authorLee Salzman <lsalzman@mozilla.com>
Tue, 09 Jun 2015 14:41:03 -0400
changeset 267728 9060127fc5ae128a3da392413f89f6f954ac37f4
parent 267727 4b179ee959987ef8036f002b240c738a0629b5b7
child 267729 f398d95abaa988864713f0ed440a85a4f605dad4
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert, lizzard
bugs1167332
milestone39.0
Bug 1167332 - Pass failures out of SetBufferData. r=jgilbert, a=lizzard
gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp
gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h
--- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp
+++ b/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/PixelTransfer11.cpp
@@ -196,31 +196,41 @@ gl::Error PixelTransfer11::copyBufferToT
     ID3D11PixelShader *pixelShader = findBufferToTexturePS(destinationFormat);
     ASSERT(pixelShader);
 
     // The SRV must be in the proper read format, which may be different from the destination format
     // EG: for half float data, we can load full precision floats with implicit conversion
     GLenum unsizedFormat = gl::GetInternalFormatInfo(destinationFormat).format;
     GLenum sourceFormat = gl::GetFormatTypeInfo(unsizedFormat, sourcePixelsType).internalFormat;
 
+    CopyShaderParams shaderParams;
+    setBufferToTextureCopyParams(destArea, destSize, sourceFormat, unpack, offset, &shaderParams);
+
+    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
+
+    if (!StructEquals(mParamsData, shaderParams))
+    {
+        HRESULT result = d3d11::SetBufferData(deviceContext, mParamsConstantBuffer, shaderParams);
+        if (FAILED(result))
+        {
+             return gl::Error(GL_OUT_OF_MEMORY, "Failed to set shader parameters, result: 0x%X.", result);
+        }
+        mParamsData = shaderParams;
+    }
+
     const d3d11::TextureFormat &sourceFormatInfo = d3d11::GetTextureFormatInfo(sourceFormat);
     DXGI_FORMAT srvFormat = sourceFormatInfo.srvFormat;
     ASSERT(srvFormat != DXGI_FORMAT_UNKNOWN);
     Buffer11 *bufferStorage11 = Buffer11::makeBuffer11(sourceBuffer.getImplementation());
     ID3D11ShaderResourceView *bufferSRV = bufferStorage11->getSRV(srvFormat);
     ASSERT(bufferSRV != NULL);
 
     ID3D11RenderTargetView *textureRTV = RenderTarget11::makeRenderTarget11(destRenderTarget)->getRenderTargetView();
     ASSERT(textureRTV != NULL);
 
-    CopyShaderParams shaderParams;
-    setBufferToTextureCopyParams(destArea, destSize, sourceFormat, unpack, offset, &shaderParams);
-
-    ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
-
     ID3D11Buffer *nullBuffer = NULL;
     UINT zero = 0;
 
     // Are we doing a 2D or 3D copy?
     ID3D11GeometryShader *geometryShader = ((destSize.depth > 1) ? mBufferToTextureGS : NULL);
 
     deviceContext->VSSetShader(mBufferToTextureVS, NULL, 0);
     deviceContext->GSSetShader(geometryShader, NULL, 0);
@@ -231,22 +241,16 @@ gl::Error PixelTransfer11::copyBufferToT
 
     deviceContext->IASetVertexBuffers(0, 1, &nullBuffer, &zero, &zero);
     deviceContext->OMSetBlendState(NULL, NULL, 0xFFFFFFF);
     deviceContext->OMSetDepthStencilState(mCopyDepthStencilState, 0xFFFFFFFF);
     deviceContext->RSSetState(mCopyRasterizerState);
 
     mRenderer->setOneTimeRenderTarget(textureRTV);
 
-    if (!StructEquals(mParamsData, shaderParams))
-    {
-        d3d11::SetBufferData(deviceContext, mParamsConstantBuffer, shaderParams);
-        mParamsData = shaderParams;
-    }
-
     deviceContext->VSSetConstantBuffers(0, 1, &mParamsConstantBuffer);
 
     // Set the viewport
     D3D11_VIEWPORT viewport;
     viewport.TopLeftX = 0;
     viewport.TopLeftY = 0;
     viewport.Width = destSize.width;
     viewport.Height = destSize.height;
--- a/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h
+++ b/gfx/angle/src/libGLESv2/renderer/d3d/d3d11/renderer11_utils.h
@@ -163,24 +163,27 @@ inline ID3D11PixelShader *CompilePS(ID3D
     ASSERT(SUCCEEDED(result));
     SetDebugName(ps, name);
     return ps;
 }
 
 // Copy data to small D3D11 buffers, such as for small constant buffers, which use one struct to
 // represent an entire buffer.
 template <class T>
-inline void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBuffer, const T &value)
+inline HRESULT SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBuffer, const T &value)
 {
     D3D11_MAPPED_SUBRESOURCE mappedResource;
-    context->Map(constantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+    HRESULT result = context->Map(constantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+    if(SUCCEEDED(result))
+    {
+        memcpy(mappedResource.pData, &value, sizeof(T));
 
-    memcpy(mappedResource.pData, &value, sizeof(T));
-
-    context->Unmap(constantBuffer, 0);
+        context->Unmap(constantBuffer, 0);
+    }
+    return result;
 }
 
 gl::Error GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment, RenderTarget11 **outRT);
 
 Workarounds GenerateWorkarounds();
 
 }