Panda3D
bufferContext.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file bufferContext.h
10  * @author drose
11  * @date 2006-03-16
12  */
13 
14 #ifndef BUFFERCONTEXT_H
15 #define BUFFERCONTEXT_H
16 
17 #include "pandabase.h"
18 
19 #include "savedContext.h"
20 #include "updateSeq.h"
21 #include "linkedListNode.h"
22 #include "bufferContextChain.h"
23 #include "bufferResidencyTracker.h"
24 
27 
28 /**
29  * This is a base class for those kinds of SavedContexts that occupy an
30  * easily-measured (and substantial) number of bytes in the video card's frame
31  * buffer memory or AGP memory. At the present, this includes most of the
32  * SavedContext types: VertexBufferContext and IndexBufferContext, as well as
33  * TextureContext.
34  *
35  * This class provides methods for tracking the video memory utilization, as
36  * well as residency of each object, via PStats.
37  */
38 class EXPCL_PANDA_GOBJ BufferContext : public SavedContext, private LinkedListNode {
39 public:
41  virtual ~BufferContext();
42 
43  INLINE TypedWritableReferenceCount *get_object() const;
44 
45 PUBLISHED:
46  INLINE size_t get_data_size_bytes() const;
47  INLINE UpdateSeq get_modified() const;
48  INLINE bool get_active() const;
49  INLINE bool get_resident() const;
50 
51  MAKE_PROPERTY(object, get_object);
52 
53  MAKE_PROPERTY(data_size_bytes, get_data_size_bytes);
54  MAKE_PROPERTY(modified, get_modified);
55  MAKE_PROPERTY(active, get_active);
56  MAKE_PROPERTY(resident, get_resident);
57 
58 public:
59  INLINE void set_active(bool flag);
60  INLINE void set_resident(bool flag);
61 
62  INLINE BufferContext *get_next() const;
63 
64  INLINE void update_data_size_bytes(size_t new_data_size_bytes);
65  INLINE void update_modified(UpdateSeq new_modified);
66 
67 private:
68  void set_owning_chain(BufferContextChain *chain);
69 
70 protected:
71  // This cannot be a PT(), because the object and the GSG both own their
72  // BufferContexts! That would create a circular reference count.
74 
75 private:
76  BufferResidencyTracker *_residency;
77  int _residency_state;
78 
79  size_t _data_size_bytes;
80  UpdateSeq _modified;
81  BufferContextChain *_owning_chain;
82 
83 public:
84  static TypeHandle get_class_type() {
85  return _type_handle;
86  }
87  static void init_type() {
88  SavedContext::init_type();
89  register_type(_type_handle, "BufferContext",
90  SavedContext::get_class_type());
91  }
92  virtual TypeHandle get_type() const {
93  return get_class_type();
94  }
95  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
96 
97 private:
98  static TypeHandle _type_handle;
99 
100  friend class PreparedGraphicsObjects;
101  friend class BufferResidencyTracker;
102  friend class BufferContextChain;
103 };
104 
105 #include "bufferContext.I"
106 
107 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:38
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
This just stores the pointers to implement a doubly-linked list of some kind of object.
This class maintains a linked list of BufferContexts that might be allocated on the graphics card in ...
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37
This is the base class for all GSG-specific context objects, such as TextureContext and GeomContext.
Definition: savedContext.h:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.