From c325eabb9d4a0a7f903843e1f51b1ed6c170323d Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 29 Jun 2022 15:15:02 +0200 Subject: [PATCH] glgsg: Fix texture format selection when using `T_half_float` component type --- .../src/glstuff/glGraphicsStateGuardian_src.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index c536ed6747..43982312f0 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -10249,7 +10249,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const { case Texture::F_rgba: case Texture::F_rgbm: #ifndef OPENGLES_1 - if (component_type == Texture::T_float) { + if (component_type == Texture::T_float || + component_type == Texture::T_half_float) { return GL_RGBA16F; } else #endif @@ -10315,7 +10316,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const { #endif // OPENGLES #ifndef OPENGLES case Texture::F_rgba16: - if (component_type == Texture::T_float) { + if (component_type == Texture::T_float || + component_type == Texture::T_half_float) { return GL_RGBA16F; } else if (Texture::is_unsigned(component_type)) { return GL_RGBA16; @@ -10335,6 +10337,7 @@ get_internal_image_format(Texture *tex, bool force_sized) const { case Texture::F_rgb: switch (component_type) { case Texture::T_float: return GL_RGB16F; + case Texture::T_half_float: return GL_RGB16F; #ifndef OPENGLES case Texture::T_unsigned_short: return GL_RGB16; case Texture::T_short: return GL_RGB16_SNORM; @@ -10371,7 +10374,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const { case Texture::F_rgb12: return GL_RGB12; case Texture::F_rgb16: - if (component_type == Texture::T_float) { + if (component_type == Texture::T_float || + component_type == Texture::T_half_float) { return GL_RGB16F; } else if (Texture::is_unsigned(component_type)) { return GL_RGB16; @@ -10394,7 +10398,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const { return GL_RG16F_EXT; #elif !defined(OPENGLES_1) case Texture::F_r16: - if (component_type == Texture::T_float) { + if (component_type == Texture::T_float || + component_type == Texture::T_half_float) { return GL_R16F; } else if (Texture::is_unsigned(component_type)) { return GL_R16; @@ -10402,7 +10407,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const { return GL_R16_SNORM; } case Texture::F_rg16: - if (component_type == Texture::T_float) { + if (component_type == Texture::T_float || + component_type == Texture::T_half_float) { return GL_RG16F; } else if (Texture::is_unsigned(component_type)) { return GL_RG16;