diff --git a/panda/src/gobj/preparedGraphicsObjects.I b/panda/src/gobj/preparedGraphicsObjects.I index bef68d9178..50b59d8eb0 100644 --- a/panda/src/gobj/preparedGraphicsObjects.I +++ b/panda/src/gobj/preparedGraphicsObjects.I @@ -25,26 +25,6 @@ get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::set_graphics_memory_limit -// Access: Public -// Description: Sets an artificial cap on graphics memory that -// will be imposed on this GSG. -// -// This limits the total amount of graphics memory, -// including texture memory and vertex buffer memory, -// that will be consumed by the GSG, regardless of -// whether the hardware claims to provide more graphics -// memory than this. It is useful to put a ceiling on -// graphics memory consumed, since some drivers seem to -// allow the application to consume more memory than the -// hardware can realistically support. -//////////////////////////////////////////////////////////////////// -INLINE void PreparedGraphicsObjects:: -set_graphics_memory_limit(size_t limit) { - _graphics_memory_lru.set_max_size(limit); -} - //////////////////////////////////////////////////////////////////// // Function: PreparedGraphicsObjects::get_graphics_memory_limit // Access: Public diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 35e3253ef9..f8237d7584 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -25,6 +25,7 @@ #include "geomContext.h" #include "shaderContext.h" #include "config_gobj.h" +#include "throw_event.h" int PreparedGraphicsObjects::_name_index = 0; @@ -101,6 +102,32 @@ PreparedGraphicsObjects:: _released_index_buffers.clear(); } +//////////////////////////////////////////////////////////////////// +// Function: PreparedGraphicsObjects::set_graphics_memory_limit +// Access: Public +// Description: Sets an artificial cap on graphics memory that +// will be imposed on this GSG. +// +// This limits the total amount of graphics memory, +// including texture memory and vertex buffer memory, +// that will be consumed by the GSG, regardless of +// whether the hardware claims to provide more graphics +// memory than this. It is useful to put a ceiling on +// graphics memory consumed, since some drivers seem to +// allow the application to consume more memory than the +// hardware can realistically support. +//////////////////////////////////////////////////////////////////// +void PreparedGraphicsObjects:: +set_graphics_memory_limit(size_t limit) { + if (limit != _graphics_memory_lru.get_max_size()) { + _graphics_memory_lru.set_max_size(limit); + + // We throw an event here so global objects (particularly the + // TexMemWatcher) can automatically respond to this change. + throw_event("graphics_memory_limit_changed"); + } +} + //////////////////////////////////////////////////////////////////// // Function: PreparedGraphicsObjects::show_graphics_memory_lru // Access: Public diff --git a/panda/src/gobj/preparedGraphicsObjects.h b/panda/src/gobj/preparedGraphicsObjects.h index 0e70ffa785..360902d709 100644 --- a/panda/src/gobj/preparedGraphicsObjects.h +++ b/panda/src/gobj/preparedGraphicsObjects.h @@ -63,7 +63,7 @@ public: PUBLISHED: INLINE const string &get_name() const; - INLINE void set_graphics_memory_limit(size_t limit); + void set_graphics_memory_limit(size_t limit); INLINE size_t get_graphics_memory_limit() const; void show_graphics_memory_lru(ostream &out) const; void show_residency_trackers(ostream &out) const;