15 #include "preparedGraphicsObjects.h" 16 #include "textureContext.h" 17 #include "vertexBufferContext.h" 18 #include "indexBufferContext.h" 21 #include "geomVertexArrayData.h" 22 #include "geomPrimitive.h" 23 #include "samplerContext.h" 25 #include "reMutexHolder.h" 26 #include "geomContext.h" 27 #include "shaderContext.h" 28 #include "config_gobj.h" 29 #include "throw_event.h" 31 int PreparedGraphicsObjects::_name_index = 0;
38 PreparedGraphicsObjects::
39 PreparedGraphicsObjects() :
40 _lock(
"PreparedGraphicsObjects::_lock"),
42 _vertex_buffer_cache_size(0),
43 _index_buffer_cache_size(0),
44 _texture_residency(_name,
"texture"),
45 _vbuffer_residency(_name,
"vbuffer"),
46 _ibuffer_residency(_name,
"ibuffer"),
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;
61 PreparedGraphicsObjects::
62 ~PreparedGraphicsObjects() {
70 Textures::iterator tci;
71 for (tci = _released_textures.begin();
72 tci != _released_textures.end();
75 tc->set_owning_chain(NULL);
78 _released_textures.clear();
81 _released_samplers.clear();
84 _released_geoms.clear();
87 _released_shaders.clear();
90 Buffers::iterator vbci;
91 for (vbci = _released_vertex_buffers.begin();
92 vbci != _released_vertex_buffers.end();
95 vbc->set_owning_chain(NULL);
97 _released_vertex_buffers.clear();
100 Buffers::iterator ibci;
101 for (ibci = _released_index_buffers.begin();
102 ibci != _released_index_buffers.end();
105 ibc->set_owning_chain(NULL);
107 _released_index_buffers.clear();
132 throw_event(
"graphics_memory_limit_changed");
145 _graphics_memory_lru.write(out, 0);
157 out <<
"Textures:\n";
158 _texture_residency.write(out, 2);
160 out <<
"\nVertex buffers:\n";
161 _vbuffer_residency.write(out, 2);
163 out <<
"\nIndex buffers:\n";
164 _ibuffer_residency.write(out, 2);
178 _enqueued_textures.insert(tex);
191 EnqueuedTextures::const_iterator qi = _enqueued_textures.find((
Texture *)tex);
192 return (qi != _enqueued_textures.end());
213 EnqueuedTextures::iterator qi = _enqueued_textures.find(tex);
214 if (qi != _enqueued_textures.end()) {
215 _enqueued_textures.erase(qi);
249 tc->_texture->clear_prepared(tc->
get_view(),
this);
254 tc->_texture = (
Texture *)NULL;
256 bool removed = (_prepared_textures.erase(tc) != 0);
259 _released_textures.insert(tc);
285 int num_textures = (int)_prepared_textures.size() + (int)_enqueued_textures.size();
287 Textures::iterator tci;
288 for (tci = _prepared_textures.begin();
289 tci != _prepared_textures.end();
292 tc->_texture->clear_prepared(tc->
get_view(),
this);
293 tc->_texture = (
Texture *)NULL;
295 _released_textures.insert(tc);
298 _prepared_textures.clear();
299 _enqueued_textures.clear();
312 return _enqueued_textures.size();
323 return _prepared_textures.size();
359 bool prepared = _prepared_textures.insert(tc).second;
360 nassertr(prepared, tc);
377 _enqueued_samplers.insert(sampler);
390 EnqueuedSamplers::const_iterator qi = _enqueued_samplers.find(sampler);
391 return (qi != _enqueued_samplers.end());
412 EnqueuedSamplers::iterator qi = _enqueued_samplers.find(sampler);
413 if (qi != _enqueued_samplers.end()) {
414 _enqueued_samplers.erase(qi);
430 PreparedSamplers::const_iterator it = _prepared_samplers.find(sampler);
431 return (it != _prepared_samplers.end());
447 _released_samplers.insert(sc);
460 PreparedSamplers::iterator it = _prepared_samplers.find(sampler);
461 if (it != _prepared_samplers.end()) {
462 _released_samplers.insert(it->second);
463 _prepared_samplers.erase(it);
466 _enqueued_samplers.erase(sampler);
480 int num_samplers = (int)_prepared_samplers.size() + (int)_enqueued_samplers.size();
482 PreparedSamplers::iterator sci;
483 for (sci = _prepared_samplers.begin();
484 sci != _prepared_samplers.end();
486 _released_samplers.insert(sci->second);
489 _prepared_samplers.clear();
490 _enqueued_samplers.clear();
503 return _enqueued_samplers.size();
514 return _prepared_samplers.size();
543 PreparedSamplers::const_iterator it = _prepared_samplers.find(sampler);
544 if (it != _prepared_samplers.end()) {
552 _prepared_samplers[sampler] = sc;
569 _enqueued_geoms.insert(geom);
582 EnqueuedGeoms::const_iterator qi = _enqueued_geoms.find((
Geom *)geom);
583 return (qi != _enqueued_geoms.end());
604 EnqueuedGeoms::iterator qi = _enqueued_geoms.find(geom);
605 if (qi != _enqueued_geoms.end()) {
606 _enqueued_geoms.erase(qi);
640 gc->_geom->clear_prepared(
this);
645 gc->_geom = (
Geom *)NULL;
647 bool removed = (_prepared_geoms.erase(gc) != 0);
650 _released_geoms.insert(gc);
665 int num_geoms = (int)_prepared_geoms.size() + (int)_enqueued_geoms.size();
668 for (gci = _prepared_geoms.begin();
669 gci != _prepared_geoms.end();
672 gc->_geom->clear_prepared(
this);
673 gc->_geom = (
Geom *)NULL;
675 _released_geoms.insert(gc);
678 _prepared_geoms.clear();
679 _enqueued_geoms.clear();
692 return _enqueued_geoms.size();
703 return _prepared_geoms.size();
739 bool prepared = _prepared_geoms.insert(gc).second;
740 nassertr(prepared, gc);
757 _enqueued_shaders.insert(se);
770 EnqueuedShaders::const_iterator qi = _enqueued_shaders.find((
Shader *)shader);
771 return (qi != _enqueued_shaders.end());
792 EnqueuedShaders::iterator qi = _enqueued_shaders.find(se);
793 if (qi != _enqueued_shaders.end()) {
794 _enqueued_shaders.erase(qi);
828 sc->_shader->clear_prepared(
this);
833 sc->_shader = (
Shader *)NULL;
835 bool removed = (_prepared_shaders.erase(sc) != 0);
838 _released_shaders.insert(sc);
853 int num_shaders = (int)_prepared_shaders.size() + (int)_enqueued_shaders.size();
855 Shaders::iterator sci;
856 for (sci = _prepared_shaders.begin();
857 sci != _prepared_shaders.end();
860 sc->_shader->clear_prepared(
this);
861 sc->_shader = (
Shader *)NULL;
863 _released_shaders.insert(sc);
866 _prepared_shaders.clear();
867 _enqueued_shaders.clear();
880 return _enqueued_shaders.size();
891 return _prepared_shaders.size();
927 bool prepared = _prepared_shaders.insert(sc).second;
928 nassertr(prepared, sc);
945 _enqueued_vertex_buffers.insert(data);
958 EnqueuedVertexBuffers::const_iterator qi = _enqueued_vertex_buffers.find((
GeomVertexArrayData *)data);
959 return (qi != _enqueued_vertex_buffers.end());
980 EnqueuedVertexBuffers::iterator qi = _enqueued_vertex_buffers.find(data);
981 if (qi != _enqueued_vertex_buffers.end()) {
982 _enqueued_vertex_buffers.erase(qi);
1016 vbc->_data->clear_prepared(
this);
1026 bool removed = (_prepared_vertex_buffers.erase(vbc) != 0);
1029 if (_support_released_buffer_cache) {
1030 cache_unprepared_buffer(vbc, data_size_bytes, usage_hint,
1031 _vertex_buffer_cache,
1032 _vertex_buffer_cache_lru, _vertex_buffer_cache_size,
1033 released_vbuffer_cache_size,
1034 _released_vertex_buffers);
1036 _released_vertex_buffers.insert(vbc);
1052 int num_vertex_buffers = (int)_prepared_vertex_buffers.size() + (int)_enqueued_vertex_buffers.size();
1054 Buffers::iterator vbci;
1055 for (vbci = _prepared_vertex_buffers.begin();
1056 vbci != _prepared_vertex_buffers.end();
1059 vbc->_data->clear_prepared(
this);
1062 _released_vertex_buffers.insert(vbc);
1065 _prepared_vertex_buffers.clear();
1066 _enqueued_vertex_buffers.clear();
1069 BufferCache::iterator bci;
1070 for (bci = _vertex_buffer_cache.begin();
1071 bci != _vertex_buffer_cache.end();
1074 nassertr(!buffer_list.empty(), num_vertex_buffers);
1075 BufferList::iterator li;
1076 for (li = buffer_list.begin(); li != buffer_list.end(); ++li) {
1078 _released_vertex_buffers.insert(vbc);
1081 _vertex_buffer_cache.clear();
1082 _vertex_buffer_cache_lru.clear();
1083 _vertex_buffer_cache_size = 0;
1085 return num_vertex_buffers;
1096 return _enqueued_vertex_buffers.size();
1107 return _prepared_vertex_buffers.size();
1141 get_cached_buffer(data_size_bytes, usage_hint,
1142 _vertex_buffer_cache, _vertex_buffer_cache_lru,
1143 _vertex_buffer_cache_size);
1152 vbc = gsg->prepare_vertex_buffer(data);
1156 bool prepared = _prepared_vertex_buffers.insert(vbc).second;
1157 nassertr(prepared, vbc);
1174 _enqueued_index_buffers.insert(data);
1187 EnqueuedIndexBuffers::const_iterator qi = _enqueued_index_buffers.find((
GeomPrimitive *)data);
1188 return (qi != _enqueued_index_buffers.end());
1209 EnqueuedIndexBuffers::iterator qi = _enqueued_index_buffers.find(data);
1210 if (qi != _enqueued_index_buffers.end()) {
1211 _enqueued_index_buffers.erase(qi);
1245 ibc->_data->clear_prepared(
this);
1255 bool removed = (_prepared_index_buffers.erase(ibc) != 0);
1258 if (_support_released_buffer_cache) {
1259 cache_unprepared_buffer(ibc, data_size_bytes, usage_hint,
1260 _index_buffer_cache,
1261 _index_buffer_cache_lru, _index_buffer_cache_size,
1262 released_ibuffer_cache_size,
1263 _released_index_buffers);
1265 _released_index_buffers.insert(ibc);
1281 int num_index_buffers = (int)_prepared_index_buffers.size() + (int)_enqueued_index_buffers.size();
1283 Buffers::iterator ibci;
1284 for (ibci = _prepared_index_buffers.begin();
1285 ibci != _prepared_index_buffers.end();
1288 ibc->_data->clear_prepared(
this);
1291 _released_index_buffers.insert(ibc);
1294 _prepared_index_buffers.clear();
1295 _enqueued_index_buffers.clear();
1298 BufferCache::iterator bci;
1299 for (bci = _index_buffer_cache.begin();
1300 bci != _index_buffer_cache.end();
1303 nassertr(!buffer_list.empty(), num_index_buffers);
1304 BufferList::iterator li;
1305 for (li = buffer_list.begin(); li != buffer_list.end(); ++li) {
1307 _released_index_buffers.insert(vbc);
1310 _index_buffer_cache.clear();
1311 _index_buffer_cache_lru.clear();
1312 _index_buffer_cache_size = 0;
1314 return num_index_buffers;
1325 return _enqueued_index_buffers.size();
1336 return _prepared_index_buffers.size();
1370 get_cached_buffer(data_size_bytes, usage_hint,
1371 _index_buffer_cache, _index_buffer_cache_lru,
1372 _index_buffer_cache_size);
1381 ibc = gsg->prepare_index_buffer(data);
1385 bool prepared = _prepared_index_buffers.insert(ibc).second;
1386 nassertr(prepared, ibc);
1410 if (!_released_textures.empty()) {
1411 Textures::iterator tci;
1412 for (tci = _released_textures.begin();
1413 tci != _released_textures.end();
1416 gsg->release_texture(tc);
1419 _released_textures.clear();
1422 if (!_released_samplers.empty()) {
1423 ReleasedSamplers::iterator sci;
1424 for (sci = _released_samplers.begin();
1425 sci != _released_samplers.end();
1428 gsg->release_sampler(sc);
1431 _released_samplers.clear();
1434 Geoms::iterator gci;
1435 for (gci = _released_geoms.begin();
1436 gci != _released_geoms.end();
1439 gsg->release_geom(gc);
1442 _released_geoms.clear();
1444 Shaders::iterator sci;
1445 for (sci = _released_shaders.begin();
1446 sci != _released_shaders.end();
1449 gsg->release_shader(sc);
1452 _released_shaders.clear();
1454 Buffers::iterator vbci;
1455 for (vbci = _released_vertex_buffers.begin();
1456 vbci != _released_vertex_buffers.end();
1459 gsg->release_vertex_buffer(vbc);
1462 _released_vertex_buffers.clear();
1464 Buffers::iterator ibci;
1465 for (ibci = _released_index_buffers.begin();
1466 ibci != _released_index_buffers.end();
1469 gsg->release_index_buffer(ibc);
1472 _released_index_buffers.clear();
1481 EnqueuedTextures::iterator qti;
1482 for (qti = _enqueued_textures.begin();
1483 qti != _enqueued_textures.end();
1489 gsg->update_texture(tc,
true);
1494 _enqueued_textures.clear();
1496 EnqueuedSamplers::iterator qsmi;
1497 for (qsmi = _enqueued_samplers.begin();
1498 qsmi != _enqueued_samplers.end();
1504 _enqueued_samplers.clear();
1506 EnqueuedGeoms::iterator qgi;
1507 for (qgi = _enqueued_geoms.begin();
1508 qgi != _enqueued_geoms.end();
1510 Geom *geom = (*qgi);
1514 _enqueued_geoms.clear();
1516 EnqueuedShaders::iterator qsi;
1517 for (qsi = _enqueued_shaders.begin();
1518 qsi != _enqueued_shaders.end();
1524 _enqueued_shaders.clear();
1526 EnqueuedVertexBuffers::iterator qvbi;
1527 for (qvbi = _enqueued_vertex_buffers.begin();
1528 qvbi != _enqueued_vertex_buffers.end();
1534 _enqueued_vertex_buffers.clear();
1536 EnqueuedIndexBuffers::iterator qibi;
1537 for (qibi = _enqueued_index_buffers.begin();
1538 qibi != _enqueued_index_buffers.end();
1548 _enqueued_index_buffers.clear();
1562 _texture_residency.
end_frame(current_thread);
1563 _vbuffer_residency.
end_frame(current_thread);
1564 _ibuffer_residency.
end_frame(current_thread);
1573 string PreparedGraphicsObjects::
1577 strm <<
"context" << _name_index;
1592 void PreparedGraphicsObjects::
1593 cache_unprepared_buffer(
BufferContext *buffer,
size_t data_size_bytes,
1594 GeomEnums::UsageHint usage_hint,
1597 size_t &buffer_cache_size,
1598 int released_buffer_cache_size,
1599 PreparedGraphicsObjects::Buffers &released_buffers) {
1601 key._data_size_bytes = data_size_bytes;
1602 key._usage_hint = usage_hint;
1604 buffer_cache[key].push_back(buffer);
1605 buffer_cache_size += data_size_bytes;
1608 BufferCacheLRU::iterator li =
1609 find(buffer_cache_lru.begin(), buffer_cache_lru.end(), key);
1610 if (li != buffer_cache_lru.end()) {
1611 buffer_cache_lru.erase(li);
1613 buffer_cache_lru.insert(buffer_cache_lru.begin(), key);
1617 while ((
int)buffer_cache_size > released_buffer_cache_size) {
1618 nassertv(!buffer_cache_lru.empty());
1619 const BufferCacheKey &release_key = *buffer_cache_lru.rbegin();
1620 BufferList &buffer_list = buffer_cache[release_key];
1621 while (!buffer_list.empty() &&
1622 (int)buffer_cache_size > released_buffer_cache_size) {
1624 buffer_list.pop_back();
1625 released_buffers.insert(released_buffer);
1626 buffer_cache_size -= release_key._data_size_bytes;
1629 if (buffer_list.empty()) {
1630 buffer_cache.erase(release_key);
1631 buffer_cache_lru.pop_back();
1643 get_cached_buffer(
size_t data_size_bytes, GeomEnums::UsageHint usage_hint,
1646 size_t &buffer_cache_size) {
1648 key._data_size_bytes = data_size_bytes;
1649 key._usage_hint = usage_hint;
1651 BufferCache::iterator bci = buffer_cache.find(key);
1652 if (bci == buffer_cache.end()) {
1657 nassertr(!buffer_list.empty(), NULL);
1660 buffer_list.pop_back();
1661 if (buffer_list.empty()) {
1662 buffer_cache.erase(bci);
1663 BufferCacheLRU::iterator li =
1664 find(buffer_cache_lru.begin(), buffer_cache_lru.end(), key);
1665 if (li != buffer_cache_lru.end()) {
1666 buffer_cache_lru.erase(li);
1670 buffer_cache_size -= data_size_bytes;
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.
IndexBufferContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the data on the particular GSG, if it does not already exist.
int release_all_shaders()
Releases all shaders at once.
VertexBufferContext * prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
Creates a context for the data on the particular GSG, if it does not already exist.
bool is_texture_prepared(const Texture *tex) const
Returns true if the texture has been prepared on this GSG, false otherwise.
bool is_index_buffer_queued(const GeomPrimitive *data) const
Returns true if the index buffer has been queued on this GSG, false otherwise.
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...
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(), is no longer needed.
void show_graphics_memory_lru(ostream &out) const
Writes to the indicated ostream a report of how the various textures and vertex buffers are allocated...
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.
void show_residency_trackers(ostream &out) const
Writes to the indicated ostream a report of how the various textures and vertex buffers are allocated...
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.
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...
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(), is no longer needed.
int get_num_queued_textures() const
Returns the number of textures that have been enqueued to be prepared on this GSG.
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the data has already been prepared or enqueued for preparation on the indicated 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.
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.
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.
bool is_geom_prepared(const Geom *geom) const
Returns true if the vertex buffer has been prepared on this GSG, false otherwise. ...
void release_index_buffer(IndexBufferContext *ibc)
Indicates that a data context, created by a previous call to prepare_index_buffer(), is no longer needed.
size_t get_max_size() const
Returns the max size of all objects that are allowed to be active on the LRU.
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. ...
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.
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const
Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG...
bool dequeue_shader(Shader *shader)
Removes a shader from the queued list of shaders to be prepared.
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.
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.
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 ...
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.
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.
UsageHint get_usage_hint() const
Returns the usage hint that describes to the rendering backend how often the vertex data will be modi...
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 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...
UsageHint get_usage_hint() const
Returns the usage hint for this primitive.
int get_num_views() const
Returns the number of "views" in the texture.
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...
void release_sampler(SamplerContext *sc)
Indicates that a sampler context, created by a previous call to prepare_sampler(), is no longer needed.
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...
void set_graphics_memory_limit(size_t limit)
Sets an artificial cap on graphics memory that will be imposed on this GSG.
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.
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
int get_num_prepared_samplers() const
Returns the number of samplers that have already been prepared on this GSG.
int get_data_size_bytes() const
Returns the number of bytes stored in the array.
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.
int get_data_size_bytes() const
Returns the number of bytes stored in the vertices array.