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