Skip to content

Commit

Permalink
test_common: Capitalize macro and clang-format (#1813)
Browse files Browse the repository at this point in the history
The `CHECK_GL_ERROR` macro was lowercase before, which confused
clang-format and resulted in some odd indentations.  Capitalize the
macro and run clang-format to fix the indentation.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
  • Loading branch information
svenvh authored Sep 20, 2023
1 parent d20913b commit 1c61623
Showing 1 changed file with 44 additions and 43 deletions.
87 changes: 44 additions & 43 deletions test_common/gl/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,12 +966,13 @@ void reorder_verification_buffer(GLenum glFormat, GLenum glType, char* buffer, s

#ifdef GL_VERSION_3_2

#define check_gl_error() \
{ \
GLenum errnom = GL_NO_ERROR;\
if ((errnom = glGetError()) != GL_NO_ERROR)\
log_error("GL Error: 0x%04X at %s:%d\n", errnom, __FILE__, __LINE__);\
}
#define CHECK_GL_ERROR() \
{ \
GLenum errnom = GL_NO_ERROR; \
if ((errnom = glGetError()) != GL_NO_ERROR) \
log_error("GL Error: 0x%04X at %s:%d\n", errnom, __FILE__, \
__LINE__); \
}

const char *get_gl_vector_type( GLenum internalformat )
{
Expand Down Expand Up @@ -1045,12 +1046,12 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples

// Check if the renderer supports enough samples
GLint max_samples = get_gl_max_samples(target, internalFormat);
check_gl_error()
CHECK_GL_ERROR()

if (max_samples < (GLint)samples)
log_error("GL error: requested samples (%zu) exceeds renderer max "
"samples (%d)\n",
samples, max_samples);
if (max_samples < (GLint)samples)
log_error("GL error: requested samples (%zu) exceeds renderer max "
"samples (%d)\n",
samples, max_samples);

// Setup the GLSL program
const GLchar *vertex_source =
Expand All @@ -1077,36 +1078,36 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
glShaderWrapper vertex_shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex_shader, 1, &vertex_source, NULL);
glCompileShader(vertex_shader);
check_gl_error()
CHECK_GL_ERROR()

glShaderWrapper fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragment_shader, 1, &fragment_source, NULL);
glCompileShader(fragment_shader);
check_gl_error()
CHECK_GL_ERROR()

GLuint prog = glCreateProgram();
glAttachShader(prog, vertex_shader);
glAttachShader(prog, fragment_shader);
check_gl_error()
CHECK_GL_ERROR()

glBindAttribLocation(prog, 0, "att0");
glLinkProgram(prog);
check_gl_error()
CHECK_GL_ERROR()

// Setup the FBO and texture
glFramebufferWrapper fbo;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
check_gl_error()
CHECK_GL_ERROR()

glViewport(0, 0, width, height);
check_gl_error()
CHECK_GL_ERROR()

GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, internalFormat, width, height, fixedSampleLocations);
check_gl_error()
CHECK_GL_ERROR()

GLint attachment;
switch (internalFormat) {
Expand All @@ -1124,7 +1125,7 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
}

glFramebufferTexture(GL_FRAMEBUFFER, attachment, tex, 0);
check_gl_error()
CHECK_GL_ERROR()

GLint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status == GL_FRAMEBUFFER_UNSUPPORTED) {
Expand All @@ -1144,24 +1145,24 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
// Check if the framebuffer supports enough samples
GLint fbo_samples = 0;
glGetIntegerv(GL_SAMPLES, &fbo_samples);
check_gl_error();
CHECK_GL_ERROR();

if (fbo_samples < (GLint)samples)
log_error(
"GL Error: requested samples (%zu) exceeds FBO capability (%d)\n",
samples, fbo_samples);

glUseProgram(prog);
check_gl_error()
CHECK_GL_ERROR()

if (attachment != GL_DEPTH_ATTACHMENT && attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
glDisable(GL_DEPTH_TEST);
check_gl_error()
CHECK_GL_ERROR()
}
else {
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
check_gl_error()
CHECK_GL_ERROR()
}

// Setup the VBO for rendering a quad
Expand All @@ -1176,14 +1177,14 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STREAM_DRAW);
check_gl_error()
CHECK_GL_ERROR()

glVertexArraysWrapper vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*2, 0);
check_gl_error()
CHECK_GL_ERROR()

//clearing color and depth buffer
glClearColor(0, 0, 0, 0);
Expand Down Expand Up @@ -1227,13 +1228,13 @@ void * CreateGLTexture2DMultisample( size_t width, size_t height, size_t samples
color += color_delta;

glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
check_gl_error();
CHECK_GL_ERROR();

glFlush();
}

glDisable(GL_SAMPLE_MASK);
check_gl_error();
CHECK_GL_ERROR();

*outTextureID = tex;

Expand Down Expand Up @@ -1339,36 +1340,36 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
glShaderWrapper vertex_shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex_shader, 1, &vertex_source, NULL);
glCompileShader(vertex_shader);
check_gl_error()
CHECK_GL_ERROR()

glShaderWrapper fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragment_shader, 1, &fragment_source, NULL);
glCompileShader(fragment_shader);
check_gl_error()
CHECK_GL_ERROR()

glProgramWrapper prog = glCreateProgram();
glAttachShader(prog, vertex_shader);
glAttachShader(prog, fragment_shader);
check_gl_error()
CHECK_GL_ERROR()

glBindAttribLocation(prog, 0, "att0");
glLinkProgram(prog);
check_gl_error()
CHECK_GL_ERROR()

// Setup the FBO and texture
glFramebufferWrapper fbo;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
check_gl_error()
CHECK_GL_ERROR()

glViewport(0, 0, width, height);
check_gl_error()
CHECK_GL_ERROR()

GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, tex);
glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, samples, internalFormat, width, height, total_layers, fixedSampleLocations);
check_gl_error()
CHECK_GL_ERROR()

GLint attachment;
switch (internalFormat) {
Expand All @@ -1390,12 +1391,12 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,

if (attachment != GL_DEPTH_ATTACHMENT && attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
glDisable(GL_DEPTH_TEST);
check_gl_error()
CHECK_GL_ERROR()
}
else {
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
check_gl_error()
CHECK_GL_ERROR()
}

// Setup the VBO for rendering a quad
Expand All @@ -1410,18 +1411,18 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STREAM_DRAW);
check_gl_error()
CHECK_GL_ERROR()

glVertexArraysWrapper vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat)*2, 0);
check_gl_error()
CHECK_GL_ERROR()

for (size_t l=0; l!=total_layers; ++l) {
glFramebufferTextureLayer(GL_FRAMEBUFFER, attachment, tex, 0, l);
check_gl_error()
CHECK_GL_ERROR()

GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status == GL_FRAMEBUFFER_UNSUPPORTED) {
Expand All @@ -1441,15 +1442,15 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
// Check if the framebuffer supports enough samples
GLint fbo_samples = 0;
glGetIntegerv(GL_SAMPLES, &fbo_samples);
check_gl_error();
CHECK_GL_ERROR();

if (fbo_samples < (GLint)samples)
log_error(
"GL Error: requested samples (%zu) exceeds FBO capability (%d)\n",
samples, fbo_samples);

glUseProgram(prog);
check_gl_error()
CHECK_GL_ERROR()

//clearing color and depth buffer
glClearColor(0, 0, 0, 0);
Expand Down Expand Up @@ -1490,13 +1491,13 @@ void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
glUniform1f(glGetUniformLocation(prog, "depthVal"), val);

glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
check_gl_error();
CHECK_GL_ERROR();

glFlush();
}

glDisable(GL_SAMPLE_MASK);
check_gl_error();
CHECK_GL_ERROR();
}

*outTextureID = tex;
Expand Down

0 comments on commit 1c61623

Please sign in to comment.