preparedGraphicsObjects.I 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // Filename: preparedGraphicsObjects.I
  2. // Created by: drose (23Feb04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: PreparedGraphicsObjects::get_name
  16. // Access: Public
  17. // Description: Returns the name of the PreparedGraphicsObjects
  18. // structure. This is an arbitrary name that serves
  19. // mainly to uniquify the context for PStats reporting.
  20. ////////////////////////////////////////////////////////////////////
  21. INLINE const string &PreparedGraphicsObjects::
  22. get_name() const {
  23. return _name;
  24. }
  25. ////////////////////////////////////////////////////////////////////
  26. // Function: PreparedGraphicsObjects::get_graphics_memory_limit
  27. // Access: Public
  28. // Description: Returns the artificial cap on graphics memory that
  29. // will be imposed on this GSG. See
  30. // set_graphics_memory_limit().
  31. ////////////////////////////////////////////////////////////////////
  32. INLINE size_t PreparedGraphicsObjects::
  33. get_graphics_memory_limit() const {
  34. return _graphics_memory_lru.get_max_size();
  35. }
  36. ////////////////////////////////////////////////////////////////////
  37. // Function: PreparedGraphicsObjects::release_all
  38. // Access: Public
  39. // Description: Releases all prepared objects of all kinds at once.
  40. ////////////////////////////////////////////////////////////////////
  41. INLINE void PreparedGraphicsObjects::
  42. release_all() {
  43. release_all_textures();
  44. release_all_geoms();
  45. release_all_shaders();
  46. release_all_vertex_buffers();
  47. release_all_index_buffers();
  48. _texture_residency.set_levels();
  49. _vbuffer_residency.set_levels();
  50. _ibuffer_residency.set_levels();
  51. }
  52. ////////////////////////////////////////////////////////////////////
  53. // Function: PreparedGraphicsObjects::get_num_queued
  54. // Access: Public
  55. // Description: Returns the number of objects of any kind that have
  56. // been enqueued to be prepared on this GSG.
  57. ////////////////////////////////////////////////////////////////////
  58. INLINE int PreparedGraphicsObjects::
  59. get_num_queued() const {
  60. return (get_num_queued_textures() +
  61. get_num_queued_geoms() +
  62. get_num_queued_shaders() +
  63. get_num_queued_vertex_buffers() +
  64. get_num_queued_index_buffers());
  65. }
  66. ////////////////////////////////////////////////////////////////////
  67. // Function: PreparedGraphicsObjects::get_num_prepared
  68. // Access: Public
  69. // Description: Returns the number of objects of any kind that have
  70. // already been prepared on this GSG.
  71. ////////////////////////////////////////////////////////////////////
  72. INLINE int PreparedGraphicsObjects::
  73. get_num_prepared() const {
  74. return (get_num_prepared_textures() +
  75. get_num_prepared_geoms() +
  76. get_num_prepared_shaders() +
  77. get_num_prepared_vertex_buffers() +
  78. get_num_prepared_index_buffers());
  79. }
  80. ////////////////////////////////////////////////////////////////////
  81. // Function: PreparedGraphicsObjects::BufferCacheKey::operator <
  82. // Access: Public
  83. // Description:
  84. ////////////////////////////////////////////////////////////////////
  85. INLINE bool PreparedGraphicsObjects::BufferCacheKey::
  86. operator < (const PreparedGraphicsObjects::BufferCacheKey &other) const {
  87. if (_data_size_bytes != other._data_size_bytes) {
  88. return _data_size_bytes < other._data_size_bytes;
  89. }
  90. return (int)_usage_hint < (int)other._usage_hint;
  91. }
  92. ////////////////////////////////////////////////////////////////////
  93. // Function: PreparedGraphicsObjects::BufferCacheKey::operator ==
  94. // Access: Public
  95. // Description:
  96. ////////////////////////////////////////////////////////////////////
  97. INLINE bool PreparedGraphicsObjects::BufferCacheKey::
  98. operator == (const PreparedGraphicsObjects::BufferCacheKey &other) const {
  99. return (_data_size_bytes == other._data_size_bytes &&
  100. _usage_hint == other._usage_hint);
  101. }
  102. ////////////////////////////////////////////////////////////////////
  103. // Function: PreparedGraphicsObjects::BufferCacheKey::operator !=
  104. // Access: Public
  105. // Description:
  106. ////////////////////////////////////////////////////////////////////
  107. INLINE bool PreparedGraphicsObjects::BufferCacheKey::
  108. operator != (const PreparedGraphicsObjects::BufferCacheKey &other) const {
  109. return !operator == (other);
  110. }