VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGlTextureResidencyManager.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
12 
13 #include <map>
14 #include <unordered_map>
15 
16 namespace makVrv
17 {
18  class DtGlTextureResidentMemoryTracker;
19 
22  {
23  public:
24  typedef std::map<unsigned int, int> TexIDToCount;
25  typedef std::map<void*, TexIDToCount> ContextToTexID;
26 
27  public:
30 
32  virtual ~DtGlTextureResidencyManager();
33 
36 
38  DtGlTextureResidencyManager& operator=(const DtGlTextureResidencyManager&) = delete;
39 
40  public:
42  virtual void makeResidentIfNecessary(void* gContext, GLuint textureID);
43 
47  virtual bool makeNonResidentIfNecessary(void* gContext, GLuint textureID, bool canDelete);
48 
50  virtual GLuint64 gpuTextureAddress(GLuint textureID) const;
51 
53  virtual bool isTexture(GLuint textureID) const;
54 
58  virtual DtGlTextureResidentMemoryTracker* tracker() const;
59 
60  protected:
62  virtual DtGlTextureResidentMemoryTracker* getOrCreateTracker(void* graphicsContext);
63  protected:
64  // Count of textures we've made resident *across all contexts*
65  // So 1 texture in 3 contexts will have a count of 3
66  // When this array goes to 0 then we call glDeleteTextures if the
67  // texture is also marked
69 
70  // So for pageable terrains, the textures can be shared between tiles
71  // However, when you releaseGLObjects and say glMakeTextureHandleNonResidentARB,
72  // other tiles which share the texture will not draw or have other problems
73  // since we removed the data from underneath them
74  // This is a basic (non-thread safe!) reference counting of textures by
75  // context ID
77 
78  std::unordered_map<void*, DtGlTextureResidentMemoryTracker*> myContextsToTrackers;
79  };
80 }
std::map< unsigned int, int > TexIDToCount
Definition: DtGlTextureResidencyManager.h:24
Dll export defines.
helper class to handle texture residency
Definition: DtGlTextureResidencyManager.h:21
std::map< void *, TexIDToCount > ContextToTexID
Definition: DtGlTextureResidencyManager.h:25
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
DtGlTextureResidentMemoryTracker class is used to track resident memory of the textures in the system...
Definition: DtGlTextureResidentMemoryTracker.h:73
ContextToTexID myTextureCountByContext
Definition: DtGlTextureResidencyManager.h:68
#define DT_DLL_VRVGRAPHICSUTILS
Definition: vrvGraphicsUtils.h:18
TexIDToCount myTextureIdToRefCountAcrossContexts
Definition: DtGlTextureResidencyManager.h:76
std::unordered_map< void *, DtGlTextureResidentMemoryTracker * > myContextsToTrackers
Definition: DtGlTextureResidencyManager.h:78

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)