Removes legacy GL error handling

We have GL_KHR_debug for proper error handling. ogl_WarnIfError isn't
really useful since it doesn't provide per-call granularity and requires
recompilation. So if it'll be really needed we can wrap all GL calls
into a macro like GL_CALL.
This commit is contained in:
Vladislav Belov
2026-07-09 22:53:29 +02:00
parent 711a584d3e
commit 552d91e92a
6 changed files with 1 additions and 72 deletions
-7
View File
@@ -459,7 +459,6 @@ CDevice::~CDevice()
ENSURE(!query.occupied);
glDeleteQueries(1, &query.query);
}
ogl_WarnIfError();
#endif
if (m_Context)
@@ -486,8 +485,6 @@ void CDevice::Report(const Script::Request& rq, JS::HandleValue settings)
#define QUERY_COUNTER_BITS(NAME) ReportParameter<GLint, 1, true>(rq, settings, GL_##NAME, "GL_" #NAME ".GL_QUERY_COUNTER_BITS")
ogl_WarnIfError();
// Core OpenGL 1.3:
// (We don't bother checking extension strings for anything older than 1.3;
// it'll just produce harmless warnings)
@@ -831,7 +828,6 @@ uint32_t CDevice::AllocateQuery()
m_Queries.emplace_back();
#if !CONFIG2_GLES
glGenQueries(1, &m_Queries.back().query);
ogl_WarnIfError();
#endif
it = prev(m_Queries.end());
}
@@ -853,7 +849,6 @@ bool CDevice::IsQueryResultAvailable(const uint32_t handle) const
GLint available{};
#if !CONFIG2_GLES
glGetQueryObjectiv(m_Queries[handle].query, GL_QUERY_RESULT_AVAILABLE, &available);
ogl_WarnIfError();
#endif
return available;
}
@@ -868,7 +863,6 @@ uint64_t CDevice::GetQueryResult(const uint32_t handle)
#if !CONFIG2_GLES
// Use the non-suffixed function here, as defined by GL_ARB_timer_query.
glGetQueryObjectui64v(m_Queries[handle].query, GL_QUERY_RESULT, &queryTimestamp);
ogl_WarnIfError();
#endif
return queryTimestamp;
}
@@ -878,7 +872,6 @@ void CDevice::InsertTimestampQuery(const uint32_t handle)
ENSURE(handle < m_Queries.size());
#if !CONFIG2_GLES
glQueryCounter(m_Queries[handle].query, GL_TIMESTAMP);
ogl_WarnIfError();
#endif
}
@@ -135,7 +135,6 @@ void UploadDynamicBufferRegionImpl(
ENSURE(dataOffset < dataSize);
// Tell the driver that it can reallocate the whole VBO
glBufferData(target, bufferSize, nullptr, GL_DYNAMIC_DRAW);
ogl_WarnIfError();
while (true)
{
@@ -217,7 +216,6 @@ void InvalidateFramebuffer(
#else
glInvalidateFramebuffer(GL_FRAMEBUFFER_EXT, numberOfAttachments, attachments);
#endif
ogl_WarnIfError();
}
}
@@ -380,7 +378,6 @@ void CDeviceCommandContext::UploadTextureRegion(
glTexSubImage2D(GL_TEXTURE_2D, level,
xOffset, yOffset, width, height,
pixelFormat, GL_UNSIGNED_BYTE, data);
ogl_WarnIfError();
}
else if (
texture->GetFormat() == Format::BC1_RGB_UNORM ||
@@ -410,7 +407,6 @@ void CDeviceCommandContext::UploadTextureRegion(
ScopedBind scopedBind(this, GL_TEXTURE_2D, texture->GetHandle());
glCompressedTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, 0, dataSize, data);
ogl_WarnIfError();
}
else
debug_warn("Unsupported format");
@@ -439,7 +435,6 @@ void CDeviceCommandContext::UploadTextureRegion(
ScopedBind scopedBind(this, GL_TEXTURE_CUBE_MAP, texture->GetHandle());
glTexImage2D(targets[layer], level, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
ogl_WarnIfError();
}
else
debug_warn("Unsupported format");
@@ -481,7 +476,6 @@ void CDeviceCommandContext::UploadBufferRegion(
else
{
glBufferSubData(target, dataOffset, dataSize, data);
ogl_WarnIfError();
}
}
@@ -543,7 +537,6 @@ void CDeviceCommandContext::BindTexture(
glBindTexture(m_BoundTextures[unit].target, 0);
if (m_BoundTextures[unit].handle != handle)
glBindTexture(target, handle);
ogl_WarnIfError();
m_BoundTextures[unit] = {target, handle};
}
@@ -565,7 +558,6 @@ void CDeviceCommandContext::BindBuffer(const IBuffer::Type type, CBuffer* buffer
const GLenum target = BufferTypeToGLTarget(type);
const GLuint handle = buffer ? buffer->GetHandle() : 0;
glBindBuffer(target, handle);
ogl_WarnIfError();
const size_t cacheIndex = static_cast<size_t>(type);
ENSURE(cacheIndex < m_BoundBuffers.size());
m_BoundBuffers[cacheIndex].second = handle;
@@ -607,7 +599,6 @@ void CDeviceCommandContext::ResetStates()
SetScissors(0, nullptr);
m_Framebuffer = nullptr;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
ogl_WarnIfError();
}
void CDeviceCommandContext::SetGraphicsPipelineStateImpl(
@@ -851,8 +842,6 @@ void CDeviceCommandContext::SetGraphicsPipelineStateImpl(
}
#endif
ogl_WarnIfError();
m_GraphicsPipelineStateDesc = pipelineStateDesc;
}
@@ -878,7 +867,6 @@ void CDeviceCommandContext::BlitFramebuffer(
destinationRegion.x, destinationRegion.y, destinationRegion.width, destinationRegion.height,
(sourceFramebuffer->GetAttachmentMask() & destinationFramebuffer->GetAttachmentMask()),
filter == Sampler::Filter::LINEAR ? GL_LINEAR : GL_NEAREST);
ogl_WarnIfError();
#endif
}
@@ -903,7 +891,6 @@ void CDeviceCommandContext::ResolveFramebuffer(
0, 0, sourceFramebuffer->GetWidth(), sourceFramebuffer->GetHeight(),
(sourceFramebuffer->GetAttachmentMask() & destinationFramebuffer->GetAttachmentMask()),
GL_NEAREST);
ogl_WarnIfError();
#endif
}
@@ -935,7 +922,6 @@ void CDeviceCommandContext::ClearFramebuffer(const bool color, const bool depth,
mask |= GL_STENCIL_BUFFER_BIT;
}
glClear(mask);
ogl_WarnIfError();
if (needsColor)
ApplyColorMask(m_GraphicsPipelineStateDesc.blendState.colorWriteMask);
if (needsDepth)
@@ -955,7 +941,6 @@ void CDeviceCommandContext::BeginFramebufferPass(IFramebuffer* framebuffer)
m_Framebuffer = framebuffer->As<CFramebuffer>();
ENSURE(m_Framebuffer->GetHandle() == 0 || (m_Framebuffer->GetWidth() > 0 && m_Framebuffer->GetHeight() > 0));
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_Framebuffer->GetHandle());
ogl_WarnIfError();
if (m_Device->UseFramebufferInvalidating())
{
InvalidateFramebuffer(
@@ -988,7 +973,6 @@ void CDeviceCommandContext::EndFramebufferPass()
if (m_Framebuffer->GetHandle() != 0)
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
ogl_WarnIfError();
}
m_Framebuffer = nullptr;
@@ -1001,7 +985,6 @@ void CDeviceCommandContext::ReadbackFramebufferSync(
void* data)
{
glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
ogl_WarnIfError();
}
void CDeviceCommandContext::SetScissors(const uint32_t scissorCount, const Rect* scissors)
@@ -1023,7 +1006,6 @@ void CDeviceCommandContext::SetScissors(const uint32_t scissorCount, const Rect*
glScissor(m_Scissors[0].x, m_Scissors[0].y, m_Scissors[0].width, m_Scissors[0].height);
}
}
ogl_WarnIfError();
m_ScissorCount = scissorCount;
}
@@ -1032,7 +1014,6 @@ void CDeviceCommandContext::SetViewports(const uint32_t viewportCount, const Rec
ENSURE(m_InsideFramebufferPass);
ENSURE(viewportCount == 1);
glViewport(viewports[0].x, viewports[0].y, viewports[0].width, viewports[0].height);
ogl_WarnIfError();
}
void CDeviceCommandContext::SetVertexInputLayout(
@@ -1146,7 +1127,6 @@ void CDeviceCommandContext::Draw(
return;
m_ShaderProgram->AssertPointersBound();
glDrawArrays(GL_TRIANGLES, firstVertex, vertexCount);
ogl_WarnIfError();
}
void CDeviceCommandContext::DrawIndexed(
@@ -1168,7 +1148,6 @@ void CDeviceCommandContext::DrawIndexed(
// in Mesa 7.10 swrast with index VBOs).
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT,
static_cast<const void*>((static_cast<const uint8_t*>(m_IndexBufferData) + sizeof(uint16_t) * firstIndex)));
ogl_WarnIfError();
}
void CDeviceCommandContext::DrawInstanced(
@@ -1187,7 +1166,6 @@ void CDeviceCommandContext::DrawInstanced(
#else
glDrawArraysInstancedARB(GL_TRIANGLES, firstVertex, vertexCount, instanceCount);
#endif
ogl_WarnIfError();
}
void CDeviceCommandContext::DrawIndexedInstanced(
@@ -1217,7 +1195,6 @@ void CDeviceCommandContext::DrawIndexedInstanced(
static_cast<const void*>((static_cast<const uint8_t*>(m_IndexBufferData) + sizeof(uint16_t) * firstIndex)),
instanceCount);
#endif
ogl_WarnIfError();
}
void CDeviceCommandContext::DrawIndexedInRange(
@@ -1239,7 +1216,6 @@ void CDeviceCommandContext::DrawIndexedInRange(
#else
glDrawRangeElements(GL_TRIANGLES, start, end, indexCount, GL_UNSIGNED_SHORT, indices);
#endif
ogl_WarnIfError();
}
void CDeviceCommandContext::BeginComputePass()
@@ -124,8 +124,6 @@ std::unique_ptr<CFramebuffer> CFramebuffer::Create(
framebuffer->m_Height = colorAttachment->texture->GetHeight();
}
ogl_WarnIfError();
#if !CONFIG2_GLES
if (!colorAttachment)
{
@@ -136,8 +134,6 @@ std::unique_ptr<CFramebuffer> CFramebuffer::Create(
glDrawBuffer(GL_COLOR_ATTACHMENT0);
#endif
ogl_WarnIfError();
#if !CONFIG2_GLES
if (framebuffer->m_Device->GetCapabilities().debugLabels)
{
@@ -153,8 +149,6 @@ std::unique_ptr<CFramebuffer> CFramebuffer::Create(
return nullptr;
}
ogl_WarnIfError();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
return framebuffer;
@@ -238,8 +238,6 @@ bool CompileGLSL(GLuint shader, const VfsPath& file, const CStr& code)
GLint codeLength = code.length();
glShaderSource(shader, 1, &codeString, &codeLength);
ogl_WarnIfError();
glCompileShader(shader);
GLint ok = 0;
@@ -264,8 +262,6 @@ bool CompileGLSL(GLuint shader, const VfsPath& file, const CStr& code)
LOGERROR("Failed to compile shader '%s':\n%s", file.string8(), infolog.get());
}
ogl_WarnIfError();
return ok;
}
@@ -376,7 +372,6 @@ bool CShaderProgram::Link(const VfsPath& path)
for (ShaderStage& stage : m_ShaderStages)
{
glAttachShader(m_Program, stage.shader);
ogl_WarnIfError();
}
// Set up the attribute bindings explicitly, since apparently drivers
@@ -409,15 +404,11 @@ bool CShaderProgram::Link(const VfsPath& path)
delete[] infolog;
}
ogl_WarnIfError();
if (!ok)
return false;
Bind(nullptr);
ogl_WarnIfError();
// Reorder sampler units to decrease redundant texture unit changes when
// samplers bound in a different order.
const std::unordered_map<CStrIntern, int> requiredUnits =
@@ -441,11 +432,9 @@ bool CShaderProgram::Link(const VfsPath& path)
GLint maxUniformBlockNameLength{0};
glGetProgramInterfaceiv(m_Program, GL_UNIFORM_BLOCK, GL_MAX_NAME_LENGTH, &maxUniformBlockNameLength);
ogl_WarnIfError();
GLint numberOfActiveUniformBlocks{0};
glGetProgramInterfaceiv(m_Program, GL_UNIFORM_BLOCK, GL_ACTIVE_RESOURCES, &numberOfActiveUniformBlocks);
ogl_WarnIfError();
// Currently we support the only one uniform buffer per shader.
if (numberOfActiveUniformBlocks == 1)
{
@@ -460,11 +449,9 @@ bool CShaderProgram::Link(const VfsPath& path)
GLint maxStorageNameLength{0};
glGetProgramInterfaceiv(m_Program, GL_SHADER_STORAGE_BLOCK, GL_MAX_NAME_LENGTH, &maxStorageNameLength);
ogl_WarnIfError();
ENSURE(maxStorageNameLength <= maxBlockNameLength);
GLint numberOfActiveStorages{0};
glGetProgramInterfaceiv(m_Program, GL_SHADER_STORAGE_BLOCK, GL_ACTIVE_RESOURCES, &numberOfActiveStorages);
ogl_WarnIfError();
for (GLint index{0}; index < numberOfActiveStorages; ++index)
{
GLsizei length{0};
@@ -487,7 +474,6 @@ bool CShaderProgram::Link(const VfsPath& path)
GLint numUniforms = 0;
glGetProgramiv(m_Program, GL_ACTIVE_UNIFORMS, &numUniforms);
ogl_WarnIfError();
for (GLint i = 0; i < numUniforms; ++i)
{
// TODO: use GL_ACTIVE_UNIFORM_MAX_LENGTH for the size.
@@ -496,7 +482,6 @@ bool CShaderProgram::Link(const VfsPath& path)
GLint size = 0;
GLenum type = 0;
glGetActiveUniform(m_Program, i, ARRAY_SIZE(name), &nameLength, &size, &type, name);
ogl_WarnIfError();
const GLint location = glGetUniformLocation(m_Program, name);
@@ -599,11 +584,9 @@ bool CShaderProgram::Link(const VfsPath& path)
GLuint uniformIndex{0};
const GLchar* nameToQuery{name};
glGetUniformIndices(m_Program, 1, &nameToQuery, &uniformIndex);
ogl_WarnIfError();
GLint uniformOffset{0};
glGetActiveUniformsiv(m_Program, 1, &uniformIndex, GL_UNIFORM_OFFSET, &uniformOffset);
ogl_WarnIfError();
// According to the OpenGL spec:
// https://registry.khronos.org/OpenGL-Refpages/es3/html/glGetActiveUniformsiv.xhtml
@@ -638,7 +621,6 @@ bool CShaderProgram::Link(const VfsPath& path)
}
// Link uniform to unit.
glUniform1i(bindingSlot.location, bindingSlot.elementCount);
ogl_WarnIfError();
}
if (m_UniformBufferSize > 0 && m_UniformBufferLocation != -1)
@@ -758,7 +740,6 @@ void CShaderProgram::SetUniform(const int32_t bindingSlot, const float value)
return;
}
glUniform1f(m_BindingSlots[bindingSlot].location, value);
ogl_WarnIfError();
}
void CShaderProgram::SetUniform(
@@ -774,7 +755,6 @@ void CShaderProgram::SetUniform(
return;
}
glUniform2f(m_BindingSlots[bindingSlot].location, valueX, valueY);
ogl_WarnIfError();
}
void CShaderProgram::SetUniform(
@@ -790,7 +770,6 @@ void CShaderProgram::SetUniform(
return;
}
glUniform3f(m_BindingSlots[bindingSlot].location, valueX, valueY, valueZ);
ogl_WarnIfError();
}
void CShaderProgram::SetUniform(
@@ -807,7 +786,6 @@ void CShaderProgram::SetUniform(
return;
}
glUniform4f(m_BindingSlots[bindingSlot].location, valueX, valueY, valueZ, valueW);
ogl_WarnIfError();
}
void CShaderProgram::SetUniform(
@@ -858,7 +836,6 @@ void CShaderProgram::SetUniform(
}
else
LOGERROR("CShaderProgram::SetUniform(): Invalid uniform type (expected float, vec2, vec3, vec4, mat4) '%s'", m_BindingSlots[bindingSlot].name.c_str());
ogl_WarnIfError();
}
void CShaderProgram::VertexAttribPointer(
+1 -2
View File
@@ -115,7 +115,6 @@ void CSwapChain::Present()
{
PROFILE3("swap buffers");
SDL_GL_SwapWindow(m_Window);
ogl_WarnIfError();
}
#if defined(NDEBUG)
@@ -126,7 +125,7 @@ void CSwapChain::Present()
// We have to check GL errors after SwapBuffer to avoid possible
// synchronizations during rendering.
if (GLenum err = glGetError())
ONCE(LOGERROR("GL error %s (0x%04x) occurred", ogl_GetErrorName(err), err));
ONCE(LOGERROR("GL error 0x%04x occurred", err));
}
} // namespace GL
-10
View File
@@ -110,8 +110,6 @@ std::unique_ptr<CTexture> CTexture::Create(
glGenTextures(1, &texture->m_Handle);
ogl_WarnIfError();
const GLenum target = TypeToGLEnum(type);
CDeviceCommandContext::ScopedBind scopedBind(
@@ -123,8 +121,6 @@ std::unique_ptr<CTexture> CTexture::Create(
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, CalculateMinFilter(defaultSamplerDesc, MIPLevelCount));
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, defaultSamplerDesc.magFilter == Sampler::Filter::LINEAR ? GL_LINEAR : GL_NEAREST);
ogl_WarnIfError();
glTexParameteri(target, GL_TEXTURE_WRAP_S, AddressModeToGLEnum(defaultSamplerDesc.addressModeU));
glTexParameteri(target, GL_TEXTURE_WRAP_T, AddressModeToGLEnum(defaultSamplerDesc.addressModeV));
}
@@ -134,8 +130,6 @@ std::unique_ptr<CTexture> CTexture::Create(
glTexParameteri(target, GL_TEXTURE_WRAP_R, AddressModeToGLEnum(defaultSamplerDesc.addressModeW));
#endif
ogl_WarnIfError();
#if !CONFIG2_GLES
glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, MIPLevelCount - 1);
@@ -171,8 +165,6 @@ std::unique_ptr<CTexture> CTexture::Create(
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, borderColor.AsFloatArray().data());
}
ogl_WarnIfError();
if (type == CTexture::Type::TEXTURE_2D)
{
bool compressedFormat = false;
@@ -318,8 +310,6 @@ std::unique_ptr<CTexture> CTexture::Create(
}
#endif
ogl_WarnIfError();
if (texture->m_Device->GetCapabilities().debugLabels)
{
glObjectLabel(GL_TEXTURE, texture->m_Handle, -1, name);