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