Skip to content

Commit 521ebe3

Browse files
GL: limit glGetError to device initialization in Release builds
1 parent c25ede4 commit 521ebe3

File tree

12 files changed

+21
-15
lines changed

12 files changed

+21
-15
lines changed

Graphics/GraphicsEngineOpenGL/include/pch.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,16 @@
153153
} while (false)
154154

155155
#ifdef DILIGENT_DEVELOPMENT
156-
# define DEV_CHECK_GL_ERROR CHECK_GL_ERROR
156+
# define DEV_CHECK_GL_ERROR CHECK_GL_ERROR
157+
# define DEV_CHECK_GL_ERROR_AND_THROW CHECK_GL_ERROR_AND_THROW
157158
#else
158159
# define DEV_CHECK_GL_ERROR(...) \
159160
do \
160161
{ \
161162
} while (false)
163+
164+
# define DEV_CHECK_GL_ERROR_AND_THROW(...) \
165+
do \
166+
{ \
167+
} while (false)
162168
#endif

Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters,
145145
// All buffer bind targets (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER etc.) relate to the same
146146
// kind of objects. As a result they are all equivalent from a transfer point of view.
147147
glBufferData(m_BindTarget, StaticCast<GLsizeiptr>(BuffDesc.Size), pData, m_GLUsageHint);
148-
CHECK_GL_ERROR_AND_THROW("glBufferData() failed");
148+
DEV_CHECK_GL_ERROR("glBufferData() failed");
149149
GLState.BindBuffer(m_BindTarget, GLObjectWrappers::GLBufferObj::Null(), ResetVAO);
150150

151151
m_MemoryProperties = MEMORY_PROPERTY_HOST_COHERENT;

Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -95,7 +95,7 @@ BufferViewGLImpl::BufferViewGLImpl(IReferenceCounters* pRefCounters,
9595
"Only full-buffer views can be created on this device.");
9696
#endif
9797
}
98-
CHECK_GL_ERROR_AND_THROW("Failed to create texture buffer");
98+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to create texture buffer");
9999

100100
CtxState.BindTexture(-1, GL_TEXTURE_BUFFER, GLObjectWrappers::GLTextureObj(false));
101101

Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ SamplerGLImpl::SamplerGLImpl(IReferenceCounters* pRefCounters, class RenderDevic
122122
glSamplerParameterf(m_GlSampler, GL_TEXTURE_MAX_LOD, SamplerDesc.MaxLOD);
123123
glSamplerParameterf(m_GlSampler, GL_TEXTURE_MIN_LOD, SamplerDesc.MinLOD);
124124

125-
CHECK_GL_ERROR_AND_THROW("Failed to create OpenGL texture sampler\n");
125+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to create OpenGL texture sampler\n");
126126

127127
m_GlSampler.SetName(m_Desc.Name);
128128
}

Graphics/GraphicsEngineOpenGL/src/Texture1DArray_GL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Texture1DArray_GL::Texture1DArray_GL(IReferenceCounters* pRefCounters,
6666

6767
// levels format width height
6868
glTexStorage2D(m_BindTarget, m_Desc.MipLevels, m_GLTexFormat, m_Desc.Width, m_Desc.ArraySize);
69-
CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 1D texture array");
69+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 1D texture array");
7070
// When target is GL_TEXTURE_1D_ARRAY, calling glTexStorage2D() is equivalent to the following code:
7171
//for (i = 0; i < levels; i++)
7272
//{

Graphics/GraphicsEngineOpenGL/src/Texture1D_GL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Texture1D_GL::Texture1D_GL(IReferenceCounters* pRefCounters,
6565

6666
// levels format width
6767
glTexStorage1D(m_BindTarget, m_Desc.MipLevels, m_GLTexFormat, m_Desc.Width);
68-
CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 1D texture");
68+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 1D texture");
6969
// When target is GL_TEXTURE_1D, calling glTexStorage1D is equivalent to the following pseudo-code:
7070
//for (i = 0; i < levels; i++)
7171
//{

Graphics/GraphicsEngineOpenGL/src/Texture2DArray_GL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Texture2DArray_GL::Texture2DArray_GL(IReferenceCounters* pRefCounters,
7272
// The last parameter specifies whether the image will use identical sample locations and the same number of
7373
// samples for all texels in the image, and the sample locations will not depend on the internal format or size
7474
// of the image.
75-
CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 2D multisample texture array");
75+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 2D multisample texture array");
7676
// * An INVALID_ENUM error is generated if sizedinternalformat is not colorrenderable,
7777
// depth - renderable, or stencil - renderable
7878
// * An INVALID_OPERATION error is generated if samples is greater than the maximum number of samples
@@ -85,7 +85,7 @@ Texture2DArray_GL::Texture2DArray_GL(IReferenceCounters* pRefCounters,
8585
{
8686
// levels format width height depth
8787
glTexStorage3D(m_BindTarget, m_Desc.MipLevels, m_GLTexFormat, m_Desc.Width, m_Desc.Height, m_Desc.ArraySize);
88-
CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 2D texture array");
88+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 2D texture array");
8989
// When target is GL_TEXTURE_2D_ARRAY, calling glTexStorage3D is equivalent to the following pseudo-code:
9090
//for (i = 0; i < levels; i++)
9191
//{

Graphics/GraphicsEngineOpenGL/src/Texture2D_GL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Texture2D_GL::Texture2D_GL(IReferenceCounters* pRefCounters,
7373
// The last parameter specifies whether the image will use identical sample locations and the same number of
7474
// samples for all texels in the image, and the sample locations will not depend on the internal format or size
7575
// of the image.
76-
CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 2D multisample texture");
76+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 2D multisample texture");
7777
// * An INVALID_ENUM error is generated if sizedinternalformat is not colorrenderable,
7878
// depth - renderable, or stencil - renderable
7979
// * An INVALID_OPERATION error is generated if samples is greater than the maximum number of samples
@@ -91,7 +91,7 @@ Texture2D_GL::Texture2D_GL(IReferenceCounters* pRefCounters,
9191
{
9292
// levels format width height
9393
glTexStorage2D(m_BindTarget, m_Desc.MipLevels, m_GLTexFormat, m_Desc.Width, m_Desc.Height);
94-
CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 2D texture");
94+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 2D texture");
9595
// When target is GL_TEXTURE_2D, calling glTexStorage2D is equivalent to the following pseudo-code:
9696
//for (i = 0; i < levels; i++)
9797
//{

Graphics/GraphicsEngineOpenGL/src/Texture3D_GL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Texture3D_GL::Texture3D_GL(IReferenceCounters* pRefCounters,
6767

6868
// levels format width height depth
6969
glTexStorage3D(m_BindTarget, m_Desc.MipLevels, m_GLTexFormat, m_Desc.Width, m_Desc.Height, m_Desc.Depth);
70-
CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 3D texture");
70+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to allocate storage for the 3D texture");
7171
// When target is GL_TEXTURE_3D, calling glTexStorage3D is equivalent to the following pseudo-code:
7272
//for (i = 0; i < levels; i++)
7373
//{

Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ void TextureBaseGL::CreateViewInternal(const TextureViewDesc& OrigViewDesc, ITex
464464
LOG_ERROR_AND_THROW("glTextureView is not supported");
465465

466466
glTextureView(pViewOGL->GetHandle(), GLViewTarget, m_GlTexture, GLViewFormat, ViewDesc.MostDetailedMip, ViewDesc.NumMipLevels, ViewDesc.FirstArraySlice, NumLayers);
467-
CHECK_GL_ERROR_AND_THROW("Failed to create texture view");
467+
DEV_CHECK_GL_ERROR_AND_THROW("Failed to create texture view");
468468
pViewOGL->SetBindTarget(GLViewTarget);
469469

470470
if (!IsIdentityComponentMapping(ViewDesc.Swizzle))

0 commit comments

Comments
 (0)