Panda3D
 All Classes Functions Variables Enumerations
bufferContext.h
1 // Filename: bufferContext.h
2 // Created by: drose (16Mar06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BUFFERCONTEXT_H
16 #define BUFFERCONTEXT_H
17 
18 #include "pandabase.h"
19 
20 #include "savedContext.h"
21 #include "updateSeq.h"
22 #include "linkedListNode.h"
23 #include "bufferContextChain.h"
24 #include "bufferResidencyTracker.h"
25 
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : BufferContext
30 // Description : This is a base class for those kinds of SavedContexts
31 // that occupy an easily-measured (and substantial)
32 // number of bytes in the video card's frame buffer
33 // memory or AGP memory. At the present, this includes
34 // most of the SavedContext types: VertexBufferContext
35 // and IndexBufferContext, as well as TextureContext.
36 //
37 // This class provides methods for tracking the video
38 // memory utilization, as well as residency of each
39 // object, via PStats.
40 ////////////////////////////////////////////////////////////////////
41 class EXPCL_PANDA_GOBJ BufferContext : public SavedContext, private LinkedListNode {
42 public:
44  virtual ~BufferContext();
45 
46 PUBLISHED:
47  INLINE size_t get_data_size_bytes() const;
48  INLINE UpdateSeq get_modified() const;
49  INLINE bool get_active() const;
50  INLINE bool get_resident() const;
51 
52 public:
53  INLINE void set_active(bool flag);
54  INLINE void set_resident(bool flag);
55 
56  INLINE BufferContext *get_next() const;
57 
58  INLINE void update_data_size_bytes(size_t new_data_size_bytes);
59  INLINE void update_modified(UpdateSeq new_modified);
60 
61 private:
62  void set_owning_chain(BufferContextChain *chain);
63 
64 private:
65  BufferResidencyTracker *_residency;
66  int _residency_state;
67 
68  size_t _data_size_bytes;
69  UpdateSeq _modified;
70  BufferContextChain *_owning_chain;
71 
72 public:
73  static TypeHandle get_class_type() {
74  return _type_handle;
75  }
76  static void init_type() {
77  SavedContext::init_type();
78  register_type(_type_handle, "BufferContext",
79  SavedContext::get_class_type());
80  }
81  virtual TypeHandle get_type() const {
82  return get_class_type();
83  }
84  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
85 
86 private:
87  static TypeHandle _type_handle;
88 
89  friend class PreparedGraphicsObjects;
90  friend class BufferResidencyTracker;
91  friend class BufferContextChain;
92 };
93 
94 #include "bufferContext.I"
95 
96 #endif
97 
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:41
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 ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
This is the base class for all GSG-specific context objects, such as TextureContext and GeomContext...
Definition: savedContext.h:29