open_toontown_panda3d/panda/src/gobj/preparedGraphicsObjects.I

137 lines
5.5 KiB
Plaintext

// Filename: preparedGraphicsObjects.I
// Created by: drose (23Feb04)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: PreparedGraphicsObjects::get_name
// Access: Public
// Description: Returns the name of the PreparedGraphicsObjects
// structure. This is an arbitrary name that serves
// mainly to uniquify the context for PStats reporting.
////////////////////////////////////////////////////////////////////
INLINE const string &PreparedGraphicsObjects::
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
// Description: Returns the artificial cap on graphics memory that
// will be imposed on this GSG. See
// set_graphics_memory_limit().
////////////////////////////////////////////////////////////////////
INLINE size_t PreparedGraphicsObjects::
get_graphics_memory_limit() const {
return _graphics_memory_lru.get_max_size();
}
////////////////////////////////////////////////////////////////////
// Function: PreparedGraphicsObjects::release_all
// Access: Public
// Description: Releases all prepared objects of all kinds at once.
////////////////////////////////////////////////////////////////////
INLINE void PreparedGraphicsObjects::
release_all() {
release_all_textures();
release_all_geoms();
release_all_shaders();
release_all_vertex_buffers();
release_all_index_buffers();
}
////////////////////////////////////////////////////////////////////
// Function: PreparedGraphicsObjects::get_num_queued
// Access: Public
// Description: Returns the number of objects of any kind that have
// been enqueued to be prepared on this GSG.
////////////////////////////////////////////////////////////////////
INLINE int PreparedGraphicsObjects::
get_num_queued() const {
return (get_num_queued_textures() +
get_num_queued_geoms() +
get_num_queued_shaders() +
get_num_queued_vertex_buffers() +
get_num_queued_index_buffers());
}
////////////////////////////////////////////////////////////////////
// Function: PreparedGraphicsObjects::get_num_prepared
// Access: Public
// Description: Returns the number of objects of any kind that have
// already been prepared on this GSG.
////////////////////////////////////////////////////////////////////
INLINE int PreparedGraphicsObjects::
get_num_prepared() const {
return (get_num_prepared_textures() +
get_num_prepared_geoms() +
get_num_prepared_shaders() +
get_num_prepared_vertex_buffers() +
get_num_prepared_index_buffers());
}
////////////////////////////////////////////////////////////////////
// Function: PreparedGraphicsObjects::BufferCacheKey::operator <
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PreparedGraphicsObjects::BufferCacheKey::
operator < (const PreparedGraphicsObjects::BufferCacheKey &other) const {
if (_data_size_bytes != other._data_size_bytes) {
return _data_size_bytes < other._data_size_bytes;
}
return (int)_usage_hint < (int)other._usage_hint;
}
////////////////////////////////////////////////////////////////////
// Function: PreparedGraphicsObjects::BufferCacheKey::operator ==
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PreparedGraphicsObjects::BufferCacheKey::
operator == (const PreparedGraphicsObjects::BufferCacheKey &other) const {
return (_data_size_bytes == other._data_size_bytes &&
_usage_hint == other._usage_hint);
}
////////////////////////////////////////////////////////////////////
// Function: PreparedGraphicsObjects::BufferCacheKey::operator !=
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool PreparedGraphicsObjects::BufferCacheKey::
operator != (const PreparedGraphicsObjects::BufferCacheKey &other) const {
return !operator == (other);
}