Browse Source

check in 32-bit float texture formats

rdb 11 years ago
parent
commit
dda0d9c15f

+ 35 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -6649,6 +6649,8 @@ get_external_image_format(Texture *tex) const {
       case Texture::F_rgba4:
       case Texture::F_rgba4:
       case Texture::F_rgba8:
       case Texture::F_rgba8:
       case Texture::F_rgba12:
       case Texture::F_rgba12:
+      case Texture::F_rgba16:
+      case Texture::F_rgba32:
         return GL_COMPRESSED_RGBA;
         return GL_COMPRESSED_RGBA;
 
 
       case Texture::F_rgb:
       case Texture::F_rgb:
@@ -6658,6 +6660,7 @@ get_external_image_format(Texture *tex) const {
       case Texture::F_rgb12:
       case Texture::F_rgb12:
       case Texture::F_rgb332:
       case Texture::F_rgb332:
       case Texture::F_rgb16:
       case Texture::F_rgb16:
+      case Texture::F_rgb32:
         return GL_COMPRESSED_RGB;
         return GL_COMPRESSED_RGB;
 
 
       case Texture::F_alpha:
       case Texture::F_alpha:
@@ -6667,9 +6670,11 @@ get_external_image_format(Texture *tex) const {
       case Texture::F_green:
       case Texture::F_green:
       case Texture::F_blue:
       case Texture::F_blue:
       case Texture::F_r16:
       case Texture::F_r16:
+      case Texture::F_r32:
         return GL_COMPRESSED_RED;
         return GL_COMPRESSED_RED;
 
 
       case Texture::F_rg16:
       case Texture::F_rg16:
+      case Texture::F_rg32:
         return GL_COMPRESSED_RG;
         return GL_COMPRESSED_RG;
 
 
       case Texture::F_luminance:
       case Texture::F_luminance:
@@ -6778,6 +6783,7 @@ get_external_image_format(Texture *tex) const {
 #ifndef OPENGLES
 #ifndef OPENGLES
   case Texture::F_red:
   case Texture::F_red:
   case Texture::F_r16:
   case Texture::F_r16:
+  case Texture::F_r32:
     return GL_RED;
     return GL_RED;
   case Texture::F_green:
   case Texture::F_green:
     return GL_GREEN;
     return GL_GREEN;
@@ -6788,6 +6794,7 @@ get_external_image_format(Texture *tex) const {
     return GL_ALPHA;
     return GL_ALPHA;
 #ifndef OPENGLES_1
 #ifndef OPENGLES_1
   case Texture::F_rg16:
   case Texture::F_rg16:
+  case Texture::F_rg32:
     return GL_RG;
     return GL_RG;
 #endif
 #endif
   case Texture::F_rgb:
   case Texture::F_rgb:
@@ -6796,6 +6803,7 @@ get_external_image_format(Texture *tex) const {
   case Texture::F_rgb12:
   case Texture::F_rgb12:
   case Texture::F_rgb332:
   case Texture::F_rgb332:
   case Texture::F_rgb16:
   case Texture::F_rgb16:
+  case Texture::F_rgb32:
   case Texture::F_srgb:
   case Texture::F_srgb:
 #ifdef OPENGLES
 #ifdef OPENGLES
     return GL_RGB;
     return GL_RGB;
@@ -6892,6 +6900,8 @@ get_internal_image_format(Texture *tex) const {
       case Texture::F_rgba:
       case Texture::F_rgba:
       case Texture::F_rgba8:
       case Texture::F_rgba8:
       case Texture::F_rgba12:
       case Texture::F_rgba12:
+      case Texture::F_rgba16:
+      case Texture::F_rgba32:
         if (get_supports_compressed_texture_format(Texture::CM_dxt5) && !is_3d) {
         if (get_supports_compressed_texture_format(Texture::CM_dxt5) && !is_3d) {
           return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
           return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
         } else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
         } else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
@@ -6906,6 +6916,7 @@ get_internal_image_format(Texture *tex) const {
       case Texture::F_rgb12:
       case Texture::F_rgb12:
       case Texture::F_rgb332:
       case Texture::F_rgb332:
       case Texture::F_rgb16:
       case Texture::F_rgb16:
+      case Texture::F_rgb32:
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
           return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
           return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
         } else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
         } else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
@@ -6925,6 +6936,7 @@ get_internal_image_format(Texture *tex) const {
       case Texture::F_green:
       case Texture::F_green:
       case Texture::F_blue:
       case Texture::F_blue:
       case Texture::F_r16:
       case Texture::F_r16:
+      case Texture::F_r32:
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
           return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
           return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
         } else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
         } else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
@@ -6933,6 +6945,7 @@ get_internal_image_format(Texture *tex) const {
         return GL_COMPRESSED_RED;
         return GL_COMPRESSED_RED;
 
 
       case Texture::F_rg16:
       case Texture::F_rg16:
+      case Texture::F_rg32:
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
           return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
           return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
         } else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
         } else if (get_supports_compressed_texture_format(Texture::CM_fxt1) && !is_3d) {
@@ -7174,6 +7187,8 @@ get_internal_image_format(Texture *tex) const {
       return GL_RGB16;
       return GL_RGB16;
     }
     }
 #endif  // OPENGLES
 #endif  // OPENGLES
+  case Texture::F_rgb32:
+    return GL_RGB32F;
 
 
 #ifndef OPENGLES
 #ifndef OPENGLES
   case Texture::F_rgb332:
   case Texture::F_rgb332:
@@ -7199,6 +7214,10 @@ get_internal_image_format(Texture *tex) const {
       return GL_RG16;
       return GL_RG16;
     }
     }
 #endif
 #endif
+  case Texture::F_r32:
+    return GL_R32F;
+  case Texture::F_rg32:
+    return GL_RG32F;
 
 
   case Texture::F_alpha:
   case Texture::F_alpha:
     return GL_ALPHA;
     return GL_ALPHA;
@@ -10364,6 +10383,22 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
     type = Texture::T_float;
     type = Texture::T_float;
     format = Texture::F_r16;
     format = Texture::F_r16;
     break;
     break;
+  case GL_RGBA32F:
+    type = Texture::T_float;
+    format = Texture::F_rgba32;
+    break;
+  case GL_RGB32F:
+    type = Texture::T_float;
+    format = Texture::F_rgb32;
+    break;
+  case GL_RG32F:
+    type = Texture::T_float;
+    format = Texture::F_rg32;
+    break;
+  case GL_R32F:
+    type = Texture::T_float;
+    format = Texture::F_r32;
+    break;    
 #endif
 #endif
 
 
 #ifndef OPENGLES
 #ifndef OPENGLES

+ 37 - 0
panda/src/gobj/texture.cxx

@@ -585,6 +585,16 @@ estimate_texture_memory() const {
     bpp = 4;
     bpp = 4;
     break;
     break;
 
 
+  case Texture::F_r32:
+    bpp = 4;
+    break;
+  case Texture::F_rg32:
+    bpp = 8;
+    break;
+  case Texture::F_rgb32:
+    bpp = 12;
+    break;
+
   default:
   default:
     break;
     break;
   }
   }
@@ -1719,6 +1729,16 @@ write(ostream &out, int indent_level) const {
   case F_r32i:
   case F_r32i:
     out << "r32i";
     out << "r32i";
     break;
     break;
+
+  case F_r32:
+    out << "r32";
+    break;
+  case F_rg32:
+    out << "rg32";
+    break;
+  case F_rgb32:
+    out << "rgb32";
+    break;
   }
   }
 
 
   if (cdata->_compression != CM_default) {
   if (cdata->_compression != CM_default) {
@@ -2155,6 +2175,12 @@ format_format(Format format) {
     return "sluminance_alpha";
     return "sluminance_alpha";
   case F_r32i:
   case F_r32i:
     return "r32i";
     return "r32i";
+  case F_r32:
+    return "r32";
+  case F_rg32:
+    return "rg32";
+  case F_rgb32:
+    return "rgb32";
   }
   }
   return "**invalid**";
   return "**invalid**";
 }
 }
@@ -2235,6 +2261,12 @@ string_format(const string &str) {
     return F_sluminance_alpha;
     return F_sluminance_alpha;
   } else if (cmp_nocase(str, "r32i") == 0) {
   } else if (cmp_nocase(str, "r32i") == 0) {
     return F_r32i;
     return F_r32i;
+  } else if (cmp_nocase(str, "r32") == 0 || cmp_nocase(str, "red32") == 0) {
+    return F_r32;
+  } else if (cmp_nocase(str, "rg32") == 0 || cmp_nocase(str, "r32g32") == 0) {
+    return F_rg32;
+  } else if (cmp_nocase(str, "rgb32") == 0 || cmp_nocase(str, "r32g32b32") == 0) {
+    return F_rgb32;
   }
   }
 
 
   gobj_cat->error()
   gobj_cat->error()
@@ -4542,6 +4574,8 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression,
     case Texture::F_rgb8:
     case Texture::F_rgb8:
     case Texture::F_rgb12:
     case Texture::F_rgb12:
     case Texture::F_rgb332:
     case Texture::F_rgb332:
+    case Texture::F_rgb16:
+    case Texture::F_rgb32:
       if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt1)) {
       if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt1)) {
         compression = CM_dxt1;
         compression = CM_dxt1;
       } else if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt3)) {
       } else if (gsg == NULL || gsg->get_supports_compressed_texture_format(CM_dxt3)) {
@@ -5081,6 +5115,7 @@ do_set_format(CData *cdata, Texture::Format format) {
   case F_r16:
   case F_r16:
   case F_sluminance:
   case F_sluminance:
   case F_r32i:
   case F_r32i:
+  case F_r32:
     cdata->_num_components = 1;
     cdata->_num_components = 1;
     break;
     break;
 
 
@@ -5088,6 +5123,7 @@ do_set_format(CData *cdata, Texture::Format format) {
   case F_luminance_alphamask:
   case F_luminance_alphamask:
   case F_rg16:
   case F_rg16:
   case F_sluminance_alpha:
   case F_sluminance_alpha:
+  case F_rg32:
     cdata->_num_components = 2;
     cdata->_num_components = 2;
     break;
     break;
 
 
@@ -5098,6 +5134,7 @@ do_set_format(CData *cdata, Texture::Format format) {
   case F_rgb332:
   case F_rgb332:
   case F_rgb16:
   case F_rgb16:
   case F_srgb:
   case F_srgb:
+  case F_rgb32:
     cdata->_num_components = 3;
     cdata->_num_components = 3;
     break;
     break;
 
 

+ 3 - 0
panda/src/gobj/texture.h

@@ -142,6 +142,9 @@ PUBLISHED:
     F_sluminance_alpha,
     F_sluminance_alpha,
 
 
     F_r32i,  // 32-bit integer, used for atomic access
     F_r32i,  // 32-bit integer, used for atomic access
+    F_r32,
+    F_rg32,
+    F_rgb32,
   };
   };
 
 
   enum FilterType {
   enum FilterType {