Cleanup: GPU: Replace multiple checks by GLContext::debug_layer_support
This commit is contained in:
@@ -330,6 +330,7 @@ GLint GLContext::max_ubo_size;
|
||||
GLint GLContext::max_ubo_binds;
|
||||
/** Extensions. */
|
||||
bool GLContext::base_instance_support = false;
|
||||
bool GLContext::debug_layer_support = false;
|
||||
bool GLContext::texture_cube_map_array_support = false;
|
||||
/** Workarounds. */
|
||||
bool GLContext::texture_copy_workaround = false;
|
||||
@@ -354,6 +355,12 @@ void GLBackend::capabilities_init(void)
|
||||
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &GLContext::max_ubo_size);
|
||||
GLContext::base_instance_support = GLEW_ARB_base_instance;
|
||||
GLContext::texture_cube_map_array_support = GLEW_ARB_texture_cube_map_array;
|
||||
GLContext::debug_layer_support = (GLEW_VERSION_4_3 || GLEW_KHR_debug);
|
||||
|
||||
if ((G.debug & G_DEBUG_GPU) == 0) {
|
||||
/* Disable this feature entierly when not debugging. */
|
||||
GLContext::debug_layer_support = false;
|
||||
}
|
||||
|
||||
detect_workarounds();
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class GLContext : public Context {
|
||||
static GLint max_ubo_binds;
|
||||
/** Extensions. */
|
||||
static bool base_instance_support;
|
||||
static bool debug_layer_support;
|
||||
static bool texture_cube_map_array_support;
|
||||
/** Workarounds. */
|
||||
static bool texture_copy_workaround;
|
||||
|
||||
@@ -122,7 +122,7 @@ void init_gl_callbacks(void)
|
||||
char msg[256] = "";
|
||||
const char format[] = "Successfully hooked OpenGL debug callback using %s";
|
||||
|
||||
if (GLEW_VERSION_4_3 || GLEW_KHR_debug) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
SNPRINTF(msg, format, GLEW_VERSION_4_3 ? "OpenGL 4.3" : "KHR_debug extension");
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
|
||||
@@ -63,13 +63,11 @@ GLFrameBuffer::GLFrameBuffer(
|
||||
viewport_[2] = scissor_[2] = w;
|
||||
viewport_[3] = scissor_[3] = h;
|
||||
|
||||
#ifndef __APPLE__
|
||||
if (fbo_id_ && (G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (fbo_id_ && GLContext::debug_layer_support) {
|
||||
char sh_name[32];
|
||||
SNPRINTF(sh_name, "FrameBuffer-%s", name);
|
||||
glObjectLabel(GL_FRAMEBUFFER, fbo_id_, -1, sh_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
GLFrameBuffer::~GLFrameBuffer()
|
||||
@@ -100,15 +98,13 @@ void GLFrameBuffer::init(void)
|
||||
state_manager_ = static_cast<GLStateManager *>(context_->state_manager);
|
||||
glGenFramebuffers(1, &fbo_id_);
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
char sh_name[64];
|
||||
SNPRINTF(sh_name, "FrameBuffer-%s", name_);
|
||||
/* Binding before setting the label is needed on some drivers. */
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo_id_);
|
||||
glObjectLabel(GL_FRAMEBUFFER, fbo_id_, -1, sh_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -60,13 +60,11 @@ GLImmediate::GLImmediate()
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
glObjectLabel(GL_VERTEX_ARRAY, vao_id_, -1, "VAO-Immediate");
|
||||
glObjectLabel(GL_BUFFER, buffer.vbo_id, -1, "VBO-ImmediateBuffer");
|
||||
glObjectLabel(GL_BUFFER, buffer_strict.vbo_id, -1, "VBO-ImmediateBufferStrict");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
GLImmediate::~GLImmediate()
|
||||
|
||||
@@ -48,13 +48,11 @@ GLShader::GLShader(const char *name) : Shader(name)
|
||||
#endif
|
||||
shader_program_ = glCreateProgram();
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
char sh_name[64];
|
||||
SNPRINTF(sh_name, "ShaderProgram-%s", name);
|
||||
glObjectLabel(GL_PROGRAM, shader_program_, -1, sh_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
GLShader::~GLShader(void)
|
||||
@@ -165,8 +163,7 @@ GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *>
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
char sh_name[64];
|
||||
switch (gl_stage) {
|
||||
case GL_VERTEX_SHADER:
|
||||
@@ -181,7 +178,6 @@ GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *>
|
||||
}
|
||||
glObjectLabel(GL_SHADER, shader, -1, sh_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
glAttachShader(shader_program_, shader);
|
||||
return shader;
|
||||
|
||||
@@ -96,14 +96,12 @@ bool GLTexture::init_internal(void)
|
||||
glTexParameteri(target_, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
char sh_name[64];
|
||||
SNPRINTF(sh_name, "Texture-%s", name_);
|
||||
/* Binding before setting the label is needed on some drivers. */
|
||||
glObjectLabel(GL_TEXTURE, tex_id_, -1, sh_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
GL_CHECK_ERROR("Post-texture creation");
|
||||
return true;
|
||||
@@ -127,14 +125,12 @@ bool GLTexture::init_internal(GPUVertBuf *vbo)
|
||||
glTexBuffer(target_, internal_format, gl_vbo->vbo_id_);
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
char sh_name[64];
|
||||
SNPRINTF(sh_name, "Texture-%s", name_);
|
||||
/* Binding before setting the label is needed on some drivers. */
|
||||
glObjectLabel(GL_TEXTURE, tex_id_, -1, sh_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
GL_CHECK_ERROR("Post-texture buffer creation");
|
||||
return true;
|
||||
@@ -514,8 +510,7 @@ void GLTexture::samplers_init(void)
|
||||
* - GL_TEXTURE_LOD_BIAS is 0.0f.
|
||||
**/
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
char sampler_name[128];
|
||||
SNPRINTF(sampler_name,
|
||||
"Sampler%s%s%s%s%s%s%s%s%s%s",
|
||||
@@ -531,7 +526,6 @@ void GLTexture::samplers_init(void)
|
||||
(state & GPU_SAMPLER_ANISO) ? "_aniso" : "");
|
||||
glObjectLabel(GL_SAMPLER, samplers_[i], -1, sampler_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
samplers_update();
|
||||
|
||||
@@ -541,11 +535,9 @@ void GLTexture::samplers_init(void)
|
||||
glSamplerParameteri(icon_sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameterf(icon_sampler, GL_TEXTURE_LOD_BIAS, -0.5f);
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
glObjectLabel(GL_SAMPLER, icon_sampler, -1, "Sampler-icons");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLTexture::samplers_update(void)
|
||||
|
||||
@@ -62,13 +62,11 @@ void GLUniformBuf::init(void)
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, ubo_id_);
|
||||
glBufferData(GL_UNIFORM_BUFFER, size_in_bytes_, NULL, GL_DYNAMIC_DRAW);
|
||||
|
||||
#ifndef __APPLE__
|
||||
if ((G.debug & G_DEBUG_GPU) && (GLEW_VERSION_4_3 || GLEW_KHR_debug)) {
|
||||
if (GLContext::debug_layer_support) {
|
||||
char sh_name[64];
|
||||
SNPRINTF(sh_name, "UBO-%s", name_);
|
||||
glObjectLabel(GL_BUFFER, ubo_id_, -1, sh_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLUniformBuf::update(const void *data)
|
||||
|
||||
Reference in New Issue
Block a user