Commit 63d2fc7f by Geoff Lang

Update the ReadPixels calls to return Error objects instead of calling gl::error.

BUG=angle:520 Change-Id: I2ead221e7d1f02cf088b60d0e98376fcd68dde8e Reviewed-on: https://chromium-review.googlesource.com/211441Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent cc79b8c6
...@@ -1674,8 +1674,8 @@ Error Context::clearBufferfi(GLenum buffer, int drawbuffer, float depth, int ste ...@@ -1674,8 +1674,8 @@ Error Context::clearBufferfi(GLenum buffer, int drawbuffer, float depth, int ste
return mRenderer->clear(clearParams, mState.getDrawFramebuffer()); return mRenderer->clear(clearParams, mState.getDrawFramebuffer());
} }
void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, Error Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLsizei *bufSize, void* pixels) GLenum format, GLenum type, GLsizei *bufSize, void* pixels)
{ {
gl::Framebuffer *framebuffer = mState.getReadFramebuffer(); gl::Framebuffer *framebuffer = mState.getReadFramebuffer();
...@@ -1683,8 +1683,8 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, ...@@ -1683,8 +1683,8 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
const InternalFormat &sizedFormatInfo = GetInternalFormatInfo(sizedInternalFormat); const InternalFormat &sizedFormatInfo = GetInternalFormatInfo(sizedInternalFormat);
GLuint outputPitch = sizedFormatInfo.computeRowPitch(type, width, mState.getPackAlignment()); GLuint outputPitch = sizedFormatInfo.computeRowPitch(type, width, mState.getPackAlignment());
mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.getPackState(), return mRenderer->readPixels(framebuffer, x, y, width, height, format, type, outputPitch, mState.getPackState(),
reinterpret_cast<uint8_t*>(pixels)); reinterpret_cast<uint8_t*>(pixels));
} }
void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances) void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances)
......
...@@ -191,7 +191,7 @@ class Context ...@@ -191,7 +191,7 @@ class Context
Error clearBufferiv(GLenum buffer, int drawbuffer, const int *values); Error clearBufferiv(GLenum buffer, int drawbuffer, const int *values);
Error clearBufferfi(GLenum buffer, int drawbuffer, float depth, int stencil); Error clearBufferfi(GLenum buffer, int drawbuffer, float depth, int stencil);
void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels); Error readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances); void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances);
void drawElements(GLenum mode, GLsizei count, GLenum type, void drawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
......
...@@ -3693,7 +3693,12 @@ void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, ...@@ -3693,7 +3693,12 @@ void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
return; return;
} }
context->readPixels(x, y, width, height, format, type, &bufSize, data); gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
...@@ -3719,7 +3724,12 @@ void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, ...@@ -3719,7 +3724,12 @@ void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
return; return;
} }
context->readPixels(x, y, width, height, format, type, NULL, pixels); gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
......
...@@ -188,8 +188,9 @@ class Renderer ...@@ -188,8 +188,9 @@ class Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0; const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter) = 0;
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) = 0; virtual gl::Error readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) = 0;
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0; virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0;
......
...@@ -140,7 +140,7 @@ class Buffer11::PackStorage11 : public Buffer11::BufferStorage11 ...@@ -140,7 +140,7 @@ class Buffer11::PackStorage11 : public Buffer11::BufferStorage11
virtual void *map(size_t offset, size_t length, GLbitfield access); virtual void *map(size_t offset, size_t length, GLbitfield access);
virtual void unmap(); virtual void unmap();
void packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params); gl::Error packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params);
private: private:
...@@ -491,7 +491,7 @@ ID3D11ShaderResourceView *Buffer11::getSRV(DXGI_FORMAT srvFormat) ...@@ -491,7 +491,7 @@ ID3D11ShaderResourceView *Buffer11::getSRV(DXGI_FORMAT srvFormat)
return bufferSRV; return bufferSRV;
} }
void Buffer11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, const PackPixelsParams &params) gl::Error Buffer11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, const PackPixelsParams &params)
{ {
PackStorage11 *packStorage = getPackStorage(); PackStorage11 *packStorage = getPackStorage();
...@@ -499,9 +499,15 @@ void Buffer11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, cons ...@@ -499,9 +499,15 @@ void Buffer11::packPixels(ID3D11Texture2D *srcTexture, UINT srcSubresource, cons
if (packStorage) if (packStorage)
{ {
packStorage->packPixels(srcTexture, srcSubresource, params); gl::Error error = packStorage->packPixels(srcTexture, srcSubresource, params);
if (error.isError())
{
return error;
}
packStorage->setDataRevision(latestStorage ? latestStorage->getDataRevision() + 1 : 1); packStorage->setDataRevision(latestStorage ? latestStorage->getDataRevision() + 1 : 1);
} }
return gl::Error(GL_NO_ERROR);
} }
Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage requestedUsage) Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage requestedUsage)
...@@ -927,7 +933,7 @@ void Buffer11::PackStorage11::unmap() ...@@ -927,7 +933,7 @@ void Buffer11::PackStorage11::unmap()
// No-op // No-op
} }
void Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params) gl::Error Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params)
{ {
flushQueuedPackCommand(); flushQueuedPackCommand();
mQueuedPackCommand = new PackPixelsParams(params); mQueuedPackCommand = new PackPixelsParams(params);
...@@ -969,7 +975,11 @@ void Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSub ...@@ -969,7 +975,11 @@ void Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSub
stagingDesc.MiscFlags = 0; stagingDesc.MiscFlags = 0;
hr = device->CreateTexture2D(&stagingDesc, NULL, &mStagingTexture); hr = device->CreateTexture2D(&stagingDesc, NULL, &mStagingTexture);
ASSERT(SUCCEEDED(hr)); if (FAILED(hr))
{
ASSERT(hr == E_OUTOFMEMORY);
return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal staging texture.");
}
} }
// ReadPixels from multisampled FBOs isn't supported in current GL // ReadPixels from multisampled FBOs isn't supported in current GL
...@@ -986,6 +996,8 @@ void Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSub ...@@ -986,6 +996,8 @@ void Buffer11::PackStorage11::packPixels(ID3D11Texture2D *srcTexure, UINT srcSub
// Asynchronous copy // Asynchronous copy
immediateContext->CopySubresourceRegion(mStagingTexture, 0, 0, 0, 0, srcTexure, srcSubresource, &srcBox); immediateContext->CopySubresourceRegion(mStagingTexture, 0, 0, 0, 0, srcTexure, srcSubresource, &srcBox);
return gl::Error(GL_NO_ERROR);
} }
void Buffer11::PackStorage11::flushQueuedPackCommand() void Buffer11::PackStorage11::flushQueuedPackCommand()
......
...@@ -60,7 +60,7 @@ class Buffer11 : public BufferD3D ...@@ -60,7 +60,7 @@ class Buffer11 : public BufferD3D
ID3D11Buffer *getBuffer(BufferUsage usage); ID3D11Buffer *getBuffer(BufferUsage usage);
ID3D11ShaderResourceView *getSRV(DXGI_FORMAT srvFormat); ID3D11ShaderResourceView *getSRV(DXGI_FORMAT srvFormat);
bool isMapped() const { return mMappedStorage != NULL; } bool isMapped() const { return mMappedStorage != NULL; }
void packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params); gl::Error packPixels(ID3D11Texture2D *srcTexure, UINT srcSubresource, const PackPixelsParams &params);
// BufferD3D implementation // BufferD3D implementation
virtual size_t getSize() const { return mSize; } virtual size_t getSize() const { return mSize; }
......
...@@ -2581,8 +2581,8 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read ...@@ -2581,8 +2581,8 @@ bool Renderer11::blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &read
return true; return true;
} }
void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, gl::Error Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
{ {
ID3D11Texture2D *colorBufferTexture = NULL; ID3D11Texture2D *colorBufferTexture = NULL;
unsigned int subresourceIndex = 0; unsigned int subresourceIndex = 0;
...@@ -2603,16 +2603,27 @@ void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsi ...@@ -2603,16 +2603,27 @@ void Renderer11::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsi
rx::Buffer11 *packBufferStorage = Buffer11::makeBuffer11(packBuffer->getImplementation()); rx::Buffer11 *packBufferStorage = Buffer11::makeBuffer11(packBuffer->getImplementation());
PackPixelsParams packParams(area, format, type, outputPitch, pack, reinterpret_cast<ptrdiff_t>(pixels)); PackPixelsParams packParams(area, format, type, outputPitch, pack, reinterpret_cast<ptrdiff_t>(pixels));
gl::Error error = packBufferStorage->packPixels(colorBufferTexture, subresourceIndex, packParams);
if (error.isError())
{
return error;
}
packBuffer->getIndexRangeCache()->clear(); packBuffer->getIndexRangeCache()->clear();
packBufferStorage->packPixels(colorBufferTexture, subresourceIndex, packParams);
} }
else else
{ {
readTextureData(colorBufferTexture, subresourceIndex, area, format, type, outputPitch, pack, pixels); gl::Error error = readTextureData(colorBufferTexture, subresourceIndex, area, format, type, outputPitch, pack, pixels);
if (error.isError())
{
return error;
}
} }
SafeRelease(colorBufferTexture); SafeRelease(colorBufferTexture);
} }
return gl::Error(GL_NO_ERROR);
} }
Image *Renderer11::createImage() Image *Renderer11::createImage()
...@@ -2668,8 +2679,8 @@ TextureImpl *Renderer11::createTexture(GLenum target) ...@@ -2668,8 +2679,8 @@ TextureImpl *Renderer11::createTexture(GLenum target)
return NULL; return NULL;
} }
void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format, gl::Error Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
{ {
ASSERT(area.width >= 0); ASSERT(area.width >= 0);
ASSERT(area.height >= 0); ASSERT(area.height >= 0);
...@@ -2694,7 +2705,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou ...@@ -2694,7 +2705,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
if (safeArea.width == 0 || safeArea.height == 0) if (safeArea.width == 0 || safeArea.height == 0)
{ {
// no work to do // no work to do
return; return gl::Error(GL_NO_ERROR);
} }
D3D11_TEXTURE2D_DESC stagingDesc; D3D11_TEXTURE2D_DESC stagingDesc;
...@@ -2714,8 +2725,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou ...@@ -2714,8 +2725,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
HRESULT result = mDevice->CreateTexture2D(&stagingDesc, NULL, &stagingTex); HRESULT result = mDevice->CreateTexture2D(&stagingDesc, NULL, &stagingTex);
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Failed to create staging texture for readPixels, HRESULT: 0x%X.", result); return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal staging texture for ReadPixels, HRESULT: 0x%X.", result);
return;
} }
ID3D11Texture2D* srcTex = NULL; ID3D11Texture2D* srcTex = NULL;
...@@ -2737,9 +2747,8 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou ...@@ -2737,9 +2747,8 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
result = mDevice->CreateTexture2D(&resolveDesc, NULL, &srcTex); result = mDevice->CreateTexture2D(&resolveDesc, NULL, &srcTex);
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Failed to create resolve texture for readPixels, HRESULT: 0x%X.", result);
SafeRelease(stagingTex); SafeRelease(stagingTex);
return; return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal resolve texture for ReadPixels, HRESULT: 0x%X.", result);
} }
mDeviceContext->ResolveSubresource(srcTex, 0, texture, subResource, textureDesc.Format); mDeviceContext->ResolveSubresource(srcTex, 0, texture, subResource, textureDesc.Format);
...@@ -2767,6 +2776,8 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou ...@@ -2767,6 +2776,8 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
packPixels(stagingTex, packParams, pixels); packPixels(stagingTex, packParams, pixels);
SafeRelease(stagingTex); SafeRelease(stagingTex);
return gl::Error(GL_NO_ERROR);
} }
void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut) void Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, uint8_t *pixelsOut)
......
...@@ -131,8 +131,9 @@ class Renderer11 : public Renderer ...@@ -131,8 +131,9 @@ class Renderer11 : public Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter); const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels); virtual gl::Error readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth); virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
...@@ -207,8 +208,8 @@ class Renderer11 : public Renderer ...@@ -207,8 +208,8 @@ class Renderer11 : public Renderer
void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer); void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances); void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format, gl::Error readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels); GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
bool blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget, bool blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget,
RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor, RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor,
......
...@@ -2559,8 +2559,8 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle & ...@@ -2559,8 +2559,8 @@ bool Renderer9::blitRect(gl::Framebuffer *readFramebuffer, const gl::Rectangle &
return true; return true;
} }
void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, gl::Error Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels) GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels)
{ {
ASSERT(pack.pixelBuffer.get() == NULL); ASSERT(pack.pixelBuffer.get() == NULL);
...@@ -2581,7 +2581,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2581,7 +2581,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
if (!surface) if (!surface)
{ {
// context must be lost // context must be lost
return; return gl::Error(GL_NO_ERROR);
} }
D3DSURFACE_DESC desc; D3DSURFACE_DESC desc;
...@@ -2591,7 +2591,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2591,7 +2591,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
{ {
UNIMPLEMENTED(); // FIXME: Requires resolve using StretchRect into non-multisampled render target UNIMPLEMENTED(); // FIXME: Requires resolve using StretchRect into non-multisampled render target
SafeRelease(surface); SafeRelease(surface);
return gl::error(GL_OUT_OF_MEMORY); return gl::Error(GL_OUT_OF_MEMORY, "ReadPixels is unimplemented for multisampled framebuffer attachments.");
} }
HRESULT result; HRESULT result;
...@@ -2619,7 +2619,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2619,7 +2619,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
{ {
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
SafeRelease(surface); SafeRelease(surface);
return gl::error(GL_OUT_OF_MEMORY); return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal texture for ReadPixels.");
} }
} }
...@@ -2635,20 +2635,19 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2635,20 +2635,19 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
if (d3d9::isDeviceLostError(result)) if (d3d9::isDeviceLostError(result))
{ {
notifyDeviceLost(); notifyDeviceLost();
return gl::error(GL_OUT_OF_MEMORY);
} }
else else
{ {
UNREACHABLE(); UNREACHABLE();
return;
} }
return gl::Error(GL_OUT_OF_MEMORY, "Failed to read internal render target data.");
} }
if (directToPixels) if (directToPixels)
{ {
SafeRelease(systemSurface); SafeRelease(systemSurface);
return; return gl::Error(GL_NO_ERROR);
} }
RECT rect; RECT rect;
...@@ -2665,7 +2664,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2665,7 +2664,7 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
UNREACHABLE(); UNREACHABLE();
SafeRelease(systemSurface); SafeRelease(systemSurface);
return; // No sensible error to generate return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal render target.");
} }
uint8_t *source; uint8_t *source;
...@@ -2734,6 +2733,8 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz ...@@ -2734,6 +2733,8 @@ void Renderer9::readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsiz
systemSurface->UnlockRect(); systemSurface->UnlockRect();
SafeRelease(systemSurface); SafeRelease(systemSurface);
return gl::Error(GL_NO_ERROR);
} }
RenderTarget *Renderer9::createRenderTarget(SwapChain *swapChain, bool depth) RenderTarget *Renderer9::createRenderTarget(SwapChain *swapChain, bool depth)
......
...@@ -134,8 +134,9 @@ class Renderer9 : public Renderer ...@@ -134,8 +134,9 @@ class Renderer9 : public Renderer
virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter); const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels); virtual gl::Error readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, uint8_t *pixels);
// RenderTarget creation // RenderTarget creation
virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth); virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
......
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