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