Skip to content

Commit

Permalink
Improved robustness with OpenGL driver wonkiness with float16 textures.
Browse files Browse the repository at this point in the history
  • Loading branch information
luciusDXL committed Aug 1, 2023
1 parent 1d6f5bd commit a47d40e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion TheForceEngine/TFE_RenderBackend/Win32OpenGL/textureGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ bool TextureGpu::create(u32 width, u32 height, TexFormat format, bool hasMipmaps

glBindTexture(GL_TEXTURE_2D, m_gpuHandle);
glTexImage2D(GL_TEXTURE_2D, 0, c_internalFormat[format], width, height, 0, c_baseFormat[format], c_channelFormat[format], nullptr);
assert(glGetError() == GL_NO_ERROR);
GLenum error = glGetError();
// Handle OpenGL driver wonkiness around float16 textures.
if (error != GL_NO_ERROR && c_channelFormat[format] == GL_FLOAT)
{
glTexImage2D(GL_TEXTURE_2D, 0, c_internalFormat[format], width, height, 0, c_baseFormat[format], GL_HALF_FLOAT, nullptr);
error = glGetError();
}
assert(error == GL_NO_ERROR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, hasMipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter == MAG_FILTER_LINEAR ? GL_LINEAR : GL_NEAREST);
Expand Down

0 comments on commit a47d40e

Please sign in to comment.