Commit 24d4a3c1 by Geoff Lang

Update Renderer11::packPixels to return Error objects.

BUG=angle:520 BUG=394361 Change-Id: I95f2f806210ac7aea8b0c57bece610eb22d018ed Reviewed-on: https://chromium-review.googlesource.com/222481Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 9d6d498c
...@@ -144,7 +144,7 @@ class Buffer11::PackStorage11 : public Buffer11::BufferStorage11 ...@@ -144,7 +144,7 @@ class Buffer11::PackStorage11 : public Buffer11::BufferStorage11
private: private:
void flushQueuedPackCommand(); gl::Error flushQueuedPackCommand();
ID3D11Texture2D *mStagingTexture; ID3D11Texture2D *mStagingTexture;
DXGI_FORMAT mTextureFormat; DXGI_FORMAT mTextureFormat;
...@@ -870,7 +870,12 @@ void *Buffer11::PackStorage11::map(size_t offset, size_t length, GLbitfield acce ...@@ -870,7 +870,12 @@ void *Buffer11::PackStorage11::map(size_t offset, size_t length, GLbitfield acce
// and if D3D packs the staging texture memory identically to how we would fill // and if D3D packs the staging texture memory identically to how we would fill
// the pack buffer according to the current pack state. // the pack buffer according to the current pack state.
flushQueuedPackCommand(); gl::Error error = flushQueuedPackCommand();
if (error.isError())
{
return NULL;
}
mDataModified = (mDataModified || (access & GL_MAP_WRITE_BIT) != 0); mDataModified = (mDataModified || (access & GL_MAP_WRITE_BIT) != 0);
return mMemoryBuffer.data() + offset; return mMemoryBuffer.data() + offset;
...@@ -883,7 +888,12 @@ void Buffer11::PackStorage11::unmap() ...@@ -883,7 +888,12 @@ void Buffer11::PackStorage11::unmap()
gl::Error Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params) gl::Error Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params)
{ {
flushQueuedPackCommand(); gl::Error error = flushQueuedPackCommand();
if (error.isError())
{
return error;
}
mQueuedPackCommand = new PackPixelsParams(params); mQueuedPackCommand = new PackPixelsParams(params);
D3D11_TEXTURE2D_DESC textureDesc; D3D11_TEXTURE2D_DESC textureDesc;
...@@ -948,15 +958,21 @@ gl::Error Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT s ...@@ -948,15 +958,21 @@ gl::Error Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT s
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
void Buffer11::PackStorage11::flushQueuedPackCommand() gl::Error Buffer11::PackStorage11::flushQueuedPackCommand()
{ {
ASSERT(mMemoryBuffer.size() > 0); ASSERT(mMemoryBuffer.size() > 0);
if (mQueuedPackCommand) if (mQueuedPackCommand)
{ {
mRenderer->packPixels(mStagingTexture, *mQueuedPackCommand, mMemoryBuffer.data()); gl::Error error = mRenderer->packPixels(mStagingTexture, *mQueuedPackCommand, mMemoryBuffer.data());
SafeDelete(mQueuedPackCommand); SafeDelete(mQueuedPackCommand);
if (error.isError())
{
return error;
}
} }
return gl::Error(GL_NO_ERROR);
} }
} }
...@@ -2812,22 +2812,25 @@ gl::Error Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int sub ...@@ -2812,22 +2812,25 @@ gl::Error Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int sub
SafeRelease(srcTex); SafeRelease(srcTex);
PackPixelsParams packParams(safeArea, format, type, outputPitch, pack, 0); PackPixelsParams packParams(safeArea, format, type, outputPitch, pack, 0);
packPixels(stagingTex, packParams, pixels); gl::Error error = packPixels(stagingTex, packParams, pixels);
SafeRelease(stagingTex); SafeRelease(stagingTex);
return gl::Error(GL_NO_ERROR); return error;
} }
void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut) gl::Error Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut)
{ {
D3D11_TEXTURE2D_DESC textureDesc; D3D11_TEXTURE2D_DESC textureDesc;
readTexture->GetDesc(&textureDesc); readTexture->GetDesc(&textureDesc);
D3D11_MAPPED_SUBRESOURCE mapping; D3D11_MAPPED_SUBRESOURCE mapping;
HRESULT hr = mDeviceContext->Map(readTexture, 0, D3D11_MAP_READ, 0, &mapping); HRESULT hr = mDeviceContext->Map(readTexture, 0, D3D11_MAP_READ, 0, &mapping);
UNUSED_ASSERTION_VARIABLE(hr); if (FAILED(hr))
ASSERT(SUCCEEDED(hr)); {
ASSERT(hr == E_OUTOFMEMORY);
return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal texture for reading, result: 0x%X.", hr);
}
uint8_t *source; uint8_t *source;
int inputPitch; int inputPitch;
...@@ -2898,6 +2901,8 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams ...@@ -2898,6 +2901,8 @@ void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams
} }
mDeviceContext->Unmap(readTexture, 0); mDeviceContext->Unmap(readTexture, 0);
return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget, gl::Error Renderer11::blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget,
......
...@@ -193,7 +193,7 @@ class Renderer11 : public Renderer ...@@ -193,7 +193,7 @@ class Renderer11 : public Renderer
bool getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndexOut, ID3D11Texture2D **texture2DOut); bool getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndexOut, ID3D11Texture2D **texture2DOut);
void unapplyRenderTargets(); void unapplyRenderTargets();
void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView); void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView);
void packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut); gl::Error packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut);
virtual bool getLUID(LUID *adapterLuid) const; virtual bool getLUID(LUID *adapterLuid) const;
virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const; virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment