/OgreMain/include/OgreHardwareBufferManager.h

https://bitbucket.org/ZCube/ogre-android/ · C++ Header · 539 lines · 225 code · 48 blank · 266 comment · 0 complexity · 4a2146567faaf6818c9fb3fcb05301de MD5 · raw file

  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __HardwareBufferManager__
  25. #define __HardwareBufferManager__
  26. // Precompiler options
  27. #include "OgrePrerequisites.h"
  28. #include "OgreSingleton.h"
  29. #include "OgreHardwareVertexBuffer.h"
  30. #include "OgreHardwareIndexBuffer.h"
  31. #include "OgreRenderToVertexBuffer.h"
  32. namespace Ogre {
  33. /** \addtogroup Core
  34. * @{
  35. */
  36. /** \addtogroup RenderSystem
  37. * @{
  38. */
  39. /** Abstract interface representing a 'licensee' of a hardware buffer copy.
  40. remarks
  41. Often it's useful to have temporary buffers which are used for working
  42. but are not necessarily needed permanently. However, creating and
  43. destroying buffers is expensive, so we need a way to share these
  44. working areas, especially those based on existing fixed buffers.
  45. This class represents a licensee of one of those temporary buffers,
  46. and must be implemented by any user of a temporary buffer if they
  47. wish to be notified when the license is expired.
  48. */
  49. class _OgreExport HardwareBufferLicensee
  50. {
  51. public:
  52. virtual ~HardwareBufferLicensee() { }
  53. /** This method is called when the buffer license is expired and is about
  54. to be returned to the shared pool. */
  55. virtual void licenseExpired(HardwareBuffer* buffer) = 0;
  56. };
  57. /** Structure for recording the use of temporary blend buffers */
  58. class _OgreExport TempBlendedBufferInfo : public HardwareBufferLicensee, public BufferAlloc
  59. {
  60. private:
  61. // Pre-blended
  62. HardwareVertexBufferSharedPtr srcPositionBuffer;
  63. HardwareVertexBufferSharedPtr srcNormalBuffer;
  64. // Post-blended
  65. HardwareVertexBufferSharedPtr destPositionBuffer;
  66. HardwareVertexBufferSharedPtr destNormalBuffer;
  67. /// Both positions and normals are contained in the same buffer
  68. bool posNormalShareBuffer;
  69. unsigned short posBindIndex;
  70. unsigned short normBindIndex;
  71. bool bindPositions;
  72. bool bindNormals;
  73. public:
  74. ~TempBlendedBufferInfo(void);
  75. /// Utility method, extract info from the given VertexData
  76. void extractFrom(const VertexData* sourceData);
  77. /// Utility method, checks out temporary copies of src into dest
  78. void checkoutTempCopies(bool positions = true, bool normals = true);
  79. /// Utility method, binds dest copies into a given VertexData struct
  80. void bindTempCopies(VertexData* targetData, bool suppressHardwareUpload);
  81. /** Overridden member from HardwareBufferLicensee. */
  82. void licenseExpired(HardwareBuffer* buffer);
  83. /** Detect currently have buffer copies checked out and touch it */
  84. bool buffersCheckedOut(bool positions = true, bool normals = true) const;
  85. };
  86. /** Base definition of a hardware buffer manager.
  87. @remarks
  88. This class is deliberately not a Singleton, so that multiple types can
  89. exist at once. The Singleton is wrapped via the Decorator pattern
  90. in HardwareBufferManager, below. Each concrete implementation should
  91. provide a subclass of HardwareBufferManagerBase, which does the actual
  92. work, and also a very simple subclass of HardwareBufferManager which
  93. simply constructs the instance of the HardwareBufferManagerBase subclass
  94. and passes it to the HardwareBufferManager superclass as a delegate.
  95. This subclass must also delete the implementation instance it creates.
  96. */
  97. class _OgreExport HardwareBufferManagerBase : public BufferAlloc
  98. {
  99. friend class HardwareVertexBufferSharedPtr;
  100. friend class HardwareIndexBufferSharedPtr;
  101. protected:
  102. /** WARNING: The following two members should place before all other members.
  103. Members destruct order is very important here, because destructing other
  104. members will cause notify back to this class, and then will access to this
  105. two members.
  106. */
  107. typedef set<HardwareVertexBuffer*>::type VertexBufferList;
  108. typedef set<HardwareIndexBuffer*>::type IndexBufferList;
  109. VertexBufferList mVertexBuffers;
  110. IndexBufferList mIndexBuffers;
  111. typedef set<VertexDeclaration*>::type VertexDeclarationList;
  112. typedef set<VertexBufferBinding*>::type VertexBufferBindingList;
  113. VertexDeclarationList mVertexDeclarations;
  114. VertexBufferBindingList mVertexBufferBindings;
  115. // Mutexes
  116. OGRE_MUTEX(mVertexBuffersMutex)
  117. OGRE_MUTEX(mIndexBuffersMutex)
  118. OGRE_MUTEX(mVertexDeclarationsMutex)
  119. OGRE_MUTEX(mVertexBufferBindingsMutex)
  120. /// Internal method for destroys all vertex declarations
  121. virtual void destroyAllDeclarations(void);
  122. /// Internal method for destroys all vertex buffer bindings
  123. virtual void destroyAllBindings(void);
  124. /// Internal method for creates a new vertex declaration, may be overridden by certain rendering APIs
  125. virtual VertexDeclaration* createVertexDeclarationImpl(void);
  126. /// Internal method for destroys a vertex declaration, may be overridden by certain rendering APIs
  127. virtual void destroyVertexDeclarationImpl(VertexDeclaration* decl);
  128. /// Internal method for creates a new VertexBufferBinding, may be overridden by certain rendering APIs
  129. virtual VertexBufferBinding* createVertexBufferBindingImpl(void);
  130. /// Internal method for destroys a VertexBufferBinding, may be overridden by certain rendering APIs
  131. virtual void destroyVertexBufferBindingImpl(VertexBufferBinding* binding);
  132. public:
  133. enum BufferLicenseType
  134. {
  135. /// Licensee will only release buffer when it says so
  136. BLT_MANUAL_RELEASE,
  137. /// Licensee can have license revoked
  138. BLT_AUTOMATIC_RELEASE
  139. };
  140. protected:
  141. /** Struct holding details of a license to use a temporary shared buffer. */
  142. class _OgrePrivate VertexBufferLicense
  143. {
  144. public:
  145. HardwareVertexBuffer* originalBufferPtr;
  146. BufferLicenseType licenseType;
  147. size_t expiredDelay;
  148. HardwareVertexBufferSharedPtr buffer;
  149. HardwareBufferLicensee* licensee;
  150. VertexBufferLicense(
  151. HardwareVertexBuffer* orig,
  152. BufferLicenseType ltype,
  153. size_t delay,
  154. HardwareVertexBufferSharedPtr buf,
  155. HardwareBufferLicensee* lic)
  156. : originalBufferPtr(orig)
  157. , licenseType(ltype)
  158. , expiredDelay(delay)
  159. , buffer(buf)
  160. , licensee(lic)
  161. {}
  162. };
  163. /// Map from original buffer to temporary buffers
  164. typedef multimap<HardwareVertexBuffer*, HardwareVertexBufferSharedPtr>::type FreeTemporaryVertexBufferMap;
  165. /// Map of current available temp buffers
  166. FreeTemporaryVertexBufferMap mFreeTempVertexBufferMap;
  167. /// Map from temporary buffer to details of a license
  168. typedef map<HardwareVertexBuffer*, VertexBufferLicense>::type TemporaryVertexBufferLicenseMap;
  169. /// Map of currently licensed temporary buffers
  170. TemporaryVertexBufferLicenseMap mTempVertexBufferLicenses;
  171. /// Number of frames elapsed since temporary buffers utilization was above half the available
  172. size_t mUnderUsedFrameCount;
  173. /// Number of frames to wait before free unused temporary buffers
  174. static const size_t UNDER_USED_FRAME_THRESHOLD;
  175. /// Frame delay for BLT_AUTOMATIC_RELEASE temporary buffers
  176. static const size_t EXPIRED_DELAY_FRAME_THRESHOLD;
  177. // Mutexes
  178. OGRE_MUTEX(mTempBuffersMutex)
  179. /// Creates a new buffer as a copy of the source, does not copy data
  180. virtual HardwareVertexBufferSharedPtr makeBufferCopy(
  181. const HardwareVertexBufferSharedPtr& source,
  182. HardwareBuffer::Usage usage, bool useShadowBuffer);
  183. public:
  184. HardwareBufferManagerBase();
  185. virtual ~HardwareBufferManagerBase();
  186. /** Create a hardware vertex buffer.
  187. @remarks
  188. This method creates a new vertex buffer; this will act as a source of geometry
  189. data for rendering objects. Note that because the meaning of the contents of
  190. the vertex buffer depends on the usage, this method does not specify a
  191. vertex format; the user of this buffer can actually insert whatever data
  192. they wish, in any format. However, in order to use this with a RenderOperation,
  193. the data in this vertex buffer will have to be associated with a semantic element
  194. of the rendering pipeline, e.g. a position, or texture coordinates. This is done
  195. using the VertexDeclaration class, which itself contains VertexElement structures
  196. referring to the source data.
  197. @remarks Note that because vertex buffers can be shared, they are reference
  198. counted so you do not need to worry about destroying themm this will be done
  199. automatically.
  200. @param vertexSize The size in bytes of each vertex in this buffer; you must calculate
  201. this based on the kind of data you expect to populate this buffer with.
  202. @param numVerts The number of vertices in this buffer.
  203. @param usage One or more members of the HardwareBuffer::Usage enumeration; you are
  204. strongly advised to use HBU_STATIC_WRITE_ONLY wherever possible, if you need to
  205. update regularly, consider HBU_DYNAMIC_WRITE_ONLY and useShadowBuffer=true.
  206. @param useShadowBuffer If set to true, this buffer will be 'shadowed' by one stored in
  207. system memory rather than GPU or AGP memory. You should set this flag if you intend
  208. to read data back from the vertex buffer, because reading data from a buffer
  209. in the GPU or AGP memory is very expensive, and is in fact impossible if you
  210. specify HBU_WRITE_ONLY for the main buffer. If you use this option, all
  211. reads and writes will be done to the shadow buffer, and the shadow buffer will
  212. be synchronised with the real buffer at an appropriate time.
  213. */
  214. virtual HardwareVertexBufferSharedPtr
  215. createVertexBuffer(size_t vertexSize, size_t numVerts, HardwareBuffer::Usage usage,
  216. bool useShadowBuffer = false) = 0;
  217. /** Create a hardware index buffer.
  218. @remarks Note that because buffers can be shared, they are reference
  219. counted so you do not need to worry about destroying them this will be done
  220. automatically.
  221. @param itype The type in index, either 16- or 32-bit, depending on how many vertices
  222. you need to be able to address
  223. @param numIndexes The number of indexes in the buffer
  224. @param usage One or more members of the HardwareBuffer::Usage enumeration.
  225. @param useShadowBuffer If set to true, this buffer will be 'shadowed' by one stored in
  226. system memory rather than GPU or AGP memory. You should set this flag if you intend
  227. to read data back from the index buffer, because reading data from a buffer
  228. in the GPU or AGP memory is very expensive, and is in fact impossible if you
  229. specify HBU_WRITE_ONLY for the main buffer. If you use this option, all
  230. reads and writes will be done to the shadow buffer, and the shadow buffer will
  231. be synchronised with the real buffer at an appropriate time.
  232. */
  233. virtual HardwareIndexBufferSharedPtr
  234. createIndexBuffer(HardwareIndexBuffer::IndexType itype, size_t numIndexes,
  235. HardwareBuffer::Usage usage, bool useShadowBuffer = false) = 0;
  236. /** Create a render to vertex buffer.
  237. @remarks The parameters (such as vertex size etc) are determined later
  238. and are allocated when needed.
  239. */
  240. virtual RenderToVertexBufferSharedPtr createRenderToVertexBuffer() = 0;
  241. /** Creates a new vertex declaration. */
  242. virtual VertexDeclaration* createVertexDeclaration(void);
  243. /** Destroys a vertex declaration. */
  244. virtual void destroyVertexDeclaration(VertexDeclaration* decl);
  245. /** Creates a new VertexBufferBinding. */
  246. virtual VertexBufferBinding* createVertexBufferBinding(void);
  247. /** Destroys a VertexBufferBinding. */
  248. virtual void destroyVertexBufferBinding(VertexBufferBinding* binding);
  249. /** Registers a vertex buffer as a copy of another.
  250. @remarks
  251. This is useful for registering an existing buffer as a temporary buffer
  252. which can be allocated just like a copy.
  253. */
  254. virtual void registerVertexBufferSourceAndCopy(
  255. const HardwareVertexBufferSharedPtr& sourceBuffer,
  256. const HardwareVertexBufferSharedPtr& copy);
  257. /** Allocates a copy of a given vertex buffer.
  258. @remarks
  259. This method allocates a temporary copy of an existing vertex buffer.
  260. This buffer is subsequently stored and can be made available for
  261. other purposes later without incurring the cost of construction /
  262. destruction.
  263. @param sourceBuffer The source buffer to use as a copy
  264. @param licenseType The type of license required on this buffer - automatic
  265. release causes this class to release licenses every frame so that
  266. they can be reallocated anew.
  267. @param licensee Pointer back to the class requesting the copy, which must
  268. implement HardwareBufferLicense in order to be notified when the license
  269. expires.
  270. @param copyData If true, the current data is copied as well as the
  271. structure of the buffer
  272. */
  273. virtual HardwareVertexBufferSharedPtr allocateVertexBufferCopy(
  274. const HardwareVertexBufferSharedPtr& sourceBuffer,
  275. BufferLicenseType licenseType,
  276. HardwareBufferLicensee* licensee,
  277. bool copyData = false);
  278. /** Manually release a vertex buffer copy for others to subsequently use.
  279. @remarks
  280. Only required if the original call to allocateVertexBufferCopy
  281. included a licenseType of BLT_MANUAL_RELEASE.
  282. @param bufferCopy The buffer copy. The caller is expected to delete
  283. or at least no longer use this reference, since another user may
  284. well begin to modify the contents of the buffer.
  285. */
  286. virtual void releaseVertexBufferCopy(
  287. const HardwareVertexBufferSharedPtr& bufferCopy);
  288. /** Tell engine that the vertex buffer copy intent to reuse.
  289. @remarks
  290. Ogre internal keep an expired delay counter of BLT_AUTOMATIC_RELEASE
  291. buffers, when the counter count down to zero, it'll release for other
  292. purposes later. But you can use this function to reset the counter to
  293. the internal configured value, keep the buffer not get released for
  294. some frames.
  295. @param bufferCopy The buffer copy. The caller is expected to keep this
  296. buffer copy for use.
  297. */
  298. virtual void touchVertexBufferCopy(
  299. const HardwareVertexBufferSharedPtr& bufferCopy);
  300. /** Free all unused vertex buffer copies.
  301. @remarks
  302. This method free all temporary vertex buffers that not in used.
  303. In normally, temporary vertex buffers are subsequently stored and can
  304. be made available for other purposes later without incurring the cost
  305. of construction / destruction. But in some cases you want to free them
  306. to save hardware memory (e.g. application was runs in a long time, you
  307. might free temporary buffers periodically to avoid memory overload).
  308. */
  309. virtual void _freeUnusedBufferCopies(void);
  310. /** Internal method for releasing all temporary buffers which have been
  311. allocated using BLT_AUTOMATIC_RELEASE; is called by OGRE.
  312. @param forceFreeUnused If true, free all unused temporary buffers.
  313. If false, auto detect and free all unused temporary buffers based on
  314. temporary buffers utilization.
  315. */
  316. virtual void _releaseBufferCopies(bool forceFreeUnused = false);
  317. /** Internal method that forces the release of copies of a given buffer.
  318. @remarks
  319. This usually means that the buffer which the copies are based on has
  320. been changed in some fundamental way, and the owner of the original
  321. wishes to make that known so that new copies will reflect the
  322. changes.
  323. @param sourceBuffer the source buffer as a shared pointer. Any buffer copies created from the source buffer
  324. are deleted.
  325. */
  326. virtual void _forceReleaseBufferCopies(
  327. const HardwareVertexBufferSharedPtr& sourceBuffer);
  328. /** Internal method that forces the release of copies of a given buffer.
  329. @remarks
  330. This usually means that the buffer which the copies are based on has
  331. been changed in some fundamental way, and the owner of the original
  332. wishes to make that known so that new copies will reflect the
  333. changes.
  334. @param sourceBuffer the source buffer as a pointer. Any buffer copies created from the source buffer
  335. are deleted.
  336. */
  337. virtual void _forceReleaseBufferCopies(HardwareVertexBuffer* sourceBuffer);
  338. /// Notification that a hardware vertex buffer has been destroyed
  339. void _notifyVertexBufferDestroyed(HardwareVertexBuffer* buf);
  340. /// Notification that a hardware index buffer has been destroyed
  341. void _notifyIndexBufferDestroyed(HardwareIndexBuffer* buf);
  342. };
  343. /** Singleton wrapper for hardware buffer manager. */
  344. class _OgreExport HardwareBufferManager : public HardwareBufferManagerBase, public Singleton<HardwareBufferManager>
  345. {
  346. friend class HardwareVertexBufferSharedPtr;
  347. friend class HardwareIndexBufferSharedPtr;
  348. protected:
  349. HardwareBufferManagerBase* mImpl;
  350. public:
  351. HardwareBufferManager(HardwareBufferManagerBase* imp);
  352. ~HardwareBufferManager();
  353. /** @copydoc HardwareBufferManagerInterface::createVertexBuffer */
  354. HardwareVertexBufferSharedPtr
  355. createVertexBuffer(size_t vertexSize, size_t numVerts, HardwareBuffer::Usage usage,
  356. bool useShadowBuffer = false)
  357. {
  358. return mImpl->createVertexBuffer(vertexSize, numVerts, usage, useShadowBuffer);
  359. }
  360. /** @copydoc HardwareBufferManagerInterface::createIndexBuffer */
  361. HardwareIndexBufferSharedPtr
  362. createIndexBuffer(HardwareIndexBuffer::IndexType itype, size_t numIndexes,
  363. HardwareBuffer::Usage usage, bool useShadowBuffer = false)
  364. {
  365. return mImpl->createIndexBuffer(itype, numIndexes, usage, useShadowBuffer);
  366. }
  367. /** @copydoc HardwareBufferManagerInterface::createRenderToVertexBuffer */
  368. RenderToVertexBufferSharedPtr createRenderToVertexBuffer()
  369. {
  370. return mImpl->createRenderToVertexBuffer();
  371. }
  372. /** @copydoc HardwareBufferManagerInterface::createVertexDeclaration */
  373. virtual VertexDeclaration* createVertexDeclaration(void)
  374. {
  375. return mImpl->createVertexDeclaration();
  376. }
  377. /** @copydoc HardwareBufferManagerInterface::destroyVertexDeclaration */
  378. virtual void destroyVertexDeclaration(VertexDeclaration* decl)
  379. {
  380. mImpl->destroyVertexDeclaration(decl);
  381. }
  382. /** @copydoc HardwareBufferManagerInterface::createVertexBufferBinding */
  383. virtual VertexBufferBinding* createVertexBufferBinding(void)
  384. {
  385. return mImpl->createVertexBufferBinding();
  386. }
  387. /** @copydoc HardwareBufferManagerInterface::destroyVertexBufferBinding */
  388. virtual void destroyVertexBufferBinding(VertexBufferBinding* binding)
  389. {
  390. mImpl->destroyVertexBufferBinding(binding);
  391. }
  392. /** @copydoc HardwareBufferManagerInterface::registerVertexBufferSourceAndCopy */
  393. virtual void registerVertexBufferSourceAndCopy(
  394. const HardwareVertexBufferSharedPtr& sourceBuffer,
  395. const HardwareVertexBufferSharedPtr& copy)
  396. {
  397. mImpl->registerVertexBufferSourceAndCopy(sourceBuffer, copy);
  398. }
  399. /** @copydoc HardwareBufferManagerInterface::allocateVertexBufferCopy */
  400. virtual HardwareVertexBufferSharedPtr allocateVertexBufferCopy(
  401. const HardwareVertexBufferSharedPtr& sourceBuffer,
  402. BufferLicenseType licenseType,
  403. HardwareBufferLicensee* licensee,
  404. bool copyData = false)
  405. {
  406. return mImpl->allocateVertexBufferCopy(sourceBuffer, licenseType, licensee, copyData);
  407. }
  408. /** @copydoc HardwareBufferManagerInterface::releaseVertexBufferCopy */
  409. virtual void releaseVertexBufferCopy(
  410. const HardwareVertexBufferSharedPtr& bufferCopy)
  411. {
  412. mImpl->releaseVertexBufferCopy(bufferCopy);
  413. }
  414. /** @copydoc HardwareBufferManagerInterface::touchVertexBufferCopy */
  415. virtual void touchVertexBufferCopy(
  416. const HardwareVertexBufferSharedPtr& bufferCopy)
  417. {
  418. mImpl->touchVertexBufferCopy(bufferCopy);
  419. }
  420. /** @copydoc HardwareBufferManagerInterface::_freeUnusedBufferCopies */
  421. virtual void _freeUnusedBufferCopies(void)
  422. {
  423. mImpl->_freeUnusedBufferCopies();
  424. }
  425. /** @copydoc HardwareBufferManagerInterface::_releaseBufferCopies */
  426. virtual void _releaseBufferCopies(bool forceFreeUnused = false)
  427. {
  428. mImpl->_releaseBufferCopies(forceFreeUnused);
  429. }
  430. /** @copydoc HardwareBufferManagerInterface::_forceReleaseBufferCopies */
  431. virtual void _forceReleaseBufferCopies(
  432. const HardwareVertexBufferSharedPtr& sourceBuffer)
  433. {
  434. mImpl->_forceReleaseBufferCopies(sourceBuffer);
  435. }
  436. /** @copydoc HardwareBufferManagerInterface::_forceReleaseBufferCopies */
  437. virtual void _forceReleaseBufferCopies(HardwareVertexBuffer* sourceBuffer)
  438. {
  439. mImpl->_forceReleaseBufferCopies(sourceBuffer);
  440. }
  441. /** @copydoc HardwareBufferManagerInterface::_notifyVertexBufferDestroyed */
  442. void _notifyVertexBufferDestroyed(HardwareVertexBuffer* buf)
  443. {
  444. mImpl->_notifyVertexBufferDestroyed(buf);
  445. }
  446. /** @copydoc HardwareBufferManagerInterface::_notifyIndexBufferDestroyed */
  447. void _notifyIndexBufferDestroyed(HardwareIndexBuffer* buf)
  448. {
  449. mImpl->_notifyIndexBufferDestroyed(buf);
  450. }
  451. /** Override standard Singleton retrieval.
  452. @remarks
  453. Why do we do this? Well, it's because the Singleton
  454. implementation is in a .h file, which means it gets compiled
  455. into anybody who includes it. This is needed for the
  456. Singleton template to work, but we actually only want it
  457. compiled into the implementation of the class based on the
  458. Singleton, not all of them. If we don't change this, we get
  459. link errors when trying to use the Singleton-based class from
  460. an outside dll.
  461. @par
  462. This method just delegates to the template version anyway,
  463. but the implementation stays in this single compilation unit,
  464. preventing link errors.
  465. */
  466. static HardwareBufferManager& getSingleton(void);
  467. /** Override standard Singleton retrieval.
  468. @remarks
  469. Why do we do this? Well, it's because the Singleton
  470. implementation is in a .h file, which means it gets compiled
  471. into anybody who includes it. This is needed for the
  472. Singleton template to work, but we actually only want it
  473. compiled into the implementation of the class based on the
  474. Singleton, not all of them. If we don't change this, we get
  475. link errors when trying to use the Singleton-based class from
  476. an outside dll.
  477. @par
  478. This method just delegates to the template version anyway,
  479. but the implementation stays in this single compilation unit,
  480. preventing link errors.
  481. */
  482. static HardwareBufferManager* getSingletonPtr(void);
  483. };
  484. /** @} */
  485. /** @} */
  486. }
  487. #endif