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