daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 1 | // |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 2 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 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 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 10 | #ifndef LIBANGLE_RESOURCEMANAGER_H_ |
| 11 | #define LIBANGLE_RESOURCEMANAGER_H_ |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 12 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 13 | #include "angle_gl.h" |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 14 | #include "common/angleutils.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 15 | #include "libANGLE/angletypes.h" |
| 16 | #include "libANGLE/HandleAllocator.h" |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 17 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 18 | #include <map> |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 19 | |
daniel@transgaming.com | 370482e | 2012-11-28 19:32:13 +0000 | [diff] [blame] | 20 | namespace rx |
| 21 | { |
Jamie Madill | ae6495e | 2015-03-16 10:46:56 -0400 | [diff] [blame] | 22 | class ImplFactory; |
daniel@transgaming.com | 370482e | 2012-11-28 19:32:13 +0000 | [diff] [blame] | 23 | } |
| 24 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 25 | namespace gl |
| 26 | { |
| 27 | class Buffer; |
Jamie Madill | 006cbc5 | 2015-09-23 16:47:54 -0400 | [diff] [blame^] | 28 | struct Data; |
| 29 | class FenceSync; |
| 30 | struct Limitations; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 31 | class Program; |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 32 | class Renderbuffer; |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 33 | class Sampler; |
Jamie Madill | 006cbc5 | 2015-09-23 16:47:54 -0400 | [diff] [blame^] | 34 | class Shader; |
| 35 | class Texture; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 36 | |
Jamie Madill | f0d10f8 | 2015-03-31 12:56:52 -0400 | [diff] [blame] | 37 | class ResourceManager : angle::NonCopyable |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 38 | { |
| 39 | public: |
Jamie Madill | ae6495e | 2015-03-16 10:46:56 -0400 | [diff] [blame] | 40 | explicit ResourceManager(rx::ImplFactory *factory); |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 41 | ~ResourceManager(); |
| 42 | |
daniel@transgaming.com | 0d25b00 | 2010-07-28 19:21:07 +0000 | [diff] [blame] | 43 | void addRef(); |
| 44 | void release(); |
| 45 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 46 | GLuint createBuffer(); |
Jamie Madill | 006cbc5 | 2015-09-23 16:47:54 -0400 | [diff] [blame^] | 47 | GLuint createShader(const gl::Limitations &rendererLimitations, GLenum type); |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 48 | GLuint createProgram(); |
| 49 | GLuint createTexture(); |
| 50 | GLuint createRenderbuffer(); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 51 | GLuint createSampler(); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 52 | GLuint createFenceSync(); |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 53 | |
| 54 | void deleteBuffer(GLuint buffer); |
| 55 | void deleteShader(GLuint shader); |
| 56 | void deleteProgram(GLuint program); |
| 57 | void deleteTexture(GLuint texture); |
| 58 | void deleteRenderbuffer(GLuint renderbuffer); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 59 | void deleteSampler(GLuint sampler); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 60 | void deleteFenceSync(GLuint fenceSync); |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 61 | |
| 62 | Buffer *getBuffer(GLuint handle); |
| 63 | Shader *getShader(GLuint handle); |
Jamie Madill | d9e5830 | 2014-11-06 15:27:26 -0500 | [diff] [blame] | 64 | Program *getProgram(GLuint handle) const; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 65 | Texture *getTexture(GLuint handle); |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 66 | Renderbuffer *getRenderbuffer(GLuint handle); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 67 | Sampler *getSampler(GLuint handle); |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 68 | FenceSync *getFenceSync(GLuint handle); |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 69 | |
Jamie Madill | 6c7b4ad | 2014-06-16 10:33:59 -0400 | [diff] [blame] | 70 | void setRenderbuffer(GLuint handle, Renderbuffer *renderbuffer); |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 71 | |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 72 | void checkBufferAllocation(GLuint handle); |
| 73 | void checkTextureAllocation(GLuint handle, GLenum type); |
| 74 | void checkRenderbufferAllocation(GLuint handle); |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 75 | void checkSamplerAllocation(GLuint sampler); |
| 76 | |
| 77 | bool isSampler(GLuint sampler); |
apatrick@chromium.org | ff8bdfb | 2010-09-15 17:27:49 +0000 | [diff] [blame] | 78 | |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 79 | private: |
Jamie Madill | bdd419f | 2015-03-20 15:29:42 -0400 | [diff] [blame] | 80 | void createTextureInternal(GLuint handle); |
| 81 | |
Jamie Madill | ae6495e | 2015-03-16 10:46:56 -0400 | [diff] [blame] | 82 | rx::ImplFactory *mFactory; |
Jamie Madill | 93e13fb | 2014-11-06 15:27:25 -0500 | [diff] [blame] | 83 | std::size_t mRefCount; |
daniel@transgaming.com | 0d25b00 | 2010-07-28 19:21:07 +0000 | [diff] [blame] | 84 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 85 | typedef std::map<GLuint, Buffer*> BufferMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 86 | BufferMap mBufferMap; |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 87 | HandleAllocator mBufferHandleAllocator; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 88 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 89 | typedef std::map<GLuint, Shader*> ShaderMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 90 | ShaderMap mShaderMap; |
| 91 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 92 | typedef std::map<GLuint, Program*> ProgramMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 93 | ProgramMap mProgramMap; |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 94 | HandleAllocator mProgramShaderHandleAllocator; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 95 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 96 | typedef std::map<GLuint, Texture*> TextureMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 97 | TextureMap mTextureMap; |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 98 | HandleAllocator mTextureHandleAllocator; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 99 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 100 | typedef std::map<GLuint, Renderbuffer*> RenderbufferMap; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 101 | RenderbufferMap mRenderbufferMap; |
benvanik@google.com | 1a23334 | 2011-04-28 19:44:39 +0000 | [diff] [blame] | 102 | HandleAllocator mRenderbufferHandleAllocator; |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 103 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 104 | typedef std::map<GLuint, Sampler*> SamplerMap; |
Geoff Lang | 9b8f92e | 2013-07-30 15:23:30 -0400 | [diff] [blame] | 105 | SamplerMap mSamplerMap; |
Jamie Madill | dc35604 | 2013-07-19 16:36:57 -0400 | [diff] [blame] | 106 | HandleAllocator mSamplerHandleAllocator; |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 107 | |
Jamie Madill | cd1db9e | 2015-01-05 16:09:05 -0500 | [diff] [blame] | 108 | typedef std::map<GLuint, FenceSync*> FenceMap; |
Geoff Lang | 9b8f92e | 2013-07-30 15:23:30 -0400 | [diff] [blame] | 109 | FenceMap mFenceSyncMap; |
Jamie Madill | cd055f8 | 2013-07-26 11:55:15 -0400 | [diff] [blame] | 110 | HandleAllocator mFenceSyncHandleAllocator; |
daniel@transgaming.com | da13f3e | 2010-07-28 19:20:56 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | } |
| 114 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 115 | #endif // LIBANGLE_RESOURCEMANAGER_H_ |