mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
correctly release gsg on window close
This commit is contained in:
parent
384c789535
commit
d1a06d8f02
@ -370,6 +370,18 @@ get_render_buffer(int buffer_type, const FrameBufferProperties &prop) {
|
||||
return RenderBuffer(this, buffer_type & prop.get_buffer_mask() & _stereo_buffer_mask);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::get_prepared_objects
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns the set of texture and geom objects that have
|
||||
// been prepared with this GSG (and possibly other GSG's
|
||||
// that share objects).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PreparedGraphicsObjects *GraphicsStateGuardian::
|
||||
get_prepared_objects() {
|
||||
return _prepared_objects;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::set_scene
|
||||
// Access: Public
|
||||
@ -404,18 +416,6 @@ get_scene() const {
|
||||
return _scene_setup;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::get_prepared_objects
|
||||
// Access: Public, Virtual
|
||||
// Description: Returns the set of texture and geom objects that have
|
||||
// been prepared with this GSG (and possibly other GSG's
|
||||
// that share objects).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PreparedGraphicsObjects *GraphicsStateGuardian::
|
||||
get_prepared_objects() {
|
||||
return _prepared_objects;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GraphicsStateGuardian::prepare_texture
|
||||
// Access: Public, Virtual
|
||||
|
@ -152,12 +152,12 @@ PUBLISHED:
|
||||
INLINE void make_global_gsg();
|
||||
INLINE static GraphicsStateGuardian *get_global_gsg();
|
||||
|
||||
virtual PreparedGraphicsObjects *get_prepared_objects();
|
||||
|
||||
public:
|
||||
bool set_scene(SceneSetup *scene_setup);
|
||||
virtual SceneSetup *get_scene() const;
|
||||
|
||||
virtual PreparedGraphicsObjects *get_prepared_objects();
|
||||
|
||||
virtual TextureContext *prepare_texture(Texture *tex);
|
||||
virtual void release_texture(TextureContext *tc);
|
||||
virtual bool extract_texture_data(Texture *tex);
|
||||
|
@ -224,6 +224,11 @@ munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data,
|
||||
int StandardMunger::
|
||||
compare_to_impl(const GeomMunger *other) const {
|
||||
const StandardMunger *om = DCAST(StandardMunger, other);
|
||||
|
||||
if (_gsg != om->_gsg) {
|
||||
return _gsg < om->_gsg ? -1 : 1;
|
||||
}
|
||||
|
||||
if (_render_mode != om->_render_mode) {
|
||||
return _render_mode < om->_render_mode ? -1 : 1;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "colorScaleAttrib.h"
|
||||
#include "renderModeAttrib.h"
|
||||
#include "pointerTo.h"
|
||||
#include "weakPointerTo.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : StandardMunger
|
||||
@ -55,7 +56,7 @@ private:
|
||||
int _num_components;
|
||||
NumericType _numeric_type;
|
||||
Contents _contents;
|
||||
PT(GraphicsStateGuardian) _gsg;
|
||||
WPT(GraphicsStateGuardian) _gsg;
|
||||
CPT(RenderModeAttrib) _render_mode;
|
||||
|
||||
bool _munge_color;
|
||||
|
@ -2938,10 +2938,7 @@ close_gsg() {
|
||||
// Unlike in OpenGL, in DX8 it is safe to try to explicitly release
|
||||
// any textures here. And it may even be a good idea.
|
||||
if (_prepared_objects->get_ref_count() == 1) {
|
||||
release_all_textures();
|
||||
release_all_geoms();
|
||||
release_all_vertex_buffers();
|
||||
release_all_index_buffers();
|
||||
release_all();
|
||||
|
||||
// Now we need to actually delete all of the objects we just
|
||||
// released.
|
||||
|
@ -4048,10 +4048,7 @@ close_gsg() {
|
||||
// Unlike in OpenGL, in DX9 it is safe to try to explicitly release
|
||||
// any textures here. And it may even be a good idea.
|
||||
if (_prepared_objects->get_ref_count() == 1) {
|
||||
release_all_textures();
|
||||
release_all_geoms();
|
||||
release_all_vertex_buffers();
|
||||
release_all_index_buffers();
|
||||
release_all();
|
||||
|
||||
// Now we need to actually delete all of the objects we just
|
||||
// released.
|
||||
|
@ -47,9 +47,11 @@ public:
|
||||
BufferContext(BufferResidencyTracker *residency);
|
||||
virtual ~BufferContext();
|
||||
|
||||
PUBLISHED:
|
||||
INLINE size_t get_data_size_bytes() const;
|
||||
INLINE UpdateSeq get_modified() const;
|
||||
|
||||
public:
|
||||
INLINE void set_active(bool flag);
|
||||
INLINE void set_resident(bool flag);
|
||||
|
||||
|
@ -896,6 +896,23 @@ prepare(PreparedGraphicsObjects *prepared_objects) {
|
||||
prepared_objects->enqueue_geom(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Geom::is_prepared
|
||||
// Access: Published
|
||||
// Description: Returns true if the geom has already been prepared
|
||||
// or enqueued for preparation on the indicated GSG,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Geom::
|
||||
is_prepared(PreparedGraphicsObjects *prepared_objects) const {
|
||||
Contexts::const_iterator ci;
|
||||
ci = _contexts.find(prepared_objects);
|
||||
if (ci != _contexts.end()) {
|
||||
return true;
|
||||
}
|
||||
return prepared_objects->is_geom_queued(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Geom::release
|
||||
// Access: Published
|
||||
|
@ -126,13 +126,14 @@ PUBLISHED:
|
||||
void clear_cache_stage(Thread *current_thread);
|
||||
|
||||
void prepare(PreparedGraphicsObjects *prepared_objects);
|
||||
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const;
|
||||
bool release(PreparedGraphicsObjects *prepared_objects);
|
||||
int release_all();
|
||||
|
||||
public:
|
||||
GeomContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
|
||||
GraphicsStateGuardianBase *gsg);
|
||||
|
||||
public:
|
||||
void draw(GraphicsStateGuardianBase *gsg,
|
||||
const GeomMunger *munger,
|
||||
const GeomVertexData *vertex_data,
|
||||
|
@ -27,3 +27,13 @@ GeomContext(Geom *geom) :
|
||||
_geom(geom)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomContext::get_geom
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE Geom *GeomContext::
|
||||
get_geom() const {
|
||||
return _geom;
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ class EXPCL_PANDA GeomContext : public SavedContext {
|
||||
public:
|
||||
INLINE GeomContext(Geom *geom);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE Geom *get_geom() const;
|
||||
|
||||
public:
|
||||
// This cannot be a PT(Geom), because the geom and the GSG
|
||||
// both own their GeomContexts! That would create a circular
|
||||
// reference count.
|
||||
|
@ -1076,6 +1076,23 @@ prepare(PreparedGraphicsObjects *prepared_objects) {
|
||||
prepared_objects->enqueue_index_buffer(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomPrimitive::is_prepared
|
||||
// Access: Published
|
||||
// Description: Returns true if the data has already been prepared
|
||||
// or enqueued for preparation on the indicated GSG,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool GeomPrimitive::
|
||||
is_prepared(PreparedGraphicsObjects *prepared_objects) const {
|
||||
Contexts::const_iterator ci;
|
||||
ci = _contexts.find(prepared_objects);
|
||||
if (ci != _contexts.end()) {
|
||||
return true;
|
||||
}
|
||||
return prepared_objects->is_index_buffer_queued(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomPrimitive::prepare_now
|
||||
// Access: Public
|
||||
|
@ -176,8 +176,8 @@ public:
|
||||
virtual int get_num_unused_vertices_per_primitive() const;
|
||||
|
||||
void prepare(PreparedGraphicsObjects *prepared_objects);
|
||||
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const;
|
||||
|
||||
public:
|
||||
IndexBufferContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
|
||||
GraphicsStateGuardianBase *gsg);
|
||||
bool release(PreparedGraphicsObjects *prepared_objects);
|
||||
|
@ -174,6 +174,23 @@ prepare(PreparedGraphicsObjects *prepared_objects) {
|
||||
prepared_objects->enqueue_vertex_buffer(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexArrayData::is_prepared
|
||||
// Access: Published
|
||||
// Description: Returns true if the data has already been prepared
|
||||
// or enqueued for preparation on the indicated GSG,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool GeomVertexArrayData::
|
||||
is_prepared(PreparedGraphicsObjects *prepared_objects) const {
|
||||
Contexts::const_iterator ci;
|
||||
ci = _contexts.find(prepared_objects);
|
||||
if (ci != _contexts.end()) {
|
||||
return true;
|
||||
}
|
||||
return prepared_objects->is_vertex_buffer_queued(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GeomVertexArrayData::prepare_now
|
||||
// Access: Public
|
||||
|
@ -95,8 +95,8 @@ PUBLISHED:
|
||||
INLINE PTA_uchar modify_data();
|
||||
INLINE void set_data(CPTA_uchar data);
|
||||
|
||||
public:
|
||||
void prepare(PreparedGraphicsObjects *prepared_objects);
|
||||
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const;
|
||||
|
||||
VertexBufferContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
|
||||
GraphicsStateGuardianBase *gsg);
|
||||
|
@ -40,12 +40,14 @@ class EXPCL_PANDA IndexBufferContext : public BufferContext {
|
||||
public:
|
||||
INLINE IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE GeomPrimitive *get_data() const;
|
||||
|
||||
INLINE bool changed_size(const GeomPrimitivePipelineReader *reader) const;
|
||||
INLINE bool changed_usage_hint(const GeomPrimitivePipelineReader *reader) const;
|
||||
INLINE bool was_modified(const GeomPrimitivePipelineReader *reader) const;
|
||||
|
||||
public:
|
||||
INLINE void mark_loaded(const GeomPrimitivePipelineReader *reader);
|
||||
|
||||
private:
|
||||
|
@ -42,3 +42,33 @@ release_all() {
|
||||
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());
|
||||
}
|
||||
|
@ -137,6 +137,20 @@ enqueue_texture(Texture *tex) {
|
||||
_enqueued_textures.insert(tex);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::is_texture_queued
|
||||
// Access: Public
|
||||
// Description: Returns true if the texture has been queued on this
|
||||
// GSG, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PreparedGraphicsObjects::
|
||||
is_texture_queued(const Texture *tex) const {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
EnqueuedTextures::const_iterator qi = _enqueued_textures.find((Texture *)tex);
|
||||
return (qi != _enqueued_textures.end());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::dequeue_texture
|
||||
// Access: Public
|
||||
@ -205,7 +219,7 @@ int PreparedGraphicsObjects::
|
||||
release_all_textures() {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
int num_textures = (int)_prepared_textures.size();
|
||||
int num_textures = (int)_prepared_textures.size() + (int)_enqueued_textures.size();
|
||||
|
||||
Textures::iterator tci;
|
||||
for (tci = _prepared_textures.begin();
|
||||
@ -219,10 +233,33 @@ release_all_textures() {
|
||||
}
|
||||
|
||||
_prepared_textures.clear();
|
||||
_enqueued_textures.clear();
|
||||
|
||||
return num_textures;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_queued_textures
|
||||
// Access: Public
|
||||
// Description: Returns the number of textures that have been
|
||||
// enqueued to be prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_queued_textures() const {
|
||||
return _enqueued_textures.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_prepared_textures
|
||||
// Access: Public
|
||||
// Description: Returns the number of textures that have already been
|
||||
// prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_prepared_textures() const {
|
||||
return _prepared_textures.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::prepare_texture_now
|
||||
// Access: Public
|
||||
@ -277,6 +314,20 @@ enqueue_geom(Geom *geom) {
|
||||
_enqueued_geoms.insert(geom);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::is_geom_queued
|
||||
// Access: Public
|
||||
// Description: Returns true if the geom has been queued on this
|
||||
// GSG, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PreparedGraphicsObjects::
|
||||
is_geom_queued(const Geom *geom) const {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
EnqueuedGeoms::const_iterator qi = _enqueued_geoms.find((Geom *)geom);
|
||||
return (qi != _enqueued_geoms.end());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::dequeue_geom
|
||||
// Access: Public
|
||||
@ -345,7 +396,7 @@ int PreparedGraphicsObjects::
|
||||
release_all_geoms() {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
int num_geoms = (int)_prepared_geoms.size();
|
||||
int num_geoms = (int)_prepared_geoms.size() + (int)_enqueued_geoms.size();
|
||||
|
||||
Geoms::iterator gci;
|
||||
for (gci = _prepared_geoms.begin();
|
||||
@ -359,10 +410,33 @@ release_all_geoms() {
|
||||
}
|
||||
|
||||
_prepared_geoms.clear();
|
||||
_enqueued_geoms.clear();
|
||||
|
||||
return num_geoms;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_queued_geoms
|
||||
// Access: Public
|
||||
// Description: Returns the number of geoms that have been
|
||||
// enqueued to be prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_queued_geoms() const {
|
||||
return _enqueued_geoms.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_prepared_geoms
|
||||
// Access: Public
|
||||
// Description: Returns the number of geoms that have already been
|
||||
// prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_prepared_geoms() const {
|
||||
return _prepared_geoms.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::prepare_geom_now
|
||||
// Access: Public
|
||||
@ -417,6 +491,20 @@ enqueue_shader(ShaderExpansion *se) {
|
||||
_enqueued_shaders.insert(se);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::is_shader_queued
|
||||
// Access: Public
|
||||
// Description: Returns true if the shader has been queued on this
|
||||
// GSG, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PreparedGraphicsObjects::
|
||||
is_shader_queued(const ShaderExpansion *shader) const {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
EnqueuedShaders::const_iterator qi = _enqueued_shaders.find((ShaderExpansion *)shader);
|
||||
return (qi != _enqueued_shaders.end());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::dequeue_shader
|
||||
// Access: Public
|
||||
@ -485,7 +573,7 @@ int PreparedGraphicsObjects::
|
||||
release_all_shaders() {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
int num_shaders = (int)_prepared_shaders.size();
|
||||
int num_shaders = (int)_prepared_shaders.size() + (int)_enqueued_shaders.size();
|
||||
|
||||
Shaders::iterator sci;
|
||||
for (sci = _prepared_shaders.begin();
|
||||
@ -499,10 +587,33 @@ release_all_shaders() {
|
||||
}
|
||||
|
||||
_prepared_shaders.clear();
|
||||
_enqueued_shaders.clear();
|
||||
|
||||
return num_shaders;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_queued_shaders
|
||||
// Access: Public
|
||||
// Description: Returns the number of shaders that have been
|
||||
// enqueued to be prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_queued_shaders() const {
|
||||
return _enqueued_shaders.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_prepared_shaders
|
||||
// Access: Public
|
||||
// Description: Returns the number of shaders that have already been
|
||||
// prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_prepared_shaders() const {
|
||||
return _prepared_shaders.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::prepare_shader_now
|
||||
// Access: Public
|
||||
@ -557,6 +668,20 @@ enqueue_vertex_buffer(GeomVertexArrayData *data) {
|
||||
_enqueued_vertex_buffers.insert(data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::is_vertex_buffer_queued
|
||||
// Access: Public
|
||||
// Description: Returns true if the vertex buffer has been queued on
|
||||
// this GSG, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PreparedGraphicsObjects::
|
||||
is_vertex_buffer_queued(const GeomVertexArrayData *data) const {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
EnqueuedVertexBuffers::const_iterator qi = _enqueued_vertex_buffers.find((GeomVertexArrayData *)data);
|
||||
return (qi != _enqueued_vertex_buffers.end());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::dequeue_vertex_buffer
|
||||
// Access: Public
|
||||
@ -625,7 +750,7 @@ int PreparedGraphicsObjects::
|
||||
release_all_vertex_buffers() {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
int num_vertex_buffers = (int)_prepared_vertex_buffers.size();
|
||||
int num_vertex_buffers = (int)_prepared_vertex_buffers.size() + (int)_enqueued_vertex_buffers.size();
|
||||
|
||||
VertexBuffers::iterator vbci;
|
||||
for (vbci = _prepared_vertex_buffers.begin();
|
||||
@ -639,10 +764,33 @@ release_all_vertex_buffers() {
|
||||
}
|
||||
|
||||
_prepared_vertex_buffers.clear();
|
||||
_enqueued_vertex_buffers.clear();
|
||||
|
||||
return num_vertex_buffers;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_queued_vertex_buffers
|
||||
// Access: Public
|
||||
// Description: Returns the number of vertex buffers that have been
|
||||
// enqueued to be prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_queued_vertex_buffers() const {
|
||||
return _enqueued_vertex_buffers.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_prepared_vertex_buffers
|
||||
// Access: Public
|
||||
// Description: Returns the number of vertex buffers that have
|
||||
// already been prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_prepared_vertex_buffers() const {
|
||||
return _prepared_vertex_buffers.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::prepare_vertex_buffer_now
|
||||
// Access: Public
|
||||
@ -697,6 +845,20 @@ enqueue_index_buffer(GeomPrimitive *data) {
|
||||
_enqueued_index_buffers.insert(data);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::is_index_buffer_queued
|
||||
// Access: Public
|
||||
// Description: Returns true if the index buffer has been queued on
|
||||
// this GSG, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PreparedGraphicsObjects::
|
||||
is_index_buffer_queued(const GeomPrimitive *data) const {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
EnqueuedIndexBuffers::const_iterator qi = _enqueued_index_buffers.find((GeomPrimitive *)data);
|
||||
return (qi != _enqueued_index_buffers.end());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::dequeue_index_buffer
|
||||
// Access: Public
|
||||
@ -765,7 +927,7 @@ int PreparedGraphicsObjects::
|
||||
release_all_index_buffers() {
|
||||
ReMutexHolder holder(_lock);
|
||||
|
||||
int num_index_buffers = (int)_prepared_index_buffers.size();
|
||||
int num_index_buffers = (int)_prepared_index_buffers.size() + (int)_enqueued_index_buffers.size();
|
||||
|
||||
IndexBuffers::iterator ibci;
|
||||
for (ibci = _prepared_index_buffers.begin();
|
||||
@ -779,10 +941,33 @@ release_all_index_buffers() {
|
||||
}
|
||||
|
||||
_prepared_index_buffers.clear();
|
||||
_enqueued_index_buffers.clear();
|
||||
|
||||
return num_index_buffers;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_queued_index_buffers
|
||||
// Access: Public
|
||||
// Description: Returns the number of index buffers that have been
|
||||
// enqueued to be prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_queued_index_buffers() const {
|
||||
return _enqueued_index_buffers.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::get_num_prepared_index_buffers
|
||||
// Access: Public
|
||||
// Description: Returns the number of index buffers that have
|
||||
// already been prepared on this GSG.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PreparedGraphicsObjects::
|
||||
get_num_prepared_index_buffers() const {
|
||||
return _prepared_index_buffers.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PreparedGraphicsObjects::prepare_index_buffer_now
|
||||
// Access: Public
|
||||
|
@ -63,49 +63,68 @@ public:
|
||||
PreparedGraphicsObjects();
|
||||
~PreparedGraphicsObjects();
|
||||
|
||||
PUBLISHED:
|
||||
INLINE const string &get_name() const;
|
||||
|
||||
INLINE void release_all();
|
||||
INLINE int get_num_queued() const;
|
||||
INLINE int get_num_prepared() const;
|
||||
|
||||
void enqueue_texture(Texture *tex);
|
||||
bool is_texture_queued(const Texture *tex) const;
|
||||
bool dequeue_texture(Texture *tex);
|
||||
void release_texture(TextureContext *tc);
|
||||
int release_all_textures();
|
||||
int get_num_queued_textures() const;
|
||||
int get_num_prepared_textures() const;
|
||||
|
||||
TextureContext *prepare_texture_now(Texture *tex, GraphicsStateGuardianBase *gsg);
|
||||
|
||||
void enqueue_geom(Geom *geom);
|
||||
bool is_geom_queued(const Geom *geom) const;
|
||||
bool dequeue_geom(Geom *geom);
|
||||
void release_geom(GeomContext *gc);
|
||||
int release_all_geoms();
|
||||
int get_num_queued_geoms() const;
|
||||
int get_num_prepared_geoms() const;
|
||||
|
||||
GeomContext *prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg);
|
||||
|
||||
void enqueue_shader(ShaderExpansion *shader);
|
||||
bool is_shader_queued(const ShaderExpansion *shader) const;
|
||||
bool dequeue_shader(ShaderExpansion *shader);
|
||||
void release_shader(ShaderContext *sc);
|
||||
int release_all_shaders();
|
||||
int get_num_queued_shaders() const;
|
||||
int get_num_prepared_shaders() const;
|
||||
|
||||
ShaderContext *prepare_shader_now(ShaderExpansion *shader, GraphicsStateGuardianBase *gsg);
|
||||
|
||||
void enqueue_vertex_buffer(GeomVertexArrayData *data);
|
||||
bool is_vertex_buffer_queued(const GeomVertexArrayData *data) const;
|
||||
bool dequeue_vertex_buffer(GeomVertexArrayData *data);
|
||||
void release_vertex_buffer(VertexBufferContext *vbc);
|
||||
int release_all_vertex_buffers();
|
||||
int get_num_queued_vertex_buffers() const;
|
||||
int get_num_prepared_vertex_buffers() const;
|
||||
|
||||
VertexBufferContext *
|
||||
prepare_vertex_buffer_now(GeomVertexArrayData *data,
|
||||
GraphicsStateGuardianBase *gsg);
|
||||
|
||||
void enqueue_index_buffer(GeomPrimitive *data);
|
||||
bool is_index_buffer_queued(const GeomPrimitive *data) const;
|
||||
bool dequeue_index_buffer(GeomPrimitive *data);
|
||||
void release_index_buffer(IndexBufferContext *ibc);
|
||||
int release_all_index_buffers();
|
||||
int get_num_queued_index_buffers() const;
|
||||
int get_num_prepared_index_buffers() const;
|
||||
|
||||
IndexBufferContext *
|
||||
prepare_index_buffer_now(GeomPrimitive *data,
|
||||
GraphicsStateGuardianBase *gsg);
|
||||
|
||||
public:
|
||||
void begin_frame(GraphicsStateGuardianBase *gsg,
|
||||
Thread *current_thread);
|
||||
void end_frame(Thread *current_thread);
|
||||
|
@ -36,10 +36,11 @@ class EXPCL_PANDA SavedContext : public TypedObject {
|
||||
public:
|
||||
INLINE SavedContext();
|
||||
|
||||
public:
|
||||
PUBLISHED:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
public:
|
||||
static void init_type() {
|
||||
TypedObject::init_type();
|
||||
register_type(_type_handle, "SavedContext",
|
||||
|
@ -27,4 +27,12 @@ ShaderContext(ShaderExpansion *se) :
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderContext::get_expansion
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ShaderExpansion *ShaderContext::
|
||||
get_expansion() const {
|
||||
return _expansion;
|
||||
}
|
||||
|
@ -39,7 +39,11 @@
|
||||
class EXPCL_PANDA ShaderContext: public SavedContext {
|
||||
public:
|
||||
INLINE ShaderContext(ShaderExpansion *se);
|
||||
|
||||
|
||||
PUBLISHED:
|
||||
INLINE ShaderExpansion *get_expansion() const;
|
||||
|
||||
public:
|
||||
ShaderExpansion *_expansion;
|
||||
|
||||
public:
|
||||
|
@ -1308,6 +1308,23 @@ prepare(PreparedGraphicsObjects *prepared_objects) {
|
||||
prepared_objects->enqueue_shader(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderExpansion::is_prepared
|
||||
// Access: Published
|
||||
// Description: Returns true if the shader has already been prepared
|
||||
// or enqueued for preparation on the indicated GSG,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool ShaderExpansion::
|
||||
is_prepared(PreparedGraphicsObjects *prepared_objects) const {
|
||||
Contexts::const_iterator ci;
|
||||
ci = _contexts.find(prepared_objects);
|
||||
if (ci != _contexts.end()) {
|
||||
return true;
|
||||
}
|
||||
return prepared_objects->is_shader_queued(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderExpansion::release
|
||||
// Access: Published
|
||||
@ -1335,7 +1352,7 @@ release(PreparedGraphicsObjects *prepared_objects) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderExpansion::prepare_now
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Creates a context for the texture on the particular
|
||||
// GSG, if it does not already exist. Returns the new
|
||||
// (or old) ShaderContext. This assumes that the
|
||||
|
@ -54,8 +54,12 @@ PUBLISHED:
|
||||
INLINE bool get_error_flag() const;
|
||||
|
||||
void prepare(PreparedGraphicsObjects *prepared_objects);
|
||||
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const;
|
||||
bool release(PreparedGraphicsObjects *prepared_objects);
|
||||
int release_all();
|
||||
|
||||
ShaderContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
|
||||
GraphicsStateGuardianBase *gsg);
|
||||
|
||||
public:
|
||||
|
||||
@ -268,9 +272,6 @@ public:
|
||||
typedef pmap <PreparedGraphicsObjects *, ShaderContext *> Contexts;
|
||||
Contexts _contexts;
|
||||
|
||||
public:
|
||||
ShaderContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
|
||||
GraphicsStateGuardianBase *gsg);
|
||||
|
||||
private:
|
||||
ShaderExpansion(const string &name, const string &text,
|
||||
|
@ -1244,6 +1244,23 @@ prepare(PreparedGraphicsObjects *prepared_objects) {
|
||||
prepared_objects->enqueue_texture(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::is_prepared
|
||||
// Access: Published
|
||||
// Description: Returns true if the texture has already been prepared
|
||||
// or enqueued for preparation on the indicated GSG,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool Texture::
|
||||
is_prepared(PreparedGraphicsObjects *prepared_objects) const {
|
||||
Contexts::const_iterator ci;
|
||||
ci = _contexts.find(prepared_objects);
|
||||
if (ci != _contexts.end()) {
|
||||
return true;
|
||||
}
|
||||
return prepared_objects->is_texture_queued(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::release
|
||||
// Access: Published
|
||||
@ -1581,7 +1598,7 @@ is_mipmap(FilterType filter_type) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::prepare_now
|
||||
// Access: Public
|
||||
// Access: Published
|
||||
// Description: Creates a context for the texture on the particular
|
||||
// GSG, if it does not already exist. Returns the new
|
||||
// (or old) TextureContext. This assumes that the
|
||||
|
@ -311,6 +311,7 @@ PUBLISHED:
|
||||
INLINE UpdateSeq get_image_modified() const;
|
||||
|
||||
void prepare(PreparedGraphicsObjects *prepared_objects);
|
||||
bool is_prepared(PreparedGraphicsObjects *prepared_objects) const;
|
||||
bool release(PreparedGraphicsObjects *prepared_objects);
|
||||
int release_all();
|
||||
|
||||
@ -352,10 +353,10 @@ PUBLISHED:
|
||||
INLINE bool get_match_framebuffer_format() const;
|
||||
INLINE void set_match_framebuffer_format(bool flag);
|
||||
|
||||
public:
|
||||
|
||||
TextureContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
|
||||
GraphicsStateGuardianBase *gsg);
|
||||
|
||||
public:
|
||||
void texture_uploaded();
|
||||
|
||||
virtual bool has_cull_callback() const;
|
||||
|
@ -42,11 +42,14 @@ class EXPCL_PANDA TextureContext : public BufferContext {
|
||||
public:
|
||||
INLINE TextureContext(PreparedGraphicsObjects *pgo, Texture *tex);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE Texture *get_texture() const;
|
||||
|
||||
INLINE bool was_modified() const;
|
||||
INLINE bool was_properties_modified() const;
|
||||
INLINE bool was_image_modified() const;
|
||||
|
||||
public:
|
||||
INLINE void mark_loaded();
|
||||
|
||||
private:
|
||||
|
@ -41,12 +41,14 @@ public:
|
||||
INLINE VertexBufferContext(PreparedGraphicsObjects *pgo,
|
||||
GeomVertexArrayData *data);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE GeomVertexArrayData *get_data() const;
|
||||
|
||||
INLINE bool changed_size(const GeomVertexArrayDataPipelineReader *reader) const;
|
||||
INLINE bool changed_usage_hint(const GeomVertexArrayDataPipelineReader *reader) const;
|
||||
INLINE bool was_modified(const GeomVertexArrayDataPipelineReader *reader) const;
|
||||
|
||||
public:
|
||||
INLINE void mark_loaded(const GeomVertexArrayDataPipelineReader *reader);
|
||||
|
||||
private:
|
||||
|
@ -120,7 +120,12 @@ public:
|
||||
// mainly to make it easy to call these from code in some directory
|
||||
// that display depends on.
|
||||
virtual SceneSetup *get_scene() const=0;
|
||||
|
||||
#ifndef CPPPARSER
|
||||
// We hide this from interrogate, so that it will be properly
|
||||
// exported from the GraphicsStateGuardian class, later.
|
||||
virtual PreparedGraphicsObjects *get_prepared_objects()=0;
|
||||
#endif
|
||||
|
||||
virtual TextureContext *prepare_texture(Texture *tex)=0;
|
||||
virtual void release_texture(TextureContext *tc)=0;
|
||||
|
@ -39,7 +39,7 @@ Camera(const string &name) :
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Camera::Copy Constructor
|
||||
// Access: Protected
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
Camera::
|
||||
|
@ -41,9 +41,8 @@ class DisplayRegion;
|
||||
class EXPCL_PANDA Camera : public LensNode {
|
||||
PUBLISHED:
|
||||
Camera(const string &name);
|
||||
|
||||
protected:
|
||||
Camera(const Camera ©);
|
||||
|
||||
public:
|
||||
virtual ~Camera();
|
||||
|
||||
|
@ -77,7 +77,7 @@ event_W(CPT_Event, void *) {
|
||||
WindowFramework *old_window = framework.get_window(0);
|
||||
GraphicsWindow *win = old_window->get_graphics_window();
|
||||
pipe = win->get_pipe();
|
||||
gsg = win->get_gsg();
|
||||
// gsg = win->get_gsg();
|
||||
}
|
||||
|
||||
WindowFramework *window = framework.open_window(pipe, gsg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user