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" |
| 17 | #include "libANGLE/Error.h" |
| 18 | #include "libANGLE/RefCountObject.h" |
Geoff Lang | 64f23f6 | 2014-09-10 14:40:12 -0400 | [diff] [blame] | 19 | |
daniel@transgaming.com | 16418b1 | 2012-11-28 19:32:22 +0000 | [diff] [blame] | 20 | namespace rx |
| 21 | { |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 22 | class DefaultAttachmentImpl; |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 23 | class FramebufferImpl; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 24 | class RenderbufferImpl; |
| 25 | class Renderer; |
| 26 | struct Workarounds; |
| 27 | } |
| 28 | |
| 29 | namespace egl |
| 30 | { |
| 31 | class Surface; |
daniel@transgaming.com | 16418b1 | 2012-11-28 19:32:22 +0000 | [diff] [blame] | 32 | } |
| 33 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 34 | namespace gl |
| 35 | { |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 36 | class FramebufferAttachment; |
Geoff Lang | ab75a05 | 2014-10-15 12:56:37 -0400 | [diff] [blame] | 37 | class Renderbuffer; |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 38 | class State; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 39 | class Texture; |
| 40 | class TextureCapsMap; |
| 41 | struct Caps; |
| 42 | struct Data; |
| 43 | struct Extensions; |
| 44 | struct ImageIndex; |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 45 | struct Rectangle; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 46 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 47 | typedef std::vector<FramebufferAttachment *> AttachmentList; |
Jamie Madill | ce20c7f | 2014-09-03 11:56:29 -0400 | [diff] [blame] | 48 | |
Geoff Lang | 9d9132d | 2014-12-03 14:46:48 -0500 | [diff] [blame] | 49 | class Framebuffer |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 50 | { |
| 51 | public: |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 52 | |
| 53 | class Data final |
| 54 | { |
| 55 | public: |
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 | |
Jamie Madill | 7147f01 | 2015-03-05 15:41:40 -0500 | [diff] [blame] | 59 | FramebufferAttachment *getReadAttachment() const; |
| 60 | FramebufferAttachment *getFirstColorAttachment() const; |
| 61 | FramebufferAttachment *getDepthOrStencilAttachment() const; |
| 62 | |
| 63 | AttachmentList mColorAttachments; |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 64 | FramebufferAttachment *mDepthAttachment; |
| 65 | FramebufferAttachment *mStencilAttachment; |
| 66 | |
| 67 | std::vector<GLenum> mDrawBufferStates; |
| 68 | GLenum mReadBufferState; |
| 69 | |
| 70 | private: |
| 71 | DISALLOW_COPY_AND_ASSIGN(Data); |
| 72 | }; |
| 73 | |
| 74 | Framebuffer(const Caps &caps, rx::Renderer *renderer, GLuint id); |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 75 | virtual ~Framebuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 76 | |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 77 | const rx::FramebufferImpl *getImplementation() const { return mImpl; } |
| 78 | rx::FramebufferImpl *getImplementation() { return mImpl; } |
| 79 | |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 80 | GLuint id() const { return mId; } |
| 81 | |
Geoff Lang | ab75a05 | 2014-10-15 12:56:37 -0400 | [diff] [blame] | 82 | void setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex); |
| 83 | void setRenderbufferAttachment(GLenum attachment, Renderbuffer *renderbuffer); |
| 84 | void setNULLAttachment(GLenum attachment); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 85 | |
| 86 | void detachTexture(GLuint texture); |
| 87 | void detachRenderbuffer(GLuint renderbuffer); |
| 88 | |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 89 | FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const; |
| 90 | FramebufferAttachment *getDepthbuffer() const; |
| 91 | FramebufferAttachment *getStencilbuffer() const; |
| 92 | FramebufferAttachment *getDepthStencilBuffer() const; |
| 93 | FramebufferAttachment *getDepthOrStencilbuffer() const; |
| 94 | FramebufferAttachment *getReadColorbuffer() const; |
shannon.woods%transgaming.com@gtempaccount.com | f6863e0 | 2013-04-13 03:34:00 +0000 | [diff] [blame] | 95 | GLenum getReadColorbufferType() const; |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 96 | FramebufferAttachment *getFirstColorbuffer() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 97 | |
Geoff Lang | 528ce3c | 2014-12-01 10:44:07 -0500 | [diff] [blame] | 98 | FramebufferAttachment *getAttachment(GLenum attachment) const; |
Geoff Lang | c90d73a | 2013-07-22 16:39:23 -0400 | [diff] [blame] | 99 | |
shannon.woods%transgaming.com@gtempaccount.com | f30ccc2 | 2013-04-13 03:28:36 +0000 | [diff] [blame] | 100 | GLenum getDrawBufferState(unsigned int colorAttachment) const; |
Geoff Lang | 164d54e | 2014-12-01 10:55:33 -0500 | [diff] [blame] | 101 | void setDrawBuffers(size_t count, const GLenum *buffers); |
shannon.woods%transgaming.com@gtempaccount.com | f30ccc2 | 2013-04-13 03:28:36 +0000 | [diff] [blame] | 102 | |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 103 | GLenum getReadBufferState() const; |
| 104 | void setReadBuffer(GLenum buffer); |
| 105 | |
shannon.woods%transgaming.com@gtempaccount.com | dae2409 | 2013-04-13 03:31:31 +0000 | [diff] [blame] | 106 | bool isEnabledColorAttachment(unsigned int colorAttachment) const; |
| 107 | bool hasEnabledColorAttachment() const; |
shannon.woods%transgaming.com@gtempaccount.com | 3b57b4f | 2013-04-13 03:28:29 +0000 | [diff] [blame] | 108 | bool hasStencil() const; |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 109 | int getSamples(const gl::Data &data) const; |
shannonwoods@chromium.org | 24ac850 | 2013-05-30 00:01:37 +0000 | [diff] [blame] | 110 | bool usingExtendedDrawBuffers() const; |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 111 | |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 112 | GLenum checkStatus(const gl::Data &data) const; |
Jamie Madill | e92a354 | 2014-07-03 10:38:58 -0400 | [diff] [blame] | 113 | bool hasValidDepthStencil() const; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 114 | |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 115 | Error invalidate(size_t count, const GLenum *attachments); |
| 116 | Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area); |
Jamie Madill | 400a441 | 2014-08-29 15:46:45 -0400 | [diff] [blame] | 117 | |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 118 | Error clear(const State &state, GLbitfield mask); |
| 119 | Error clearBufferfv(const State &state, GLenum buffer, GLint drawbuffer, const GLfloat *values); |
| 120 | Error clearBufferuiv(const State &state, GLenum buffer, GLint drawbuffer, const GLuint *values); |
| 121 | Error clearBufferiv(const State &state, GLenum buffer, GLint drawbuffer, const GLint *values); |
| 122 | Error clearBufferfi(const State &state, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); |
| 123 | |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 124 | GLenum getImplementationColorReadFormat() const; |
| 125 | GLenum getImplementationColorReadType() const; |
| 126 | Error readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const; |
| 127 | |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame] | 128 | Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, |
| 129 | GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer); |
| 130 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 131 | protected: |
Geoff Lang | 528ce3c | 2014-12-01 10:44:07 -0500 | [diff] [blame] | 132 | void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj); |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 133 | void detachResourceById(GLenum resourceType, GLuint resourceId); |
Geoff Lang | 528ce3c | 2014-12-01 10:44:07 -0500 | [diff] [blame] | 134 | |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 135 | Data mData; |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 136 | rx::FramebufferImpl *mImpl; |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 137 | GLuint mId; |
| 138 | |
Jamie Madill | aef95de | 2014-09-05 10:12:41 -0400 | [diff] [blame] | 139 | private: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 140 | DISALLOW_COPY_AND_ASSIGN(Framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 141 | }; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 142 | |
| 143 | class DefaultFramebuffer : public Framebuffer |
| 144 | { |
| 145 | public: |
Jamie Madill | d1405e5 | 2015-03-05 15:41:39 -0500 | [diff] [blame] | 146 | DefaultFramebuffer(const gl::Caps &caps, rx::Renderer *renderer, egl::Surface *surface); |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 147 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 148 | private: |
| 149 | DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer); |
| 150 | }; |
| 151 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 154 | #endif // LIBANGLE_FRAMEBUFFER_H_ |