daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // ResourceManager.h : Defines the ResourceManager class, which tracks objects |
| 8 | // shared by multiple GL contexts. |
| 9 | |
| 10 | #ifndef LIBGLESV2_RESOURCEMANAGER_H_ |
| 11 | #define LIBGLESV2_RESOURCEMANAGER_H_ |
| 12 | |
| 13 | #define GL_APICALL |
shannon.woods%transgaming.com@gtempaccount.com | f26ddae | 2013-04-13 03:29:13 +0000 | [diff] [blame^] | 14 | #include <GLES3/gl3.h> |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 15 | #include <GLES2/gl2.h> |
| 16 | |
daniel@transgaming.com | db2115d | 2012-08-27 16:25:33 +0000 | [diff] [blame] | 17 | #ifdef _MSC_VER |
daniel@transgaming.com | 733ba93 | 2011-04-14 15:03:48 +0000 | [diff] [blame] | 18 | #include <hash_map> |
daniel@transgaming.com | db2115d | 2012-08-27 16:25:33 +0000 | [diff] [blame] | 19 | #else |
| 20 | #include <unordered_map> |
| 21 | #endif |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 22 | |
| 23 | #include "common/angleutils.h" |
daniel@transgaming.com | ef19da5 | 2012-11-28 19:35:08 +0000 | [diff] [blame] | 24 | #include "libGLESv2/angletypes.h" |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 25 | #include "libGLESv2/HandleAllocator.h" |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 26 | |
daniel@transgaming.com | 370482e | 2012-11-28 19:32:13 +0000 | [diff] [blame] | 27 | namespace rx |
| 28 | { |
| 29 | class Renderer; |
| 30 | } |
| 31 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 32 | namespace gl |
| 33 | { |
| 34 | class Buffer; |
| 35 | class Shader; |
| 36 | class Program; |
| 37 | class Texture; |
| 38 | class Renderbuffer; |
| 39 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 40 | class ResourceManager |
| 41 | { |
| 42 | public: |
daniel@transgaming.com | 370482e | 2012-11-28 19:32:13 +0000 | [diff] [blame] | 43 | explicit ResourceManager(rx::Renderer *renderer); |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 44 | ~ResourceManager(); |
| 45 | |
daniel@transgaming.com | 0d25b00 | 2010-07-28 19:21:07 +0000 | [diff] [blame] | 46 | void addRef(); |
| 47 | void release(); |
| 48 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 49 | GLuint createBuffer(); |
| 50 | GLuint createShader(GLenum type); |
| 51 | GLuint createProgram(); |
| 52 | GLuint createTexture(); |
| 53 | GLuint createRenderbuffer(); |
| 54 | |
| 55 | void deleteBuffer(GLuint buffer); |
| 56 | void deleteShader(GLuint shader); |
| 57 | void deleteProgram(GLuint program); |
| 58 | void deleteTexture(GLuint texture); |
| 59 | void deleteRenderbuffer(GLuint renderbuffer); |
| 60 | |
| 61 | Buffer *getBuffer(GLuint handle); |
| 62 | Shader *getShader(GLuint handle); |
| 63 | Program *getProgram(GLuint handle); |
| 64 | Texture *getTexture(GLuint handle); |
| 65 | Renderbuffer *getRenderbuffer(GLuint handle); |
| 66 | |
| 67 | void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer); |
| 68 | |
| 69 | void checkBufferAllocation(unsigned int buffer); |
daniel@transgaming.com | 0e64dd6 | 2011-05-11 15:36:37 +0000 | [diff] [blame] | 70 | void checkTextureAllocation(GLuint texture, TextureType type); |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 71 | void checkRenderbufferAllocation(GLuint renderbuffer); |
apatrick@chromium.org | ff8bdfb | 2010-09-15 17:27:49 +0000 | [diff] [blame] | 72 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 73 | private: |
| 74 | DISALLOW_COPY_AND_ASSIGN(ResourceManager); |
| 75 | |
daniel@transgaming.com | 0d25b00 | 2010-07-28 19:21:07 +0000 | [diff] [blame] | 76 | std::size_t mRefCount; |
daniel@transgaming.com | 370482e | 2012-11-28 19:32:13 +0000 | [diff] [blame] | 77 | rx::Renderer *mRenderer; |
daniel@transgaming.com | 0d25b00 | 2010-07-28 19:21:07 +0000 | [diff] [blame] | 78 | |
daniel@transgaming.com | db2115d | 2012-08-27 16:25:33 +0000 | [diff] [blame] | 79 | #ifndef HASH_MAP |
| 80 | # ifdef _MSC_VER |
| 81 | # define HASH_MAP stdext::hash_map |
| 82 | # else |
| 83 | # define HASH_MAP std::unordered_map |
| 84 | # endif |
| 85 | #endif |
| 86 | |
| 87 | typedef HASH_MAP<GLuint, Buffer*> BufferMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 88 | BufferMap mBufferMap; |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 89 | HandleAllocator mBufferHandleAllocator; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 90 | |
daniel@transgaming.com | db2115d | 2012-08-27 16:25:33 +0000 | [diff] [blame] | 91 | typedef HASH_MAP<GLuint, Shader*> ShaderMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 92 | ShaderMap mShaderMap; |
| 93 | |
daniel@transgaming.com | db2115d | 2012-08-27 16:25:33 +0000 | [diff] [blame] | 94 | typedef HASH_MAP<GLuint, Program*> ProgramMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 95 | ProgramMap mProgramMap; |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 96 | HandleAllocator mProgramShaderHandleAllocator; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 97 | |
daniel@transgaming.com | db2115d | 2012-08-27 16:25:33 +0000 | [diff] [blame] | 98 | typedef HASH_MAP<GLuint, Texture*> TextureMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 99 | TextureMap mTextureMap; |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 100 | HandleAllocator mTextureHandleAllocator; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 101 | |
daniel@transgaming.com | db2115d | 2012-08-27 16:25:33 +0000 | [diff] [blame] | 102 | typedef HASH_MAP<GLuint, Renderbuffer*> RenderbufferMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 103 | RenderbufferMap mRenderbufferMap; |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 104 | HandleAllocator mRenderbufferHandleAllocator; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | } |
| 108 | |
| 109 | #endif // LIBGLESV2_RESOURCEMANAGER_H_ |