blob: 241d1c8300e9b0f7e121a5286a2cc270f057f2dd [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
alokp@chromium.orgea0e1af2010-03-22 19:33:14 +000015#include "common/angleutils.h"
Jamie Madill7147f012015-03-05 15:41:40 -050016#include "libANGLE/Constants.h"
17#include "libANGLE/Error.h"
18#include "libANGLE/RefCountObject.h"
Geoff Lang64f23f62014-09-10 14:40:12 -040019
daniel@transgaming.com16418b12012-11-28 19:32:22 +000020namespace rx
21{
Geoff Lang6a1e6b92014-11-06 10:42:45 -050022class DefaultAttachmentImpl;
Geoff Langda88add2014-12-01 10:22:01 -050023class FramebufferImpl;
Jamie Madilld1405e52015-03-05 15:41:39 -050024class RenderbufferImpl;
25class Renderer;
26struct Workarounds;
27}
28
29namespace egl
30{
31class Surface;
daniel@transgaming.com16418b12012-11-28 19:32:22 +000032}
33
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000034namespace gl
35{
Jamie Madill3c7fa222014-06-05 13:08:51 -040036class FramebufferAttachment;
Geoff Langab75a052014-10-15 12:56:37 -040037class Renderbuffer;
Geoff Langb04dc822014-12-01 12:02:02 -050038class State;
Jamie Madilld1405e52015-03-05 15:41:39 -050039class Texture;
40class TextureCapsMap;
41struct Caps;
42struct Data;
43struct Extensions;
44struct ImageIndex;
Geoff Lang9ad4bda2014-12-01 11:03:09 -050045struct Rectangle;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046
Jamie Madill7147f012015-03-05 15:41:40 -050047typedef std::vector<FramebufferAttachment *> AttachmentList;
Jamie Madillce20c7f2014-09-03 11:56:29 -040048
Geoff Lang9d9132d2014-12-03 14:46:48 -050049class Framebuffer
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000050{
51 public:
Jamie Madilld1405e52015-03-05 15:41:39 -050052
53 class Data final
54 {
55 public:
56 Data(const Caps &caps);
57 ~Data();
58
Jamie Madill7147f012015-03-05 15:41:40 -050059 FramebufferAttachment *getReadAttachment() const;
60 FramebufferAttachment *getFirstColorAttachment() const;
61 FramebufferAttachment *getDepthOrStencilAttachment() const;
62
63 AttachmentList mColorAttachments;
Jamie Madilld1405e52015-03-05 15:41:39 -050064 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.com9ecb9f92010-07-28 19:21:12 +000075 virtual ~Framebuffer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000076
Geoff Langda88add2014-12-01 10:22:01 -050077 const rx::FramebufferImpl *getImplementation() const { return mImpl; }
78 rx::FramebufferImpl *getImplementation() { return mImpl; }
79
Shannon Woodsaa2ab7d2014-06-24 17:51:51 -040080 GLuint id() const { return mId; }
81
Geoff Langab75a052014-10-15 12:56:37 -040082 void setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex);
83 void setRenderbufferAttachment(GLenum attachment, Renderbuffer *renderbuffer);
84 void setNULLAttachment(GLenum attachment);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000085
86 void detachTexture(GLuint texture);
87 void detachRenderbuffer(GLuint renderbuffer);
88
Jamie Madill3c7fa222014-06-05 13:08:51 -040089 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.comf6863e02013-04-13 03:34:00 +000095 GLenum getReadColorbufferType() const;
Jamie Madill3c7fa222014-06-05 13:08:51 -040096 FramebufferAttachment *getFirstColorbuffer() const;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000097
Geoff Lang528ce3c2014-12-01 10:44:07 -050098 FramebufferAttachment *getAttachment(GLenum attachment) const;
Geoff Langc90d73a2013-07-22 16:39:23 -040099
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +0000100 GLenum getDrawBufferState(unsigned int colorAttachment) const;
Geoff Lang164d54e2014-12-01 10:55:33 -0500101 void setDrawBuffers(size_t count, const GLenum *buffers);
shannon.woods%transgaming.com@gtempaccount.comf30ccc22013-04-13 03:28:36 +0000102
Geoff Lang9dd95802014-12-01 11:12:59 -0500103 GLenum getReadBufferState() const;
104 void setReadBuffer(GLenum buffer);
105
shannon.woods%transgaming.com@gtempaccount.comdae24092013-04-13 03:31:31 +0000106 bool isEnabledColorAttachment(unsigned int colorAttachment) const;
107 bool hasEnabledColorAttachment() const;
shannon.woods%transgaming.com@gtempaccount.com3b57b4f2013-04-13 03:28:29 +0000108 bool hasStencil() const;
Jamie Madill48faf802014-11-06 15:27:22 -0500109 int getSamples(const gl::Data &data) const;
shannonwoods@chromium.org24ac8502013-05-30 00:01:37 +0000110 bool usingExtendedDrawBuffers() const;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +0000111
Geoff Lang748f74e2014-12-01 11:25:34 -0500112 GLenum checkStatus(const gl::Data &data) const;
Jamie Madille92a3542014-07-03 10:38:58 -0400113 bool hasValidDepthStencil() const;
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000114
Geoff Lang9ad4bda2014-12-01 11:03:09 -0500115 Error invalidate(size_t count, const GLenum *attachments);
116 Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area);
Jamie Madill400a4412014-08-29 15:46:45 -0400117
Geoff Langb04dc822014-12-01 12:02:02 -0500118 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 Langbce529e2014-12-01 12:48:41 -0500124 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 Lang54bd5a42014-12-01 12:51:04 -0500128 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.com9ecb9f92010-07-28 19:21:12 +0000131 protected:
Geoff Lang528ce3c2014-12-01 10:44:07 -0500132 void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
Jamie Madilld1405e52015-03-05 15:41:39 -0500133 void detachResourceById(GLenum resourceType, GLuint resourceId);
Geoff Lang528ce3c2014-12-01 10:44:07 -0500134
Jamie Madilld1405e52015-03-05 15:41:39 -0500135 Data mData;
Geoff Langda88add2014-12-01 10:22:01 -0500136 rx::FramebufferImpl *mImpl;
Shannon Woodsaa2ab7d2014-06-24 17:51:51 -0400137 GLuint mId;
138
Jamie Madillaef95de2014-09-05 10:12:41 -0400139 private:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000140 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000141};
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000142
143class DefaultFramebuffer : public Framebuffer
144{
145 public:
Jamie Madilld1405e52015-03-05 15:41:39 -0500146 DefaultFramebuffer(const gl::Caps &caps, rx::Renderer *renderer, egl::Surface *surface);
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000147
daniel@transgaming.com9ecb9f92010-07-28 19:21:12 +0000148 private:
149 DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
150};
151
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000152}
153
Geoff Lang0a73dd82014-11-19 16:18:08 -0500154#endif // LIBANGLE_FRAMEBUFFER_H_