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/1255647
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill 2018-10-05 08:17:38 -04:00 коммит произвёл Commit Bot
Родитель 06270c9eac
Коммит e39e8f46c3
27 изменённых файлов: 738 добавлений и 702 удалений

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

@ -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();

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

@ -16,6 +16,7 @@
#include "libANGLE/Framebuffer.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/Format.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/RenderbufferGL.h"
@ -34,31 +35,31 @@ namespace rx
namespace
{
gl::Error CheckCompileStatus(const rx::FunctionsGL *functions, GLuint shader)
angle::Result CheckCompileStatus(ContextGL *contextGL,
const rx::FunctionsGL *functions,
GLuint shader)
{
GLint compileStatus = GL_FALSE;
functions->getShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
ASSERT(compileStatus == GL_TRUE);
if (compileStatus == GL_FALSE)
{
return gl::OutOfMemory() << "Failed to compile internal blit shader.";
}
ANGLE_CHECK(contextGL, compileStatus == GL_TRUE, "Failed to compile internal blit shader.",
GL_OUT_OF_MEMORY);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error CheckLinkStatus(const rx::FunctionsGL *functions, GLuint program)
angle::Result CheckLinkStatus(ContextGL *contextGL,
const rx::FunctionsGL *functions,
GLuint program)
{
GLint linkStatus = GL_FALSE;
functions->getProgramiv(program, GL_LINK_STATUS, &linkStatus);
ASSERT(linkStatus == GL_TRUE);
if (linkStatus == GL_FALSE)
{
return gl::OutOfMemory() << "Failed to link internal blit program.";
}
ANGLE_CHECK(contextGL, linkStatus == GL_TRUE, "Failed to link internal blit program.",
GL_OUT_OF_MEMORY);
return gl::NoError();
return angle::Result::Continue();
}
class ScopedGLState : angle::NonCopyable
@ -69,56 +70,65 @@ class ScopedGLState : angle::NonCopyable
KEEP_SCISSOR = 1,
};
ScopedGLState(StateManagerGL *stateManager,
const FunctionsGL *functions,
gl::Rectangle viewport,
int keepState = 0)
: mStateManager(stateManager), mFunctions(functions)
ScopedGLState() {}
~ScopedGLState() { ASSERT(mExited); }
angle::Result enter(const gl::Context *context, gl::Rectangle viewport, int keepState = 0)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
StateManagerGL *stateManager = contextGL->getStateManager();
if (!(keepState & KEEP_SCISSOR))
{
mStateManager->setScissorTestEnabled(false);
stateManager->setScissorTestEnabled(false);
}
mStateManager->setViewport(viewport);
mStateManager->setDepthRange(0.0f, 1.0f);
mStateManager->setBlendEnabled(false);
mStateManager->setColorMask(true, true, true, true);
mStateManager->setSampleAlphaToCoverageEnabled(false);
mStateManager->setSampleCoverageEnabled(false);
mStateManager->setDepthTestEnabled(false);
mStateManager->setStencilTestEnabled(false);
mStateManager->setCullFaceEnabled(false);
mStateManager->setPolygonOffsetFillEnabled(false);
mStateManager->setRasterizerDiscardEnabled(false);
stateManager->setViewport(viewport);
stateManager->setDepthRange(0.0f, 1.0f);
stateManager->setBlendEnabled(false);
stateManager->setColorMask(true, true, true, true);
stateManager->setSampleAlphaToCoverageEnabled(false);
stateManager->setSampleCoverageEnabled(false);
stateManager->setDepthTestEnabled(false);
stateManager->setStencilTestEnabled(false);
stateManager->setCullFaceEnabled(false);
stateManager->setPolygonOffsetFillEnabled(false);
stateManager->setRasterizerDiscardEnabled(false);
mStateManager->pauseTransformFeedback();
ANGLE_SWALLOW_ERR(mStateManager->pauseAllQueries());
stateManager->pauseTransformFeedback();
return stateManager->pauseAllQueries(context);
}
~ScopedGLState()
angle::Result exit(const gl::Context *context)
{
mExited = true;
ContextGL *contextGL = GetImplAs<ContextGL>(context);
StateManagerGL *stateManager = contextGL->getStateManager();
// XFB resuming will be done automatically
ANGLE_SWALLOW_ERR(mStateManager->resumeAllQueries());
return stateManager->resumeAllQueries(context);
}
void willUseTextureUnit(int unit)
void willUseTextureUnit(const gl::Context *context, int unit)
{
if (mFunctions->bindSampler)
ContextGL *contextGL = GetImplAs<ContextGL>(context);
if (contextGL->getFunctions()->bindSampler)
{
mStateManager->bindSampler(unit, 0);
contextGL->getStateManager()->bindSampler(unit, 0);
}
}
private:
StateManagerGL *mStateManager;
const FunctionsGL *mFunctions;
bool mExited = false;
};
gl::Error SetClearState(StateManagerGL *stateManager,
bool colorClear,
bool depthClear,
bool stencilClear,
GLbitfield *outClearMask)
angle::Result SetClearState(StateManagerGL *stateManager,
bool colorClear,
bool depthClear,
bool stencilClear,
GLbitfield *outClearMask)
{
*outClearMask = 0;
if (colorClear)
@ -141,15 +151,15 @@ gl::Error SetClearState(StateManagerGL *stateManager,
stateManager->setScissorTestEnabled(false);
return gl::NoError();
return angle::Result::Continue();
}
using ClearBindTargetVector = angle::FixedVector<GLenum, 3>;
gl::Error PrepareForClear(StateManagerGL *stateManager,
GLenum sizedInternalFormat,
ClearBindTargetVector *outBindtargets,
GLbitfield *outClearMask)
angle::Result PrepareForClear(StateManagerGL *stateManager,
GLenum sizedInternalFormat,
ClearBindTargetVector *outBindtargets,
GLbitfield *outClearMask)
{
const gl::InternalFormat &internalFormatInfo =
gl::GetSizedInternalFormatInfo(sizedInternalFormat);
@ -173,7 +183,7 @@ gl::Error PrepareForClear(StateManagerGL *stateManager,
ANGLE_TRY(SetClearState(stateManager, bindColor, bindDepth, bindStencil, outClearMask));
return gl::NoError();
return angle::Result::Continue();
}
void UnbindAttachments(const FunctionsGL *functions,
@ -237,15 +247,15 @@ BlitGL::~BlitGL()
}
}
gl::Error BlitGL::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 BlitGL::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)
{
mStateManager->bindTexture(textureType, texture);
@ -253,7 +263,7 @@ gl::Error BlitGL::copyImageToLUMAWorkaroundTexture(const gl::Context *context,
GLenum format = gl::GetUnsizedFormat(internalFormat);
GLenum readType = GL_NONE;
ANGLE_TRY(source->getImplementationColorReadType(context, &readType));
ANGLE_TRY_HANDLE(context, source->getImplementationColorReadType(context, &readType));
gl::PixelUnpackState unpack;
mStateManager->setPixelUnpackState(unpack);
@ -266,30 +276,30 @@ gl::Error BlitGL::copyImageToLUMAWorkaroundTexture(const gl::Context *context,
level, gl::Offset(0, 0, 0), sourceArea, source);
}
gl::Error BlitGL::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 BlitGL::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_TRY(initializeResources());
BlitProgram *blitProgram = nullptr;
ANGLE_TRY(getBlitProgram(BlitProgramType::FLOAT_TO_FLOAT, &blitProgram));
ANGLE_TRY(getBlitProgram(context, BlitProgramType::FLOAT_TO_FLOAT, &blitProgram));
// Blit the framebuffer to the first scratch texture
const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source);
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID());
GLenum readFormat = GL_NONE;
ANGLE_TRY(source->getImplementationColorReadFormat(context, &readFormat));
ANGLE_TRY_HANDLE(context, source->getImplementationColorReadFormat(context, &readFormat));
GLenum readType = GL_NONE;
ANGLE_TRY(source->getImplementationColorReadType(context, &readType));
ANGLE_TRY_HANDLE(context, source->getImplementationColorReadType(context, &readType));
nativegl::CopyTexImageImageFormat copyTexImageFormat =
nativegl::GetCopyTexImageImageFormat(mFunctions, mWorkarounds, readFormat, readType);
@ -318,9 +328,9 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(const gl::Context *context
mScratchTextures[1], 0);
// Render to the destination texture, sampling from the scratch texture
ScopedGLState scopedState(mStateManager, mFunctions,
gl::Rectangle(0, 0, sourceArea.width, sourceArea.height));
scopedState.willUseTextureUnit(0);
ScopedGLState scopedState;
ANGLE_TRY(scopedState.enter(context, gl::Rectangle(0, 0, sourceArea.width, sourceArea.height)));
scopedState.willUseTextureUnit(context, 0);
setScratchTextureParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
setScratchTextureParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@ -356,19 +366,21 @@ gl::Error BlitGL::copySubImageToLUMAWorkaroundTexture(const gl::Context *context
// Finally orphan the scratch textures so they can be GCed by the driver.
orphanScratchTextures();
return gl::NoError();
ANGLE_TRY(scopedState.exit(context));
return angle::Result::Continue();
}
gl::Error BlitGL::blitColorBufferWithShader(const gl::Framebuffer *source,
const gl::Framebuffer *dest,
const gl::Rectangle &sourceAreaIn,
const gl::Rectangle &destAreaIn,
GLenum filter)
angle::Result BlitGL::blitColorBufferWithShader(const gl::Context *context,
const gl::Framebuffer *source,
const gl::Framebuffer *dest,
const gl::Rectangle &sourceAreaIn,
const gl::Rectangle &destAreaIn,
GLenum filter)
{
ANGLE_TRY(initializeResources());
BlitProgram *blitProgram = nullptr;
ANGLE_TRY(getBlitProgram(BlitProgramType::FLOAT_TO_FLOAT, &blitProgram));
ANGLE_TRY(getBlitProgram(context, BlitProgramType::FLOAT_TO_FLOAT, &blitProgram));
// We'll keep things simple by removing reversed coordinates from the rectangles. In the end
// we'll apply the reversal to the source texture coordinates if needed. The destination
@ -390,7 +402,7 @@ gl::Error BlitGL::blitColorBufferWithShader(const gl::Framebuffer *source,
{
// Early out when the sampled part is empty as the blit will be a noop,
// and it prevents a division by zero in later computations.
return gl::NoError();
return angle::Result::Continue();
}
}
@ -445,8 +457,9 @@ gl::Error BlitGL::blitColorBufferWithShader(const gl::Framebuffer *source,
// Reset all the state except scissor and use the viewport to draw exactly to the destination
// rectangle
ScopedGLState scopedState(mStateManager, mFunctions, destArea, ScopedGLState::KEEP_SCISSOR);
scopedState.willUseTextureUnit(0);
ScopedGLState scopedState;
ANGLE_TRY(scopedState.enter(context, destArea, ScopedGLState::KEEP_SCISSOR));
scopedState.willUseTextureUnit(context, 0);
// Set uniforms
mStateManager->activeTexture(0);
@ -465,26 +478,27 @@ gl::Error BlitGL::blitColorBufferWithShader(const gl::Framebuffer *source,
mStateManager->bindVertexArray(mVAO, 0);
mFunctions->drawArrays(GL_TRIANGLES, 0, 3);
return gl::NoError();
ANGLE_TRY(scopedState.exit(context));
return angle::Result::Continue();
}
gl::Error BlitGL::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 BlitGL::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)
{
ASSERT(source->getType() == gl::TextureType::_2D);
ANGLE_TRY(initializeResources());
@ -498,12 +512,12 @@ gl::Error BlitGL::copySubTexture(const gl::Context *context,
if (status != GL_FRAMEBUFFER_COMPLETE)
{
*copySucceededOut = false;
return gl::NoError();
return angle::Result::Continue();
}
BlitProgramType blitProgramType = getBlitProgramType(sourceComponentType, destComponentType);
BlitProgram *blitProgram = nullptr;
ANGLE_TRY(getBlitProgram(blitProgramType, &blitProgram));
ANGLE_TRY(getBlitProgram(context, blitProgramType, &blitProgram));
// Setup the source texture
if (needsLumaWorkaround)
@ -529,13 +543,13 @@ gl::Error BlitGL::copySubTexture(const gl::Context *context,
}
source->setMinFilter(context, GL_NEAREST);
source->setMagFilter(context, GL_NEAREST);
ANGLE_TRY(source->setBaseLevel(context, static_cast<GLuint>(sourceLevel)));
ANGLE_TRY_HANDLE(context, source->setBaseLevel(context, static_cast<GLuint>(sourceLevel)));
// Render to the destination texture, sampling from the source texture
ScopedGLState scopedState(
mStateManager, mFunctions,
gl::Rectangle(destOffset.x, destOffset.y, sourceArea.width, sourceArea.height));
scopedState.willUseTextureUnit(0);
ScopedGLState scopedState;
ANGLE_TRY(scopedState.enter(
context, gl::Rectangle(destOffset.x, destOffset.y, sourceArea.width, sourceArea.height)));
scopedState.willUseTextureUnit(context, 0);
mStateManager->activeTexture(0);
mStateManager->bindTexture(gl::TextureType::_2D, source->getTextureID());
@ -569,26 +583,29 @@ gl::Error BlitGL::copySubTexture(const gl::Context *context,
mFunctions->drawArrays(GL_TRIANGLES, 0, 3);
*copySucceededOut = true;
return gl::NoError();
ANGLE_TRY(scopedState.exit(context));
return angle::Result::Continue();
}
gl::Error BlitGL::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 BlitGL::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_TRY(initializeResources());
ContextGL *contextGL = GetImplAs<ContextGL>(context);
ASSERT(source->getType() == gl::TextureType::_2D);
const auto &destInternalFormatInfo = gl::GetInternalFormatInfo(destFormat, destType);
@ -604,7 +621,8 @@ gl::Error BlitGL::copySubTextureCPUReadback(const gl::Context *context,
size_t destBufferSize =
sourceArea.width * sourceArea.height * destInternalFormatInfo.pixelBytes;
angle::MemoryBuffer *buffer = nullptr;
ANGLE_TRY_ALLOCATION(context->getScratchBuffer(sourceBufferSize + destBufferSize, &buffer));
ANGLE_CHECK_GL_ALLOC(contextGL,
context->getScratchBuffer(sourceBufferSize + destBufferSize, &buffer));
uint8_t *sourceMemory = buffer->data();
uint8_t *destMemory = buffer->data() + sourceBufferSize;
@ -653,17 +671,17 @@ gl::Error BlitGL::copySubTextureCPUReadback(const gl::Context *context,
destOffset.y, sourceArea.width, sourceArea.height,
texSubImageFormat.format, texSubImageFormat.type, destMemory);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error BlitGL::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 BlitGL::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_TRY(initializeResources());
@ -675,7 +693,7 @@ gl::Error BlitGL::copyTexSubImage(TextureGL *source,
if (status != GL_FRAMEBUFFER_COMPLETE)
{
*copySucceededOut = false;
return gl::NoError();
return angle::Result::Continue();
}
mStateManager->bindTexture(dest->getType(), dest->getTextureID());
@ -685,14 +703,14 @@ gl::Error BlitGL::copyTexSubImage(TextureGL *source,
sourceArea.height);
*copySucceededOut = true;
return gl::NoError();
return angle::Result::Continue();
}
gl::Error BlitGL::clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex,
bool *clearSucceededOut)
angle::Result BlitGL::clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex,
bool *clearSucceededOut)
{
ANGLE_TRY(initializeResources());
@ -721,7 +739,7 @@ gl::Error BlitGL::clearRenderableTexture(TextureGL *source,
{
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
*clearSucceededOut = false;
return gl::NoError();
return angle::Result::Continue();
}
}
else
@ -746,7 +764,7 @@ gl::Error BlitGL::clearRenderableTexture(TextureGL *source,
{
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
*clearSucceededOut = false;
return gl::NoError();
return angle::Result::Continue();
}
}
else
@ -777,7 +795,7 @@ gl::Error BlitGL::clearRenderableTexture(TextureGL *source,
{
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
*clearSucceededOut = false;
return gl::NoError();
return angle::Result::Continue();
}
}
}
@ -785,10 +803,10 @@ gl::Error BlitGL::clearRenderableTexture(TextureGL *source,
UnbindAttachments(mFunctions, GL_FRAMEBUFFER, bindTargets);
*clearSucceededOut = true;
return gl::NoError();
return angle::Result::Continue();
}
gl::Error BlitGL::clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat)
angle::Result BlitGL::clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat)
{
ANGLE_TRY(initializeResources());
@ -810,10 +828,10 @@ gl::Error BlitGL::clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternal
mFunctions->framebufferRenderbuffer(GL_FRAMEBUFFER, bindTarget, GL_RENDERBUFFER, 0);
}
return gl::NoError();
return angle::Result::Continue();
}
gl::Error BlitGL::clearFramebuffer(FramebufferGL *source)
angle::Result BlitGL::clearFramebuffer(FramebufferGL *source)
{
// initializeResources skipped because no local state is used
@ -824,10 +842,10 @@ gl::Error BlitGL::clearFramebuffer(FramebufferGL *source)
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, source->getFramebufferID());
mFunctions->clear(clearMask);
return gl::NoError();
return angle::Result::Continue();
}
gl::Error BlitGL::initializeResources()
angle::Result BlitGL::initializeResources()
{
for (size_t i = 0; i < ArraySize(mScratchTextures); i++)
{
@ -875,7 +893,7 @@ gl::Error BlitGL::initializeResources()
}
}
return gl::NoError();
return angle::Result::Continue();
}
void BlitGL::orphanScratchTextures()
@ -925,8 +943,12 @@ BlitGL::BlitProgramType BlitGL::getBlitProgramType(GLenum sourceComponentType,
}
}
gl::Error BlitGL::getBlitProgram(BlitProgramType type, BlitProgram **program)
angle::Result BlitGL::getBlitProgram(const gl::Context *context,
BlitProgramType type,
BlitProgram **program)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
BlitProgram &result = mBlitPrograms[type];
if (result.program == 0)
{
@ -989,7 +1011,7 @@ gl::Error BlitGL::getBlitProgram(BlitProgramType type, BlitProgram **program)
GLuint vs = mFunctions->createShader(GL_VERTEX_SHADER);
mFunctions->shaderSource(vs, 1, &vsSourceCStr, nullptr);
mFunctions->compileShader(vs);
ANGLE_TRY(CheckCompileStatus(mFunctions, vs));
ANGLE_TRY(CheckCompileStatus(contextGL, mFunctions, vs));
mFunctions->attachShader(result.program, vs);
mFunctions->deleteShader(vs);
@ -1096,14 +1118,14 @@ gl::Error BlitGL::getBlitProgram(BlitProgramType type, BlitProgram **program)
GLuint fs = mFunctions->createShader(GL_FRAGMENT_SHADER);
mFunctions->shaderSource(fs, 1, &fsSourceCStr, nullptr);
mFunctions->compileShader(fs);
ANGLE_TRY(CheckCompileStatus(mFunctions, fs));
ANGLE_TRY(CheckCompileStatus(contextGL, mFunctions, fs));
mFunctions->attachShader(result.program, fs);
mFunctions->deleteShader(fs);
}
mFunctions->linkProgram(result.program);
ANGLE_TRY(CheckLinkStatus(mFunctions, result.program));
ANGLE_TRY(CheckLinkStatus(contextGL, mFunctions, result.program));
result.sourceTextureLocation =
mFunctions->getUniformLocation(result.program, "u_source_texture");
@ -1116,7 +1138,7 @@ gl::Error BlitGL::getBlitProgram(BlitProgramType type, BlitProgram **program)
}
*program = &result;
return gl::NoError();
return angle::Result::Continue();
}
} // namespace rx

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

@ -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);
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);
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);
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);
gl::Error blitColorBufferWithShader(const gl::Framebuffer *source,
const gl::Framebuffer *dest,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
GLenum filter);
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);
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);
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);
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);
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);
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);
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);
gl::Error clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex,
bool *clearSucceededOut);
angle::Result clearRenderableTexture(TextureGL *source,
GLenum sizedInternalFormat,
int numTextureLayers,
const gl::ImageIndex &imageIndex,
bool *clearSucceededOut);
gl::Error clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat);
angle::Result clearRenderbuffer(RenderbufferGL *source, GLenum sizedInternalFormat);
gl::Error clearFramebuffer(FramebufferGL *source);
angle::Result clearFramebuffer(FramebufferGL *source);
gl::Error initializeResources();
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;
angle::Result 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 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();
angle::Result flush();
angle::Result 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);
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);
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 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);
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);
gl::Error setDispatchComputeState(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);

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

@ -18,6 +18,7 @@
#include "libANGLE/queryconversions.h"
#include "libANGLE/renderer/gl/BlitGL.h"
#include "libANGLE/renderer/gl/BufferGL.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/FramebufferGL.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
#include "libANGLE/renderer/gl/ImageGL.h"
@ -170,9 +171,9 @@ gl::Error TextureGL::setImage(const gl::Context *context,
if (workarounds.unpackLastRowSeparatelyForPaddingInclusion)
{
bool apply = false;
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(size, unpack, unpackBuffer, format, type,
nativegl::UseTexImage3D(getType()), pixels,
&apply));
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(
GetImplAs<ContextGL>(context), size, unpack, unpackBuffer, format, type,
nativegl::UseTexImage3D(getType()), pixels, &apply));
// The driver will think the pixel buffer doesn't have enough data, work around this bug
// by uploading the last row (and last level if 3D) separately.
@ -288,9 +289,9 @@ gl::Error TextureGL::setSubImage(const gl::Context *context,
gl::Extents size(area.width, area.height, area.depth);
bool apply = false;
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(size, unpack, unpackBuffer, format, type,
nativegl::UseTexImage3D(getType()), pixels,
&apply));
ANGLE_TRY(ShouldApplyLastRowPaddingWorkaround(
GetImplAs<ContextGL>(context), size, unpack, unpackBuffer, format, type,
nativegl::UseTexImage3D(getType()), pixels, &apply));
// The driver will think the pixel buffer doesn't have enough data, work around this bug
// by uploading the last row (and last level if 3D) separately.
@ -329,6 +330,7 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(const gl::Context *context,
const gl::Buffer *unpackBuffer,
const uint8_t *pixels)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
@ -339,16 +341,16 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(const gl::Context *context,
const gl::InternalFormat &glFormat = gl::GetInternalFormatInfo(format, type);
GLuint rowBytes = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength, &rowBytes));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeRowPitch(type, area.width, unpack.alignment,
unpack.rowLength, &rowBytes));
GLuint imageBytes = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeDepthPitch(area.height, unpack.imageHeight, rowBytes, &imageBytes));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeDepthPitch(area.height, unpack.imageHeight,
rowBytes, &imageBytes));
bool useTexImage3D = nativegl::UseTexImage3D(getType());
GLuint skipBytes = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeSkipBytes(type, rowBytes, imageBytes, unpack, useTexImage3D, &skipBytes));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeSkipBytes(type, rowBytes, imageBytes, unpack,
useTexImage3D, &skipBytes));
const uint8_t *pixelsWithSkip = pixels + skipBytes;
if (useTexImage3D)
@ -390,20 +392,21 @@ gl::Error TextureGL::setSubImagePaddingWorkaround(const gl::Context *context,
const gl::Buffer *unpackBuffer,
const uint8_t *pixels)
{
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, unpack.alignment, unpack.rowLength, &rowBytes));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeRowPitch(type, area.width, unpack.alignment,
unpack.rowLength, &rowBytes));
GLuint imageBytes = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeDepthPitch(area.height, unpack.imageHeight, rowBytes, &imageBytes));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeDepthPitch(area.height, unpack.imageHeight,
rowBytes, &imageBytes));
bool useTexImage3D = nativegl::UseTexImage3D(getType());
GLuint skipBytes = 0;
ANGLE_TRY_CHECKED_MATH(
glFormat.computeSkipBytes(type, rowBytes, imageBytes, unpack, useTexImage3D, &skipBytes));
ANGLE_CHECK_GL_MATH(contextGL, glFormat.computeSkipBytes(type, rowBytes, imageBytes, unpack,
useTexImage3D, &skipBytes));
stateManager->setPixelUnpackState(unpack);
stateManager->setPixelUnpackBuffer(unpackBuffer);
@ -563,6 +566,7 @@ gl::Error TextureGL::copyImage(const gl::Context *context,
GLenum internalFormat,
gl::Framebuffer *source)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const WorkaroundsGL &workarounds = GetWorkaroundsGL(context);
@ -598,8 +602,9 @@ gl::Error TextureGL::copyImage(const gl::Context *context,
GLuint pixelBytes =
gl::GetInternalFormatInfo(copyTexImageFormat.internalFormat, type).pixelBytes;
angle::MemoryBuffer *zero;
ANGLE_TRY_ALLOCATION(context->getZeroFilledBuffer(
origSourceArea.width * origSourceArea.height * pixelBytes, &zero));
ANGLE_CHECK_GL_ALLOC(contextGL,
context->getZeroFilledBuffer(
origSourceArea.width * origSourceArea.height * pixelBytes, &zero));
gl::PixelUnpackState unpack;
unpack.alignment = 1;
@ -849,6 +854,7 @@ gl::Error TextureGL::setStorage(const gl::Context *context,
GLenum internalFormat,
const gl::Extents &size)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const WorkaroundsGL &workarounds = GetWorkaroundsGL(context);
@ -890,7 +896,8 @@ gl::Error TextureGL::setStorage(const gl::Context *context,
internalFormat);
GLuint dataSize = 0;
ANGLE_TRY_CHECKED_MATH(
ANGLE_CHECK_GL_MATH(
contextGL,
internalFormatInfo.computeCompressedImageSize(levelSize, &dataSize));
functions->compressedTexImage2D(ToGLenum(type), static_cast<GLint>(level),
compressedTexImageFormat.format,
@ -920,8 +927,9 @@ gl::Error TextureGL::setStorage(const gl::Context *context,
internalFormat);
GLuint dataSize = 0;
ANGLE_TRY_CHECKED_MATH(internalFormatInfo.computeCompressedImageSize(
levelSize, &dataSize));
ANGLE_CHECK_GL_MATH(contextGL,
internalFormatInfo.computeCompressedImageSize(
levelSize, &dataSize));
functions->compressedTexImage2D(
ToGLenum(face), static_cast<GLint>(level),
compressedTexImageFormat.format, levelSize.width, levelSize.height,
@ -979,8 +987,8 @@ gl::Error TextureGL::setStorage(const gl::Context *context,
internalFormat);
GLuint dataSize = 0;
ANGLE_TRY_CHECKED_MATH(
internalFormatInfo.computeCompressedImageSize(levelSize, &dataSize));
ANGLE_CHECK_GL_MATH(contextGL, internalFormatInfo.computeCompressedImageSize(
levelSize, &dataSize));
functions->compressedTexImage3D(
ToGLenum(type), i, compressedTexImageFormat.format, levelSize.width,
levelSize.height, levelSize.depth, 0, static_cast<GLsizei>(dataSize),
@ -1533,6 +1541,7 @@ gl::TextureType TextureGL::getType() const
gl::Error TextureGL::initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex)
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
const FunctionsGL *functions = GetFunctionsGL(context);
StateManagerGL *stateManager = GetStateManagerGL(context);
const WorkaroundsGL &workarounds = GetWorkaroundsGL(context);
@ -1570,11 +1579,11 @@ gl::Error TextureGL::initializeContents(const gl::Context *context,
internalFormatInfo.internalFormat);
GLuint imageSize = 0;
ANGLE_TRY_CHECKED_MATH(
internalFormatInfo.computeCompressedImageSize(desc.size, &imageSize));
ANGLE_CHECK_GL_MATH(contextGL,
internalFormatInfo.computeCompressedImageSize(desc.size, &imageSize));
angle::MemoryBuffer *zero;
ANGLE_TRY_ALLOCATION(context->getZeroFilledBuffer(imageSize, &zero));
ANGLE_CHECK_GL_ALLOC(contextGL, context->getZeroFilledBuffer(imageSize, &zero));
// WebGL spec requires that zero data is uploaded to compressed textures even if it might
// not result in zero color data.
@ -1599,12 +1608,12 @@ gl::Error TextureGL::initializeContents(const gl::Context *context,
functions, workarounds, internalFormatInfo.format, internalFormatInfo.type);
GLuint imageSize = 0;
ANGLE_TRY_CHECKED_MATH(internalFormatInfo.computePackUnpackEndByte(
nativeSubImageFormat.type, desc.size, unpackState, nativegl::UseTexImage3D(getType()),
&imageSize));
ANGLE_CHECK_GL_MATH(contextGL, internalFormatInfo.computePackUnpackEndByte(
nativeSubImageFormat.type, desc.size, unpackState,
nativegl::UseTexImage3D(getType()), &imageSize));
angle::MemoryBuffer *zero;
ANGLE_TRY_ALLOCATION(context->getZeroFilledBuffer(imageSize, &zero));
ANGLE_CHECK_GL_ALLOC(contextGL, context->getZeroFilledBuffer(imageSize, &zero));
if (nativegl::UseTexImage2D(getType()))
{

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

@ -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_