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 | |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 15 | #include "common/Optional.h" |
alokp@chromium.org | ea0e1af | 2010-03-22 19:33:14 +0000 | [diff] [blame] | 16 | #include "common/angleutils.h" |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 17 | #include "libANGLE/Constants.h" |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 18 | #include "libANGLE/Debug.h" |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 19 | #include "libANGLE/Error.h" |
Jamie Madill | 2d06b73 | 2015-04-20 12:53:28 -0400 | [diff] [blame] | 20 | #include "libANGLE/FramebufferAttachment.h" |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 21 | #include "libANGLE/RefCountObject.h" |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 22 | #include "libANGLE/signal_utils.h" |
Geoff Lang | 64f23f6 | 2014-09-10 14:40:12 -0400 | [diff] [blame] | 23 | |
daniel@transgaming.com | 16418b1 | 2012-11-28 19:32:22 +0000 | [diff] [blame] | 24 | namespace rx |
| 25 | { |
Jamie Madill | 7aea7e0 | 2016-05-10 10:39:45 -0400 | [diff] [blame] | 26 | class GLImplFactory; |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 27 | class FramebufferImpl; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 28 | class RenderbufferImpl; |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 29 | class SurfaceImpl; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | namespace egl |
| 33 | { |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 34 | class Display; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 35 | class Surface; |
daniel@transgaming.com | 16418b1 | 2012-11-28 19:32:22 +0000 | [diff] [blame] | 36 | } |
| 37 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 38 | namespace gl |
| 39 | { |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 40 | class Context; |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 41 | class ContextState; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 42 | class Framebuffer; |
Geoff Lang | ab75a05 | 2014-10-15 12:56:37 -0400 | [diff] [blame] | 43 | class Renderbuffer; |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 44 | class State; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 45 | class Texture; |
| 46 | class TextureCapsMap; |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 47 | class ValidationContext; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 48 | struct Caps; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 49 | struct Extensions; |
| 50 | struct ImageIndex; |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 51 | struct Rectangle; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 52 | |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 53 | class FramebufferState final : angle::NonCopyable |
| 54 | { |
| 55 | public: |
| 56 | FramebufferState(); |
| 57 | explicit FramebufferState(const Caps &caps); |
| 58 | ~FramebufferState(); |
| 59 | |
| 60 | const std::string &getLabel(); |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 61 | size_t getReadIndex() const; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 62 | |
Geoff Lang | 4b7f12b | 2016-06-21 16:47:07 -0400 | [diff] [blame] | 63 | const FramebufferAttachment *getAttachment(GLenum attachment) const; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 64 | const FramebufferAttachment *getReadAttachment() const; |
Jamie Madill | 7b57b9d | 2017-01-13 09:33:38 -0500 | [diff] [blame] | 65 | const FramebufferAttachment *getFirstNonNullAttachment() const; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 66 | const FramebufferAttachment *getFirstColorAttachment() const; |
| 67 | const FramebufferAttachment *getDepthOrStencilAttachment() const; |
Corentin Wallez | b1d0a255 | 2016-12-19 16:15:54 -0500 | [diff] [blame] | 68 | const FramebufferAttachment *getStencilOrDepthStencilAttachment() const; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 69 | const FramebufferAttachment *getColorAttachment(size_t colorAttachment) const; |
| 70 | const FramebufferAttachment *getDepthAttachment() const; |
| 71 | const FramebufferAttachment *getStencilAttachment() const; |
| 72 | const FramebufferAttachment *getDepthStencilAttachment() const; |
| 73 | |
| 74 | const std::vector<GLenum> &getDrawBufferStates() const { return mDrawBufferStates; } |
Corentin Wallez | e755774 | 2017-06-01 13:09:57 -0400 | [diff] [blame] | 75 | DrawBufferMask getEnabledDrawBuffers() const { return mEnabledDrawBuffers; } |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 76 | GLenum getReadBufferState() const { return mReadBufferState; } |
| 77 | const std::vector<FramebufferAttachment> &getColorAttachments() const |
| 78 | { |
| 79 | return mColorAttachments; |
| 80 | } |
| 81 | |
| 82 | bool attachmentsHaveSameDimensions() const; |
Geoff Lang | b21e20d | 2016-07-19 15:35:41 -0400 | [diff] [blame] | 83 | bool colorAttachmentsAreUniqueImages() const; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 84 | Box getDimensions() const; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 85 | |
Geoff Lang | 4b7f12b | 2016-06-21 16:47:07 -0400 | [diff] [blame] | 86 | const FramebufferAttachment *getDrawBuffer(size_t drawBufferIdx) const; |
| 87 | size_t getDrawBufferCount() const; |
| 88 | |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 89 | GLint getDefaultWidth() const { return mDefaultWidth; }; |
| 90 | GLint getDefaultHeight() const { return mDefaultHeight; }; |
| 91 | GLint getDefaultSamples() const { return mDefaultSamples; }; |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 92 | bool getDefaultFixedSampleLocations() const { return mDefaultFixedSampleLocations; }; |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 93 | |
Jamie Madill | 9c33586 | 2017-07-18 11:51:38 -0400 | [diff] [blame] | 94 | bool hasDepth() const; |
| 95 | bool hasStencil() const; |
| 96 | |
Martin Radev | 5c00d0d | 2017-08-07 10:06:59 +0300 | [diff] [blame] | 97 | GLenum getMultiviewLayout() const; |
| 98 | GLsizei getNumViews() const; |
| 99 | const std::vector<Offset> *getViewportOffsets() const; |
Martin Radev | 4e619f5 | 2017-08-09 11:50:06 +0300 | [diff] [blame] | 100 | GLint getBaseViewIndex() const; |
Martin Radev | 5c00d0d | 2017-08-07 10:06:59 +0300 | [diff] [blame] | 101 | |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 102 | private: |
| 103 | friend class Framebuffer; |
| 104 | |
| 105 | std::string mLabel; |
| 106 | |
| 107 | std::vector<FramebufferAttachment> mColorAttachments; |
| 108 | FramebufferAttachment mDepthAttachment; |
| 109 | FramebufferAttachment mStencilAttachment; |
| 110 | |
| 111 | std::vector<GLenum> mDrawBufferStates; |
| 112 | GLenum mReadBufferState; |
Corentin Wallez | e755774 | 2017-06-01 13:09:57 -0400 | [diff] [blame] | 113 | DrawBufferMask mEnabledDrawBuffers; |
Brandon Jones | 76746f9 | 2017-11-22 11:44:41 -0800 | [diff] [blame^] | 114 | DrawBufferTypeMask mDrawBufferTypeMask; |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 115 | |
| 116 | GLint mDefaultWidth; |
| 117 | GLint mDefaultHeight; |
| 118 | GLint mDefaultSamples; |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 119 | bool mDefaultFixedSampleLocations; |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 120 | |
| 121 | // It's necessary to store all this extra state so we can restore attachments |
| 122 | // when DEPTH_STENCIL/DEPTH/STENCIL is unbound in WebGL 1. |
| 123 | FramebufferAttachment mWebGLDepthStencilAttachment; |
| 124 | FramebufferAttachment mWebGLDepthAttachment; |
| 125 | FramebufferAttachment mWebGLStencilAttachment; |
| 126 | bool mWebGLDepthStencilConsistent; |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 127 | |
| 128 | // Tracks if we need to initialize the resources for each attachment. |
| 129 | angle::BitSet<IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS + 2> mResourceNeedsInit; |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 130 | }; |
| 131 | |
Jamie Madill | 1e5499d | 2017-04-05 11:22:16 -0400 | [diff] [blame] | 132 | class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 133 | { |
| 134 | public: |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 135 | // Constructor to build application-defined framebuffers |
Jamie Madill | 7aea7e0 | 2016-05-10 10:39:45 -0400 | [diff] [blame] | 136 | Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 137 | // Constructor to build default framebuffers for a surface |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 138 | Framebuffer(const egl::Display *display, egl::Surface *surface); |
Corentin Wallez | ccab69d | 2017-01-27 16:57:15 -0500 | [diff] [blame] | 139 | // Constructor to build a fake default framebuffer when surfaceless |
| 140 | Framebuffer(rx::GLImplFactory *factory); |
| 141 | |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 142 | ~Framebuffer() override; |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 143 | void onDestroy(const Context *context); |
Jamie Madill | 6c1f671 | 2017-02-14 19:08:04 -0500 | [diff] [blame] | 144 | void destroyDefault(const egl::Display *display); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 145 | |
Geoff Lang | 70d0f49 | 2015-12-10 17:45:46 -0500 | [diff] [blame] | 146 | void setLabel(const std::string &label) override; |
| 147 | const std::string &getLabel() const override; |
| 148 | |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 149 | rx::FramebufferImpl *getImplementation() const { return mImpl; } |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 150 | |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 151 | GLuint id() const { return mId; } |
| 152 | |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 153 | void setAttachment(const Context *context, |
| 154 | GLenum type, |
Jamie Madill | 2d06b73 | 2015-04-20 12:53:28 -0400 | [diff] [blame] | 155 | GLenum binding, |
| 156 | const ImageIndex &textureIndex, |
| 157 | FramebufferAttachmentObject *resource); |
Martin Radev | 82ef774 | 2017-08-08 17:44:58 +0300 | [diff] [blame] | 158 | void setAttachmentMultiviewLayered(const Context *context, |
| 159 | GLenum type, |
| 160 | GLenum binding, |
| 161 | const ImageIndex &textureIndex, |
| 162 | FramebufferAttachmentObject *resource, |
| 163 | GLsizei numViews, |
| 164 | GLint baseViewIndex); |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 165 | void setAttachmentMultiviewSideBySide(const Context *context, |
| 166 | GLenum type, |
| 167 | GLenum binding, |
| 168 | const ImageIndex &textureIndex, |
| 169 | FramebufferAttachmentObject *resource, |
| 170 | GLsizei numViews, |
| 171 | const GLint *viewportOffsets); |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 172 | void resetAttachment(const Context *context, GLenum binding); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 173 | |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 174 | bool detachTexture(const Context *context, GLuint texture); |
| 175 | bool detachRenderbuffer(const Context *context, GLuint renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 176 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 177 | const FramebufferAttachment *getColorbuffer(size_t colorAttachment) const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 178 | const FramebufferAttachment *getDepthbuffer() const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 179 | const FramebufferAttachment *getStencilbuffer() const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 180 | const FramebufferAttachment *getDepthStencilBuffer() const; |
| 181 | const FramebufferAttachment *getDepthOrStencilbuffer() const; |
Corentin Wallez | b1d0a255 | 2016-12-19 16:15:54 -0500 | [diff] [blame] | 182 | const FramebufferAttachment *getStencilOrDepthStencilAttachment() const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 183 | const FramebufferAttachment *getReadColorbuffer() const; |
shannon.woods%transgaming.com@gtempaccount.com | f6863e0 | 2013-04-13 03:34:00 +0000 | [diff] [blame] | 184 | GLenum getReadColorbufferType() const; |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 185 | const FramebufferAttachment *getFirstColorbuffer() const; |
Jamie Madill | 6dd06ea | 2017-07-19 13:47:55 -0400 | [diff] [blame] | 186 | const FramebufferAttachment *getFirstNonNullAttachment() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 187 | |
Jamie Madill | b6bda4a | 2015-04-20 12:53:26 -0400 | [diff] [blame] | 188 | const FramebufferAttachment *getAttachment(GLenum attachment) const; |
Martin Radev | 878c8b1 | 2017-07-28 09:51:04 +0300 | [diff] [blame] | 189 | GLenum getMultiviewLayout() const; |
Martin Radev | 14a26ae | 2017-07-24 15:56:29 +0300 | [diff] [blame] | 190 | GLsizei getNumViews() const; |
Martin Radev | 4e619f5 | 2017-08-09 11:50:06 +0300 | [diff] [blame] | 191 | GLint getBaseViewIndex() const; |
Martin Radev | 878c8b1 | 2017-07-28 09:51:04 +0300 | [diff] [blame] | 192 | const std::vector<Offset> *getViewportOffsets() const; |
Geoff Lang | c90d73a | 2013-07-22 16:39:23 -0400 | [diff] [blame] | 193 | |
Geoff Lang | a15472a | 2015-08-11 11:48:03 -0400 | [diff] [blame] | 194 | size_t getDrawbufferStateCount() const; |
| 195 | GLenum getDrawBufferState(size_t drawBuffer) const; |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame] | 196 | const std::vector<GLenum> &getDrawBufferStates() const; |
Geoff Lang | 164d54e | 2014-12-01 10:55:33 -0500 | [diff] [blame] | 197 | void setDrawBuffers(size_t count, const GLenum *buffers); |
Geoff Lang | a15472a | 2015-08-11 11:48:03 -0400 | [diff] [blame] | 198 | const FramebufferAttachment *getDrawBuffer(size_t drawBuffer) const; |
Geoff Lang | e0cff19 | 2017-05-30 13:04:56 -0400 | [diff] [blame] | 199 | GLenum getDrawbufferWriteType(size_t drawBuffer) const; |
Brandon Jones | 76746f9 | 2017-11-22 11:44:41 -0800 | [diff] [blame^] | 200 | DrawBufferTypeMask getDrawBufferTypeMask() const; |
| 201 | DrawBufferMask getDrawBufferMask() const; |
Geoff Lang | a15472a | 2015-08-11 11:48:03 -0400 | [diff] [blame] | 202 | bool hasEnabledDrawBuffer() const; |
shannon.woods%transgaming.com@gtempaccount.com | f30ccc2 | 2013-04-13 03:28:36 +0000 | [diff] [blame] | 203 | |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 204 | GLenum getReadBufferState() const; |
| 205 | void setReadBuffer(GLenum buffer); |
| 206 | |
Corentin Wallez | 37c3979 | 2015-08-20 14:19:46 -0400 | [diff] [blame] | 207 | size_t getNumColorBuffers() const; |
Jamie Madill | 0df8fe4 | 2015-11-24 16:10:24 -0500 | [diff] [blame] | 208 | bool hasDepth() const; |
shannon.woods%transgaming.com@gtempaccount.com | 3b57b4f | 2013-04-13 03:28:29 +0000 | [diff] [blame] | 209 | bool hasStencil() const; |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 210 | |
shannonwoods@chromium.org | 24ac850 | 2013-05-30 00:01:37 +0000 | [diff] [blame] | 211 | bool usingExtendedDrawBuffers() const; |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 212 | |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 213 | // This method calls checkStatus. |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 214 | int getSamples(const Context *context); |
JiangYizhou | bddc46b | 2016-12-09 09:50:51 +0800 | [diff] [blame] | 215 | |
| 216 | Error getSamplePosition(size_t index, GLfloat *xy) const; |
| 217 | |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 218 | GLint getDefaultWidth() const; |
| 219 | GLint getDefaultHeight() const; |
| 220 | GLint getDefaultSamples() const; |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 221 | bool getDefaultFixedSampleLocations() const; |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 222 | void setDefaultWidth(GLint defaultWidth); |
| 223 | void setDefaultHeight(GLint defaultHeight); |
| 224 | void setDefaultSamples(GLint defaultSamples); |
Geoff Lang | 9201943 | 2017-11-20 13:09:34 -0500 | [diff] [blame] | 225 | void setDefaultFixedSampleLocations(bool defaultFixedSampleLocations); |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 226 | |
Geoff Lang | 9aded17 | 2017-04-05 11:07:56 -0400 | [diff] [blame] | 227 | void invalidateCompletenessCache(); |
| 228 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 229 | GLenum checkStatus(const Context *context); |
| 230 | |
| 231 | // TODO(jmadill): Remove this kludge. |
| 232 | GLenum checkStatus(const ValidationContext *context); |
| 233 | int getSamples(const ValidationContext *context); |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 234 | |
Jamie Madill | 9c33586 | 2017-07-18 11:51:38 -0400 | [diff] [blame] | 235 | // For when we don't want to check completeness in getSamples(). |
| 236 | int getCachedSamples(const Context *context); |
| 237 | |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 238 | // Helper for checkStatus == GL_FRAMEBUFFER_COMPLETE. |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 239 | bool complete(const Context *context); |
| 240 | bool cachedComplete() const; |
Jamie Madill | 51f40ec | 2016-06-15 14:06:00 -0400 | [diff] [blame] | 241 | |
Jamie Madill | e92a354 | 2014-07-03 10:38:58 -0400 | [diff] [blame] | 242 | bool hasValidDepthStencil() const; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 243 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 244 | Error discard(const Context *context, size_t count, const GLenum *attachments); |
| 245 | Error invalidate(const Context *context, size_t count, const GLenum *attachments); |
| 246 | Error invalidateSub(const Context *context, |
| 247 | size_t count, |
| 248 | const GLenum *attachments, |
| 249 | const gl::Rectangle &area); |
Jamie Madill | 400a441 | 2014-08-29 15:46:45 -0400 | [diff] [blame] | 250 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 251 | Error clear(const gl::Context *context, GLbitfield mask); |
| 252 | Error clearBufferfv(const gl::Context *context, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 253 | GLenum buffer, |
| 254 | GLint drawbuffer, |
| 255 | const GLfloat *values); |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 256 | Error clearBufferuiv(const gl::Context *context, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 257 | GLenum buffer, |
| 258 | GLint drawbuffer, |
| 259 | const GLuint *values); |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 260 | Error clearBufferiv(const gl::Context *context, |
Jamie Madill | 9082b98 | 2016-04-27 15:21:51 -0400 | [diff] [blame] | 261 | GLenum buffer, |
| 262 | GLint drawbuffer, |
| 263 | const GLint *values); |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 264 | Error clearBufferfi(const gl::Context *context, |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 265 | GLenum buffer, |
| 266 | GLint drawbuffer, |
| 267 | GLfloat depth, |
| 268 | GLint stencil); |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 269 | |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 270 | GLenum getImplementationColorReadFormat(const Context *context) const; |
| 271 | GLenum getImplementationColorReadType(const Context *context) const; |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 272 | Error readPixels(const gl::Context *context, |
Jamie Madill | 1b94d43 | 2015-08-07 13:23:23 -0400 | [diff] [blame] | 273 | const gl::Rectangle &area, |
| 274 | GLenum format, |
| 275 | GLenum type, |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 276 | void *pixels); |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 277 | |
Jamie Madill | c564c07 | 2017-06-01 12:45:42 -0400 | [diff] [blame] | 278 | Error blit(const gl::Context *context, |
Jamie Madill | c29968b | 2016-01-20 11:17:23 -0500 | [diff] [blame] | 279 | const Rectangle &sourceArea, |
| 280 | const Rectangle &destArea, |
Geoff Lang | 242468f | 2015-09-24 14:15:41 -0400 | [diff] [blame] | 281 | GLbitfield mask, |
Jamie Madill | 8415b5f | 2016-04-26 13:41:39 -0400 | [diff] [blame] | 282 | GLenum filter); |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame] | 283 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 284 | enum DirtyBitType : size_t |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 285 | { |
| 286 | DIRTY_BIT_COLOR_ATTACHMENT_0, |
| 287 | DIRTY_BIT_COLOR_ATTACHMENT_MAX = |
| 288 | DIRTY_BIT_COLOR_ATTACHMENT_0 + gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS, |
| 289 | DIRTY_BIT_DEPTH_ATTACHMENT = DIRTY_BIT_COLOR_ATTACHMENT_MAX, |
| 290 | DIRTY_BIT_STENCIL_ATTACHMENT, |
| 291 | DIRTY_BIT_DRAW_BUFFERS, |
| 292 | DIRTY_BIT_READ_BUFFER, |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 293 | DIRTY_BIT_DEFAULT_WIDTH, |
| 294 | DIRTY_BIT_DEFAULT_HEIGHT, |
| 295 | DIRTY_BIT_DEFAULT_SAMPLES, |
| 296 | DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS, |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 297 | DIRTY_BIT_UNKNOWN, |
JiangYizhou | f7bbc8a | 2016-11-16 09:57:22 +0800 | [diff] [blame] | 298 | DIRTY_BIT_MAX = DIRTY_BIT_UNKNOWN |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 299 | }; |
| 300 | |
Yunchao He | 1f679cc | 2017-11-29 18:06:00 +0800 | [diff] [blame] | 301 | using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>; |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 302 | bool hasAnyDirtyBit() const { return mDirtyBits.any(); } |
| 303 | |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 304 | void syncState(const Context *context); |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 305 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 306 | // OnAttachmentChangedReceiver implementation |
| 307 | void signal(size_t dirtyBit, InitState state) override; |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 308 | |
Jamie Madill | a4595b8 | 2017-01-11 17:36:34 -0500 | [diff] [blame] | 309 | bool formsRenderingFeedbackLoopWith(const State &state) const; |
Jamie Madill | fd3dd43 | 2017-02-02 19:59:59 -0500 | [diff] [blame] | 310 | bool formsCopyingFeedbackLoopWith(GLuint copyTextureID, |
| 311 | GLint copyTextureLevel, |
| 312 | GLint copyTextureLayer) const; |
Jamie Madill | a4595b8 | 2017-01-11 17:36:34 -0500 | [diff] [blame] | 313 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 314 | Error ensureDrawAttachmentsInitialized(const Context *context); |
| 315 | Error ensureReadAttachmentInitialized(const Context *context, GLbitfield blitMask); |
| 316 | Box getDimensions() const; |
| 317 | |
Jamie Madill | 4297564 | 2017-10-12 12:31:51 -0400 | [diff] [blame] | 318 | bool hasTextureAttachment(const Texture *texture) const; |
| 319 | |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 320 | private: |
Jamie Madill | 8693bdb | 2017-09-02 15:32:14 -0400 | [diff] [blame] | 321 | bool detachResourceById(const Context *context, GLenum resourceType, GLuint resourceId); |
| 322 | bool detachMatchingAttachment(const Context *context, |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 323 | FramebufferAttachment *attachment, |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 324 | GLenum matchType, |
| 325 | GLuint matchId, |
| 326 | size_t dirtyBit); |
Jamie Madill | dd43e6c | 2017-03-24 14:18:49 -0400 | [diff] [blame] | 327 | GLenum checkStatusImpl(const Context *context); |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 328 | void setAttachment(const Context *context, |
| 329 | GLenum type, |
| 330 | GLenum binding, |
| 331 | const ImageIndex &textureIndex, |
| 332 | FramebufferAttachmentObject *resource, |
| 333 | GLsizei numViews, |
| 334 | GLuint baseViewIndex, |
| 335 | GLenum multiviewLayout, |
| 336 | const GLint *viewportOffsets); |
| 337 | void commitWebGL1DepthStencilIfConsistent(const Context *context, |
| 338 | GLsizei numViews, |
| 339 | GLuint baseViewIndex, |
| 340 | GLenum multiviewLayout, |
| 341 | const GLint *viewportOffsets); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 342 | void setAttachmentImpl(const Context *context, |
| 343 | GLenum type, |
Jamie Madill | a02315b | 2017-02-23 14:14:47 -0500 | [diff] [blame] | 344 | GLenum binding, |
| 345 | const ImageIndex &textureIndex, |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 346 | FramebufferAttachmentObject *resource, |
| 347 | GLsizei numViews, |
| 348 | GLuint baseViewIndex, |
| 349 | GLenum multiviewLayout, |
| 350 | const GLint *viewportOffsets); |
Jamie Madill | 4928b7c | 2017-06-20 12:57:39 -0400 | [diff] [blame] | 351 | void updateAttachment(const Context *context, |
| 352 | FramebufferAttachment *attachment, |
Jamie Madill | b812669 | 2017-04-05 11:22:17 -0400 | [diff] [blame] | 353 | size_t dirtyBit, |
| 354 | OnAttachmentDirtyBinding *onDirtyBinding, |
| 355 | GLenum type, |
| 356 | GLenum binding, |
| 357 | const ImageIndex &textureIndex, |
Martin Radev | 5dae57b | 2017-07-14 16:15:55 +0300 | [diff] [blame] | 358 | FramebufferAttachmentObject *resource, |
| 359 | GLsizei numViews, |
| 360 | GLuint baseViewIndex, |
| 361 | GLenum multiviewLayout, |
| 362 | const GLint *viewportOffsets); |
Geoff Lang | 528ce3c | 2014-12-01 10:44:07 -0500 | [diff] [blame] | 363 | |
Jamie Madill | 05b35b2 | 2017-10-03 09:01:44 -0400 | [diff] [blame] | 364 | void markDrawAttachmentsInitialized(bool color, bool depth, bool stencil); |
| 365 | void markBufferInitialized(GLenum bufferType, GLint bufferIndex); |
| 366 | Error ensureBufferInitialized(const Context *context, GLenum bufferType, GLint bufferIndex); |
| 367 | |
| 368 | // Checks that we have a partially masked clear: |
| 369 | // * some color channels are masked out |
| 370 | // * some stencil values are masked out |
| 371 | // * scissor test partially overlaps the framebuffer |
| 372 | bool partialClearNeedsInit(const Context *context, bool color, bool depth, bool stencil); |
| 373 | bool partialBufferClearNeedsInit(const Context *context, GLenum bufferType); |
| 374 | |
Jamie Madill | 48ef11b | 2016-04-27 15:21:52 -0400 | [diff] [blame] | 375 | FramebufferState mState; |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 376 | rx::FramebufferImpl *mImpl; |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 377 | GLuint mId; |
Jamie Madill | 60ec6ea | 2016-01-22 15:27:19 -0500 | [diff] [blame] | 378 | |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 379 | Optional<GLenum> mCachedStatus; |
Jamie Madill | 1e5499d | 2017-04-05 11:22:16 -0400 | [diff] [blame] | 380 | std::vector<OnAttachmentDirtyBinding> mDirtyColorAttachmentBindings; |
| 381 | OnAttachmentDirtyBinding mDirtyDepthAttachmentBinding; |
| 382 | OnAttachmentDirtyBinding mDirtyStencilAttachmentBinding; |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 383 | |
| 384 | DirtyBits mDirtyBits; |
Jamie Madill | 4297564 | 2017-10-12 12:31:51 -0400 | [diff] [blame] | 385 | |
| 386 | // A cache of attached textures for quick validation of feedback loops. |
| 387 | mutable Optional<std::set<const FramebufferAttachmentObject *>> mAttachedTextures; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 388 | }; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 389 | |
Jamie Madill | 362876b | 2016-06-16 14:46:59 -0400 | [diff] [blame] | 390 | } // namespace gl |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 391 | |
Jamie Madill | 231c7f5 | 2017-04-26 13:45:37 -0400 | [diff] [blame] | 392 | #endif // LIBANGLE_FRAMEBUFFER_H_ |