diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 24f579f70a..a521a53209 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -132,6 +132,17 @@ ConfigVariableBool prefer_single_buffer "false (since in that case the buffer can share a graphics context " "with the window).")); +ConfigVariableInt max_texture_stages +("max-texture-stages", -1, + PRC_DESC("Set this to a positive integer to limit the number of " + "texture stages reported by the GSG. This can be used to limit " + "the amount of multitexturing Panda will attempt to use. " + "If this is zero or less, the GSG will report its honest number " + "of texture stages, allowing Panda the full use of the graphics " + "card; if it is 1 or more, then Panda will never allow more than " + "this number of texture stages simultaneously, regardless of " + "what the GSG says it can do.")); + ConfigVariableBool support_render_texture ("support-render-texture", true, PRC_DESC("Set this true allow use of the render-to-a-texture feature, if it " diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index e1cca29cf7..633c8e5d2f 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -49,6 +49,7 @@ extern EXPCL_PANDA_DISPLAY ConfigVariableBool prefer_texture_buffer; extern EXPCL_PANDA_DISPLAY ConfigVariableBool prefer_parasite_buffer; extern EXPCL_PANDA_DISPLAY ConfigVariableBool prefer_single_buffer; +extern EXPCL_PANDA_DISPLAY ConfigVariableInt max_texture_stages; extern EXPCL_PANDA_DISPLAY ConfigVariableBool support_render_texture; extern EXPCL_PANDA_DISPLAY ConfigVariableBool support_rescale_normal; extern EXPCL_PANDA_DISPLAY ConfigVariableBool copy_texture_inverted; diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 45f8b74a93..732742bcbb 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -277,6 +277,9 @@ get_max_vertices_per_primitive() const { //////////////////////////////////////////////////////////////////// INLINE int GraphicsStateGuardian:: get_max_texture_stages() const { + if (max_texture_stages > 0) { + return min(_max_texture_stages, (int)max_texture_stages); + } return _max_texture_stages; } diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index d1c9817c03..f3a5cc644b 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -2068,7 +2068,8 @@ void GraphicsStateGuardian:: determine_effective_texture() { nassertv(_target._texture != (TextureAttrib *)NULL && _target._tex_gen != (TexGenAttrib *)NULL); - _effective_texture = _target._texture->filter_to_max(_max_texture_stages); + int max_texture_stages = get_max_texture_stages(); + _effective_texture = _target._texture->filter_to_max(max_texture_stages); _effective_tex_gen = _target._tex_gen; if (_has_texture_alpha_scale) { @@ -2080,7 +2081,7 @@ determine_effective_texture() { (stage, TexGenAttrib::M_constant, TexCoord3f(_current_color_scale[3], 0.0f, 0.0f))); } - nassertv(_effective_texture->get_num_on_stages() <= _max_texture_stages); + nassertv(_effective_texture->get_num_on_stages() <= max_texture_stages); } ////////////////////////////////////////////////////////////////////