30 TypeHandle PreparedGraphicsObjects::EnqueuedObject::_type_handle;
32 int PreparedGraphicsObjects::_name_index = 0;
37 PreparedGraphicsObjects::
38 PreparedGraphicsObjects() :
39 _lock(
"PreparedGraphicsObjects::_lock"),
41 _vertex_buffer_cache_size(0),
42 _index_buffer_cache_size(0),
43 _texture_residency(_name,
"texture"),
44 _vbuffer_residency(_name,
"vbuffer"),
45 _ibuffer_residency(_name,
"ibuffer"),
46 _sbuffer_residency(_name,
"sbuffer"),
47 _graphics_memory_lru(
"graphics_memory_lru", graphics_memory_limit),
48 _sampler_object_lru(
"sampler_object_lru", sampler_object_limit)
53 _support_released_buffer_cache =
false;
59 PreparedGraphicsObjects::
60 ~PreparedGraphicsObjects() {
69 Textures::iterator tci;
70 for (tci = _released_textures.begin();
71 tci != _released_textures.end();
76 _released_textures.clear();
79 ReleasedSamplers::iterator ssci;
80 for (ssci = _released_samplers.begin();
81 ssci != _released_samplers.end();
86 _released_samplers.clear();
90 for (gci = _released_geoms.begin();
91 gci != _released_geoms.end();
96 _released_geoms.clear();
99 Shaders::iterator sci;
100 for (sci = _released_shaders.begin();
101 sci != _released_shaders.end();
106 _released_shaders.clear();
109 Buffers::iterator vbci;
110 for (vbci = _released_vertex_buffers.begin();
111 vbci != _released_vertex_buffers.end();
116 _released_vertex_buffers.clear();
119 Buffers::iterator ibci;
120 for (ibci = _released_index_buffers.begin();
121 ibci != _released_index_buffers.end();
126 _released_index_buffers.clear();
129 Buffers::iterator bci;
130 for (bci = _released_shader_buffers.begin();
131 bci != _released_shader_buffers.end();
136 _released_shader_buffers.clear();
156 throw_event(
"graphics_memory_limit_changed");
166 _graphics_memory_lru.write(out, 0);
175 out <<
"Textures:\n";
176 _texture_residency.write(out, 2);
178 out <<
"\nVertex buffers:\n";
179 _vbuffer_residency.write(out, 2);
181 out <<
"\nIndex buffers:\n";
182 _ibuffer_residency.write(out, 2);
184 out <<
"\nShader buffers:\n";
185 _sbuffer_residency.write(out, 2);
196 _enqueued_textures.insert(EnqueuedTextures::value_type(tex,
nullptr));
204 enqueue_texture_future(
Texture *tex) {
207 std::pair<EnqueuedTextures::iterator, bool> result =
208 _enqueued_textures.insert(EnqueuedTextures::value_type(tex,
nullptr));
209 if (result.first->second ==
nullptr) {
210 result.first->second =
new EnqueuedObject(
this, tex);
212 PT(EnqueuedObject) fut = result.first->second;
213 nassertr(!fut->cancelled(), fut)
224 EnqueuedTextures::const_iterator qi = _enqueued_textures.find((
Texture *)tex);
225 return (qi != _enqueued_textures.end());
241 EnqueuedTextures::iterator qi = _enqueued_textures.find(tex);
242 if (qi != _enqueued_textures.end()) {
243 if (qi->second !=
nullptr) {
244 qi->second->notify_removed();
246 _enqueued_textures.erase(qi);
277 tc->_object =
nullptr;
279 bool removed = (_prepared_textures.erase(tc) != 0);
282 _released_textures.insert(tc);
303 int num_textures = (int)_prepared_textures.size() + (int)_enqueued_textures.size();
305 Textures::iterator tci;
306 for (tci = _prepared_textures.begin();
307 tci != _prepared_textures.end();
311 tc->_object =
nullptr;
313 _released_textures.insert(tc);
316 _prepared_textures.clear();
319 EnqueuedTextures::iterator qti;
320 for (qti = _enqueued_textures.begin();
321 qti != _enqueued_textures.end();
323 if (qti->second !=
nullptr) {
324 qti->second->notify_removed();
328 _enqueued_textures.clear();
339 return _enqueued_textures.size();
347 return _prepared_textures.size();
376 bool prepared = _prepared_textures.insert(tc).second;
377 nassertr(prepared, tc);
391 _enqueued_samplers.insert(sampler);
401 EnqueuedSamplers::const_iterator qi = _enqueued_samplers.find(sampler);
402 return (qi != _enqueued_samplers.end());
418 EnqueuedSamplers::iterator qi = _enqueued_samplers.find(sampler);
419 if (qi != _enqueued_samplers.end()) {
420 _enqueued_samplers.erase(qi);
433 PreparedSamplers::const_iterator it = _prepared_samplers.find(sampler);
434 return (it != _prepared_samplers.end());
447 _released_samplers.insert(sc);
458 PreparedSamplers::iterator it = _prepared_samplers.find(sampler);
459 if (it != _prepared_samplers.end()) {
460 _released_samplers.insert(it->second);
461 _prepared_samplers.erase(it);
464 _enqueued_samplers.erase(sampler);
475 int num_samplers = (int)_prepared_samplers.size() + (int)_enqueued_samplers.size();
477 PreparedSamplers::iterator sci;
478 for (sci = _prepared_samplers.begin();
479 sci != _prepared_samplers.end();
481 _released_samplers.insert(sci->second);
484 _prepared_samplers.clear();
485 _enqueued_samplers.clear();
496 return _enqueued_samplers.size();
504 return _prepared_samplers.size();
527 PreparedSamplers::const_iterator it = _prepared_samplers.find(sampler);
528 if (it != _prepared_samplers.end()) {
536 _prepared_samplers[sampler] = sc;
550 _enqueued_geoms.insert(geom);
560 EnqueuedGeoms::const_iterator qi = _enqueued_geoms.find((
Geom *)geom);
561 return (qi != _enqueued_geoms.end());
577 EnqueuedGeoms::iterator qi = _enqueued_geoms.find(geom);
578 if (qi != _enqueued_geoms.end()) {
579 _enqueued_geoms.erase(qi);
607 gc->_geom->clear_prepared(
this);
613 bool removed = (_prepared_geoms.erase(gc) != 0);
616 _released_geoms.insert(gc);
628 int num_geoms = (int)_prepared_geoms.size() + (int)_enqueued_geoms.size();
631 for (gci = _prepared_geoms.begin();
632 gci != _prepared_geoms.end();
635 gc->_geom->clear_prepared(
this);
638 _released_geoms.insert(gc);
641 _prepared_geoms.clear();
642 _enqueued_geoms.clear();
653 return _enqueued_geoms.size();
661 return _prepared_geoms.size();
690 bool prepared = _prepared_geoms.insert(gc).second;
691 nassertr(prepared, gc);
705 _enqueued_shaders.insert(EnqueuedShaders::value_type(shader,
nullptr));
713 enqueue_shader_future(
Shader *shader) {
716 std::pair<EnqueuedShaders::iterator, bool> result =
717 _enqueued_shaders.insert(EnqueuedShaders::value_type(shader,
nullptr));
718 if (result.first->second ==
nullptr) {
719 result.first->second =
new EnqueuedObject(
this, shader);
721 PT(EnqueuedObject) fut = result.first->second;
722 nassertr(!fut->cancelled(), fut)
733 EnqueuedShaders::const_iterator qi = _enqueued_shaders.find((
Shader *)shader);
734 return (qi != _enqueued_shaders.end());
750 EnqueuedShaders::iterator qi = _enqueued_shaders.find(se);
751 if (qi != _enqueued_shaders.end()) {
752 if (qi->second !=
nullptr) {
753 qi->second->notify_removed();
755 _enqueued_shaders.erase(qi);
782 sc->_shader->clear_prepared(
this);
786 sc->_shader =
nullptr;
788 bool removed = (_prepared_shaders.erase(sc) != 0);
791 _released_shaders.insert(sc);
803 int num_shaders = (int)_prepared_shaders.size() + (int)_enqueued_shaders.size();
805 Shaders::iterator sci;
806 for (sci = _prepared_shaders.begin();
807 sci != _prepared_shaders.end();
810 sc->_shader->clear_prepared(
this);
811 sc->_shader =
nullptr;
813 _released_shaders.insert(sc);
816 _prepared_shaders.clear();
819 EnqueuedShaders::iterator qsi;
820 for (qsi = _enqueued_shaders.begin();
821 qsi != _enqueued_shaders.end();
823 if (qsi->second !=
nullptr) {
824 qsi->second->notify_removed();
828 _enqueued_shaders.clear();
839 return _enqueued_shaders.size();
847 return _prepared_shaders.size();
876 bool prepared = _prepared_shaders.insert(sc).second;
877 nassertr(prepared, sc);
891 _enqueued_vertex_buffers.insert(data);
902 EnqueuedVertexBuffers::const_iterator qi = _enqueued_vertex_buffers.find((
GeomVertexArrayData *)data);
903 return (qi != _enqueued_vertex_buffers.end());
919 EnqueuedVertexBuffers::iterator qi = _enqueued_vertex_buffers.find(data);
920 if (qi != _enqueued_vertex_buffers.end()) {
921 _enqueued_vertex_buffers.erase(qi);
949 vbc->
get_data()->clear_prepared(
this);
956 vbc->_object =
nullptr;
958 bool removed = (_prepared_vertex_buffers.erase(vbc) != 0);
961 if (_support_released_buffer_cache) {
962 cache_unprepared_buffer(vbc, data_size_bytes, usage_hint,
963 _vertex_buffer_cache,
964 _vertex_buffer_cache_lru, _vertex_buffer_cache_size,
965 released_vbuffer_cache_size,
966 _released_vertex_buffers);
968 _released_vertex_buffers.insert(vbc);
981 int num_vertex_buffers = (int)_prepared_vertex_buffers.size() + (int)_enqueued_vertex_buffers.size();
983 Buffers::iterator vbci;
984 for (vbci = _prepared_vertex_buffers.begin();
985 vbci != _prepared_vertex_buffers.end();
988 vbc->
get_data()->clear_prepared(
this);
989 vbc->_object =
nullptr;
991 _released_vertex_buffers.insert(vbc);
994 _prepared_vertex_buffers.clear();
995 _enqueued_vertex_buffers.clear();
998 BufferCache::iterator bci;
999 for (bci = _vertex_buffer_cache.begin();
1000 bci != _vertex_buffer_cache.end();
1003 nassertr(!buffer_list.empty(), num_vertex_buffers);
1004 BufferList::iterator li;
1005 for (li = buffer_list.begin(); li != buffer_list.end(); ++li) {
1007 _released_vertex_buffers.insert(vbc);
1010 _vertex_buffer_cache.clear();
1011 _vertex_buffer_cache_lru.clear();
1012 _vertex_buffer_cache_size = 0;
1014 return num_vertex_buffers;
1023 return _enqueued_vertex_buffers.size();
1032 return _prepared_vertex_buffers.size();
1057 size_t data_size_bytes = data->get_data_size_bytes();
1058 GeomEnums::UsageHint usage_hint = data->get_usage_hint();
1060 get_cached_buffer(data_size_bytes, usage_hint,
1061 _vertex_buffer_cache, _vertex_buffer_cache_lru,
1062 _vertex_buffer_cache_size);
1063 if (vbc !=
nullptr) {
1064 vbc->_object = data;
1070 vbc = gsg->prepare_vertex_buffer(data);
1073 if (vbc !=
nullptr) {
1074 bool prepared = _prepared_vertex_buffers.insert(vbc).second;
1075 nassertr(prepared, vbc);
1089 _enqueued_index_buffers.insert(data);
1100 EnqueuedIndexBuffers::const_iterator qi = _enqueued_index_buffers.find((
GeomPrimitive *)data);
1101 return (qi != _enqueued_index_buffers.end());
1117 EnqueuedIndexBuffers::iterator qi = _enqueued_index_buffers.find(data);
1118 if (qi != _enqueued_index_buffers.end()) {
1119 _enqueued_index_buffers.erase(qi);
1147 ibc->
get_data()->clear_prepared(
this);
1154 ibc->_object =
nullptr;
1156 bool removed = (_prepared_index_buffers.erase(ibc) != 0);
1159 if (_support_released_buffer_cache) {
1160 cache_unprepared_buffer(ibc, data_size_bytes, usage_hint,
1161 _index_buffer_cache,
1162 _index_buffer_cache_lru, _index_buffer_cache_size,
1163 released_ibuffer_cache_size,
1164 _released_index_buffers);
1166 _released_index_buffers.insert(ibc);
1179 int num_index_buffers = (int)_prepared_index_buffers.size() + (int)_enqueued_index_buffers.size();
1181 Buffers::iterator ibci;
1182 for (ibci = _prepared_index_buffers.begin();
1183 ibci != _prepared_index_buffers.end();
1186 ibc->
get_data()->clear_prepared(
this);
1187 ibc->_object =
nullptr;
1189 _released_index_buffers.insert(ibc);
1192 _prepared_index_buffers.clear();
1193 _enqueued_index_buffers.clear();
1196 BufferCache::iterator bci;
1197 for (bci = _index_buffer_cache.begin();
1198 bci != _index_buffer_cache.end();
1201 nassertr(!buffer_list.empty(), num_index_buffers);
1202 BufferList::iterator li;
1203 for (li = buffer_list.begin(); li != buffer_list.end(); ++li) {
1205 _released_index_buffers.insert(vbc);
1208 _index_buffer_cache.clear();
1209 _index_buffer_cache_lru.clear();
1210 _index_buffer_cache_size = 0;
1212 return num_index_buffers;
1221 return _enqueued_index_buffers.size();
1230 return _prepared_index_buffers.size();
1254 size_t data_size_bytes = data->get_data_size_bytes();
1255 GeomEnums::UsageHint usage_hint = data->get_usage_hint();
1257 get_cached_buffer(data_size_bytes, usage_hint,
1258 _index_buffer_cache, _index_buffer_cache_lru,
1259 _index_buffer_cache_size);
1260 if (ibc !=
nullptr) {
1261 ibc->_object = data;
1267 ibc = gsg->prepare_index_buffer(data);
1270 if (ibc !=
nullptr) {
1271 bool prepared = _prepared_index_buffers.insert(ibc).second;
1272 nassertr(prepared, ibc);
1286 _enqueued_shader_buffers.insert(data);
1297 EnqueuedShaderBuffers::const_iterator qi = _enqueued_shader_buffers.find((
ShaderBuffer *)data);
1298 return (qi != _enqueued_shader_buffers.end());
1314 EnqueuedShaderBuffers::iterator qi = _enqueued_shader_buffers.find(data);
1315 if (qi != _enqueued_shader_buffers.end()) {
1316 _enqueued_shader_buffers.erase(qi);
1345 buffer->clear_prepared(
this);
1349 bc->_object =
nullptr;
1351 bool removed = (_prepared_shader_buffers.erase(bc) != 0);
1354 _released_shader_buffers.insert(bc);
1366 int num_shader_buffers = (int)_prepared_shader_buffers.size() + (int)_enqueued_shader_buffers.size();
1368 Buffers::iterator bci;
1369 for (bci = _prepared_shader_buffers.begin();
1370 bci != _prepared_shader_buffers.end();
1374 _released_shader_buffers.insert(bc);
1377 _prepared_shader_buffers.clear();
1378 _enqueued_shader_buffers.clear();
1380 return num_shader_buffers;
1389 return _enqueued_shader_buffers.size();
1398 return _prepared_shader_buffers.size();
1426 if (bc !=
nullptr) {
1427 bool prepared = _prepared_shader_buffers.insert(bc).second;
1428 nassertr(prepared, bc);
1470 if (_object ==
nullptr || pgo ==
nullptr) {
1471 nassertr(done(),
false);
1480 if (_object->is_of_type(Texture::get_class_type())) {
1483 }
else if (_object->is_of_type(Geom::get_class_type())) {
1486 }
else if (_object->is_of_type(Shader::get_class_type())) {
1489 }
else if (_object->is_of_type(GeomVertexArrayData::get_class_type())) {
1492 }
else if (_object->is_of_type(GeomPrimitive::get_class_type())) {
1495 }
else if (_object->is_of_type(ShaderBuffer::get_class_type())) {
1514 if (!_released_textures.empty()) {
1515 Textures::iterator tci;
1516 for (tci = _released_textures.begin();
1517 tci != _released_textures.end();
1520 gsg->release_texture(tc);
1523 _released_textures.clear();
1526 if (!_released_samplers.empty()) {
1527 ReleasedSamplers::iterator sci;
1528 for (sci = _released_samplers.begin();
1529 sci != _released_samplers.end();
1532 gsg->release_sampler(sc);
1535 _released_samplers.clear();
1538 Geoms::iterator gci;
1539 for (gci = _released_geoms.begin();
1540 gci != _released_geoms.end();
1543 gsg->release_geom(gc);
1546 _released_geoms.clear();
1548 Shaders::iterator sci;
1549 for (sci = _released_shaders.begin();
1550 sci != _released_shaders.end();
1553 gsg->release_shader(sc);
1556 _released_shaders.clear();
1558 Buffers::iterator vbci;
1559 for (vbci = _released_vertex_buffers.begin();
1560 vbci != _released_vertex_buffers.end();
1563 gsg->release_vertex_buffer(vbc);
1566 _released_vertex_buffers.clear();
1568 Buffers::iterator ibci;
1569 for (ibci = _released_index_buffers.begin();
1570 ibci != _released_index_buffers.end();
1573 gsg->release_index_buffer(ibc);
1576 _released_index_buffers.clear();
1585 EnqueuedTextures::iterator qti;
1586 for (qti = _enqueued_textures.begin();
1587 qti != _enqueued_textures.end();
1592 if (tc !=
nullptr) {
1593 gsg->update_texture(tc,
true);
1594 if (view == 0 && qti->second !=
nullptr) {
1595 qti->second->set_result(tc);
1601 _enqueued_textures.clear();
1603 EnqueuedSamplers::iterator qsmi;
1604 for (qsmi = _enqueued_samplers.begin();
1605 qsmi != _enqueued_samplers.end();
1611 _enqueued_samplers.clear();
1613 EnqueuedGeoms::iterator qgi;
1614 for (qgi = _enqueued_geoms.begin();
1615 qgi != _enqueued_geoms.end();
1617 Geom *geom = (*qgi);
1621 _enqueued_geoms.clear();
1623 EnqueuedShaders::iterator qsi;
1624 for (qsi = _enqueued_shaders.begin();
1625 qsi != _enqueued_shaders.end();
1627 Shader *shader = qsi->first;
1629 if (qsi->second !=
nullptr) {
1630 qsi->second->set_result(sc);
1634 _enqueued_shaders.clear();
1636 EnqueuedVertexBuffers::iterator qvbi;
1637 for (qvbi = _enqueued_vertex_buffers.begin();
1638 qvbi != _enqueued_vertex_buffers.end();
1641 data->prepare_now(
this, gsg);
1644 _enqueued_vertex_buffers.clear();
1646 EnqueuedIndexBuffers::iterator qibi;
1647 for (qibi = _enqueued_index_buffers.begin();
1648 qibi != _enqueued_index_buffers.end();
1653 if (data->is_indexed()) {
1654 data->prepare_now(
this, gsg);
1658 _enqueued_index_buffers.clear();
1669 _texture_residency.
end_frame(current_thread);
1670 _vbuffer_residency.
end_frame(current_thread);
1671 _ibuffer_residency.
end_frame(current_thread);
1672 _sbuffer_residency.
end_frame(current_thread);
1678 std::string PreparedGraphicsObjects::
1681 std::ostringstream strm;
1682 strm <<
"context" << _name_index;
1693 void PreparedGraphicsObjects::
1694 cache_unprepared_buffer(
BufferContext *buffer,
size_t data_size_bytes,
1695 GeomEnums::UsageHint usage_hint,
1698 size_t &buffer_cache_size,
1699 int released_buffer_cache_size,
1700 PreparedGraphicsObjects::Buffers &released_buffers) {
1702 key._data_size_bytes = data_size_bytes;
1703 key._usage_hint = usage_hint;
1705 buffer_cache[key].push_back(buffer);
1706 buffer_cache_size += data_size_bytes;
1709 BufferCacheLRU::iterator li =
1710 find(buffer_cache_lru.begin(), buffer_cache_lru.end(), key);
1711 if (li != buffer_cache_lru.end()) {
1712 buffer_cache_lru.erase(li);
1714 buffer_cache_lru.insert(buffer_cache_lru.begin(), key);
1718 while ((
int)buffer_cache_size > released_buffer_cache_size) {
1719 nassertv(!buffer_cache_lru.empty());
1720 const BufferCacheKey &release_key = *buffer_cache_lru.rbegin();
1721 BufferList &buffer_list = buffer_cache[release_key];
1722 while (!buffer_list.empty() &&
1723 (int)buffer_cache_size > released_buffer_cache_size) {
1725 buffer_list.pop_back();
1726 released_buffers.insert(released_buffer);
1727 buffer_cache_size -= release_key._data_size_bytes;
1730 if (buffer_list.empty()) {
1731 buffer_cache.erase(release_key);
1732 buffer_cache_lru.pop_back();
1742 get_cached_buffer(
size_t data_size_bytes, GeomEnums::UsageHint usage_hint,
1745 size_t &buffer_cache_size) {
1747 key._data_size_bytes = data_size_bytes;
1748 key._usage_hint = usage_hint;
1750 BufferCache::iterator bci = buffer_cache.find(key);
1751 if (bci == buffer_cache.end()) {
1755 BufferList &buffer_list = (*bci).second;
1756 nassertr(!buffer_list.empty(),
nullptr);
1759 buffer_list.pop_back();
1760 if (buffer_list.empty()) {
1761 buffer_cache.erase(bci);
1762 BufferCacheLRU::iterator li =
1763 find(buffer_cache_lru.begin(), buffer_cache_lru.end(), key);
1764 if (li != buffer_cache_lru.end()) {
1765 buffer_cache_lru.erase(li);
1769 buffer_cache_size -= data_size_bytes;
EnqueuedObject(PreparedGraphicsObjects *pgo, TypedWritableReferenceCount *object)
Creates a new future for the given object.
SamplerContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) const
Creates a context for the sampler on the particular GSG, if it does not already exist.
int release_all_shaders()
Releases all shaders at once.
bool is_texture_prepared(const Texture *tex) const
Returns true if the texture has been prepared on this GSG, false otherwise.
Texture * get_texture() const
Returns the pointer to the associated Texture object.
bool is_index_buffer_queued(const GeomPrimitive *data) const
Returns true if the index buffer has been queued on this GSG, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void release_shader(ShaderContext *sc)
Indicates that a shader context, created by a previous call to prepare_shader(), is no longer needed.
void enqueue_texture(Texture *tex)
Indicates that a texture would like to be put on the list to be prepared when the GSG is next ready t...
This is a special class object that holds all the information returned by a particular GSG to indicat...
int get_num_queued_vertex_buffers() const
Returns the number of vertex buffers that have been enqueued to be prepared on this GSG.
get_usage_hint
Returns the usage hint for this primitive.
This is a generic buffer object that lives in graphics memory.
int get_num_queued_geoms() const
Returns the number of geoms that have been enqueued to be prepared on this GSG.
void release_geom(GeomContext *gc)
Indicates that a geom context, created by a previous call to prepare_geom(), is no longer needed.
GeomContext * prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg)
Immediately creates a new GeomContext for the indicated geom and returns it.
void release_texture(TextureContext *tc)
Indicates that a texture context, created by a previous call to prepare_texture(),...
void release_shader_buffer(BufferContext *bc)
Indicates that a data context, created by a previous call to prepare_shader_buffer(),...
bool is_shader_buffer_queued(const ShaderBuffer *data) const
Returns true if the index buffer has been queued on this GSG, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_shader_buffer_prepared(const ShaderBuffer *data) const
Returns true if the index buffer has been prepared on this GSG, false otherwise.
int get_view() const
Returns the specific view of a multiview texture this context represents.
int release_all_vertex_buffers()
Releases all datas at once.
int get_num_prepared_textures() const
Returns the number of textures that have already been prepared on this GSG.
bool dequeue_texture(Texture *tex)
Removes a texture from the queued list of textures to be prepared.
bool dequeue_index_buffer(GeomPrimitive *data)
Removes a buffer from the queued list of data arrays to be prepared.
int get_num_prepared_vertex_buffers() const
Returns the number of vertex buffers that have already been prepared on this GSG.
This is a special class object that holds all the information returned by a particular GSG to indicat...
bool is_vertex_buffer_prepared(const GeomVertexArrayData *data) const
Returns true if the vertex buffer has been prepared on this GSG, false otherwise.
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
void set_max_size(size_t max_size)
Changes the max size of all objects that are allowed to be active on the LRU.
bool dequeue_sampler(const SamplerState &sampler)
Removes a sampler from the queued list of samplers to be prepared.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
IndexBufferContext * prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg)
Immediately creates a new IndexBufferContext for the indicated data and returns it.
void notify_removed()
Called by PreparedGraphicsObjects to indicate that the preparation request has been cancelled.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_vertex_buffer_queued(const GeomVertexArrayData *data) const
Returns true if the vertex buffer has been queued on this GSG, false otherwise.
void enqueue_shader(Shader *shader)
Indicates that a shader would like to be put on the list to be prepared when the GSG is next ready to...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a special class object that holds all the information returned by a particular GSG to indicat...
void enqueue_index_buffer(GeomPrimitive *data)
Indicates that a buffer would like to be put on the list to be prepared when the GSG is next ready to...
void release_vertex_buffer(VertexBufferContext *vbc)
Indicates that a data context, created by a previous call to prepare_vertex_buffer(),...
int get_num_queued_shader_buffers() const
Returns the number of index buffers that have been enqueued to be prepared on this GSG.
int get_num_queued_textures() const
Returns the number of textures that have been enqueued to be prepared on this GSG.
void enqueue_sampler(const SamplerState &sampler)
Indicates that a sampler would like to be put on the list to be prepared when the GSG is next ready t...
bool is_sampler_prepared(const SamplerState &sampler) const
Returns true if the sampler has been prepared on this GSG, false otherwise.
VertexBufferContext * prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase *gsg)
Immediately creates a new VertexBufferContext for the indicated data and returns it.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int release_all_shader_buffers()
Releases all datas at once.
A table of objects that are saved within the graphics context for reference by handle later.
int get_num_prepared_index_buffers() const
Returns the number of index buffers that have already been prepared on this GSG.
int get_num_queued_index_buffers() const
Returns the number of index buffers that have been enqueued to be prepared on this GSG.
The ShaderContext is meant to contain the compiled version of a shader string.
This is our own Panda specialization on the default STL vector.
int get_num_prepared_shader_buffers() const
Returns the number of index buffers that have already been prepared on this GSG.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a handle to an enqueued object, from which the result can be obtained upon completion.
bool release(PreparedGraphicsObjects *prepared_objects)
Frees the texture context only on the indicated object, if it exists there.
ShaderContext * prepare_shader_now(Shader *shader, GraphicsStateGuardianBase *gsg)
Immediately creates a new ShaderContext for the indicated shader and returns it.
bool is_geom_queued(const Geom *geom) const
Returns true if the geom has been queued on this GSG, false otherwise.
virtual bool cancel() final
Cancels the pending preparation request.
bool is_geom_prepared(const Geom *geom) const
Returns true if the vertex buffer has been prepared on this GSG, false otherwise.
BufferContext * prepare_shader_buffer_now(ShaderBuffer *data, GraphicsStateGuardianBase *gsg)
Immediately creates a new BufferContext for the indicated data and returns it.
void release_index_buffer(IndexBufferContext *ibc)
Indicates that a data context, created by a previous call to prepare_index_buffer(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PT(PreparedGraphicsObjects::EnqueuedObject) PreparedGraphicsObjects
Like enqueue_texture, but returns an AsyncFuture that can be used to query the status of the texture'...
size_t get_max_size() const
Returns the max size of all objects that are allowed to be active on the LRU.
void enqueue_shader_buffer(ShaderBuffer *data)
Indicates that a buffer would like to be put on the list to be prepared when the GSG is next ready to...
void set_result(std::nullptr_t)
Sets this future's result.
int get_num_queued_samplers() const
Returns the number of samplers that have been enqueued to be prepared on this GSG.
A container for geometry primitives.
GeomContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the geom on the particular GSG, if it does not already exist.
bool dequeue_vertex_buffer(GeomVertexArrayData *data)
Removes a buffer from the queued list of data arrays to be prepared.
int get_num_queued_shaders() const
Returns the number of shaders that have been enqueued to be prepared on this GSG.
get_data_size_bytes
Returns the number of bytes stored in the vertices array.
SamplerContext * prepare_sampler_now(const SamplerState &sampler, GraphicsStateGuardianBase *gsg)
Immediately creates a new SamplerContext for the indicated sampler and returns it.
void enqueue_vertex_buffer(GeomVertexArrayData *data)
Indicates that a buffer would like to be put on the list to be prepared when the GSG is next ready to...
Similar to MutexHolder, but for a reentrant mutex.
int release_all_textures()
Releases all textures at once.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
bool dequeue_shader(Shader *shader)
Removes a shader from the queued list of shaders to be prepared.
get_data_size_bytes
Returns the number of bytes stored in the array.
int release_all_geoms()
Releases all geoms at once.
bool is_sampler_queued(const SamplerState &sampler) const
Returns true if the sampler has been queued on this GSG, false otherwise.
get_num_views
Returns the number of "views" in the texture.
bool is_texture_queued(const Texture *tex) const
Returns true if the texture has been queued on this GSG, false otherwise.
Represents a set of settings that indicate how a texture is sampled.
TextureContext * prepare_now(int view, PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the texture on the particular GSG, if it does not already exist.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void end_frame(Thread *current_thread)
This is called by the GraphicsStateGuardian to indicate that it has finished processing of the frame.
This is a special class object that holds a handle to the sampler state object given by the graphics ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
int get_num_prepared_shaders() const
Returns the number of shaders that have already been prepared on this GSG.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
GeomVertexArrayData * get_data() const
Returns the pointer to the client-side array data object.
bool is_shader_prepared(const Shader *shader) const
Returns true if the shader has been prepared on this GSG, false otherwise.
A thread; that is, a lightweight process.
TextureContext * prepare_texture_now(Texture *tex, int view, GraphicsStateGuardianBase *gsg)
Immediately creates a new TextureContext for the indicated texture and returns it.
void show_residency_trackers(std::ostream &out) const
Writes to the indicated ostream a report of how the various textures and vertex buffers are allocated...
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the texture has already been prepared or enqueued for preparation on the indicated GS...
This is a special class object that holds all the information returned by a particular GSG to indicat...
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the shader has already been prepared or enqueued for preparation on the indicated GSG...
void show_graphics_memory_lru(std::ostream &out) const
Writes to the indicated ostream a report of how the various textures and vertex buffers are allocated...
void begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread)
This is called by the GraphicsStateGuardian to indicate that it is about to begin processing of the f...
void enqueue_geom(Geom *geom)
Indicates that a geom would like to be put on the list to be prepared when the GSG is next ready to d...
get_usage_hint
Returns the usage hint that describes to the rendering backend how often the vertex data will be modi...
GeomPrimitive * get_data() const
Returns the pointer to the client-side array data object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void release_sampler(SamplerContext *sc)
Indicates that a sampler context, created by a previous call to prepare_sampler(),...
bool is_index_buffer_prepared(const GeomPrimitive *data) const
Returns true if the index buffer has been prepared on this GSG, false otherwise.
void begin_frame(Thread *current_thread)
To be called at the beginning of a frame, this initializes the active/inactive status.
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the geom has already been prepared or enqueued for preparation on the indicated GSG,...
TypeHandle is the identifier used to differentiate C++ class types.
void set_graphics_memory_limit(size_t limit)
Sets an artificial cap on graphics memory that will be imposed on this GSG.
virtual bool cancel()
Cancels the future.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for all GSG-specific context objects, such as TextureContext and GeomContext.
void end_frame(Thread *current_thread)
To be called at the end of a frame, this updates the PStatCollectors appropriately.
int get_num_prepared_geoms() const
Returns the number of geoms that have already been prepared on this GSG.
int release_all_samplers()
Releases all samplers at once.
ShaderContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the shader on the particular GSG, if it does not already exist.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_prepared_samplers() const
Returns the number of samplers that have already been prepared on this GSG.
bool dequeue_shader_buffer(ShaderBuffer *data)
Removes a buffer from the queued list of data arrays to be prepared.
bool dequeue_geom(Geom *geom)
Removes a geom from the queued list of geoms to be prepared.
This is the data for one array of a GeomVertexData structure.
int release_all_index_buffers()
Releases all datas at once.
bool is_shader_queued(const Shader *shader) const
Returns true if the shader has been queued on this GSG, false otherwise.
void set_result(SavedContext *result)
Indicates that the preparation request is done.