15 #ifndef PREPAREDGRAPHICSOBJECTS_H 16 #define PREPAREDGRAPHICSOBJECTS_H 18 #include "pandabase.h" 19 #include "referenceCount.h" 21 #include "samplerState.h" 23 #include "geomVertexArrayData.h" 24 #include "geomPrimitive.h" 26 #include "pointerTo.h" 27 #include "pStatCollector.h" 30 #include "bufferResidencyTracker.h" 31 #include "adaptiveLru.h" 66 INLINE
const string &get_name()
const;
68 void set_graphics_memory_limit(
size_t limit);
69 INLINE
size_t get_graphics_memory_limit()
const;
70 void show_graphics_memory_lru(ostream &out)
const;
71 void show_residency_trackers(ostream &out)
const;
73 INLINE
void release_all();
74 INLINE
int get_num_queued()
const;
75 INLINE
int get_num_prepared()
const;
77 void enqueue_texture(
Texture *tex);
78 bool is_texture_queued(
const Texture *tex)
const;
79 bool dequeue_texture(
Texture *tex);
80 bool is_texture_prepared(
const Texture *tex)
const;
82 void release_texture(
Texture *tex);
83 int release_all_textures();
84 int get_num_queued_textures()
const;
85 int get_num_prepared_textures()
const;
91 bool is_sampler_queued(
const SamplerState &sampler)
const;
93 bool is_sampler_prepared(
const SamplerState &sampler)
const;
96 int release_all_samplers();
97 int get_num_queued_samplers()
const;
98 int get_num_prepared_samplers()
const;
103 void enqueue_geom(
Geom *geom);
104 bool is_geom_queued(
const Geom *geom)
const;
105 bool dequeue_geom(
Geom *geom);
106 bool is_geom_prepared(
const Geom *geom)
const;
108 int release_all_geoms();
109 int get_num_queued_geoms()
const;
110 int get_num_prepared_geoms()
const;
114 void enqueue_shader(
Shader *shader);
115 bool is_shader_queued(
const Shader *shader)
const;
116 bool dequeue_shader(
Shader *shader);
117 bool is_shader_prepared(
const Shader *shader)
const;
119 int release_all_shaders();
120 int get_num_queued_shaders()
const;
121 int get_num_prepared_shaders()
const;
130 int release_all_vertex_buffers();
131 int get_num_queued_vertex_buffers()
const;
132 int get_num_prepared_vertex_buffers()
const;
139 bool is_index_buffer_queued(
const GeomPrimitive *data)
const;
141 bool is_index_buffer_prepared(
const GeomPrimitive *data)
const;
143 int release_all_index_buffers();
144 int get_num_queued_index_buffers()
const;
145 int get_num_prepared_index_buffers()
const;
154 void end_frame(
Thread *current_thread);
157 static string init_name();
160 typedef phash_set<TextureContext *, pointer_hash> Textures;
161 typedef phash_set< PT(Texture) > EnqueuedTextures;
162 typedef phash_set<GeomContext *, pointer_hash> Geoms;
163 typedef phash_set< PT(Geom) > EnqueuedGeoms;
164 typedef phash_set<ShaderContext *, pointer_hash> Shaders;
165 typedef phash_set< PT(Shader) > EnqueuedShaders;
166 typedef phash_set<BufferContext *, pointer_hash> Buffers;
167 typedef phash_set< PT(GeomVertexArrayData) > EnqueuedVertexBuffers;
168 typedef phash_set< PT(GeomPrimitive) > EnqueuedIndexBuffers;
176 class BufferCacheKey {
178 INLINE
bool operator < (
const BufferCacheKey &other)
const;
179 INLINE
bool operator == (
const BufferCacheKey &other)
const;
180 INLINE
bool operator != (
const BufferCacheKey &other)
const;
181 size_t _data_size_bytes;
182 GeomEnums::UsageHint _usage_hint;
188 void cache_unprepared_buffer(
BufferContext *buffer,
size_t data_size_bytes,
189 GeomEnums::UsageHint usage_hint,
190 BufferCache &buffer_cache,
191 BufferCacheLRU &buffer_cache_lru,
192 size_t &buffer_cache_size,
193 int released_buffer_cache_size,
194 Buffers &released_buffers);
196 GeomEnums::UsageHint usage_hint,
197 BufferCache &buffer_cache,
198 BufferCacheLRU &buffer_cache_lru,
199 size_t &buffer_cache_size);
203 Textures _prepared_textures, _released_textures;
204 EnqueuedTextures _enqueued_textures;
205 PreparedSamplers _prepared_samplers;
206 ReleasedSamplers _released_samplers;
207 EnqueuedSamplers _enqueued_samplers;
208 Geoms _prepared_geoms, _released_geoms;
209 EnqueuedGeoms _enqueued_geoms;
210 Shaders _prepared_shaders, _released_shaders;
211 EnqueuedShaders _enqueued_shaders;
212 Buffers _prepared_vertex_buffers, _released_vertex_buffers;
213 EnqueuedVertexBuffers _enqueued_vertex_buffers;
214 Buffers _prepared_index_buffers, _released_index_buffers;
215 EnqueuedIndexBuffers _enqueued_index_buffers;
217 BufferCache _vertex_buffer_cache;
218 BufferCacheLRU _vertex_buffer_cache_lru;
219 size_t _vertex_buffer_cache_size;
221 BufferCache _index_buffer_cache;
222 BufferCacheLRU _index_buffer_cache_lru;
223 size_t _index_buffer_cache_size;
236 bool _support_released_buffer_cache;
239 static int _name_index;
244 #include "preparedGraphicsObjects.I" An implementation of a very simple LRU algorithm.
This is a special class object that holds all the information returned by a particular GSG to indicat...
This is a special class object that holds all the information returned by a particular GSG to indicat...
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-...
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
This is a special class object that holds all the information returned by a particular GSG to indicat...
This class is used to keep track of the current state of all the BufferContexts for a particular grap...
A table of objects that are saved within the graphics context for reference by handle later...
The ShaderContext is meant to contain the compiled version of a shader string.
This is our own Panda specialization on the default STL vector.
A container for geometry primitives.
A basic LRU-type algorithm, except that it is adaptive and attempts to avoid evicting pages that have...
Represents a set of settings that indicate how a texture is sampled.
This is a special class object that holds a handle to the sampler state object given by the graphics ...
A base class for all things that want to be reference-counted.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A thread; that is, a lightweight process.
This is a special class object that holds all the information returned by a particular GSG to indicat...
Encapsulates all the communication with a particular instance of a given rendering backend...
This is the data for one array of a GeomVertexData structure.