OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreGL3PlusHardwareBufferManager.h
Go to the documentation of this 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 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9  Permission is hereby granted, free of charge, to any person obtaining a copy
10  of this software and associated documentation files (the "Software"), to deal
11  in the Software without restriction, including without limitation the rights
12  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  copies of the Software, and to permit persons to whom the Software is
14  furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25  THE SOFTWARE.
26  -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __GL3PlusHardwareBufferManager_H__
30 #define __GL3PlusHardwareBufferManager_H__
31 
34 
35 namespace Ogre {
36  // Default threshold at which glMapBuffer becomes more efficient than glBufferSubData (32k?)
37  //TODO Double check that this still holds.
38 # define OGRE_GL_DEFAULT_MAP_BUFFER_THRESHOLD (1024 * 32)
39 
42  {
43  protected:
45  OGRE_MUTEX(mScratchMutex);
47 
49 
50  public:
54  HardwareVertexBufferSharedPtr createVertexBuffer(size_t vertexSize,
55  size_t numVerts, HardwareBuffer::Usage usage, bool useShadowBuffer = false);
57  HardwareIndexBufferSharedPtr createIndexBuffer(
58  HardwareIndexBuffer::IndexType itype, size_t numIndexes,
59  HardwareBuffer::Usage usage, bool useShadowBuffer = false);
61  HardwareUniformBufferSharedPtr createUniformBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
62  bool useShadowBuffer, const String& name = "");
64  HardwareUniformBufferSharedPtr createUniformBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
65  bool useShadowBuffer, size_t binding, const String& name = "");
66 
68  HardwareUniformBufferSharedPtr createShaderStorageBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
69  bool useShadowBuffer, const String& name = "");
71  HardwareUniformBufferSharedPtr createShaderStorageBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
72  bool useShadowBuffer, size_t binding, const String& name = "");
74  HardwareCounterBufferSharedPtr createCounterBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
75  bool useShadowBuffer, const String& name = "");
77  HardwareCounterBufferSharedPtr createCounterBuffer(size_t sizeBytes, HardwareBuffer::Usage usage,
78  bool useShadowBuffer, size_t binding, const String& name = "");
80  RenderToVertexBufferSharedPtr createRenderToVertexBuffer();
81 
83  static GLenum getGLUsage(unsigned int usage);
84 
86  static GLenum getGLType(unsigned int type);
87 
95  void* allocateScratch(uint32 size);
96 
98  void deallocateScratch(void* ptr);
99 
102  size_t getGLMapBufferThreshold() const;
103  void setGLMapBufferThreshold( const size_t value );
104  };
105 
108  {
109  // protected:
110  // UniformBufferList mShaderStorageBuffers;
111 
112  public:
115  {
116 
117  }
119  {
120  // mShaderStorageBuffers.clear();
121  OGRE_DELETE mImpl;
122  }
123 
125  static GLenum getGLUsage(unsigned int usage)
127 
129  static GLenum getGLType(unsigned int type)
131 
140  {
141  return static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->allocateScratch(size);
142  }
143 
145  void deallocateScratch(void* ptr)
146  {
147  static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->deallocateScratch(ptr);
148  }
149 
152  size_t getGLMapBufferThreshold() const
153  {
154  return static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->getGLMapBufferThreshold();
155  }
156  void setGLMapBufferThreshold( const size_t value )
157  {
158  static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->setGLMapBufferThreshold(value);
159  }
160 
163  bool useShadowBuffer, const String& name = "")
164  {
165  return static_cast<GL3PlusHardwareBufferManagerBase*>(mImpl)->createShaderStorageBuffer(sizeBytes, usage, useShadowBuffer, name);
166  }
167 
168  };
169 
170 }
171 
172 #endif
GL3PlusHardwareBufferManagerBase as a Singleton.
size_t getGLMapBufferThreshold() const
Threshold after which glMapBuffer is used and not glBufferSubData.
Implementation of HardwareBufferManager for OpenGL.
unsigned int uint32
Definition: OgrePlatform.h:420
Singleton wrapper for hardware buffer manager.
Shared pointer implementation used to share uniform buffers.
#define OGRE_MUTEX(name)
Shared pointer implementation used to share vertex buffers.
static GLenum getGLType(unsigned int type)
Utility function to get the correct GL type based on VET's.
HardwareUniformBufferSharedPtr createShaderStorageBuffer(size_t sizeBytes, HardwareBuffer::Usage usage, bool useShadowBuffer, const String &name="")
Create a shader storage buffer.
static GLenum getGLUsage(unsigned int usage)
Utility function to get the correct GL usage based on HBU's.
Shared pointer implementation used to share index buffers.
static GLenum getGLType(unsigned int type)
Utility function to get the correct GL type based on VET's.
Base definition of a hardware buffer manager.
static GLenum getGLUsage(unsigned int usage)
Utility function to get the correct GL usage based on HBU's.
Usage
Enums describing buffer usage; not mutually exclusive.
#define OGRE_DELETE
set< HardwareUniformBuffer * >::type UniformBufferList
#define _OgreGL3PlusExport
#define OGRE_NEW
Shared pointer implementation used to share counter buffers.
void * allocateScratch(uint32 size)
Allocator method to allow us to use a pool of memory as a scratch area for hardware buffers...
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String
Definition: OgreCommon.h:53