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 
26 
27 /**
28  * This is a base class for those kinds of SavedContexts that occupy an
29  * easily-measured (and substantial) number of bytes in the video card's frame
30  * buffer memory or AGP memory. At the present, this includes most of the
31  * SavedContext types: VertexBufferContext and IndexBufferContext, as well as
32  * TextureContext.
33  *
34  * This class provides methods for tracking the video memory utilization, as
35  * well as residency of each object, via PStats.
36  */
37 class EXPCL_PANDA_GOBJ BufferContext : public SavedContext, private LinkedListNode {
38 public:
40  virtual ~BufferContext();
41 
42 PUBLISHED:
43  INLINE size_t get_data_size_bytes() const;
44  INLINE UpdateSeq get_modified() const;
45  INLINE bool get_active() const;
46  INLINE bool get_resident() const;
47 
48  MAKE_PROPERTY(data_size_bytes, get_data_size_bytes);
49  MAKE_PROPERTY(modified, get_modified);
50  MAKE_PROPERTY(active, get_active);
51  MAKE_PROPERTY(resident, get_resident);
52 
53 public:
54  INLINE void set_active(bool flag);
55  INLINE void set_resident(bool flag);
56 
57  INLINE BufferContext *get_next() const;
58 
59  INLINE void update_data_size_bytes(size_t new_data_size_bytes);
60  INLINE void update_modified(UpdateSeq new_modified);
61 
62 private:
63  void set_owning_chain(BufferContextChain *chain);
64 
65 private:
66  BufferResidencyTracker *_residency;
67  int _residency_state;
68 
69  size_t _data_size_bytes;
70  UpdateSeq _modified;
71  BufferContextChain *_owning_chain;
72 
73 public:
74  static TypeHandle get_class_type() {
75  return _type_handle;
76  }
77  static void init_type() {
78  SavedContext::init_type();
79  register_type(_type_handle, "BufferContext",
80  SavedContext::get_class_type());
81  }
82  virtual TypeHandle get_type() const {
83  return get_class_type();
84  }
85  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
86 
87 private:
88  static TypeHandle _type_handle;
89 
90  friend class PreparedGraphicsObjects;
91  friend class BufferResidencyTracker;
92  friend class BufferContextChain;
93 };
94 
95 #include "bufferContext.I"
96 
97 #endif
void register_type(TypeHandle &type_handle, const string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(), along with zero to four record_derivation()s.
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This just stores the pointers to implement a doubly-linked list of some kind of object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A table of objects that are saved within the graphics context for reference by handle later...
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:37
This class maintains a linked list of BufferContexts that might be allocated on the graphics card in ...
This is the base class for all GSG-specific context objects, such as TextureContext and GeomContext...
Definition: savedContext.h:26
This is a sequence number that increments monotonically.
Definition: updateSeq.h:37
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...