Commit e39e8f46 by Jamie Madill Committed by Commit Bot

GL back-end error refactor.

Adds explicit error handling to a few scoped state handler classes. Otherwise mostly mechanical refactoring. Bug: angleproject:2753 Change-Id: I2bf969a68f45880902b6e7902297c1340a76a1c4 Reviewed-on: https://chromium-review.googlesource.com/c/1255647Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 06270c9e
......@@ -241,6 +241,15 @@ inline Error NoError()
#undef ANGLE_CONCAT2
#undef ANGLE_CONCAT1
#define ANGLE_CHECK(CONTEXT, EXPR, MESSAGE, ERROR) \
{ \
if (ANGLE_UNLIKELY(!(EXPR))) \
{ \
CONTEXT->handleError(ERROR, MESSAGE, __FILE__, ANGLE_FUNCTION, __LINE__); \
return angle::Result::Stop(); \
} \
}
namespace angle
{
// Result signals if calling code should continue running or early exit. A value of Stop() can
......
......@@ -158,8 +158,7 @@ angle::Result HLSLCompiler::ensureInitialized(d3d::Context *context)
mD3DDisassembleFunc = reinterpret_cast<pD3DDisassemble>(D3DDisassemble);
#endif
ANGLE_CHECK_HR(context, mD3DCompileFunc, "Error finding D3DCompile entry point.",
E_OUTOFMEMORY);
ANGLE_CHECK(context, mD3DCompileFunc, "Error finding D3DCompile entry point.", E_OUTOFMEMORY);
mInitialized = true;
return angle::Result::Continue();
......
......@@ -75,9 +75,8 @@ angle::Result IndexBufferInterface::mapBuffer(const gl::Context *context,
{
// Protect against integer overflow
bool check = (mWritePosition + size < mWritePosition);
ANGLE_CHECK_HR(GetImplAs<ContextD3D>(context), !check,
"Mapping of internal index buffer would cause an integer overflow.",
E_OUTOFMEMORY);
ANGLE_CHECK(GetImplAs<ContextD3D>(context), !check,
"Mapping of internal index buffer would cause an integer overflow.", E_OUTOFMEMORY);
angle::Result error = mIndexBuffer->mapBuffer(context, mWritePosition, size, outMappedMemory);
if (error == angle::Result::Stop())
......
......@@ -95,8 +95,8 @@ angle::Result StreamInIndexBuffer(const gl::Context *context,
const gl::Type &dstTypeInfo = gl::GetTypeInfo(dstType);
bool check = (count > (std::numeric_limits<unsigned int>::max() >> dstTypeInfo.bytesShift));
ANGLE_CHECK_HR(GetImplAs<ContextD3D>(context), !check,
"Reserving indices exceeds the maximum buffer size.", E_OUTOFMEMORY);
ANGLE_CHECK(GetImplAs<ContextD3D>(context), !check,
"Reserving indices exceeds the maximum buffer size.", E_OUTOFMEMORY);
unsigned int bufferSizeRequired = count << dstTypeInfo.bytesShift;
ANGLE_TRY(buffer->reserveBufferSpace(context, bufferSizeRequired, dstType));
......
......@@ -103,25 +103,15 @@ class Context : angle::NonCopyable
\
}
#define ANGLE_CHECK_HR(CONTEXT, EXPR, MESSAGE, ERROR) \
\
{ \
if (ANGLE_UNLIKELY(!(EXPR))) \
{ \
CONTEXT->handleError(ERROR, MESSAGE, __FILE__, ANGLE_FUNCTION, __LINE__); \
return angle::Result::Stop(); \
} \
}
#define ANGLE_CHECK_HR_ALLOC(context, result) \
ANGLE_CHECK_HR(context, result, "Failed to allocate host memory", E_OUTOFMEMORY)
ANGLE_CHECK(context, result, "Failed to allocate host memory", E_OUTOFMEMORY)
#define ANGLE_CHECK_HR_MATH(context, result) \
ANGLE_CHECK_HR(context, result, "Integer overflow.", E_FAIL)
ANGLE_CHECK(context, result, "Integer overflow.", E_FAIL)
#define ANGLE_HR_UNREACHABLE(context) \
UNREACHABLE(); \
ANGLE_CHECK_HR(context, false, "Unreachble code reached.", E_FAIL)
ANGLE_CHECK(context, false, "Unreachble code reached.", E_FAIL)
// Check if the device is lost every 10 failures to get the query data
constexpr unsigned int kPollingD3DDeviceLostCheckFrequency = 10;
......
......@@ -358,8 +358,8 @@ angle::Result TextureD3D::fastUnpackPixels(const gl::Context *context,
{
bool check = (unpack.skipRows != 0 || unpack.skipPixels != 0 || unpack.imageHeight != 0 ||
unpack.skipImages != 0);
ANGLE_CHECK_HR(GetImplAs<ContextD3D>(context), !check,
"Unimplemented pixel store parameters in fastUnpackPixels", E_FAIL);
ANGLE_CHECK(GetImplAs<ContextD3D>(context), !check,
"Unimplemented pixel store parameters in fastUnpackPixels", E_FAIL);
// No-op
if (destArea.width <= 0 && destArea.height <= 0 && destArea.depth <= 0)
......
......@@ -490,8 +490,8 @@ angle::Result VertexDataManager::reserveSpaceForAttrib(const gl::Context *contex
int elementsInBuffer =
ElementsInBuffer(attrib, binding, static_cast<unsigned int>(bufferD3D->getSize()));
ANGLE_CHECK_HR(GetImplAs<ContextD3D>(context), maxVertexCount <= elementsInBuffer,
"Vertex buffer is not big enough for the draw call.", E_FAIL);
ANGLE_CHECK(GetImplAs<ContextD3D>(context), maxVertexCount <= elementsInBuffer,
"Vertex buffer is not big enough for the draw call.", E_FAIL);
}
return mStreamingBuffer.reserveVertexSpace(context, attrib, binding, totalCount, instances);
}
......
......@@ -69,13 +69,13 @@ angle::Result IndexBuffer11::mapBuffer(const gl::Context *context,
void **outMappedMemory)
{
Context11 *context11 = GetImplAs<Context11>(context);
ANGLE_CHECK_HR(context11, mBuffer.valid(), "Internal index buffer is not initialized.",
E_OUTOFMEMORY);
ANGLE_CHECK(context11, mBuffer.valid(), "Internal index buffer is not initialized.",
E_OUTOFMEMORY);
// Check for integer overflows and out-out-bounds map requests
bool outOfBounds = (offset + size < offset || offset + size > mBufferSize);
ANGLE_CHECK_HR(context11, !outOfBounds, "Index buffer map range is not inside the buffer.",
E_OUTOFMEMORY);
ANGLE_CHECK(context11, !outOfBounds, "Index buffer map range is not inside the buffer.",
E_OUTOFMEMORY);
D3D11_MAPPED_SUBRESOURCE mappedResource;
ANGLE_TRY(mRenderer->mapResource(context, mBuffer.get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0,
......@@ -88,8 +88,8 @@ angle::Result IndexBuffer11::mapBuffer(const gl::Context *context,
angle::Result IndexBuffer11::unmapBuffer(const gl::Context *context)
{
Context11 *context11 = GetImplAs<Context11>(context);
ANGLE_CHECK_HR(context11, mBuffer.valid(), "Internal index buffer is not initialized.",
E_OUTOFMEMORY);
ANGLE_CHECK(context11, mBuffer.valid(), "Internal index buffer is not initialized.",
E_OUTOFMEMORY);
ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
dxContext->Unmap(mBuffer.get(), 0);
......@@ -121,8 +121,8 @@ angle::Result IndexBuffer11::setSize(const gl::Context *context,
angle::Result IndexBuffer11::discard(const gl::Context *context)
{
Context11 *context11 = GetImplAs<Context11>(context);
ANGLE_CHECK_HR(context11, mBuffer.valid(), "Internal index buffer is not initialized.",
E_OUTOFMEMORY);
ANGLE_CHECK(context11, mBuffer.valid(), "Internal index buffer is not initialized.",
E_OUTOFMEMORY);
ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext();
......
......@@ -1230,8 +1230,7 @@ angle::Result Renderer11::finish(Context11 *context11)
if (checkDeviceLost && testDeviceLost())
{
mDisplay->notifyDeviceLost();
ANGLE_CHECK_HR(context11, false, "Device was lost while waiting for sync.",
E_OUTOFMEMORY);
ANGLE_CHECK(context11, false, "Device was lost while waiting for sync.", E_OUTOFMEMORY);
}
} while (result == S_FALSE);
......@@ -1694,10 +1693,10 @@ angle::Result Renderer11::drawLineLoop(const gl::Context *context,
// Checked by Renderer11::applyPrimitiveType
bool indexCheck = static_cast<unsigned int>(count) + 1 >
(std::numeric_limits<unsigned int>::max() / sizeof(unsigned int));
ANGLE_CHECK_HR(GetImplAs<Context11>(context), !indexCheck,
"Failed to create a 32-bit looping index buffer for "
"GL_LINE_LOOP, too many indices required.",
E_OUTOFMEMORY);
ANGLE_CHECK(GetImplAs<Context11>(context), !indexCheck,
"Failed to create a 32-bit looping index buffer for "
"GL_LINE_LOOP, too many indices required.",
E_OUTOFMEMORY);
GetLineLoopIndices(indices, type, static_cast<GLuint>(count),
glState.isPrimitiveRestartEnabled(), &mScratchIndexDataBuffer);
......@@ -1775,10 +1774,10 @@ angle::Result Renderer11::drawTriangleFan(const gl::Context *context,
bool indexCheck =
(numTris > std::numeric_limits<unsigned int>::max() / (sizeof(unsigned int) * 3));
ANGLE_CHECK_HR(GetImplAs<Context11>(context), !indexCheck,
"Failed to create a scratch index buffer for GL_TRIANGLE_FAN, "
"too many indices required.",
E_OUTOFMEMORY);
ANGLE_CHECK(GetImplAs<Context11>(context), !indexCheck,
"Failed to create a scratch index buffer for GL_TRIANGLE_FAN, "
"too many indices required.",
E_OUTOFMEMORY);
GetTriFanIndices(indexPointer, type, count, glState.isPrimitiveRestartEnabled(),
&mScratchIndexDataBuffer);
......@@ -3646,8 +3645,8 @@ angle::Result Renderer11::getVertexSpaceRequired(const gl::Context *context,
d3d11::GetDXGIFormatSizeInfo(vertexFormatInfo.nativeFormat);
unsigned int elementSize = dxgiFormatInfo.pixelBytes;
bool check = (elementSize > std::numeric_limits<unsigned int>::max() / elementCount);
ANGLE_CHECK_HR(GetImplAs<Context11>(context), !check,
"New vertex buffer size would result in an overflow.", E_OUTOFMEMORY);
ANGLE_CHECK(GetImplAs<Context11>(context), !check,
"New vertex buffer size would result in an overflow.", E_OUTOFMEMORY);
*bytesRequiredOut = elementSize * elementCount;
return angle::Result::Continue();
......
......@@ -1440,12 +1440,12 @@ angle::Result Renderer9::drawLineLoop(const gl::Context *context,
// Checked by Renderer9::applyPrimitiveType
ASSERT(count >= 0);
ANGLE_CHECK_HR(context9,
static_cast<unsigned int>(count) + 1 <=
(std::numeric_limits<unsigned int>::max() / sizeof(unsigned int)),
"Failed to create a 32-bit looping index buffer for "
"GL_LINE_LOOP, too many indices required.",
E_OUTOFMEMORY);
ANGLE_CHECK(context9,
static_cast<unsigned int>(count) + 1 <=
(std::numeric_limits<unsigned int>::max() / sizeof(unsigned int)),
"Failed to create a 32-bit looping index buffer for "
"GL_LINE_LOOP, too many indices required.",
E_OUTOFMEMORY);
const unsigned int spaceNeeded =
(static_cast<unsigned int>(count) + 1) * sizeof(unsigned int);
......@@ -1506,12 +1506,12 @@ angle::Result Renderer9::drawLineLoop(const gl::Context *context,
// Checked by Renderer9::applyPrimitiveType
ASSERT(count >= 0);
ANGLE_CHECK_HR(context9,
static_cast<unsigned int>(count) + 1 <=
(std::numeric_limits<unsigned short>::max() / sizeof(unsigned short)),
"Failed to create a 16-bit looping index buffer for "
"GL_LINE_LOOP, too many indices required.",
E_OUTOFMEMORY);
ANGLE_CHECK(context9,
static_cast<unsigned int>(count) + 1 <=
(std::numeric_limits<unsigned short>::max() / sizeof(unsigned short)),
"Failed to create a 16-bit looping index buffer for "
"GL_LINE_LOOP, too many indices required.",
E_OUTOFMEMORY);
const unsigned int spaceNeeded =
(static_cast<unsigned int>(count) + 1) * sizeof(unsigned short);
......@@ -2936,8 +2936,8 @@ angle::Result Renderer9::getVertexSpaceRequired(const gl::Context *context,
bool check = (d3d9VertexInfo.outputElementSize >
std::numeric_limits<unsigned int>::max() / elementCount);
ANGLE_CHECK_HR(GetImplAs<Context9>(context), !check,
"New vertex buffer size would result in an overflow.", E_OUTOFMEMORY);
ANGLE_CHECK(GetImplAs<Context9>(context), !check,
"New vertex buffer size would result in an overflow.", E_OUTOFMEMORY);
*bytesRequiredOut = static_cast<unsigned int>(d3d9VertexInfo.outputElementSize) * elementCount;
return angle::Result::Continue();
......
......@@ -40,85 +40,86 @@ class BlitGL : angle::NonCopyable
StateManagerGL *stateManager);
~BlitGL();
gl::Error copyImageToLUMAWorkaroundTexture(const gl::Context *context,
GLuint texture,
gl::TextureType textureType,
gl::TextureTarget target,
GLenum lumaFormat,
size_t level,
const gl::Rectangle &sourceArea,
GLenum internalFormat,
gl::Framebuffer *source);
gl::Error copySubImageToLUMAWorkaroundTexture(const gl::Context *context,
GLuint texture,
gl::TextureType textureType,
gl::TextureTarget target,
GLenum lumaFormat,
size_t level,
const gl::Offset &destOffset,
const gl::Rectangle &sourceArea,
gl::Framebuffer *source);
gl::Error blitColorBufferWithShader(const gl::Framebuffer *source,
const gl::Framebuffer *dest,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLenum filter);
gl::Error copySubTexture(const gl::Context *context,
TextureGL *source,
size_t sourceLevel,
GLenum sourceComponentType,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
GLenum destComponentType,
const gl::Extents &sourceSize,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool needsLumaWorkaround,
GLenum lumaFormat,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
bool *copySucceededOut);
gl::Error copySubTextureCPUReadback(const gl::Context *context,
TextureGL *source,
size_t sourceLevel,
GLenum sourceComponentType,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
GLenum destFormat,
GLenum destType,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha);
gl::Error copyTexSubImage(TextureGL *source,
size_t sourceLevel,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool *copySucceededOut);
gl::Error clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex,
bool *clearSucceededOut);
gl::Error clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat);
gl::Error clearFramebuffer(FramebufferGL *source);
gl::Error initializeResources();
angle::Result copyImageToLUMAWorkaroundTexture(const gl::Context *context,
GLuint texture,
gl::TextureType textureType,
gl::TextureTarget target,
GLenum lumaFormat,
size_t level,
const gl::Rectangle &sourceArea,
GLenum internalFormat,
gl::Framebuffer *source);
angle::Result copySubImageToLUMAWorkaroundTexture(const gl::Context *context,
GLuint texture,
gl::TextureType textureType,
gl::TextureTarget target,
GLenum lumaFormat,
size_t level,
const gl::Offset &destOffset,
const gl::Rectangle &sourceArea,
gl::Framebuffer *source);
angle::Result blitColorBufferWithShader(const gl::Context *context,
const gl::Framebuffer *source,
const gl::Framebuffer *dest,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLenum filter);
angle::Result copySubTexture(const gl::Context *context,
TextureGL *source,
size_t sourceLevel,
GLenum sourceComponentType,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
GLenum destComponentType,
const gl::Extents &sourceSize,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool needsLumaWorkaround,
GLenum lumaFormat,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha,
bool *copySucceededOut);
angle::Result copySubTextureCPUReadback(const gl::Context *context,
TextureGL *source,
size_t sourceLevel,
GLenum sourceComponentType,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
GLenum destFormat,
GLenum destType,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool unpackFlipY,
bool unpackPremultiplyAlpha,
bool unpackUnmultiplyAlpha);
angle::Result copyTexSubImage(TextureGL *source,
size_t sourceLevel,
TextureGL *dest,
gl::TextureTarget destTarget,
size_t destLevel,
const gl::Rectangle &sourceArea,
const gl::Offset &destOffset,
bool *copySucceededOut);
angle::Result clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex,
bool *clearSucceededOut);
angle::Result clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat);
angle::Result clearFramebuffer(FramebufferGL *source);
angle::Result initializeResources();
private:
void orphanScratchTextures();
......@@ -146,7 +147,9 @@ class BlitGL : angle::NonCopyable
};
static BlitProgramType getBlitProgramType(GLenum sourceComponentType, GLenum destComponentType);
gl::Error getBlitProgram(BlitProgramType type, BlitProgram **program);
angle::Result getBlitProgram(const gl::Context *context,
BlitProgramType type,
BlitProgram **program);
std::map<BlitProgramType, BlitProgram> mBlitPrograms;
......
......@@ -9,6 +9,7 @@
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/gl/BufferGL.h"
#include "libANGLE/renderer/gl/CompilerGL.h"
#include "libANGLE/renderer/gl/FenceNVGL.h"
......@@ -107,7 +108,7 @@ QueryImpl *ContextGL::createQuery(gl::QueryType type)
switch (type)
{
case gl::QueryType::CommandsCompleted:
return new SyncQueryGL(type, getFunctions(), getStateManager());
return new SyncQueryGL(type, getFunctions());
default:
return new StandardQueryGL(type, getFunctions(), getStateManager());
......@@ -460,4 +461,16 @@ gl::Error ContextGL::memoryBarrierByRegion(const gl::Context *context, GLbitfiel
return mRenderer->memoryBarrierByRegion(barriers);
}
void ContextGL::handleError(GLenum errorCode,
const char *message,
const char *file,
const char *function,
unsigned int line)
{
std::stringstream errorStream;
errorStream << "Internal OpenGL error: " << gl::FmtHex(errorCode) << ", in " << file << ", "
<< function << ":" << line << ". " << message;
mErrors->handleError(gl::Error(errorCode, errorCode, errorStream.str()));
}
} // namespace rx
......@@ -207,6 +207,12 @@ class ContextGL : public ContextImpl
gl::Error memoryBarrier(const gl::Context *context, GLbitfield barriers) override;
gl::Error memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override;
void handleError(GLenum errorCode,
const char *message,
const char *file,
const char *function,
unsigned int line);
private:
std::shared_ptr<RendererGL> mRenderer;
};
......
......@@ -428,6 +428,7 @@ Error FramebufferGL::readPixels(const gl::Context *context,
GLenum type,
void *ptrOrOffset)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const WorkaroundsGL &workarounds = GetWorkaroundsGL(context);
......@@ -466,8 +467,9 @@ Error FramebufferGL::readPixels(const gl::Context *context,
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(readFormat, readType);
GLuint rowBytes = 0;
ANGLE_TRY_CHECKED_MATH(glFormat.computeRowPitch(
readType, origArea.width, packState.alignment, packState.rowLength, &rowBytes));
ANGLE_CHECK_GL_MATH(contextGL,
glFormat.computeRowPitch(readType, origArea.width, packState.alignment,
packState.rowLength, &rowBytes));
pixels += leftClip * glFormat.pixelBytes + topClip * rowBytes;
}
......@@ -490,9 +492,9 @@ Error FramebufferGL::readPixels(const gl::Context *context,
bool useLastRowPaddingWorkaround = false;
if (workarounds.packLastRowSeparatelyForPaddingInclusion)
{
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(gl::Extents(area.width, area.height, 1),
packState, packBuffer, readFormat, readType,
false, pixels, &useLastRowPaddingWorkaround));
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(
contextGL, gl::Extents(area.width, area.height, 1), packState, packBuffer, readFormat,
readType, false, pixels, &useLastRowPaddingWorkaround));
}
return readPixelsAllAtOnce(context, area, readFormat, readType, packState, pixels,
......@@ -570,8 +572,8 @@ Error FramebufferGL::blit(const gl::Context *context,
if (needManualColorBlit && (mask & GL_COLOR_BUFFER_BIT) && readAttachmentSamples <= 1)
{
BlitGL *blitter = GetBlitGL(context);
ANGLE_TRY(blitter->blitColorBufferWithShader(sourceFramebuffer, destFramebuffer, sourceArea,
destArea, filter));
ANGLE_TRY(blitter->blitColorBufferWithShader(context, sourceFramebuffer, destFramebuffer,
sourceArea, destArea, filter));
blitMask &= ~GL_COLOR_BUFFER_BIT;
}
......@@ -868,23 +870,25 @@ bool FramebufferGL::modifyInvalidateAttachmentsForEmulatedDefaultFBO(
return true;
}
gl::Error FramebufferGL::readPixelsRowByRow(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels) const
angle::Result FramebufferGL::readPixelsRowByRow(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels) const
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeRowPitch(type, area.width, pack.alignment, pack.rowLength, &rowBytes));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeRowPitch(type, area.width, pack.alignment,
pack.rowLength, &rowBytes));
GLuint skipBytes = 0;
ANGLE_TRY_CHECKED_MATH(glFormat.computeSkipBytes(type, rowBytes, 0, pack, false, &skipBytes));
ANGLE_CHECK_GL_MATH(contextGL,
glFormat.computeSkipBytes(type, rowBytes, 0, pack, false, &skipBytes));
gl::PixelPackState directPack;
directPack.alignment = 1;
......@@ -897,17 +901,18 @@ gl::Error FramebufferGL::readPixelsRowByRow(const gl::Context *context,
pixels += rowBytes;
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error FramebufferGL::readPixelsAllAtOnce(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels,
bool readLastRowSeparately) const
angle::Result FramebufferGL::readPixelsAllAtOnce(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels,
bool readLastRowSeparately) const
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
......@@ -923,11 +928,11 @@ gl::Error FramebufferGL::readPixelsAllAtOnce(const gl::Context *context,
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeRowPitch(type, area.width, pack.alignment, pack.rowLength, &rowBytes));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeRowPitch(type, area.width, pack.alignment,
pack.rowLength, &rowBytes));
GLuint skipBytes = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeSkipBytes(type, rowBytes, 0, pack, false, &skipBytes));
ANGLE_CHECK_GL_MATH(contextGL,
glFormat.computeSkipBytes(type, rowBytes, 0, pack, false, &skipBytes));
gl::PixelPackState directPack;
directPack.alignment = 1;
......@@ -938,6 +943,6 @@ gl::Error FramebufferGL::readPixelsAllAtOnce(const gl::Context *context,
pixels);
}
return gl::NoError();
return angle::Result::Continue();
}
} // namespace rx
......@@ -96,20 +96,20 @@ class FramebufferGL : public FramebufferImpl
const GLenum *attachments,
std::vector<GLenum> *modifiedAttachments) const;
gl::Error readPixelsRowByRow(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels) const;
gl::Error readPixelsAllAtOnce(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels,
bool readLastRowSeparately) const;
angle::Result readPixelsRowByRow(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels) const;
angle::Result readPixelsAllAtOnce(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
const gl::PixelPackState &pack,
GLubyte *pixels,
bool readLastRowSeparately) const;
GLuint mFramebufferID;
bool mIsDefault;
......
......@@ -88,12 +88,12 @@ StandardQueryGL::~StandardQueryGL()
gl::Error StandardQueryGL::begin(const gl::Context *context)
{
mResultSum = 0;
return resume();
return resume(context);
}
gl::Error StandardQueryGL::end(const gl::Context *context)
{
return pause();
return pause(context);
}
gl::Error StandardQueryGL::queryCounter(const gl::Context *context)
......@@ -111,57 +111,47 @@ gl::Error StandardQueryGL::queryCounter(const gl::Context *context)
}
template <typename T>
gl::Error StandardQueryGL::getResultBase(T *params)
angle::Result StandardQueryGL::getResultBase(const gl::Context *context, T *params)
{
ASSERT(mActiveQuery == 0);
gl::Error error = flush(true);
if (error.isError())
{
return error;
}
ANGLE_TRY(flush(context, true));
ASSERT(mPendingQueries.empty());
*params = static_cast<T>(mResultSum);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error StandardQueryGL::getResult(const gl::Context *context, GLint *params)
{
return getResultBase(params);
return getResultBase(context, params);
}
gl::Error StandardQueryGL::getResult(const gl::Context *context, GLuint *params)
{
return getResultBase(params);
return getResultBase(context, params);
}
gl::Error StandardQueryGL::getResult(const gl::Context *context, GLint64 *params)
{
return getResultBase(params);
return getResultBase(context, params);
}
gl::Error StandardQueryGL::getResult(const gl::Context *context, GLuint64 *params)
{
return getResultBase(params);
return getResultBase(context, params);
}
gl::Error StandardQueryGL::isResultAvailable(const gl::Context *context, bool *available)
{
ASSERT(mActiveQuery == 0);
gl::Error error = flush(false);
if (error.isError())
{
return error;
}
ANGLE_TRY(flush(context, false));
*available = mPendingQueries.empty();
return gl::NoError();
}
gl::Error StandardQueryGL::pause()
angle::Result StandardQueryGL::pause(const gl::Context *context)
{
if (mActiveQuery != 0)
{
......@@ -172,34 +162,23 @@ gl::Error StandardQueryGL::pause()
}
// Flush to make sure the pending queries don't add up too much.
gl::Error error = flush(false);
if (error.isError())
{
return error;
}
return gl::NoError();
return flush(context, false);
}
gl::Error StandardQueryGL::resume()
angle::Result StandardQueryGL::resume(const gl::Context *context)
{
if (mActiveQuery == 0)
{
// Flush to make sure the pending queries don't add up too much.
gl::Error error = flush(false);
if (error.isError())
{
return error;
}
ANGLE_TRY(flush(context, false));
mFunctions->genQueries(1, &mActiveQuery);
mStateManager->beginQuery(mType, this, mActiveQuery);
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error StandardQueryGL::flush(bool force)
angle::Result StandardQueryGL::flush(const gl::Context *context, bool force)
{
while (!mPendingQueries.empty())
{
......@@ -210,7 +189,7 @@ gl::Error StandardQueryGL::flush(bool force)
mFunctions->getQueryObjectuiv(id, GL_QUERY_RESULT_AVAILABLE, &resultAvailable);
if (resultAvailable == GL_FALSE)
{
return gl::NoError();
return angle::Result::Continue();
}
}
......@@ -235,14 +214,18 @@ gl::Error StandardQueryGL::flush(bool force)
mPendingQueries.pop_front();
}
return gl::NoError();
return angle::Result::Continue();
}
class SyncProviderGL
{
public:
virtual ~SyncProviderGL() {}
virtual gl::Error flush(bool force, bool *finished) = 0;
virtual angle::Result init(const gl::Context *context, gl::QueryType queryType)
{
return angle::Result::Continue();
}
virtual angle::Result flush(const gl::Context *context, bool force, bool *finished) = 0;
};
class SyncProviderGLSync : public SyncProviderGL
......@@ -255,7 +238,7 @@ class SyncProviderGLSync : public SyncProviderGL
~SyncProviderGLSync() override { mFunctions->deleteSync(mSync); }
gl::Error flush(bool force, bool *finished) override
angle::Result flush(const gl::Context *context, bool force, bool *finished) override
{
if (force)
{
......@@ -269,7 +252,7 @@ class SyncProviderGLSync : public SyncProviderGL
*finished = (value == GL_SIGNALED);
}
return gl::NoError();
return angle::Result::Continue();
}
private:
......@@ -280,21 +263,22 @@ class SyncProviderGLSync : public SyncProviderGL
class SyncProviderGLQuery : public SyncProviderGL
{
public:
SyncProviderGLQuery(const FunctionsGL *functions,
StateManagerGL *stateManager,
gl::QueryType type)
: mFunctions(functions), mQuery(0)
SyncProviderGLQuery(const FunctionsGL *functions) : mFunctions(functions), mQuery(0) {}
angle::Result init(const gl::Context *context, gl::QueryType type) override
{
StateManagerGL *stateManager = GetStateManagerGL(context);
mFunctions->genQueries(1, &mQuery);
ANGLE_SWALLOW_ERR(stateManager->pauseQuery(type));
ANGLE_TRY(stateManager->pauseQuery(context, type));
mFunctions->beginQuery(ToGLenum(type), mQuery);
mFunctions->endQuery(ToGLenum(type));
ANGLE_SWALLOW_ERR(stateManager->resumeQuery(type));
return stateManager->resumeQuery(context, type);
}
~SyncProviderGLQuery() override { mFunctions->deleteQueries(1, &mQuery); }
gl::Error flush(bool force, bool *finished) override
angle::Result flush(const gl::Context *context, bool force, bool *finished) override
{
if (force)
{
......@@ -309,7 +293,7 @@ class SyncProviderGLQuery : public SyncProviderGL
*finished = (available == GL_TRUE);
}
return gl::NoError();
return angle::Result::Continue();
}
private:
......@@ -317,14 +301,8 @@ class SyncProviderGLQuery : public SyncProviderGL
GLuint mQuery;
};
SyncQueryGL::SyncQueryGL(gl::QueryType type,
const FunctionsGL *functions,
StateManagerGL *stateManager)
: QueryGL(type),
mFunctions(functions),
mStateManager(stateManager),
mSyncProvider(nullptr),
mFinished(false)
SyncQueryGL::SyncQueryGL(gl::QueryType type, const FunctionsGL *functions)
: QueryGL(type), mFunctions(functions), mSyncProvider(nullptr), mFinished(false)
{
ASSERT(IsSupported(mFunctions));
ASSERT(type == gl::QueryType::CommandsCompleted);
......@@ -352,8 +330,8 @@ gl::Error SyncQueryGL::end(const gl::Context *context)
}
else if (nativegl::SupportsOcclusionQueries(mFunctions))
{
mSyncProvider.reset(
new SyncProviderGLQuery(mFunctions, mStateManager, gl::QueryType::AnySamples));
mSyncProvider.reset(new SyncProviderGLQuery(mFunctions));
ANGLE_TRY(mSyncProvider->init(context, gl::QueryType::AnySamples))
}
else
{
......@@ -371,63 +349,63 @@ gl::Error SyncQueryGL::queryCounter(const gl::Context *context)
gl::Error SyncQueryGL::getResult(const gl::Context *context, GLint *params)
{
return getResultBase(params);
return getResultBase(context, params);
}
gl::Error SyncQueryGL::getResult(const gl::Context *context, GLuint *params)
{
return getResultBase(params);
return getResultBase(context, params);
}
gl::Error SyncQueryGL::getResult(const gl::Context *context, GLint64 *params)
{
return getResultBase(params);
return getResultBase(context, params);
}
gl::Error SyncQueryGL::getResult(const gl::Context *context, GLuint64 *params)
{
return getResultBase(params);
return getResultBase(context, params);
}
gl::Error SyncQueryGL::isResultAvailable(const gl::Context *context, bool *available)
{
ANGLE_TRY(flush(false));
ANGLE_TRY(flush(context, false));
*available = mFinished;
return gl::NoError();
}
gl::Error SyncQueryGL::pause()
angle::Result SyncQueryGL::pause(const gl::Context *context)
{
return gl::NoError();
return angle::Result::Continue();
}
gl::Error SyncQueryGL::resume()
angle::Result SyncQueryGL::resume(const gl::Context *context)
{
return gl::NoError();
return angle::Result::Continue();
}
gl::Error SyncQueryGL::flush(bool force)
angle::Result SyncQueryGL::flush(const gl::Context *context, bool force)
{
if (mSyncProvider == nullptr)
{
ASSERT(mFinished);
return gl::NoError();
return angle::Result::Continue();
}
ANGLE_TRY(mSyncProvider->flush(force, &mFinished));
ANGLE_TRY(mSyncProvider->flush(context, force, &mFinished));
if (mFinished)
{
mSyncProvider.reset();
}
return gl::NoError();
return angle::Result::Continue();
}
template <typename T>
gl::Error SyncQueryGL::getResultBase(T *params)
angle::Result SyncQueryGL::getResultBase(const gl::Context *context, T *params)
{
ANGLE_TRY(flush(true));
ANGLE_TRY(flush(context, true));
*params = static_cast<T>(mFinished ? GL_TRUE : GL_FALSE);
return gl::NoError();
}
return angle::Result::Continue();
}
} // namespace rx
......@@ -31,8 +31,8 @@ class QueryGL : public QueryImpl
// When it is "resumed", a new query is generated and started.
// When a result is required, the queries are "flushed" by iterating over the list of pending
// queries and merging their results.
virtual gl::Error pause() = 0;
virtual gl::Error resume() = 0;
virtual angle::Result pause(const gl::Context *context) = 0;
virtual angle::Result resume(const gl::Context *context) = 0;
};
class StandardQueryGL : public QueryGL
......@@ -50,14 +50,14 @@ class StandardQueryGL : public QueryGL
gl::Error getResult(const gl::Context *context, GLuint64 *params) override;
gl::Error isResultAvailable(const gl::Context *context, bool *available) override;
gl::Error pause() override;
gl::Error resume() override;
angle::Result pause(const gl::Context *context) override;
angle::Result resume(const gl::Context *context) override;
private:
gl::Error flush(bool force);
angle::Result flush(const gl::Context *context, bool force);
template <typename T>
gl::Error getResultBase(T *params);
angle::Result getResultBase(const gl::Context *context, T *params);
gl::QueryType mType;
......@@ -73,7 +73,7 @@ class SyncProviderGL;
class SyncQueryGL : public QueryGL
{
public:
SyncQueryGL(gl::QueryType type, const FunctionsGL *functions, StateManagerGL *stateManager);
SyncQueryGL(gl::QueryType type, const FunctionsGL *functions);
~SyncQueryGL() override;
static bool IsSupported(const FunctionsGL *functions);
......@@ -87,17 +87,16 @@ class SyncQueryGL : public QueryGL
gl::Error getResult(const gl::Context *context, GLuint64 *params) override;
gl::Error isResultAvailable(const gl::Context *context, bool *available) override;
gl::Error pause() override;
gl::Error resume() override;
angle::Result pause(const gl::Context *context) override;
angle::Result resume(const gl::Context *context) override;
private:
gl::Error flush(bool force);
angle::Result flush(const gl::Context *context, bool force);
template <typename T>
gl::Error getResultBase(T *params);
angle::Result getResultBase(const gl::Context *context, T *params);
const FunctionsGL *mFunctions;
StateManagerGL *mStateManager;
std::unique_ptr<SyncProviderGL> mSyncProvider;
bool mFinished;
......
......@@ -224,13 +224,13 @@ RendererGL::~RendererGL()
SafeDelete(mStateManager);
}
gl::Error RendererGL::flush()
angle::Result RendererGL::flush()
{
mFunctions->flush();
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::finish()
angle::Result RendererGL::finish()
{
if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mUseDebugOutput)
{
......@@ -244,13 +244,13 @@ gl::Error RendererGL::finish()
mFunctions->disable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count)
angle::Result RendererGL::drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count)
{
const gl::Program *program = context->getGLState().getProgram();
const bool usesMultiview = program->usesMultiview();
......@@ -265,14 +265,14 @@ gl::Error RendererGL::drawArrays(const gl::Context *context,
{
mFunctions->drawArraysInstanced(ToGLenum(mode), first, count, instanceCount);
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::drawArraysInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count,
GLsizei instanceCount)
angle::Result RendererGL::drawArraysInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count,
GLsizei instanceCount)
{
GLsizei adjustedInstanceCount = instanceCount;
const gl::Program *program = context->getGLState().getProgram();
......@@ -283,14 +283,14 @@ gl::Error RendererGL::drawArraysInstanced(const gl::Context *context,
ANGLE_TRY(mStateManager->setDrawArraysState(context, first, count, adjustedInstanceCount));
mFunctions->drawArraysInstanced(ToGLenum(mode), first, count, adjustedInstanceCount);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::drawElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
GLenum type,
const void *indices)
angle::Result RendererGL::drawElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
GLenum type,
const void *indices)
{
const gl::Program *program = context->getGLState().getProgram();
const bool usesMultiview = program->usesMultiview();
......@@ -307,15 +307,15 @@ gl::Error RendererGL::drawElements(const gl::Context *context,
{
mFunctions->drawElementsInstanced(ToGLenum(mode), count, type, drawIndexPtr, instanceCount);
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::drawElementsInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instances)
angle::Result RendererGL::drawElementsInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instances)
{
GLsizei adjustedInstanceCount = instances;
const gl::Program *program = context->getGLState().getProgram();
......@@ -329,16 +329,16 @@ gl::Error RendererGL::drawElementsInstanced(const gl::Context *context,
adjustedInstanceCount, &drawIndexPointer));
mFunctions->drawElementsInstanced(ToGLenum(mode), count, type, drawIndexPointer,
adjustedInstanceCount);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::drawRangeElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const void *indices)
angle::Result RendererGL::drawRangeElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const void *indices)
{
const gl::Program *program = context->getGLState().getProgram();
const bool usesMultiview = program->usesMultiview();
......@@ -356,26 +356,26 @@ gl::Error RendererGL::drawRangeElements(const gl::Context *context,
mFunctions->drawElementsInstanced(ToGLenum(mode), count, type, drawIndexPointer,
instanceCount);
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::drawArraysIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
const void *indirect)
angle::Result RendererGL::drawArraysIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
const void *indirect)
{
ANGLE_TRY(mStateManager->setDrawIndirectState(context));
mFunctions->drawArraysIndirect(ToGLenum(mode), indirect);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::drawElementsIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
GLenum type,
const void *indirect)
angle::Result RendererGL::drawElementsIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
GLenum type,
const void *indirect)
{
ANGLE_TRY(mStateManager->setDrawIndirectState(context));
mFunctions->drawElementsIndirect(ToGLenum(mode), type, indirect);
return gl::NoError();
return angle::Result::Continue();
}
void RendererGL::stencilFillPath(const gl::ContextState &state,
......@@ -678,32 +678,32 @@ void RendererGL::applyNativeWorkarounds(gl::Workarounds *workarounds) const
nativegl_gl::ApplyWorkarounds(mFunctions.get(), workarounds);
}
gl::Error RendererGL::dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
GLuint numGroupsY,
GLuint numGroupsZ)
angle::Result RendererGL::dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
GLuint numGroupsY,
GLuint numGroupsZ)
{
ANGLE_TRY(mStateManager->setDispatchComputeState(context));
mFunctions->dispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
angle::Result RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
{
ANGLE_TRY(mStateManager->setDispatchComputeState(context));
mFunctions->dispatchComputeIndirect(indirect);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::memoryBarrier(GLbitfield barriers)
angle::Result RendererGL::memoryBarrier(GLbitfield barriers)
{
mFunctions->memoryBarrier(barriers);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error RendererGL::memoryBarrierByRegion(GLbitfield barriers)
angle::Result RendererGL::memoryBarrierByRegion(GLbitfield barriers)
{
mFunctions->memoryBarrierByRegion(barriers);
return gl::NoError();
return angle::Result::Continue();
}
} // namespace rx
......@@ -47,44 +47,44 @@ class RendererGL : angle::NonCopyable
RendererGL(std::unique_ptr<FunctionsGL> functions, const egl::AttributeMap &attribMap);
virtual ~RendererGL();
gl::Error flush();
gl::Error finish();
gl::Error drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count);
gl::Error drawArraysInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count,
GLsizei instanceCount);
gl::Error drawElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
GLenum type,
const void *indices);
gl::Error drawElementsInstanced(const gl::Context *context,
angle::Result flush();
angle::Result finish();
angle::Result drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count);
angle::Result drawArraysInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
GLsizei count,
GLsizei instanceCount);
angle::Result drawElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
GLenum type,
const void *indices);
angle::Result drawElementsInstanced(const gl::Context *context,
gl::PrimitiveMode mode,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instances);
angle::Result drawRangeElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instances);
gl::Error drawRangeElements(const gl::Context *context,
gl::PrimitiveMode mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const void *indices);
gl::Error drawArraysIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
const void *indirect);
gl::Error drawElementsIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
GLenum type,
const void *indirect);
const void *indices);
angle::Result drawArraysIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
const void *indirect);
angle::Result drawElementsIndirect(const gl::Context *context,
gl::PrimitiveMode mode,
GLenum type,
const void *indirect);
// CHROMIUM_path_rendering implementation
void stencilFillPath(const gl::ContextState &state,
......@@ -176,14 +176,14 @@ class RendererGL : angle::NonCopyable
const gl::Limitations &getNativeLimitations() const;
void applyNativeWorkarounds(gl::Workarounds *workarounds) const;
gl::Error dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
GLuint numGroupsY,
GLuint numGroupsZ);
gl::Error dispatchComputeIndirect(const gl::Context *context, GLintptr indirect);
angle::Result dispatchCompute(const gl::Context *context,
GLuint numGroupsX,
GLuint numGroupsY,
GLuint numGroupsZ);
angle::Result dispatchComputeIndirect(const gl::Context *context, GLintptr indirect);
gl::Error memoryBarrier(GLbitfield barriers);
gl::Error memoryBarrierByRegion(GLbitfield barriers);
angle::Result memoryBarrier(GLbitfield barriers);
angle::Result memoryBarrierByRegion(GLbitfield barriers);
private:
void ensureCapsInitialized() const;
......
......@@ -679,10 +679,10 @@ void StateManagerGL::endQuery(gl::QueryType type, QueryGL *queryObject, GLuint q
mFunctions->endQuery(ToGLenum(type));
}
gl::Error StateManagerGL::setDrawArraysState(const gl::Context *context,
GLint first,
GLsizei count,
GLsizei instanceCount)
angle::Result StateManagerGL::setDrawArraysState(const gl::Context *context,
GLint first,
GLsizei count,
GLsizei instanceCount)
{
const gl::State &glState = context->getGLState();
......@@ -697,12 +697,12 @@ gl::Error StateManagerGL::setDrawArraysState(const gl::Context *context,
return setGenericDrawState(context);
}
gl::Error StateManagerGL::setDrawElementsState(const gl::Context *context,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
const void **outIndices)
angle::Result StateManagerGL::setDrawElementsState(const gl::Context *context,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
const void **outIndices)
{
const gl::State &glState = context->getGLState();
......@@ -718,7 +718,7 @@ gl::Error StateManagerGL::setDrawElementsState(const gl::Context *context,
return setGenericDrawState(context);
}
gl::Error StateManagerGL::setDrawIndirectState(const gl::Context *context)
angle::Result StateManagerGL::setDrawIndirectState(const gl::Context *context)
{
return setGenericDrawState(context);
}
......@@ -745,10 +745,10 @@ void StateManagerGL::updateDispatchIndirectBufferBinding(const gl::Context *cont
}
}
gl::Error StateManagerGL::setDispatchComputeState(const gl::Context *context)
angle::Result StateManagerGL::setDispatchComputeState(const gl::Context *context)
{
setGenericShaderState(context);
return gl::NoError();
return angle::Result::Continue();
}
void StateManagerGL::pauseTransformFeedback()
......@@ -760,7 +760,7 @@ void StateManagerGL::pauseTransformFeedback()
}
}
gl::Error StateManagerGL::pauseAllQueries()
angle::Result StateManagerGL::pauseAllQueries(const gl::Context *context)
{
for (gl::QueryType type : angle::AllEnums<gl::QueryType>())
{
......@@ -768,30 +768,30 @@ gl::Error StateManagerGL::pauseAllQueries()
if (previousQuery != nullptr)
{
ANGLE_TRY(previousQuery->pause());
ANGLE_TRY(previousQuery->pause(context));
mTemporaryPausedQueries[type] = previousQuery;
mQueries[type] = nullptr;
}
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error StateManagerGL::pauseQuery(gl::QueryType type)
angle::Result StateManagerGL::pauseQuery(const gl::Context *context, gl::QueryType type)
{
QueryGL *previousQuery = mQueries[type];
if (previousQuery)
{
ANGLE_TRY(previousQuery->pause());
ANGLE_TRY(previousQuery->pause(context));
mTemporaryPausedQueries[type] = previousQuery;
mQueries[type] = nullptr;
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error StateManagerGL::resumeAllQueries()
angle::Result StateManagerGL::resumeAllQueries(const gl::Context *context)
{
for (gl::QueryType type : angle::AllEnums<gl::QueryType>())
{
......@@ -800,28 +800,28 @@ gl::Error StateManagerGL::resumeAllQueries()
if (pausedQuery != nullptr)
{
ASSERT(mQueries[type] == nullptr);
ANGLE_TRY(pausedQuery->resume());
ANGLE_TRY(pausedQuery->resume(context));
mTemporaryPausedQueries[type] = nullptr;
}
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error StateManagerGL::resumeQuery(gl::QueryType type)
angle::Result StateManagerGL::resumeQuery(const gl::Context *context, gl::QueryType type)
{
QueryGL *pausedQuery = mTemporaryPausedQueries[type];
if (pausedQuery != nullptr)
{
ANGLE_TRY(pausedQuery->resume());
ANGLE_TRY(pausedQuery->resume(context));
mTemporaryPausedQueries[type] = nullptr;
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error StateManagerGL::onMakeCurrent(const gl::Context *context)
angle::Result StateManagerGL::onMakeCurrent(const gl::Context *context)
{
const gl::State &glState = context->getGLState();
......@@ -843,7 +843,7 @@ gl::Error StateManagerGL::onMakeCurrent(const gl::Context *context)
// Pause any old query object
if (currentQuery != nullptr)
{
ANGLE_TRY(currentQuery->pause());
ANGLE_TRY(currentQuery->pause(context));
mQueries[type] = nullptr;
}
......@@ -852,7 +852,7 @@ gl::Error StateManagerGL::onMakeCurrent(const gl::Context *context)
if (newQuery != nullptr)
{
QueryGL *queryGL = GetImplAs<QueryGL>(newQuery);
ANGLE_TRY(queryGL->resume());
ANGLE_TRY(queryGL->resume(context));
}
}
}
......@@ -863,7 +863,7 @@ gl::Error StateManagerGL::onMakeCurrent(const gl::Context *context)
// this state here since MakeCurrent is expected to be called less frequently than draw calls.
setTextureCubemapSeamlessEnabled(context->getClientMajorVersion() >= 3);
return gl::NoError();
return angle::Result::Continue();
}
void StateManagerGL::setGenericShaderState(const gl::Context *context)
......@@ -1038,7 +1038,7 @@ void StateManagerGL::updateProgramImageBindings(const gl::Context *context)
}
}
gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context)
angle::Result StateManagerGL::setGenericDrawState(const gl::Context *context)
{
setGenericShaderState(context);
......@@ -1057,7 +1057,7 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context)
ASSERT(mVAO ==
GetImplAs<VertexArrayGL>(context->getGLState().getVertexArray())->getVertexArrayID());
return gl::NoError();
return angle::Result::Continue();
}
void StateManagerGL::setAttributeCurrentData(size_t index,
......
......@@ -153,26 +153,26 @@ class StateManagerGL final : angle::NonCopyable
void setPathRenderingProjectionMatrix(const GLfloat *m);
void setPathRenderingStencilState(GLenum func, GLint ref, GLuint mask);
gl::Error setDrawArraysState(const gl::Context *context,
GLint first,
GLsizei count,
GLsizei instanceCount);
gl::Error setDrawElementsState(const gl::Context *context,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
const void **outIndices);
gl::Error setDrawIndirectState(const gl::Context *context);
gl::Error setDispatchComputeState(const gl::Context *context);
angle::Result setDrawArraysState(const gl::Context *context,
GLint first,
GLsizei count,
GLsizei instanceCount);
angle::Result setDrawElementsState(const gl::Context *context,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
const void **outIndices);
angle::Result setDrawIndirectState(const gl::Context *context);
angle::Result setDispatchComputeState(const gl::Context *context);
void pauseTransformFeedback();
gl::Error pauseAllQueries();
gl::Error pauseQuery(gl::QueryType type);
gl::Error resumeAllQueries();
gl::Error resumeQuery(gl::QueryType type);
gl::Error onMakeCurrent(const gl::Context *context);
angle::Result pauseAllQueries(const gl::Context *context);
angle::Result pauseQuery(const gl::Context *context, gl::QueryType type);
angle::Result resumeAllQueries(const gl::Context *context);
angle::Result resumeQuery(const gl::Context *context, gl::QueryType type);
angle::Result onMakeCurrent(const gl::Context *context);
void syncState(const gl::Context *context, const gl::State::DirtyBits &glDirtyBits);
......@@ -185,7 +185,7 @@ class StateManagerGL final : angle::NonCopyable
void setGenericShaderState(const gl::Context *context);
// Set state that's common among draw commands.
gl::Error setGenericDrawState(const gl::Context *context);
angle::Result setGenericDrawState(const gl::Context *context);
void setTextureCubemapSeamlessEnabled(bool enabled);
......
......@@ -17,6 +17,7 @@
#include "libANGLE/angletypes.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/gl/BufferGL.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/StateManagerGL.h"
#include "libANGLE/renderer/gl/renderergl_utils.h"
......@@ -103,24 +104,24 @@ void VertexArrayGL::destroy(const gl::Context *context)
}
}
gl::Error VertexArrayGL::syncDrawArraysState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLsizei instanceCount) const
angle::Result VertexArrayGL::syncDrawArraysState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLsizei instanceCount) const
{
return syncDrawState(context, activeAttributesMask, first, count, GL_NONE, nullptr,
instanceCount, false, nullptr);
}
gl::Error VertexArrayGL::syncDrawElementsState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const
angle::Result VertexArrayGL::syncDrawElementsState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const
{
return syncDrawState(context, activeAttributesMask, 0, count, type, indices, instanceCount,
primitiveRestartEnabled, outIndices);
......@@ -137,15 +138,15 @@ void VertexArrayGL::updateElementArrayBufferBinding(const gl::Context *context)
}
}
gl::Error VertexArrayGL::syncDrawState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const
angle::Result VertexArrayGL::syncDrawState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const
{
// Check if any attributes need to be streamed, determines if the index range needs to be
// computed
......@@ -169,20 +170,20 @@ gl::Error VertexArrayGL::syncDrawState(const gl::Context *context,
if (needsStreamingAttribs.any())
{
ANGLE_TRY(streamAttributes(needsStreamingAttribs, instanceCount, indexRange));
ANGLE_TRY(streamAttributes(context, needsStreamingAttribs, instanceCount, indexRange));
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error VertexArrayGL::syncIndexData(const gl::Context *context,
GLsizei count,
GLenum type,
const void *indices,
bool primitiveRestartEnabled,
bool attributesNeedStreaming,
IndexRange *outIndexRange,
const void **outIndices) const
angle::Result VertexArrayGL::syncIndexData(const gl::Context *context,
GLsizei count,
GLenum type,
const void *indices,
bool primitiveRestartEnabled,
bool attributesNeedStreaming,
IndexRange *outIndexRange,
const void **outIndices) const
{
ASSERT(outIndices);
......@@ -196,13 +197,9 @@ gl::Error VertexArrayGL::syncIndexData(const gl::Context *context,
if (attributesNeedStreaming)
{
ptrdiff_t elementArrayBufferOffset = reinterpret_cast<ptrdiff_t>(indices);
Error error = mState.getElementArrayBuffer()->getIndexRange(
context, type, elementArrayBufferOffset, count, primitiveRestartEnabled,
outIndexRange);
if (error.isError())
{
return error;
}
ANGLE_TRY_HANDLE(context, mState.getElementArrayBuffer()->getIndexRange(
context, type, elementArrayBufferOffset, count,
primitiveRestartEnabled, outIndexRange));
}
// Indices serves as an offset into the index buffer in this case, use the same value for
......@@ -254,7 +251,7 @@ gl::Error VertexArrayGL::syncIndexData(const gl::Context *context,
*outIndices = nullptr;
}
return gl::NoError();
return angle::Result::Continue();
}
void VertexArrayGL::computeStreamingAttributeSizes(const gl::AttributesMask &attribsToStream,
......@@ -288,9 +285,10 @@ void VertexArrayGL::computeStreamingAttributeSizes(const gl::AttributesMask &att
}
}
gl::Error VertexArrayGL::streamAttributes(const gl::AttributesMask &attribsToStream,
GLsizei instanceCount,
const gl::IndexRange &indexRange) const
angle::Result VertexArrayGL::streamAttributes(const gl::Context *context,
const gl::AttributesMask &attribsToStream,
GLsizei instanceCount,
const gl::IndexRange &indexRange) const
{
// Sync the vertex attribute state and track what data needs to be streamed
size_t streamingDataSize = 0;
......@@ -301,7 +299,7 @@ gl::Error VertexArrayGL::streamAttributes(const gl::AttributesMask &attribsToStr
if (streamingDataSize == 0)
{
return gl::NoError();
return angle::Result::Continue();
}
if (mStreamingArrayBuffer == 0)
......@@ -392,12 +390,9 @@ gl::Error VertexArrayGL::streamAttributes(const gl::AttributesMask &attribsToStr
unmapResult = mFunctions->unmapBuffer(GL_ARRAY_BUFFER);
}
if (unmapResult != GL_TRUE)
{
return gl::OutOfMemory() << "Failed to unmap the client data streaming buffer.";
}
return gl::NoError();
ANGLE_CHECK(GetImplAs<ContextGL>(context), unmapResult == GL_TRUE,
"Failed to unmap the client data streaming buffer.", GL_OUT_OF_MEMORY);
return angle::Result::Continue();
}
GLuint VertexArrayGL::getVertexArrayID() const
......
......@@ -27,19 +27,19 @@ class VertexArrayGL : public VertexArrayImpl
void destroy(const gl::Context *context) override;
gl::Error syncDrawArraysState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLsizei instanceCount) const;
gl::Error syncDrawElementsState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const;
angle::Result syncDrawArraysState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLsizei instanceCount) const;
angle::Result syncDrawElementsState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const;
GLuint getVertexArrayID() const;
GLuint getAppliedElementArrayBufferID() const;
......@@ -53,25 +53,25 @@ class VertexArrayGL : public VertexArrayImpl
void applyActiveAttribLocationsMask(const gl::AttributesMask &activeMask);
private:
gl::Error syncDrawState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const;
angle::Result syncDrawState(const gl::Context *context,
const gl::AttributesMask &activeAttributesMask,
GLint first,
GLsizei count,
GLenum type,
const void *indices,
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const;
// Apply index data, only sets outIndexRange if attributesNeedStreaming is true
gl::Error syncIndexData(const gl::Context *context,
GLsizei count,
GLenum type,
const void *indices,
bool primitiveRestartEnabled,
bool attributesNeedStreaming,
gl::IndexRange *outIndexRange,
const void **outIndices) const;
angle::Result syncIndexData(const gl::Context *context,
GLsizei count,
GLenum type,
const void *indices,
bool primitiveRestartEnabled,
bool attributesNeedStreaming,
gl::IndexRange *outIndexRange,
const void **outIndices) const;
// Returns the amount of space needed to stream all attributes that need streaming
// and the data size of the largest attribute
......@@ -82,9 +82,10 @@ class VertexArrayGL : public VertexArrayImpl
size_t *outMaxAttributeDataSize) const;
// Stream attributes that have client data
gl::Error streamAttributes(const gl::AttributesMask &attribsToStream,
GLsizei instanceCount,
const gl::IndexRange &indexRange) const;
angle::Result streamAttributes(const gl::Context *context,
const gl::AttributesMask &attribsToStream,
GLsizei instanceCount,
const gl::IndexRange &indexRange) const;
void syncDirtyAttrib(const gl::Context *context,
size_t attribIndex,
const gl::VertexArray::DirtyAttribBits &dirtyAttribBits);
......@@ -92,7 +93,6 @@ class VertexArrayGL : public VertexArrayImpl
size_t bindingIndex,
const gl::VertexArray::DirtyBindingBits &dirtyBindingBits);
void updateNeedsStreaming(size_t attribIndex);
void updateAttribEnabled(size_t attribIndex);
void updateAttribPointer(const gl::Context *context, size_t attribIndex);
......
......@@ -1390,19 +1390,20 @@ uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions,
}
}
gl::Error ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
const gl::PixelStoreStateBase &state,
const gl::Buffer *pixelBuffer,
GLenum format,
GLenum type,
bool is3D,
const void *pixels,
bool *shouldApplyOut)
angle::Result ShouldApplyLastRowPaddingWorkaround(ContextGL *contextGL,
const gl::Extents &size,
const gl::PixelStoreStateBase &state,
const gl::Buffer *pixelBuffer,
GLenum format,
GLenum type,
bool is3D,
const void *pixels,
bool *shouldApplyOut)
{
if (pixelBuffer == nullptr)
{
*shouldApplyOut = false;
return gl::NoError();
return angle::Result::Continue();
}
// We are using an pack or unpack buffer, compute what the driver thinks is going to be the
......@@ -1411,10 +1412,11 @@ gl::Error ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint endByte = 0;
ANGLE_TRY_CHECKED_MATH(glFormat.computePackUnpackEndByte(type, size, state, is3D, &endByte));
ANGLE_CHECK_GL_MATH(contextGL,
glFormat.computePackUnpackEndByte(type, size, state, is3D, &endByte));
GLuint rowPitch = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeRowPitch(type, size.width, state.alignment, state.rowLength, &rowPitch));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeRowPitch(type, size.width, state.alignment,
state.rowLength, &rowPitch));
CheckedNumeric<size_t> checkedPixelBytes = glFormat.computePixelBytes(type);
CheckedNumeric<size_t> checkedEndByte =
......@@ -1422,16 +1424,16 @@ gl::Error ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
// At this point checkedEndByte is the actual last byte read.
// The driver adds an extra row padding (if any), mimic it.
ANGLE_TRY_CHECKED_MATH(checkedPixelBytes.IsValid());
ANGLE_CHECK_GL_MATH(contextGL, checkedPixelBytes.IsValid());
if (checkedPixelBytes.ValueOrDie() * size.width < rowPitch)
{
checkedEndByte += rowPitch - checkedPixelBytes * size.width;
}
ANGLE_TRY_CHECKED_MATH(checkedEndByte.IsValid());
ANGLE_CHECK_GL_MATH(contextGL, checkedEndByte.IsValid());
*shouldApplyOut = checkedEndByte.ValueOrDie() > static_cast<size_t>(pixelBuffer->getSize());
return gl::NoError();
return angle::Result::Continue();
}
std::vector<ContextCreationTry> GenerateContextCreationToTry(EGLint requestedType, bool isMesaGLX)
......
......@@ -32,6 +32,7 @@ namespace rx
{
class BlitGL;
class ClearMultiviewGL;
class ContextGL;
class FunctionsGL;
class StateManagerGL;
struct WorkaroundsGL;
......@@ -83,14 +84,15 @@ uint8_t *MapBufferRangeWithFallback(const FunctionsGL *functions,
size_t length,
GLbitfield access);
gl::Error ShouldApplyLastRowPaddingWorkaround(const gl::Extents &size,
const gl::PixelStoreStateBase &state,
const gl::Buffer *pixelBuffer,
GLenum format,
GLenum type,
bool is3D,
const void *pixels,
bool *shouldApplyOut);
angle::Result ShouldApplyLastRowPaddingWorkaround(ContextGL *contextGL,
const gl::Extents &size,
const gl::PixelStoreStateBase &state,
const gl::Buffer *pixelBuffer,
GLenum format,
GLenum type,
bool is3D,
const void *pixels,
bool *shouldApplyOut);
struct ContextCreationTry
{
......@@ -112,6 +114,12 @@ struct ContextCreationTry
};
std::vector<ContextCreationTry> GenerateContextCreationToTry(EGLint requestedType, bool isMesaGLX);
}
} // namespace rx
#define ANGLE_CHECK_GL_ALLOC(context, result) \
ANGLE_CHECK(context, result, "Failed to allocate host memory", GL_OUT_OF_MEMORY)
#define ANGLE_CHECK_GL_MATH(context, result) \
ANGLE_CHECK(context, result, "Integer overflow.", GL_INVALID_OPERATION)
#endif // LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
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