Commit 2a19c59f by Geoff Lang Committed by Commit Bot

GL: Check for errors around GL calls.

Add a macro to check for GL errors after each GL call to catch errors as they happen even if the debug callbacks are unavailable. GL errors are only checked when asserts are enabled unless explicitly requested with the ANGLE_GL_TRY_ALWAYS_CHECK macro to verify GL calls that may allocate memory. Updated TextureGL to use the macro. BUG=angleproject:3020 Change-Id: I7678b204899e940824b010ab4be7e7f159bee6de Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1764476Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 5c81d94f
......@@ -558,10 +558,10 @@ angle::Result BlitGL::copySubTexture(const gl::Context *context,
}
GLint swizzle[4] = {luminance, luminance, luminance, alpha};
source->setSwizzle(context, swizzle);
ANGLE_TRY(source->setSwizzle(context, swizzle));
}
source->setMinFilter(context, GL_NEAREST);
source->setMagFilter(context, GL_NEAREST);
ANGLE_TRY(source->setMinFilter(context, GL_NEAREST));
ANGLE_TRY(source->setMagFilter(context, GL_NEAREST));
ANGLE_TRY(source->setBaseLevel(context, static_cast<GLuint>(sourceLevel)));
// Render to the destination texture, sampling from the source texture
......
......@@ -198,31 +198,31 @@ class TextureGL : public TextureImpl
angle::Result initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) override;
void setMinFilter(const gl::Context *context, GLenum filter);
void setMagFilter(const gl::Context *context, GLenum filter);
angle::Result setMinFilter(const gl::Context *context, GLenum filter);
angle::Result setMagFilter(const gl::Context *context, GLenum filter);
void setSwizzle(const gl::Context *context, GLint swizzle[4]);
angle::Result setSwizzle(const gl::Context *context, GLint swizzle[4]);
GLenum getNativeInternalFormat(const gl::ImageIndex &index) const;
bool hasEmulatedAlphaChannel(const gl::ImageIndex &index) const;
private:
void setImageHelper(const gl::Context *context,
gl::TextureTarget target,
size_t level,
GLenum internalFormat,
const gl::Extents &size,
GLenum format,
GLenum type,
const uint8_t *pixels);
angle::Result setImageHelper(const gl::Context *context,
gl::TextureTarget target,
size_t level,
GLenum internalFormat,
const gl::Extents &size,
GLenum format,
GLenum type,
const uint8_t *pixels);
// This changes the current pixel unpack state that will have to be reapplied.
void reserveTexImageToBeFilled(const gl::Context *context,
gl::TextureTarget target,
size_t level,
GLenum internalFormat,
const gl::Extents &size,
GLenum format,
GLenum type);
angle::Result reserveTexImageToBeFilled(const gl::Context *context,
gl::TextureTarget target,
size_t level,
GLenum internalFormat,
const gl::Extents &size,
GLenum format,
GLenum type);
angle::Result setSubImageRowByRowWorkaround(const gl::Context *context,
gl::TextureTarget target,
size_t level,
......@@ -243,11 +243,11 @@ class TextureGL : public TextureImpl
const gl::Buffer *unpackBuffer,
const uint8_t *pixels);
void syncTextureStateSwizzle(const gl::Context *context,
const FunctionsGL *functions,
GLenum name,
GLenum value,
GLenum *outValue);
angle::Result syncTextureStateSwizzle(const gl::Context *context,
const FunctionsGL *functions,
GLenum name,
GLenum value,
GLenum *outValue);
void setLevelInfo(const gl::Context *context,
gl::TextureTarget target,
......
......@@ -1693,6 +1693,52 @@ const angle::FeaturesGL &GetFeaturesGL(const gl::Context *context)
return GetImplAs<ContextGL>(context)->getFeaturesGL();
}
void ClearErrors(const gl::Context *context,
const char *file,
const char *function,
unsigned int line)
{
const FunctionsGL *functions = GetFunctionsGL(context);
GLenum error = functions->getError();
while (error != GL_NO_ERROR)
{
ERR() << "Preexisting GL error " << gl::FmtHex(error) << " as of " << file << ", "
<< function << ":" << line << ". ";
error = functions->getError();
}
}
angle::Result CheckError(const gl::Context *context,
const char *call,
const char *file,
const char *function,
unsigned int line)
{
const FunctionsGL *functions = GetFunctionsGL(context);
GLenum error = functions->getError();
if (ANGLE_UNLIKELY(error != GL_NO_ERROR))
{
ContextGL *contextGL = GetImplAs<ContextGL>(context);
contextGL->handleError(error, "Unexpected driver error.", file, function, line);
ERR() << "GL call " << call << " generated error " << gl::FmtHex(error) << " in " << file
<< ", " << function << ":" << line << ". ";
// Check that only one GL error was generated, ClearErrors should have been called first
GLenum nextError = functions->getError();
while (nextError != GL_NO_ERROR)
{
ERR() << "Additional GL error " << gl::FmtHex(nextError) << " generated.";
nextError = functions->getError();
}
return angle::Result::Stop;
}
return angle::Result::Continue;
}
bool CanMapBufferForRead(const FunctionsGL *functions)
{
return (functions->mapBufferRange != nullptr) ||
......
......@@ -10,6 +10,7 @@
#ifndef LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
#define LIBANGLE_RENDERER_GL_RENDERERGLUTILS_H_
#include "common/debug.h"
#include "libANGLE/Error.h"
#include "libANGLE/Version.h"
#include "libANGLE/angletypes.h"
......@@ -55,6 +56,29 @@ BlitGL *GetBlitGL(const gl::Context *context);
ClearMultiviewGL *GetMultiviewClearer(const gl::Context *context);
const angle::FeaturesGL &GetFeaturesGL(const gl::Context *context);
// Clear all errors on the stored context, emits console warnings
void ClearErrors(const gl::Context *context,
const char *file,
const char *function,
unsigned int line);
// Check for a single error
angle::Result CheckError(const gl::Context *context,
const char *call,
const char *file,
const char *function,
unsigned int line);
#define ANGLE_GL_TRY_ALWAYS_CHECK(context, call) \
(ClearErrors(context, __FILE__, __FUNCTION__, __LINE__), (call)); \
ANGLE_TRY(CheckError(context, #call, __FILE__, __FUNCTION__, __LINE__))
#if defined(ANGLE_ENABLE_ASSERTS)
# define ANGLE_GL_TRY(context, call) ANGLE_GL_TRY_ALWAYS_CHECK(context, call)
#else
# define ANGLE_GL_TRY(context, call) call
#endif
namespace nativegl_gl
{
......
......@@ -262,6 +262,9 @@ TEST_P(FramebufferMultiviewTest, CopyTex)
{
ANGLE_SKIP_TEST_IF(!requestMultiviewExtension());
// glCopyTexImage2D generates GL_INVALID_FRAMEBUFFER_OPERATION. http://anglebug.com/3857
ANGLE_SKIP_TEST_IF(IsWindows() && IsOpenGL());
GLFramebuffer fbo;
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
......
......@@ -173,6 +173,9 @@ TEST_P(StateChangeTest, FramebufferIncompleteWithTexStorage)
// Test that caching works when color attachments change with CompressedTexImage2D.
TEST_P(StateChangeTestES3, FramebufferIncompleteWithCompressedTex)
{
// ETC texture formats are not supported on Mac OpenGL. http://anglebug.com/3853
ANGLE_SKIP_TEST_IF(IsOSX() && IsDesktopOpenGL());
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
glBindTexture(GL_TEXTURE_2D, mTextures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
......
......@@ -2983,11 +2983,8 @@ TEST_P(Texture2DTestES3, TextureRGB9E5ImplicitAlpha1)
// ES 3.0.4 table 3.24
TEST_P(Texture2DTestES3, TextureCOMPRESSEDRGB8ETC2ImplicitAlpha1)
{
// Seems to fail on OSX 10.12 Intel.
ANGLE_SKIP_TEST_IF(IsOSX() && IsIntel() && IsOpenGL());
// http://anglebug.com/2190
ANGLE_SKIP_TEST_IF(IsOSX() && IsNVIDIA() && IsDesktopOpenGL());
// ETC texture formats are not supported on Mac OpenGL. http://anglebug.com/3853
ANGLE_SKIP_TEST_IF(IsOSX() && IsDesktopOpenGL());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mTexture2D);
......@@ -3003,11 +3000,8 @@ TEST_P(Texture2DTestES3, TextureCOMPRESSEDRGB8ETC2ImplicitAlpha1)
// ES 3.0.4 table 3.24
TEST_P(Texture2DTestES3, TextureCOMPRESSEDSRGB8ETC2ImplicitAlpha1)
{
// Seems to fail on OSX 10.12 Intel.
ANGLE_SKIP_TEST_IF(IsOSX() && IsIntel() && IsOpenGL());
// http://anglebug.com/2190
ANGLE_SKIP_TEST_IF(IsOSX() && IsNVIDIA() && IsDesktopOpenGL());
// ETC texture formats are not supported on Mac OpenGL. http://anglebug.com/3853
ANGLE_SKIP_TEST_IF(IsOSX() && IsDesktopOpenGL());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mTexture2D);
......
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