Browse Source

Various GL tweaks

rdb 10 years ago
parent
commit
a24531ff7b

+ 1 - 1
panda/src/glstuff/glGraphicsBuffer_src.cxx

@@ -1277,7 +1277,7 @@ open_buffer() {
 
 
   // Actually, let's always get a colour buffer for now until we
   // Actually, let's always get a colour buffer for now until we
   // figure out why Intel HD Graphics cards complain otherwise.
   // figure out why Intel HD Graphics cards complain otherwise.
-  if (_fb_properties.get_color_bits() == 0) {
+  if (gl_force_fbo_color && _fb_properties.get_color_bits() == 0) {
     _fb_properties.set_color_bits(1);
     _fb_properties.set_color_bits(1);
   }
   }
 
 

+ 5 - 8
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -11116,7 +11116,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
       gtc->_height = height;
       gtc->_height = height;
       gtc->_depth = depth;
       gtc->_depth = depth;
 
 
-      gtc->update_data_size_bytes(get_texture_memory_size(tex));
+      gtc->update_data_size_bytes(get_texture_memory_size(gtc));
     }
     }
 
 
     nassertr(gtc->_has_storage, false);
     nassertr(gtc->_has_storage, false);
@@ -11665,7 +11665,8 @@ upload_simple_texture(CLP(TextureContext) *gtc) {
 //               currently-selected texture).
 //               currently-selected texture).
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 size_t CLP(GraphicsStateGuardian)::
 size_t CLP(GraphicsStateGuardian)::
-get_texture_memory_size(Texture *tex) {
+get_texture_memory_size(CLP(TextureContext) *gtc) {
+  Texture *tex = gtc->get_texture();
 #ifdef OPENGLES  // Texture querying not supported on OpenGL ES.
 #ifdef OPENGLES  // Texture querying not supported on OpenGL ES.
   int width = tex->get_x_size();
   int width = tex->get_x_size();
   int height = tex->get_y_size();
   int height = tex->get_y_size();
@@ -11692,10 +11693,6 @@ get_texture_memory_size(Texture *tex) {
     return tex->get_expected_ram_image_size();
     return tex->get_expected_ram_image_size();
   }
   }
 
 
-  GLint minfilter;
-  glGetTexParameteriv(target, GL_TEXTURE_MIN_FILTER, &minfilter);
-  bool has_mipmaps = is_mipmap_filter(minfilter);
-
   clear_my_gl_errors();
   clear_my_gl_errors();
 
 
   GLint internal_format;
   GLint internal_format;
@@ -11755,7 +11752,7 @@ get_texture_memory_size(Texture *tex) {
 #endif  // OPENGLES
 #endif  // OPENGLES
 
 
   size_t result = num_bytes * width * height * depth * scale;
   size_t result = num_bytes * width * height * depth * scale;
-  if (has_mipmaps) {
+  if (gtc->_uses_mipmaps) {
     result = (result * 4) / 3;
     result = (result * 4) / 3;
   }
   }
 
 
@@ -11770,7 +11767,7 @@ get_texture_memory_size(Texture *tex) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void CLP(GraphicsStateGuardian)::
 void CLP(GraphicsStateGuardian)::
 check_nonresident_texture(BufferContextChain &chain) {
 check_nonresident_texture(BufferContextChain &chain) {
-#ifndef OPENGLES  // Residency queries not supported by OpenGL ES.
+#if defined(SUPPORT_FIXED_FUNCTION) && !defined(OPENGLES)  // Residency queries not supported by OpenGL ES.
   size_t num_textures = chain.get_count();
   size_t num_textures = chain.get_count();
   if (num_textures == 0) {
   if (num_textures == 0) {
     return;
     return;

+ 1 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -548,7 +548,7 @@ protected:
                             Texture::CompressionMode image_compression);
                             Texture::CompressionMode image_compression);
   bool upload_simple_texture(CLP(TextureContext) *gtc);
   bool upload_simple_texture(CLP(TextureContext) *gtc);
 
 
-  size_t get_texture_memory_size(Texture *tex);
+  size_t get_texture_memory_size(CLP(TextureContext) *gtc);
   void check_nonresident_texture(BufferContextChain &chain);
   void check_nonresident_texture(BufferContextChain &chain);
   bool do_extract_texture_data(CLP(TextureContext) *gtc);
   bool do_extract_texture_data(CLP(TextureContext) *gtc);
   bool extract_texture_image(PTA_uchar &image, size_t &page_size,
   bool extract_texture_image(PTA_uchar &image, size_t &page_size,

+ 6 - 0
panda/src/glstuff/glmisc_src.cxx

@@ -187,6 +187,12 @@ ConfigVariableBool gl_force_depth_stencil
   ("gl-force-depth-stencil", false,
   ("gl-force-depth-stencil", false,
    PRC_DESC("Temporary hack variable 7x00 vs 8x00 nVidia bug.  See glGraphicsStateGuardian_src.cxx."));
    PRC_DESC("Temporary hack variable 7x00 vs 8x00 nVidia bug.  See glGraphicsStateGuardian_src.cxx."));
 
 
+ConfigVariableBool gl_force_fbo_color
+  ("gl-force-fbo-color", true,
+   PRC_DESC("This is set to true to force all FBOs to have at least one "
+            "color attachment.  This is to work around an Intel driver "
+            "issue.  Set to false to allow depth-only FBOs."));
+
 ConfigVariableBool gl_check_errors
 ConfigVariableBool gl_check_errors
   ("gl-check-errors", false,
   ("gl-check-errors", false,
    PRC_DESC("Regularly call glGetError() to check for OpenGL errors.  "
    PRC_DESC("Regularly call glGetError() to check for OpenGL errors.  "

+ 1 - 0
panda/src/glstuff/glmisc_src.h

@@ -65,6 +65,7 @@ extern ConfigVariableBool gl_debug_object_labels;
 extern ConfigVariableBool gl_debug_buffers;
 extern ConfigVariableBool gl_debug_buffers;
 extern ConfigVariableBool gl_finish;
 extern ConfigVariableBool gl_finish;
 extern ConfigVariableBool gl_force_depth_stencil;
 extern ConfigVariableBool gl_force_depth_stencil;
+extern ConfigVariableBool gl_force_fbo_color;
 extern ConfigVariableBool gl_check_errors;
 extern ConfigVariableBool gl_check_errors;
 extern ConfigVariableBool gl_force_flush;
 extern ConfigVariableBool gl_force_flush;
 extern ConfigVariableBool gl_separate_specular_color;
 extern ConfigVariableBool gl_separate_specular_color;