blob: cd1b28b5cfa6df846f8023f39dd0ca4825bf6e65 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +00002// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// 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 Lang0a73dd82014-11-19 16:18:08 -050010#ifndef LIBANGLE_FRAMEBUFFER_H_
11#define LIBANGLE_FRAMEBUFFER_H_
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000012
Jamie Madill7147f012015-03-05 15:41:40 -050013#include <vector>
Jamie Madillce20c7f2014-09-03 11:56:29 -040014
Jamie Madill362876b2016-06-16 14:46:59 -040015#include "common/Optional.h"
alokp@chromium.orgea0e1af2010-03-22 19:33:14 +000016#include "common/angleutils.h"
Jamie Madill7147f012015-03-05 15:41:40 -050017#include "libANGLE/Constants.h"
Geoff Lang70d0f492015-12-10 17:45:46 -050018#include "libANGLE/Debug.h"
Jamie Madill7147f012015-03-05 15:41:40 -050019#include "libANGLE/Error.h"
Jamie Madill2d06b732015-04-20 12:53:28 -040020#include "libANGLE/FramebufferAttachment.h"
Jamie Madill7147f012015-03-05 15:41:40 -050021#include "libANGLE/RefCountObject.h"
Jamie Madill362876b2016-06-16 14:46:59 -040022#include "libANGLE/signal_utils.h"
Geoff Lang64f23f62014-09-10 14:40:12 -040023
daniel@transgaming.com16418b12012-11-28 19:32:22 +000024namespace rx
25{
Jamie Madill7aea7e02016-05-10 10:39:45 -040026class GLImplFactory;
Geoff Langda88add2014-12-01 10:22:01 -050027class FramebufferImpl;
Jamie Madilld1405e52015-03-05 15:41:39 -050028class RenderbufferImpl;
Corentin Wallez37c39792015-08-20 14:19:46 -040029class SurfaceImpl;
Jamie Madilld1405e52015-03-05 15:41:39 -050030}
31
32namespace egl
33{
Jamie Madill6c1f6712017-02-14 19:08:04 -050034class Display;
Jamie Madilld1405e52015-03-05 15:41:39 -050035class Surface;
daniel@transgaming.com16418b12012-11-28 19:32:22 +000036}
37
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000038namespace gl
39{
Jamie Madill1b94d432015-08-07 13:23:23 -040040class Context;
Jamie Madilldd43e6c2017-03-24 14:18:49 -040041class ContextState;
Jamie Madill48ef11b2016-04-27 15:21:52 -040042class Framebuffer;
Geoff Langab75a052014-10-15 12:56:37 -040043class Renderbuffer;
Geoff Langb04dc822014-12-01 12:02:02 -050044class State;
Jamie Madilld1405e52015-03-05 15:41:39 -050045class Texture;
46class TextureCapsMap;
Jamie Madilldd43e6c2017-03-24 14:18:49 -040047class ValidationContext;
Jamie Madilld1405e52015-03-05 15:41:39 -050048struct Caps;
Jamie Madilld1405e52015-03-05 15:41:39 -050049struct Extensions;
50struct ImageIndex;
Geoff Lang9ad4bda2014-12-01 11:03:09 -050051struct Rectangle;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052
Jamie Madill48ef11b2016-04-27 15:21:52 -040053class FramebufferState final : angle::NonCopyable
54{
55 public:
56 FramebufferState();
57 explicit FramebufferState(const Caps &caps);
58 ~FramebufferState();
59
60 const std::string &getLabel();
Jamie Madill05b35b22017-10-03 09:01:44 -040061 size_t getReadIndex() const;
Jamie Madill48ef11b2016-04-27 15:21:52 -040062
Geoff Lang4b7f12b2016-06-21 16:47:07 -040063 const FramebufferAttachment *getAttachment(GLenum attachment) const;
Jamie Madill48ef11b2016-04-27 15:21:52 -040064 const FramebufferAttachment *getReadAttachment() const;
Jamie Madill7b57b9d2017-01-13 09:33:38 -050065 const FramebufferAttachment *getFirstNonNullAttachment() const;
Jamie Madill48ef11b2016-04-27 15:21:52 -040066 const FramebufferAttachment *getFirstColorAttachment() const;
67 const FramebufferAttachment *getDepthOrStencilAttachment() const;
Corentin Wallezb1d0a2552016-12-19 16:15:54 -050068 const FramebufferAttachment *getStencilOrDepthStencilAttachment() const;
Jamie Madill48ef11b2016-04-27 15:21:52 -040069 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 Walleze7557742017-06-01 13:09:57 -040075 DrawBufferMask getEnabledDrawBuffers() const { return mEnabledDrawBuffers; }
Jamie Madill48ef11b2016-04-27 15:21:52 -040076 GLenum getReadBufferState() const { return mReadBufferState; }
77 const std::vector<FramebufferAttachment> &getColorAttachments() const
78 {
79 return mColorAttachments;
80 }
81
82 bool attachmentsHaveSameDimensions() const;
Geoff Langb21e20d2016-07-19 15:35:41 -040083 bool colorAttachmentsAreUniqueImages() const;
Jamie Madill05b35b22017-10-03 09:01:44 -040084 Box getDimensions() const;
Jamie Madill48ef11b2016-04-27 15:21:52 -040085
Geoff Lang4b7f12b2016-06-21 16:47:07 -040086 const FramebufferAttachment *getDrawBuffer(size_t drawBufferIdx) const;
87 size_t getDrawBufferCount() const;
88
JiangYizhouf7bbc8a2016-11-16 09:57:22 +080089 GLint getDefaultWidth() const { return mDefaultWidth; };
90 GLint getDefaultHeight() const { return mDefaultHeight; };
91 GLint getDefaultSamples() const { return mDefaultSamples; };
Geoff Lang92019432017-11-20 13:09:34 -050092 bool getDefaultFixedSampleLocations() const { return mDefaultFixedSampleLocations; };
JiangYizhouf7bbc8a2016-11-16 09:57:22 +080093
Jamie Madill9c335862017-07-18 11:51:38 -040094 bool hasDepth() const;
95 bool hasStencil() const;
96
Martin Radev5c00d0d2017-08-07 10:06:59 +030097 GLenum getMultiviewLayout() const;
98 GLsizei getNumViews() const;
99 const std::vector<Offset> *getViewportOffsets() const;
Martin Radev4e619f52017-08-09 11:50:06 +0300100 GLint getBaseViewIndex() const;
Martin Radev5c00d0d2017-08-07 10:06:59 +0300101
Jamie Madill48ef11b2016-04-27 15:21:52 -0400102 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 Walleze7557742017-06-01 13:09:57 -0400113 DrawBufferMask mEnabledDrawBuffers;
JiangYizhouf7bbc8a2016-11-16 09:57:22 +0800114
115 GLint mDefaultWidth;
116 GLint mDefaultHeight;
117 GLint mDefaultSamples;
Geoff Lang92019432017-11-20 13:09:34 -0500118 bool mDefaultFixedSampleLocations;
Jamie Madilla02315b2017-02-23 14:14:47 -0500119
120 // It's necessary to store all this extra state so we can restore attachments
121 // when DEPTH_STENCIL/DEPTH/STENCIL is unbound in WebGL 1.
122 FramebufferAttachment mWebGLDepthStencilAttachment;
123 FramebufferAttachment mWebGLDepthAttachment;
124 FramebufferAttachment mWebGLStencilAttachment;
125 bool mWebGLDepthStencilConsistent;
Jamie Madill05b35b22017-10-03 09:01:44 -0400126
127 // Tracks if we need to initialize the resources for each attachment.
128 angle::BitSet<IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS + 2> mResourceNeedsInit;
Jamie Madill48ef11b2016-04-27 15:21:52 -0400129};
130
Jamie Madill1e5499d2017-04-05 11:22:16 -0400131class Framebuffer final : public LabeledObject, public OnAttachmentDirtyReceiver
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000132{
133 public:
Corentin Wallezccab69d2017-01-27 16:57:15 -0500134 // Constructor to build application-defined framebuffers
Jamie Madill7aea7e02016-05-10 10:39:45 -0400135 Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id);
Corentin Wallezccab69d2017-01-27 16:57:15 -0500136 // Constructor to build default framebuffers for a surface
Jamie Madill4928b7c2017-06-20 12:57:39 -0400137 Framebuffer(const egl::Display *display, egl::Surface *surface);
Corentin Wallezccab69d2017-01-27 16:57:15 -0500138 // Constructor to build a fake default framebuffer when surfaceless
139 Framebuffer(rx::GLImplFactory *factory);
140
Jamie Madillacf2f3a2017-11-21 19:22:44 -0500141 ~Framebuffer() override;
Jamie Madill4928b7c2017-06-20 12:57:39 -0400142 void onDestroy(const Context *context);
Jamie Madill6c1f6712017-02-14 19:08:04 -0500143 void destroyDefault(const egl::Display *display);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000144
Geoff Lang70d0f492015-12-10 17:45:46 -0500145 void setLabel(const std::string &label) override;
146 const std::string &getLabel() const override;
147
Jamie Madill51f40ec2016-06-15 14:06:00 -0400148 rx::FramebufferImpl *getImplementation() const { return mImpl; }
Geoff Langda88add2014-12-01 10:22:01 -0500149
Shannon Woodsaa2ab7d2014-06-24 17:51:51 -0400150 GLuint id() const { return mId; }
151
Jamie Madilla02315b2017-02-23 14:14:47 -0500152 void setAttachment(const Context *context,
153 GLenum type,
Jamie Madill2d06b732015-04-20 12:53:28 -0400154 GLenum binding,
155 const ImageIndex &textureIndex,
156 FramebufferAttachmentObject *resource);
Martin Radev82ef7742017-08-08 17:44:58 +0300157 void setAttachmentMultiviewLayered(const Context *context,
158 GLenum type,
159 GLenum binding,
160 const ImageIndex &textureIndex,
161 FramebufferAttachmentObject *resource,
162 GLsizei numViews,
163 GLint baseViewIndex);
Martin Radev5dae57b2017-07-14 16:15:55 +0300164 void setAttachmentMultiviewSideBySide(const Context *context,
165 GLenum type,
166 GLenum binding,
167 const ImageIndex &textureIndex,
168 FramebufferAttachmentObject *resource,
169 GLsizei numViews,
170 const GLint *viewportOffsets);
Jamie Madilla02315b2017-02-23 14:14:47 -0500171 void resetAttachment(const Context *context, GLenum binding);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000172
Jamie Madill8693bdb2017-09-02 15:32:14 -0400173 bool detachTexture(const Context *context, GLuint texture);
174 bool detachRenderbuffer(const Context *context, GLuint renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000175
Corentin Wallez37c39792015-08-20 14:19:46 -0400176 const FramebufferAttachment *getColorbuffer(size_t colorAttachment) const;
Jamie Madillb6bda4a2015-04-20 12:53:26 -0400177 const FramebufferAttachment *getDepthbuffer() const;
Jamie Madillb6bda4a2015-04-20 12:53:26 -0400178 const FramebufferAttachment *getStencilbuffer() const;
Jamie Madillb6bda4a2015-04-20 12:53:26 -0400179 const FramebufferAttachment *getDepthStencilBuffer() const;
180 const FramebufferAttachment *getDepthOrStencilbuffer() const;
Corentin Wallezb1d0a2552016-12-19 16:15:54 -0500181 const FramebufferAttachment *getStencilOrDepthStencilAttachment() const;
Jamie Madillb6bda4a2015-04-20 12:53:26 -0400182 const FramebufferAttachment *getReadColorbuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf6863e02013-04-13 03:34:00 +0000183 GLenum getReadColorbufferType() const;
Jamie Madillb6bda4a2015-04-20 12:53:26 -0400184 const FramebufferAttachment *getFirstColorbuffer() const;
Jamie Madill6dd06ea2017-07-19 13:47:55 -0400185 const FramebufferAttachment *getFirstNonNullAttachment() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000186
Jamie Madillb6bda4a2015-04-20 12:53:26 -0400187 const FramebufferAttachment *getAttachment(GLenum attachment) const;
Martin Radev878c8b12017-07-28 09:51:04 +0300188 GLenum getMultiviewLayout() const;
Martin Radev14a26ae2017-07-24 15:56:29 +0300189 GLsizei getNumViews() const;
Martin Radev4e619f52017-08-09 11:50:06 +0300190 GLint getBaseViewIndex() const;
Martin Radev878c8b12017-07-28 09:51:04 +0300191 const std::vector<Offset> *getViewportOffsets() const;
Geoff Langc90d73a2013-07-22 16:39:23 -0400192
Geoff Langa15472a2015-08-11 11:48:03 -0400193 size_t getDrawbufferStateCount() const;
194 GLenum getDrawBufferState(size_t drawBuffer) const;
Jamie Madill1fbc59f2016-02-24 15:25:51 -0500195 const std::vector<GLenum> &getDrawBufferStates() const;
Geoff Lang164d54e2014-12-01 10:55:33 -0500196 void setDrawBuffers(size_t count, const GLenum *buffers);
Geoff Langa15472a2015-08-11 11:48:03 -0400197 const FramebufferAttachment *getDrawBuffer(size_t drawBuffer) const;
Geoff Lange0cff192017-05-30 13:04:56 -0400198 GLenum getDrawbufferWriteType(size_t drawBuffer) const;
Geoff Langa15472a2015-08-11 11:48:03 -0400199 bool hasEnabledDrawBuffer() const;
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +0000200
Geoff Lang9dd95802014-12-01 11:12:59 -0500201 GLenum getReadBufferState() const;
202 void setReadBuffer(GLenum buffer);
203
Corentin Wallez37c39792015-08-20 14:19:46 -0400204 size_t getNumColorBuffers() const;
Jamie Madill0df8fe42015-11-24 16:10:24 -0500205 bool hasDepth() const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +0000206 bool hasStencil() const;
Jamie Madill51f40ec2016-06-15 14:06:00 -0400207
shannonwoods@chromium.org24ac8502013-05-30 00:01:37 +0000208 bool usingExtendedDrawBuffers() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +0000209
Jamie Madill51f40ec2016-06-15 14:06:00 -0400210 // This method calls checkStatus.
Jamie Madilldd43e6c2017-03-24 14:18:49 -0400211 int getSamples(const Context *context);
JiangYizhoubddc46b2016-12-09 09:50:51 +0800212
213 Error getSamplePosition(size_t index, GLfloat *xy) const;
214
JiangYizhouf7bbc8a2016-11-16 09:57:22 +0800215 GLint getDefaultWidth() const;
216 GLint getDefaultHeight() const;
217 GLint getDefaultSamples() const;
Geoff Lang92019432017-11-20 13:09:34 -0500218 bool getDefaultFixedSampleLocations() const;
JiangYizhouf7bbc8a2016-11-16 09:57:22 +0800219 void setDefaultWidth(GLint defaultWidth);
220 void setDefaultHeight(GLint defaultHeight);
221 void setDefaultSamples(GLint defaultSamples);
Geoff Lang92019432017-11-20 13:09:34 -0500222 void setDefaultFixedSampleLocations(bool defaultFixedSampleLocations);
JiangYizhouf7bbc8a2016-11-16 09:57:22 +0800223
Geoff Lang9aded172017-04-05 11:07:56 -0400224 void invalidateCompletenessCache();
225
Jamie Madilldd43e6c2017-03-24 14:18:49 -0400226 GLenum checkStatus(const Context *context);
227
228 // TODO(jmadill): Remove this kludge.
229 GLenum checkStatus(const ValidationContext *context);
230 int getSamples(const ValidationContext *context);
Jamie Madill51f40ec2016-06-15 14:06:00 -0400231
Jamie Madill9c335862017-07-18 11:51:38 -0400232 // For when we don't want to check completeness in getSamples().
233 int getCachedSamples(const Context *context);
234
Jamie Madill362876b2016-06-16 14:46:59 -0400235 // Helper for checkStatus == GL_FRAMEBUFFER_COMPLETE.
Jamie Madilldd43e6c2017-03-24 14:18:49 -0400236 bool complete(const Context *context);
237 bool cachedComplete() const;
Jamie Madill51f40ec2016-06-15 14:06:00 -0400238
Jamie Madille92a3542014-07-03 10:38:58 -0400239 bool hasValidDepthStencil() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000240
Jamie Madill4928b7c2017-06-20 12:57:39 -0400241 Error discard(const Context *context, size_t count, const GLenum *attachments);
242 Error invalidate(const Context *context, size_t count, const GLenum *attachments);
243 Error invalidateSub(const Context *context,
244 size_t count,
245 const GLenum *attachments,
246 const gl::Rectangle &area);
Jamie Madill400a4412014-08-29 15:46:45 -0400247
Jamie Madillc564c072017-06-01 12:45:42 -0400248 Error clear(const gl::Context *context, GLbitfield mask);
249 Error clearBufferfv(const gl::Context *context,
Jamie Madillc29968b2016-01-20 11:17:23 -0500250 GLenum buffer,
251 GLint drawbuffer,
252 const GLfloat *values);
Jamie Madillc564c072017-06-01 12:45:42 -0400253 Error clearBufferuiv(const gl::Context *context,
Jamie Madillc29968b2016-01-20 11:17:23 -0500254 GLenum buffer,
255 GLint drawbuffer,
256 const GLuint *values);
Jamie Madillc564c072017-06-01 12:45:42 -0400257 Error clearBufferiv(const gl::Context *context,
Jamie Madill9082b982016-04-27 15:21:51 -0400258 GLenum buffer,
259 GLint drawbuffer,
260 const GLint *values);
Jamie Madillc564c072017-06-01 12:45:42 -0400261 Error clearBufferfi(const gl::Context *context,
Jamie Madill1b94d432015-08-07 13:23:23 -0400262 GLenum buffer,
263 GLint drawbuffer,
264 GLfloat depth,
265 GLint stencil);
Geoff Langb04dc822014-12-01 12:02:02 -0500266
Jamie Madill4928b7c2017-06-20 12:57:39 -0400267 GLenum getImplementationColorReadFormat(const Context *context) const;
268 GLenum getImplementationColorReadType(const Context *context) const;
Jamie Madillc564c072017-06-01 12:45:42 -0400269 Error readPixels(const gl::Context *context,
Jamie Madill1b94d432015-08-07 13:23:23 -0400270 const gl::Rectangle &area,
271 GLenum format,
272 GLenum type,
Jamie Madill05b35b22017-10-03 09:01:44 -0400273 void *pixels);
Geoff Langbce529e2014-12-01 12:48:41 -0500274
Jamie Madillc564c072017-06-01 12:45:42 -0400275 Error blit(const gl::Context *context,
Jamie Madillc29968b2016-01-20 11:17:23 -0500276 const Rectangle &sourceArea,
277 const Rectangle &destArea,
Geoff Lang242468f2015-09-24 14:15:41 -0400278 GLbitfield mask,
Jamie Madill8415b5f2016-04-26 13:41:39 -0400279 GLenum filter);
Geoff Lang54bd5a42014-12-01 12:51:04 -0500280
Jamie Madill05b35b22017-10-03 09:01:44 -0400281 enum DirtyBitType : size_t
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500282 {
283 DIRTY_BIT_COLOR_ATTACHMENT_0,
284 DIRTY_BIT_COLOR_ATTACHMENT_MAX =
285 DIRTY_BIT_COLOR_ATTACHMENT_0 + gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS,
286 DIRTY_BIT_DEPTH_ATTACHMENT = DIRTY_BIT_COLOR_ATTACHMENT_MAX,
287 DIRTY_BIT_STENCIL_ATTACHMENT,
288 DIRTY_BIT_DRAW_BUFFERS,
289 DIRTY_BIT_READ_BUFFER,
JiangYizhouf7bbc8a2016-11-16 09:57:22 +0800290 DIRTY_BIT_DEFAULT_WIDTH,
291 DIRTY_BIT_DEFAULT_HEIGHT,
292 DIRTY_BIT_DEFAULT_SAMPLES,
293 DIRTY_BIT_DEFAULT_FIXED_SAMPLE_LOCATIONS,
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500294 DIRTY_BIT_UNKNOWN,
JiangYizhouf7bbc8a2016-11-16 09:57:22 +0800295 DIRTY_BIT_MAX = DIRTY_BIT_UNKNOWN
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500296 };
297
Yunchao He1f679cc2017-11-29 18:06:00 +0800298 using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>;
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500299 bool hasAnyDirtyBit() const { return mDirtyBits.any(); }
300
Jamie Madilldd43e6c2017-03-24 14:18:49 -0400301 void syncState(const Context *context);
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500302
Jamie Madill05b35b22017-10-03 09:01:44 -0400303 // OnAttachmentChangedReceiver implementation
304 void signal(size_t dirtyBit, InitState state) override;
Jamie Madill362876b2016-06-16 14:46:59 -0400305
Jamie Madilla4595b82017-01-11 17:36:34 -0500306 bool formsRenderingFeedbackLoopWith(const State &state) const;
Jamie Madillfd3dd432017-02-02 19:59:59 -0500307 bool formsCopyingFeedbackLoopWith(GLuint copyTextureID,
308 GLint copyTextureLevel,
309 GLint copyTextureLayer) const;
Jamie Madilla4595b82017-01-11 17:36:34 -0500310
Jamie Madill05b35b22017-10-03 09:01:44 -0400311 Error ensureDrawAttachmentsInitialized(const Context *context);
312 Error ensureReadAttachmentInitialized(const Context *context, GLbitfield blitMask);
313 Box getDimensions() const;
314
Jamie Madill42975642017-10-12 12:31:51 -0400315 bool hasTextureAttachment(const Texture *texture) const;
316
Jamie Madill362876b2016-06-16 14:46:59 -0400317 private:
Jamie Madill8693bdb2017-09-02 15:32:14 -0400318 bool detachResourceById(const Context *context, GLenum resourceType, GLuint resourceId);
319 bool detachMatchingAttachment(const Context *context,
Jamie Madill4928b7c2017-06-20 12:57:39 -0400320 FramebufferAttachment *attachment,
Jamie Madill362876b2016-06-16 14:46:59 -0400321 GLenum matchType,
322 GLuint matchId,
323 size_t dirtyBit);
Jamie Madilldd43e6c2017-03-24 14:18:49 -0400324 GLenum checkStatusImpl(const Context *context);
Martin Radev5dae57b2017-07-14 16:15:55 +0300325 void setAttachment(const Context *context,
326 GLenum type,
327 GLenum binding,
328 const ImageIndex &textureIndex,
329 FramebufferAttachmentObject *resource,
330 GLsizei numViews,
331 GLuint baseViewIndex,
332 GLenum multiviewLayout,
333 const GLint *viewportOffsets);
334 void commitWebGL1DepthStencilIfConsistent(const Context *context,
335 GLsizei numViews,
336 GLuint baseViewIndex,
337 GLenum multiviewLayout,
338 const GLint *viewportOffsets);
Jamie Madill4928b7c2017-06-20 12:57:39 -0400339 void setAttachmentImpl(const Context *context,
340 GLenum type,
Jamie Madilla02315b2017-02-23 14:14:47 -0500341 GLenum binding,
342 const ImageIndex &textureIndex,
Martin Radev5dae57b2017-07-14 16:15:55 +0300343 FramebufferAttachmentObject *resource,
344 GLsizei numViews,
345 GLuint baseViewIndex,
346 GLenum multiviewLayout,
347 const GLint *viewportOffsets);
Jamie Madill4928b7c2017-06-20 12:57:39 -0400348 void updateAttachment(const Context *context,
349 FramebufferAttachment *attachment,
Jamie Madillb8126692017-04-05 11:22:17 -0400350 size_t dirtyBit,
351 OnAttachmentDirtyBinding *onDirtyBinding,
352 GLenum type,
353 GLenum binding,
354 const ImageIndex &textureIndex,
Martin Radev5dae57b2017-07-14 16:15:55 +0300355 FramebufferAttachmentObject *resource,
356 GLsizei numViews,
357 GLuint baseViewIndex,
358 GLenum multiviewLayout,
359 const GLint *viewportOffsets);
Geoff Lang528ce3c2014-12-01 10:44:07 -0500360
Jamie Madill05b35b22017-10-03 09:01:44 -0400361 void markDrawAttachmentsInitialized(bool color, bool depth, bool stencil);
362 void markBufferInitialized(GLenum bufferType, GLint bufferIndex);
363 Error ensureBufferInitialized(const Context *context, GLenum bufferType, GLint bufferIndex);
364
365 // Checks that we have a partially masked clear:
366 // * some color channels are masked out
367 // * some stencil values are masked out
368 // * scissor test partially overlaps the framebuffer
369 bool partialClearNeedsInit(const Context *context, bool color, bool depth, bool stencil);
370 bool partialBufferClearNeedsInit(const Context *context, GLenum bufferType);
371
Jamie Madill48ef11b2016-04-27 15:21:52 -0400372 FramebufferState mState;
Geoff Langda88add2014-12-01 10:22:01 -0500373 rx::FramebufferImpl *mImpl;
Shannon Woodsaa2ab7d2014-06-24 17:51:51 -0400374 GLuint mId;
Jamie Madill60ec6ea2016-01-22 15:27:19 -0500375
Jamie Madill362876b2016-06-16 14:46:59 -0400376 Optional<GLenum> mCachedStatus;
Jamie Madill1e5499d2017-04-05 11:22:16 -0400377 std::vector<OnAttachmentDirtyBinding> mDirtyColorAttachmentBindings;
378 OnAttachmentDirtyBinding mDirtyDepthAttachmentBinding;
379 OnAttachmentDirtyBinding mDirtyStencilAttachmentBinding;
Jamie Madill362876b2016-06-16 14:46:59 -0400380
381 DirtyBits mDirtyBits;
Jamie Madill42975642017-10-12 12:31:51 -0400382
383 // A cache of attached textures for quick validation of feedback loops.
384 mutable Optional<std::set<const FramebufferAttachmentObject *>> mAttachedTextures;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000385};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000386
Jamie Madill362876b2016-06-16 14:46:59 -0400387} // namespace gl
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000388
Jamie Madill231c7f52017-04-26 13:45:37 -0400389#endif // LIBANGLE_FRAMEBUFFER_H_