Skip to content

Commit 7af00f9

Browse files
GLES: fixed issue with glBindImageTexture returning error when binding null handle with R8 format
1 parent 4230207 commit 7af00f9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ void GLContextState::GetBoundImage(Uint32 Index,
323323
IsLayered = GL_FALSE;
324324
Layer = 0;
325325
Access = GL_READ_ONLY;
326-
Format = GL_R8;
326+
// Even though image handle is null, image format must still
327+
// be one of the supported formats, or glBindImageTexture
328+
// may fail on some GLES implementations.
329+
// GL_RGBA32F seems to be the safest choice.
330+
Format = GL_RGBA32F;
327331
}
328332
}
329333

Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ void RenderDeviceGLImpl::TestTextureFormat(TEXTURE_FORMAT TexFormat)
12491249
VERIFY(Success, "Failed to create dummy render target texture");
12501250
(void)Success;
12511251
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ColorTex, 0);
1252-
CHECK_GL_ERROR("Failed to set bind dummy render target to framebuffer");
1252+
CHECK_GL_ERROR("Failed to bind dummy render target to framebuffer");
12531253

12541254
static const GLenum DrawBuffers[] = {GL_COLOR_ATTACHMENT0};
12551255
glDrawBuffers(_countof(DrawBuffers), DrawBuffers);
@@ -1298,7 +1298,8 @@ void RenderDeviceGLImpl::TestTextureFormat(TEXTURE_FORMAT TexFormat)
12981298
TexFormatInfo.BindFlags |= BIND_UNORDERED_ACCESS;
12991299

13001300
glBindImageTexture(0, CurrentImg, CurrentLevel, CurrentLayered, CurrentLayer, CurrenAccess, CurrenFormat);
1301-
CHECK_GL_ERROR("Failed to restore original image");
1301+
if (glGetError() != GL_NO_ERROR)
1302+
LOG_ERROR("Failed to restore original image");
13021303
}
13031304
#endif
13041305
}

0 commit comments

Comments
 (0)