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 | |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 13 | #include "libANGLE/Error.h" |
Geoff Lang | 2207213 | 2014-11-20 15:15:01 -0500 | [diff] [blame] | 14 | #include "libANGLE/RefCountObject.h" |
| 15 | #include "libANGLE/Constants.h" |
Jamie Madill | ce20c7f | 2014-09-03 11:56:29 -0400 | [diff] [blame] | 16 | |
alokp@chromium.org | ea0e1af | 2010-03-22 19:33:14 +0000 | [diff] [blame] | 17 | #include "common/angleutils.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 18 | |
Geoff Lang | 64f23f6 | 2014-09-10 14:40:12 -0400 | [diff] [blame] | 19 | #include <vector> |
| 20 | |
daniel@transgaming.com | 16418b1 | 2012-11-28 19:32:22 +0000 | [diff] [blame] | 21 | namespace rx |
| 22 | { |
Shannon Woods | e2632d2 | 2014-10-17 13:08:51 -0400 | [diff] [blame] | 23 | class RenderbufferImpl; |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 24 | struct Workarounds; |
Geoff Lang | 6a1e6b9 | 2014-11-06 10:42:45 -0500 | [diff] [blame] | 25 | class DefaultAttachmentImpl; |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 26 | class FramebufferImpl; |
daniel@transgaming.com | 16418b1 | 2012-11-28 19:32:22 +0000 | [diff] [blame] | 27 | } |
| 28 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 29 | namespace gl |
| 30 | { |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 31 | class FramebufferAttachment; |
Geoff Lang | ab75a05 | 2014-10-15 12:56:37 -0400 | [diff] [blame] | 32 | class Texture; |
| 33 | class Renderbuffer; |
| 34 | struct ImageIndex; |
Jamie Madill | 2d96b9e | 2014-08-29 15:46:47 -0400 | [diff] [blame] | 35 | struct Caps; |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 36 | struct Extensions; |
| 37 | class TextureCapsMap; |
| 38 | struct Data; |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 39 | class State; |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 40 | struct Rectangle; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 41 | |
Jamie Madill | ce20c7f | 2014-09-03 11:56:29 -0400 | [diff] [blame] | 42 | typedef std::vector<FramebufferAttachment *> ColorbufferInfo; |
| 43 | |
Geoff Lang | 9d9132d | 2014-12-03 14:46:48 -0500 | [diff] [blame] | 44 | class Framebuffer |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 45 | { |
| 46 | public: |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 47 | Framebuffer(rx::FramebufferImpl *impl, GLuint id); |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 48 | virtual ~Framebuffer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 49 | |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 50 | const rx::FramebufferImpl *getImplementation() const { return mImpl; } |
| 51 | rx::FramebufferImpl *getImplementation() { return mImpl; } |
| 52 | |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 53 | GLuint id() const { return mId; } |
| 54 | |
Geoff Lang | ab75a05 | 2014-10-15 12:56:37 -0400 | [diff] [blame] | 55 | void setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex); |
| 56 | void setRenderbufferAttachment(GLenum attachment, Renderbuffer *renderbuffer); |
| 57 | void setNULLAttachment(GLenum attachment); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 58 | |
| 59 | void detachTexture(GLuint texture); |
| 60 | void detachRenderbuffer(GLuint renderbuffer); |
| 61 | |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 62 | FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const; |
| 63 | FramebufferAttachment *getDepthbuffer() const; |
| 64 | FramebufferAttachment *getStencilbuffer() const; |
| 65 | FramebufferAttachment *getDepthStencilBuffer() const; |
| 66 | FramebufferAttachment *getDepthOrStencilbuffer() const; |
| 67 | FramebufferAttachment *getReadColorbuffer() const; |
shannon.woods%transgaming.com@gtempaccount.com | f6863e0 | 2013-04-13 03:34:00 +0000 | [diff] [blame] | 68 | GLenum getReadColorbufferType() const; |
Jamie Madill | 3c7fa22 | 2014-06-05 13:08:51 -0400 | [diff] [blame] | 69 | FramebufferAttachment *getFirstColorbuffer() const; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 70 | |
Geoff Lang | 528ce3c | 2014-12-01 10:44:07 -0500 | [diff] [blame] | 71 | FramebufferAttachment *getAttachment(GLenum attachment) const; |
Geoff Lang | c90d73a | 2013-07-22 16:39:23 -0400 | [diff] [blame] | 72 | |
shannon.woods%transgaming.com@gtempaccount.com | f30ccc2 | 2013-04-13 03:28:36 +0000 | [diff] [blame] | 73 | GLenum getDrawBufferState(unsigned int colorAttachment) const; |
Geoff Lang | 164d54e | 2014-12-01 10:55:33 -0500 | [diff] [blame] | 74 | void setDrawBuffers(size_t count, const GLenum *buffers); |
shannon.woods%transgaming.com@gtempaccount.com | f30ccc2 | 2013-04-13 03:28:36 +0000 | [diff] [blame] | 75 | |
Geoff Lang | 9dd9580 | 2014-12-01 11:12:59 -0500 | [diff] [blame] | 76 | GLenum getReadBufferState() const; |
| 77 | void setReadBuffer(GLenum buffer); |
| 78 | |
shannon.woods%transgaming.com@gtempaccount.com | dae2409 | 2013-04-13 03:31:31 +0000 | [diff] [blame] | 79 | bool isEnabledColorAttachment(unsigned int colorAttachment) const; |
| 80 | bool hasEnabledColorAttachment() const; |
shannon.woods%transgaming.com@gtempaccount.com | 3b57b4f | 2013-04-13 03:28:29 +0000 | [diff] [blame] | 81 | bool hasStencil() const; |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 82 | int getSamples(const gl::Data &data) const; |
shannonwoods@chromium.org | 24ac850 | 2013-05-30 00:01:37 +0000 | [diff] [blame] | 83 | bool usingExtendedDrawBuffers() const; |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 84 | |
Geoff Lang | 748f74e | 2014-12-01 11:25:34 -0500 | [diff] [blame] | 85 | GLenum checkStatus(const gl::Data &data) const; |
Jamie Madill | e92a354 | 2014-07-03 10:38:58 -0400 | [diff] [blame] | 86 | bool hasValidDepthStencil() const; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 87 | |
Geoff Lang | 9ad4bda | 2014-12-01 11:03:09 -0500 | [diff] [blame] | 88 | Error invalidate(size_t count, const GLenum *attachments); |
| 89 | Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area); |
Jamie Madill | 400a441 | 2014-08-29 15:46:45 -0400 | [diff] [blame] | 90 | |
Geoff Lang | b04dc82 | 2014-12-01 12:02:02 -0500 | [diff] [blame] | 91 | Error clear(const State &state, GLbitfield mask); |
| 92 | Error clearBufferfv(const State &state, GLenum buffer, GLint drawbuffer, const GLfloat *values); |
| 93 | Error clearBufferuiv(const State &state, GLenum buffer, GLint drawbuffer, const GLuint *values); |
| 94 | Error clearBufferiv(const State &state, GLenum buffer, GLint drawbuffer, const GLint *values); |
| 95 | Error clearBufferfi(const State &state, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); |
| 96 | |
Geoff Lang | bce529e | 2014-12-01 12:48:41 -0500 | [diff] [blame] | 97 | GLenum getImplementationColorReadFormat() const; |
| 98 | GLenum getImplementationColorReadType() const; |
| 99 | Error readPixels(const gl::State &state, const gl::Rectangle &area, GLenum format, GLenum type, GLvoid *pixels) const; |
| 100 | |
Geoff Lang | 54bd5a4 | 2014-12-01 12:51:04 -0500 | [diff] [blame^] | 101 | Error blit(const gl::State &state, const gl::Rectangle &sourceArea, const gl::Rectangle &destArea, |
| 102 | GLbitfield mask, GLenum filter, const gl::Framebuffer *sourceFramebuffer); |
| 103 | |
Jamie Madill | ce20c7f | 2014-09-03 11:56:29 -0400 | [diff] [blame] | 104 | // Use this method to retrieve the color buffer map when doing rendering. |
| 105 | // It will apply a workaround for poor shader performance on some systems |
| 106 | // by compacting the list to skip NULL values. |
Jamie Madill | 48faf80 | 2014-11-06 15:27:22 -0500 | [diff] [blame] | 107 | ColorbufferInfo getColorbuffersForRender(const rx::Workarounds &workarounds) const; |
Jamie Madill | ce20c7f | 2014-09-03 11:56:29 -0400 | [diff] [blame] | 108 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 109 | protected: |
Geoff Lang | 528ce3c | 2014-12-01 10:44:07 -0500 | [diff] [blame] | 110 | void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj); |
| 111 | |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 112 | rx::FramebufferImpl *mImpl; |
Shannon Woods | aa2ab7d | 2014-06-24 17:51:51 -0400 | [diff] [blame] | 113 | GLuint mId; |
| 114 | |
Jamie Madill | e261b44 | 2014-06-25 12:42:21 -0400 | [diff] [blame] | 115 | FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS]; |
shannon.woods%transgaming.com@gtempaccount.com | f30ccc2 | 2013-04-13 03:28:36 +0000 | [diff] [blame] | 116 | GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS]; |
| 117 | GLenum mReadBufferState; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 118 | |
Jamie Madill | e261b44 | 2014-06-25 12:42:21 -0400 | [diff] [blame] | 119 | FramebufferAttachment *mDepthbuffer; |
| 120 | FramebufferAttachment *mStencilbuffer; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 121 | |
Jamie Madill | aef95de | 2014-09-05 10:12:41 -0400 | [diff] [blame] | 122 | private: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 123 | DISALLOW_COPY_AND_ASSIGN(Framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 124 | }; |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 125 | |
| 126 | class DefaultFramebuffer : public Framebuffer |
| 127 | { |
| 128 | public: |
Geoff Lang | da88add | 2014-12-01 10:22:01 -0500 | [diff] [blame] | 129 | DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAttachmentImpl *colorAttachment, |
| 130 | rx::DefaultAttachmentImpl *depthAttachment, rx::DefaultAttachmentImpl *stencilAttachment); |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 131 | |
daniel@transgaming.com | 9ecb9f9 | 2010-07-28 19:21:12 +0000 | [diff] [blame] | 132 | private: |
| 133 | DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer); |
| 134 | }; |
| 135 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 136 | } |
| 137 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 138 | #endif // LIBANGLE_FRAMEBUFFER_H_ |