daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
shannon.woods%transgaming.com@gtempaccount.com | 3b57b4f | 2013-04-13 03:28:29 +0000 | [diff] [blame] | 2 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +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 | // Framebuffer.h: Defines the gl::Framebuffer class. Implements GL framebuffer |
| 8 | // objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105. |
| 9 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 10 | #ifndef LIBANGLE_FRAMEBUFFER_H_ |
| 11 | #define LIBANGLE_FRAMEBUFFER_H_ |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 12 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 13 | #include <vector> |
Jamie Madill | ce20c7f | 2014-09-03 11:56:29 -0400 | [diff] [blame] | 14 | |
alokp@chromium.org | ea0e1af | 2010-03-22 19:33:14 +0000 | [diff] [blame] | 15 | #include "common/angleutils.h" |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 16 | #include "libANGLE/Constants.h" |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame^] | 17 | #include "libANGLE/Debug.h" |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 18 | #include "libANGLE/Error.h" |
Jamie Madill | 2d06b73 | 2015-04-20 12:53:28 -0400 | [diff] [blame] | 19 | #include "libANGLE/FramebufferAttachment.h" |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 20 | #include "libANGLE/RefCountObject.h" |
Geoff Lang | 64f23f6 | 2014-09-10 14:40:12 -0400 | [diff] [blame] | 21 | |
daniel@transgaming.com | 16418b1 | 2012-11-28 19:32:22 +0000 | [diff] [blame] | 22 | namespace rx |
| 23 | { |
Jamie Madill | 48115b6 | 2015-03-16 10:46:57 -0400 | [diff] [blame] | 24 | class ImplFactory; |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 25 | class FramebufferImpl; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 26 | class RenderbufferImpl; |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 27 | class SurfaceImpl; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | namespace egl |
| 31 | { |
| 32 | class Surface; |
daniel@transgaming.com | 16418b1 | 2012-11-28 19:32:22 +0000 | [diff] [blame] | 33 | } |
| 34 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 35 | namespace gl |
| 36 | { |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 37 | class Context; |
Geoff Lang | ab75a05 | 2014-10-15 12:56:37 -0400 | [diff] [blame] | 38 | class Renderbuffer; |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 39 | class State; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 40 | class Texture; |
| 41 | class TextureCapsMap; |
| 42 | struct Caps; |
| 43 | struct Data; |
| 44 | struct Extensions; |
| 45 | struct ImageIndex; |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 46 | struct Rectangle; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 47 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame^] | 48 | class Framebuffer final : public LabeledObject |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 49 | { |
| 50 | public: |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 51 | |
Jamie Madill | f0d10f8 | 2015-03-31 12:56:52 -0400 | [diff] [blame] | 52 | class Data final : angle::NonCopyable |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 53 | { |
| 54 | public: |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 55 | explicit Data(); |
Jamie Madill | 28291c5 | 2015-03-16 10:46:54 -0400 | [diff] [blame] | 56 | explicit Data(const Caps &caps); |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 57 | ~Data(); |
| 58 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame^] | 59 | const std::string &getLabel(); |
| 60 | |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 61 | const FramebufferAttachment *getReadAttachment() const; |
| 62 | const FramebufferAttachment *getFirstColorAttachment() const; |
| 63 | const FramebufferAttachment *getDepthOrStencilAttachment() const; |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 64 | const FramebufferAttachment *getColorAttachment(size_t colorAttachment) const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 65 | const FramebufferAttachment *getDepthAttachment() const; |
| 66 | const FramebufferAttachment *getStencilAttachment() const; |
| 67 | const FramebufferAttachment *getDepthStencilAttachment() const; |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 68 | |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 69 | const std::vector<GLenum> &getDrawBufferStates() const { return mDrawBufferStates; } |
Jamie Madill | 2d06b73 | 2015-04-20 12:53:28 -0400 | [diff] [blame] | 70 | const std::vector<FramebufferAttachment> &getColorAttachments() const { return mColorAttachments; } |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 71 | |
Jamie Madill | cc86d64 | 2015-11-24 13:00:07 -0500 | [diff] [blame] | 72 | bool attachmentsHaveSameDimensions() const; |
| 73 | |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 74 | private: |
| 75 | friend class Framebuffer; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 76 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame^] | 77 | std::string mLabel; |
| 78 | |
Jamie Madill | 2d06b73 | 2015-04-20 12:53:28 -0400 | [diff] [blame] | 79 | std::vector<FramebufferAttachment> mColorAttachments; |
| 80 | FramebufferAttachment mDepthAttachment; |
| 81 | FramebufferAttachment mStencilAttachment; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 82 | |
| 83 | std::vector<GLenum> mDrawBufferStates; |
| 84 | GLenum mReadBufferState; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 85 | }; |
| 86 | |
Jamie Madill | 48115b6 | 2015-03-16 10:46:57 -0400 | [diff] [blame] | 87 | Framebuffer(const Caps &caps, rx::ImplFactory *factory, GLuint id); |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 88 | Framebuffer(rx::SurfaceImpl *surface); |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 89 | virtual ~Framebuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 90 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame^] | 91 | void setLabel(const std::string &label) override; |
| 92 | const std::string &getLabel() const override; |
| 93 | |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 94 | const rx::FramebufferImpl *getImplementation() const { return mImpl; } |
| 95 | rx::FramebufferImpl *getImplementation() { return mImpl; } |
| 96 | |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 97 | GLuint id() const { return mId; } |
| 98 | |
Jamie Madill | 2d06b73 | 2015-04-20 12:53:28 -0400 | [diff] [blame] | 99 | void setAttachment(GLenum type, |
| 100 | GLenum binding, |
| 101 | const ImageIndex &textureIndex, |
| 102 | FramebufferAttachmentObject *resource); |
| 103 | void resetAttachment(GLenum binding); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 104 | |
| 105 | void detachTexture(GLuint texture); |
| 106 | void detachRenderbuffer(GLuint renderbuffer); |
| 107 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 108 | const FramebufferAttachment *getColorbuffer(size_t colorAttachment) const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 109 | const FramebufferAttachment *getDepthbuffer() const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 110 | const FramebufferAttachment *getStencilbuffer() const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 111 | const FramebufferAttachment *getDepthStencilBuffer() const; |
| 112 | const FramebufferAttachment *getDepthOrStencilbuffer() const; |
| 113 | const FramebufferAttachment *getReadColorbuffer() const; |
shannon.woods%transgaming.com@gtempaccount.com | f6863e0 | 2013-04-13 03:34:00 +0000 | [diff] [blame] | 114 | GLenum getReadColorbufferType() const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 115 | const FramebufferAttachment *getFirstColorbuffer() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 116 | |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 117 | const FramebufferAttachment *getAttachment(GLenum attachment) const; |
Geoff Lang | c90d73a | 2013-07-22 16:39:23 -0400 | [diff] [blame] | 118 | |
shannon.woods%transgaming.com@gtempaccount.com | f30ccc2 | 2013-04-13 03:28:36 +0000 | [diff] [blame] | 119 | GLenum getDrawBufferState(unsigned int colorAttachment) const; |
Geoff Lang | 164d54e | 2014-12-01 10:55:33 -0500 | [diff] [blame] | 120 | void setDrawBuffers(size_t count, const GLenum *buffers); |
shannon.woods%transgaming.com@gtempaccount.com | f30ccc2 | 2013-04-13 03:28:36 +0000 | [diff] [blame] | 121 | |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 122 | GLenum getReadBufferState() const; |
| 123 | void setReadBuffer(GLenum buffer); |
| 124 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 125 | bool isEnabledColorAttachment(size_t colorAttachment) const; |
shannon.woods%transgaming.com@gtempaccount.com | dae2409 | 2013-04-13 03:31:31 +0000 | [diff] [blame] | 126 | bool hasEnabledColorAttachment() const; |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 127 | size_t getNumColorBuffers() const; |
Jamie Madill | 0df8fe4 | 2015-11-24 16:10:24 -0500 | [diff] [blame] | 128 | bool hasDepth() const; |
shannon.woods%transgaming.com@gtempaccount.com | 3b57b4f | 2013-04-13 03:28:29 +0000 | [diff] [blame] | 129 | bool hasStencil() const; |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 130 | int getSamples(const gl::Data &data) const; |
shannonwoods@chromium.org | 24ac850 | 2013-05-30 00:01:37 +0000 | [diff] [blame] | 131 | bool usingExtendedDrawBuffers() const; |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 132 | |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 133 | GLenum checkStatus(const gl::Data &data) const; |
Jamie Madill | e92a354 | 2014-07-03 10:38:58 -0400 | [diff] [blame] | 134 | bool hasValidDepthStencil() const; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 135 | |
Austin Kinross | 0833263 | 2015-05-05 13:35:47 -0700 | [diff] [blame] | 136 | Error discard(size_t count, const GLenum *attachments); |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 137 | Error invalidate(size_t count, const GLenum *attachments); |
| 138 | Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area); |
Jamie Madill | 400a441 | 2014-08-29 15:46:45 -0400 | [diff] [blame] | 139 | |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 140 | Error clear(Context *context, GLbitfield mask); |
| 141 | Error clearBufferfv(Context *context, GLenum buffer, GLint drawbuffer, const GLfloat *values); |
| 142 | Error clearBufferuiv(Context *context, GLenum buffer, GLint drawbuffer, const GLuint *values); |
| 143 | Error clearBufferiv(Context *context, GLenum buffer, GLint drawbuffer, const GLint *values); |
| 144 | Error clearBufferfi(Context *context, |
| 145 | GLenum buffer, |
| 146 | GLint drawbuffer, |
| 147 | GLfloat depth, |
| 148 | GLint stencil); |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 149 | |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 150 | GLenum getImplementationColorReadFormat() const; |
| 151 | GLenum getImplementationColorReadType() const; |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 152 | Error readPixels(Context *context, |
| 153 | const gl::Rectangle &area, |
| 154 | GLenum format, |
| 155 | GLenum type, |
| 156 | GLvoid *pixels) const; |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 157 | |
Geoff Lang | 242468f | 2015-09-24 14:15:41 -0400 | [diff] [blame] | 158 | Error blit(Context *context, |
| 159 | const gl::Rectangle &sourceArea, |
| 160 | const gl::Rectangle &destArea, |
| 161 | GLbitfield mask, |
| 162 | GLenum filter, |
| 163 | const gl::Framebuffer *sourceFramebuffer); |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame] | 164 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 165 | protected: |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 166 | void detachResourceById(GLenum resourceType, GLuint resourceId); |
Geoff Lang | 528ce3c | 2014-12-01 10:44:07 -0500 | [diff] [blame] | 167 | |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 168 | Data mData; |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 169 | rx::FramebufferImpl *mImpl; |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 170 | GLuint mId; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 171 | }; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 172 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 175 | #endif // LIBANGLE_FRAMEBUFFER_H_ |