1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2014 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Worker // FramebufferAttachment.h: Defines the wrapper class gl::FramebufferAttachment, as well as the
8*8975f5c5SAndroid Build Coastguard Worker // objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
9*8975f5c5SAndroid Build Coastguard Worker
10*8975f5c5SAndroid Build Coastguard Worker #ifndef LIBANGLE_FRAMEBUFFERATTACHMENT_H_
11*8975f5c5SAndroid Build Coastguard Worker #define LIBANGLE_FRAMEBUFFERATTACHMENT_H_
12*8975f5c5SAndroid Build Coastguard Worker
13*8975f5c5SAndroid Build Coastguard Worker #include "angle_gl.h"
14*8975f5c5SAndroid Build Coastguard Worker #include "common/angleutils.h"
15*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Error.h"
16*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/ImageIndex.h"
17*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Observer.h"
18*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/angletypes.h"
19*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/formatutils.h"
20*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/FramebufferAttachmentObjectImpl.h"
21*8975f5c5SAndroid Build Coastguard Worker
22*8975f5c5SAndroid Build Coastguard Worker namespace egl
23*8975f5c5SAndroid Build Coastguard Worker {
24*8975f5c5SAndroid Build Coastguard Worker class Surface;
25*8975f5c5SAndroid Build Coastguard Worker }
26*8975f5c5SAndroid Build Coastguard Worker
27*8975f5c5SAndroid Build Coastguard Worker namespace rx
28*8975f5c5SAndroid Build Coastguard Worker {
29*8975f5c5SAndroid Build Coastguard Worker // An implementation-specific object associated with an attachment.
30*8975f5c5SAndroid Build Coastguard Worker
31*8975f5c5SAndroid Build Coastguard Worker class FramebufferAttachmentRenderTarget : angle::NonCopyable
32*8975f5c5SAndroid Build Coastguard Worker {
33*8975f5c5SAndroid Build Coastguard Worker public:
FramebufferAttachmentRenderTarget()34*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachmentRenderTarget() {}
~FramebufferAttachmentRenderTarget()35*8975f5c5SAndroid Build Coastguard Worker virtual ~FramebufferAttachmentRenderTarget() {}
36*8975f5c5SAndroid Build Coastguard Worker };
37*8975f5c5SAndroid Build Coastguard Worker
38*8975f5c5SAndroid Build Coastguard Worker class FramebufferAttachmentObjectImpl;
39*8975f5c5SAndroid Build Coastguard Worker } // namespace rx
40*8975f5c5SAndroid Build Coastguard Worker
41*8975f5c5SAndroid Build Coastguard Worker namespace gl
42*8975f5c5SAndroid Build Coastguard Worker {
43*8975f5c5SAndroid Build Coastguard Worker class FramebufferAttachmentObject;
44*8975f5c5SAndroid Build Coastguard Worker class Renderbuffer;
45*8975f5c5SAndroid Build Coastguard Worker class Texture;
46*8975f5c5SAndroid Build Coastguard Worker
47*8975f5c5SAndroid Build Coastguard Worker // FramebufferAttachment implements a GL framebuffer attachment.
48*8975f5c5SAndroid Build Coastguard Worker // Attachments are "light" containers, which store pointers to ref-counted GL objects.
49*8975f5c5SAndroid Build Coastguard Worker // We support GL texture (2D/3D/Cube/2D array) and renderbuffer object attachments.
50*8975f5c5SAndroid Build Coastguard Worker // Note: Our old naming scheme used the term "Renderbuffer" for both GL renderbuffers and for
51*8975f5c5SAndroid Build Coastguard Worker // framebuffer attachments, which confused their usage.
52*8975f5c5SAndroid Build Coastguard Worker
53*8975f5c5SAndroid Build Coastguard Worker class FramebufferAttachment final
54*8975f5c5SAndroid Build Coastguard Worker {
55*8975f5c5SAndroid Build Coastguard Worker public:
56*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachment();
57*8975f5c5SAndroid Build Coastguard Worker
58*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachment(const Context *context,
59*8975f5c5SAndroid Build Coastguard Worker GLenum type,
60*8975f5c5SAndroid Build Coastguard Worker GLenum binding,
61*8975f5c5SAndroid Build Coastguard Worker const ImageIndex &textureIndex,
62*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachmentObject *resource,
63*8975f5c5SAndroid Build Coastguard Worker rx::UniqueSerial framebufferSerial);
64*8975f5c5SAndroid Build Coastguard Worker
65*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachment(FramebufferAttachment &&other);
66*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachment &operator=(FramebufferAttachment &&other);
67*8975f5c5SAndroid Build Coastguard Worker
68*8975f5c5SAndroid Build Coastguard Worker ~FramebufferAttachment();
69*8975f5c5SAndroid Build Coastguard Worker
70*8975f5c5SAndroid Build Coastguard Worker void detach(const Context *context, rx::UniqueSerial framebufferSerial);
71*8975f5c5SAndroid Build Coastguard Worker void attach(const Context *context,
72*8975f5c5SAndroid Build Coastguard Worker GLenum type,
73*8975f5c5SAndroid Build Coastguard Worker GLenum binding,
74*8975f5c5SAndroid Build Coastguard Worker const ImageIndex &textureIndex,
75*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachmentObject *resource,
76*8975f5c5SAndroid Build Coastguard Worker GLsizei numViews,
77*8975f5c5SAndroid Build Coastguard Worker GLuint baseViewIndex,
78*8975f5c5SAndroid Build Coastguard Worker bool isMultiview,
79*8975f5c5SAndroid Build Coastguard Worker GLsizei samples,
80*8975f5c5SAndroid Build Coastguard Worker rx::UniqueSerial framebufferSerial);
81*8975f5c5SAndroid Build Coastguard Worker
82*8975f5c5SAndroid Build Coastguard Worker // Helper methods
83*8975f5c5SAndroid Build Coastguard Worker GLuint getRedSize() const;
84*8975f5c5SAndroid Build Coastguard Worker GLuint getGreenSize() const;
85*8975f5c5SAndroid Build Coastguard Worker GLuint getBlueSize() const;
86*8975f5c5SAndroid Build Coastguard Worker GLuint getAlphaSize() const;
87*8975f5c5SAndroid Build Coastguard Worker GLuint getDepthSize() const;
88*8975f5c5SAndroid Build Coastguard Worker GLuint getStencilSize() const;
89*8975f5c5SAndroid Build Coastguard Worker GLenum getComponentType() const;
90*8975f5c5SAndroid Build Coastguard Worker GLenum getColorEncoding() const;
91*8975f5c5SAndroid Build Coastguard Worker
isTextureWithId(TextureID textureId)92*8975f5c5SAndroid Build Coastguard Worker bool isTextureWithId(TextureID textureId) const
93*8975f5c5SAndroid Build Coastguard Worker {
94*8975f5c5SAndroid Build Coastguard Worker return mType == GL_TEXTURE && id() == textureId.value;
95*8975f5c5SAndroid Build Coastguard Worker }
isExternalTexture()96*8975f5c5SAndroid Build Coastguard Worker bool isExternalTexture() const
97*8975f5c5SAndroid Build Coastguard Worker {
98*8975f5c5SAndroid Build Coastguard Worker return mType == GL_TEXTURE && getTextureImageIndex().getType() == gl::TextureType::External;
99*8975f5c5SAndroid Build Coastguard Worker }
isRenderbufferWithId(GLuint renderbufferId)100*8975f5c5SAndroid Build Coastguard Worker bool isRenderbufferWithId(GLuint renderbufferId) const
101*8975f5c5SAndroid Build Coastguard Worker {
102*8975f5c5SAndroid Build Coastguard Worker return mType == GL_RENDERBUFFER && id() == renderbufferId;
103*8975f5c5SAndroid Build Coastguard Worker }
104*8975f5c5SAndroid Build Coastguard Worker
getBinding()105*8975f5c5SAndroid Build Coastguard Worker GLenum getBinding() const { return mTarget.binding(); }
106*8975f5c5SAndroid Build Coastguard Worker GLuint id() const;
107*8975f5c5SAndroid Build Coastguard Worker
108*8975f5c5SAndroid Build Coastguard Worker // These methods are only legal to call on Texture attachments
109*8975f5c5SAndroid Build Coastguard Worker const ImageIndex &getTextureImageIndex() const;
110*8975f5c5SAndroid Build Coastguard Worker TextureTarget cubeMapFace() const;
111*8975f5c5SAndroid Build Coastguard Worker GLint mipLevel() const;
112*8975f5c5SAndroid Build Coastguard Worker GLint layer() const;
113*8975f5c5SAndroid Build Coastguard Worker bool isLayered() const;
114*8975f5c5SAndroid Build Coastguard Worker
getNumViews()115*8975f5c5SAndroid Build Coastguard Worker GLsizei getNumViews() const { return mNumViews; }
116*8975f5c5SAndroid Build Coastguard Worker
117*8975f5c5SAndroid Build Coastguard Worker bool isMultiview() const;
118*8975f5c5SAndroid Build Coastguard Worker GLint getBaseViewIndex() const;
119*8975f5c5SAndroid Build Coastguard Worker
120*8975f5c5SAndroid Build Coastguard Worker bool isRenderToTexture() const;
121*8975f5c5SAndroid Build Coastguard Worker GLsizei getRenderToTextureSamples() const;
122*8975f5c5SAndroid Build Coastguard Worker
123*8975f5c5SAndroid Build Coastguard Worker // The size of the underlying resource the attachment points to. The 'depth' value will
124*8975f5c5SAndroid Build Coastguard Worker // correspond to a 3D texture depth or the layer count of a 2D array texture. For Surfaces and
125*8975f5c5SAndroid Build Coastguard Worker // Renderbuffers, it will always be 1.
126*8975f5c5SAndroid Build Coastguard Worker Extents getSize() const;
127*8975f5c5SAndroid Build Coastguard Worker Format getFormat() const;
128*8975f5c5SAndroid Build Coastguard Worker GLsizei getSamples() const;
129*8975f5c5SAndroid Build Coastguard Worker // This will always return the actual sample count of the attachment even if
130*8975f5c5SAndroid Build Coastguard Worker // render_to_texture extension is active on this FBattachment object.
131*8975f5c5SAndroid Build Coastguard Worker GLsizei getResourceSamples() const;
type()132*8975f5c5SAndroid Build Coastguard Worker GLenum type() const { return mType; }
isAttached()133*8975f5c5SAndroid Build Coastguard Worker bool isAttached() const { return mType != GL_NONE; }
134*8975f5c5SAndroid Build Coastguard Worker bool isRenderable(const Context *context) const;
135*8975f5c5SAndroid Build Coastguard Worker bool isYUV() const;
136*8975f5c5SAndroid Build Coastguard Worker // Checks whether the attachment is an external image such as AHB or dmabuf, where
137*8975f5c5SAndroid Build Coastguard Worker // synchronization is done without individually naming the objects that are involved. This
138*8975f5c5SAndroid Build Coastguard Worker // excludes Vulkan images (EXT_external_objects) as they are individually listed during
139*8975f5c5SAndroid Build Coastguard Worker // synchronization.
140*8975f5c5SAndroid Build Coastguard Worker //
141*8975f5c5SAndroid Build Coastguard Worker // This function is used to disable optimizations that involve deferring operations, as there is
142*8975f5c5SAndroid Build Coastguard Worker // no efficient way to perform those deferred operations on sync if the specific objects are
143*8975f5c5SAndroid Build Coastguard Worker // unknown.
144*8975f5c5SAndroid Build Coastguard Worker bool isExternalImageWithoutIndividualSync() const;
145*8975f5c5SAndroid Build Coastguard Worker bool hasFrontBufferUsage() const;
146*8975f5c5SAndroid Build Coastguard Worker bool hasFoveatedRendering() const;
147*8975f5c5SAndroid Build Coastguard Worker const gl::FoveationState *getFoveationState() const;
148*8975f5c5SAndroid Build Coastguard Worker
149*8975f5c5SAndroid Build Coastguard Worker Renderbuffer *getRenderbuffer() const;
150*8975f5c5SAndroid Build Coastguard Worker Texture *getTexture() const;
151*8975f5c5SAndroid Build Coastguard Worker const egl::Surface *getSurface() const;
152*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachmentObject *getResource() const;
153*8975f5c5SAndroid Build Coastguard Worker InitState initState() const;
154*8975f5c5SAndroid Build Coastguard Worker angle::Result initializeContents(const Context *context) const;
155*8975f5c5SAndroid Build Coastguard Worker void setInitState(InitState initState) const;
156*8975f5c5SAndroid Build Coastguard Worker
157*8975f5c5SAndroid Build Coastguard Worker // "T" must be static_castable from FramebufferAttachmentRenderTarget
158*8975f5c5SAndroid Build Coastguard Worker template <typename T>
getRenderTarget(const Context * context,GLsizei samples,T ** rtOut)159*8975f5c5SAndroid Build Coastguard Worker angle::Result getRenderTarget(const Context *context, GLsizei samples, T **rtOut) const
160*8975f5c5SAndroid Build Coastguard Worker {
161*8975f5c5SAndroid Build Coastguard Worker static_assert(std::is_base_of<rx::FramebufferAttachmentRenderTarget, T>(),
162*8975f5c5SAndroid Build Coastguard Worker "Invalid RenderTarget class.");
163*8975f5c5SAndroid Build Coastguard Worker return getRenderTargetImpl(
164*8975f5c5SAndroid Build Coastguard Worker context, samples, reinterpret_cast<rx::FramebufferAttachmentRenderTarget **>(rtOut));
165*8975f5c5SAndroid Build Coastguard Worker }
166*8975f5c5SAndroid Build Coastguard Worker
167*8975f5c5SAndroid Build Coastguard Worker bool operator==(const FramebufferAttachment &other) const;
168*8975f5c5SAndroid Build Coastguard Worker bool operator!=(const FramebufferAttachment &other) const;
169*8975f5c5SAndroid Build Coastguard Worker
170*8975f5c5SAndroid Build Coastguard Worker static const GLsizei kDefaultNumViews;
171*8975f5c5SAndroid Build Coastguard Worker static const GLint kDefaultBaseViewIndex;
172*8975f5c5SAndroid Build Coastguard Worker static const GLint kDefaultRenderToTextureSamples;
173*8975f5c5SAndroid Build Coastguard Worker
174*8975f5c5SAndroid Build Coastguard Worker private:
175*8975f5c5SAndroid Build Coastguard Worker angle::Result getRenderTargetImpl(const Context *context,
176*8975f5c5SAndroid Build Coastguard Worker GLsizei samples,
177*8975f5c5SAndroid Build Coastguard Worker rx::FramebufferAttachmentRenderTarget **rtOut) const;
178*8975f5c5SAndroid Build Coastguard Worker
179*8975f5c5SAndroid Build Coastguard Worker // A framebuffer attachment points to one of three types of resources: Renderbuffers,
180*8975f5c5SAndroid Build Coastguard Worker // Textures and egl::Surface. The "Target" struct indicates which part of the
181*8975f5c5SAndroid Build Coastguard Worker // object an attachment references. For the three types:
182*8975f5c5SAndroid Build Coastguard Worker // - a Renderbuffer has a unique renderable target, and needs no target index
183*8975f5c5SAndroid Build Coastguard Worker // - a Texture has targets for every image and uses an ImageIndex
184*8975f5c5SAndroid Build Coastguard Worker // - a Surface has targets for Color and Depth/Stencil, and uses the attachment binding
185*8975f5c5SAndroid Build Coastguard Worker class Target
186*8975f5c5SAndroid Build Coastguard Worker {
187*8975f5c5SAndroid Build Coastguard Worker public:
188*8975f5c5SAndroid Build Coastguard Worker Target();
189*8975f5c5SAndroid Build Coastguard Worker Target(GLenum binding, const ImageIndex &imageIndex);
190*8975f5c5SAndroid Build Coastguard Worker Target(const Target &other);
191*8975f5c5SAndroid Build Coastguard Worker Target &operator=(const Target &other);
192*8975f5c5SAndroid Build Coastguard Worker
binding()193*8975f5c5SAndroid Build Coastguard Worker GLenum binding() const { return mBinding; }
textureIndex()194*8975f5c5SAndroid Build Coastguard Worker const ImageIndex &textureIndex() const { return mTextureIndex; }
195*8975f5c5SAndroid Build Coastguard Worker
196*8975f5c5SAndroid Build Coastguard Worker private:
197*8975f5c5SAndroid Build Coastguard Worker GLenum mBinding;
198*8975f5c5SAndroid Build Coastguard Worker ImageIndex mTextureIndex;
199*8975f5c5SAndroid Build Coastguard Worker };
200*8975f5c5SAndroid Build Coastguard Worker
201*8975f5c5SAndroid Build Coastguard Worker GLenum mType;
202*8975f5c5SAndroid Build Coastguard Worker Target mTarget;
203*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachmentObject *mResource;
204*8975f5c5SAndroid Build Coastguard Worker GLsizei mNumViews;
205*8975f5c5SAndroid Build Coastguard Worker bool mIsMultiview;
206*8975f5c5SAndroid Build Coastguard Worker GLint mBaseViewIndex;
207*8975f5c5SAndroid Build Coastguard Worker // A single-sampled texture can be attached to a framebuffer either as single-sampled or as
208*8975f5c5SAndroid Build Coastguard Worker // multisampled-render-to-texture. In the latter case, |mRenderToTextureSamples| will contain
209*8975f5c5SAndroid Build Coastguard Worker // the number of samples. For renderbuffers, the number of samples is inherited from the
210*8975f5c5SAndroid Build Coastguard Worker // renderbuffer itself.
211*8975f5c5SAndroid Build Coastguard Worker //
212*8975f5c5SAndroid Build Coastguard Worker // Note that textures cannot change storage between single and multisample once attached to a
213*8975f5c5SAndroid Build Coastguard Worker // framebuffer. Renderbuffers instead can, and caching the number of renderbuffer samples here
214*8975f5c5SAndroid Build Coastguard Worker // can lead to stale data.
215*8975f5c5SAndroid Build Coastguard Worker GLsizei mRenderToTextureSamples;
216*8975f5c5SAndroid Build Coastguard Worker };
217*8975f5c5SAndroid Build Coastguard Worker
218*8975f5c5SAndroid Build Coastguard Worker // A base class for objects that FBO Attachments may point to.
219*8975f5c5SAndroid Build Coastguard Worker class FramebufferAttachmentObject : public angle::Subject, public angle::ObserverInterface
220*8975f5c5SAndroid Build Coastguard Worker {
221*8975f5c5SAndroid Build Coastguard Worker public:
222*8975f5c5SAndroid Build Coastguard Worker FramebufferAttachmentObject();
223*8975f5c5SAndroid Build Coastguard Worker ~FramebufferAttachmentObject() override;
224*8975f5c5SAndroid Build Coastguard Worker
225*8975f5c5SAndroid Build Coastguard Worker virtual Extents getAttachmentSize(const ImageIndex &imageIndex) const = 0;
226*8975f5c5SAndroid Build Coastguard Worker virtual Format getAttachmentFormat(GLenum binding, const ImageIndex &imageIndex) const = 0;
227*8975f5c5SAndroid Build Coastguard Worker virtual GLsizei getAttachmentSamples(const ImageIndex &imageIndex) const = 0;
228*8975f5c5SAndroid Build Coastguard Worker virtual bool isRenderable(const Context *context,
229*8975f5c5SAndroid Build Coastguard Worker GLenum binding,
230*8975f5c5SAndroid Build Coastguard Worker const ImageIndex &imageIndex) const = 0;
231*8975f5c5SAndroid Build Coastguard Worker virtual bool isYUV() const = 0;
232*8975f5c5SAndroid Build Coastguard Worker virtual bool isExternalImageWithoutIndividualSync() const = 0;
233*8975f5c5SAndroid Build Coastguard Worker virtual bool hasFrontBufferUsage() const = 0;
234*8975f5c5SAndroid Build Coastguard Worker virtual bool hasProtectedContent() const = 0;
235*8975f5c5SAndroid Build Coastguard Worker virtual bool hasFoveatedRendering() const = 0;
236*8975f5c5SAndroid Build Coastguard Worker virtual const gl::FoveationState *getFoveationState() const = 0;
237*8975f5c5SAndroid Build Coastguard Worker
238*8975f5c5SAndroid Build Coastguard Worker virtual void onAttach(const Context *context, rx::UniqueSerial framebufferSerial) = 0;
239*8975f5c5SAndroid Build Coastguard Worker virtual void onDetach(const Context *context, rx::UniqueSerial framebufferSerial) = 0;
240*8975f5c5SAndroid Build Coastguard Worker virtual GLuint getId() const = 0;
241*8975f5c5SAndroid Build Coastguard Worker
242*8975f5c5SAndroid Build Coastguard Worker // These are used for robust resource initialization.
243*8975f5c5SAndroid Build Coastguard Worker virtual InitState initState(GLenum binding, const ImageIndex &imageIndex) const = 0;
244*8975f5c5SAndroid Build Coastguard Worker virtual void setInitState(GLenum binding,
245*8975f5c5SAndroid Build Coastguard Worker const ImageIndex &imageIndex,
246*8975f5c5SAndroid Build Coastguard Worker InitState initState) = 0;
247*8975f5c5SAndroid Build Coastguard Worker
248*8975f5c5SAndroid Build Coastguard Worker angle::Result getAttachmentRenderTarget(const Context *context,
249*8975f5c5SAndroid Build Coastguard Worker GLenum binding,
250*8975f5c5SAndroid Build Coastguard Worker const ImageIndex &imageIndex,
251*8975f5c5SAndroid Build Coastguard Worker GLsizei samples,
252*8975f5c5SAndroid Build Coastguard Worker rx::FramebufferAttachmentRenderTarget **rtOut) const;
253*8975f5c5SAndroid Build Coastguard Worker
254*8975f5c5SAndroid Build Coastguard Worker angle::Result initializeContents(const Context *context,
255*8975f5c5SAndroid Build Coastguard Worker GLenum binding,
256*8975f5c5SAndroid Build Coastguard Worker const ImageIndex &imageIndex);
257*8975f5c5SAndroid Build Coastguard Worker
258*8975f5c5SAndroid Build Coastguard Worker protected:
259*8975f5c5SAndroid Build Coastguard Worker virtual rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const = 0;
260*8975f5c5SAndroid Build Coastguard Worker };
261*8975f5c5SAndroid Build Coastguard Worker
getTextureImageIndex()262*8975f5c5SAndroid Build Coastguard Worker inline const ImageIndex &FramebufferAttachment::getTextureImageIndex() const
263*8975f5c5SAndroid Build Coastguard Worker {
264*8975f5c5SAndroid Build Coastguard Worker ASSERT(type() == GL_TEXTURE);
265*8975f5c5SAndroid Build Coastguard Worker return mTarget.textureIndex();
266*8975f5c5SAndroid Build Coastguard Worker }
267*8975f5c5SAndroid Build Coastguard Worker
getSize()268*8975f5c5SAndroid Build Coastguard Worker inline Extents FramebufferAttachment::getSize() const
269*8975f5c5SAndroid Build Coastguard Worker {
270*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
271*8975f5c5SAndroid Build Coastguard Worker return mResource->getAttachmentSize(mTarget.textureIndex());
272*8975f5c5SAndroid Build Coastguard Worker }
273*8975f5c5SAndroid Build Coastguard Worker
getFormat()274*8975f5c5SAndroid Build Coastguard Worker inline Format FramebufferAttachment::getFormat() const
275*8975f5c5SAndroid Build Coastguard Worker {
276*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
277*8975f5c5SAndroid Build Coastguard Worker return mResource->getAttachmentFormat(mTarget.binding(), mTarget.textureIndex());
278*8975f5c5SAndroid Build Coastguard Worker }
279*8975f5c5SAndroid Build Coastguard Worker
getSamples()280*8975f5c5SAndroid Build Coastguard Worker inline GLsizei FramebufferAttachment::getSamples() const
281*8975f5c5SAndroid Build Coastguard Worker {
282*8975f5c5SAndroid Build Coastguard Worker return isRenderToTexture() ? getRenderToTextureSamples() : getResourceSamples();
283*8975f5c5SAndroid Build Coastguard Worker }
284*8975f5c5SAndroid Build Coastguard Worker
getResourceSamples()285*8975f5c5SAndroid Build Coastguard Worker inline GLsizei FramebufferAttachment::getResourceSamples() const
286*8975f5c5SAndroid Build Coastguard Worker {
287*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
288*8975f5c5SAndroid Build Coastguard Worker return mResource->getAttachmentSamples(mTarget.textureIndex());
289*8975f5c5SAndroid Build Coastguard Worker }
290*8975f5c5SAndroid Build Coastguard Worker
getRenderTargetImpl(const Context * context,GLsizei samples,rx::FramebufferAttachmentRenderTarget ** rtOut)291*8975f5c5SAndroid Build Coastguard Worker inline angle::Result FramebufferAttachment::getRenderTargetImpl(
292*8975f5c5SAndroid Build Coastguard Worker const Context *context,
293*8975f5c5SAndroid Build Coastguard Worker GLsizei samples,
294*8975f5c5SAndroid Build Coastguard Worker rx::FramebufferAttachmentRenderTarget **rtOut) const
295*8975f5c5SAndroid Build Coastguard Worker {
296*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
297*8975f5c5SAndroid Build Coastguard Worker return mResource->getAttachmentRenderTarget(context, mTarget.binding(), mTarget.textureIndex(),
298*8975f5c5SAndroid Build Coastguard Worker samples, rtOut);
299*8975f5c5SAndroid Build Coastguard Worker }
300*8975f5c5SAndroid Build Coastguard Worker
isRenderable(const Context * context)301*8975f5c5SAndroid Build Coastguard Worker inline bool FramebufferAttachment::isRenderable(const Context *context) const
302*8975f5c5SAndroid Build Coastguard Worker {
303*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
304*8975f5c5SAndroid Build Coastguard Worker return mResource->isRenderable(context, mTarget.binding(), mTarget.textureIndex());
305*8975f5c5SAndroid Build Coastguard Worker }
306*8975f5c5SAndroid Build Coastguard Worker
isYUV()307*8975f5c5SAndroid Build Coastguard Worker inline bool FramebufferAttachment::isYUV() const
308*8975f5c5SAndroid Build Coastguard Worker {
309*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
310*8975f5c5SAndroid Build Coastguard Worker return mResource->isYUV();
311*8975f5c5SAndroid Build Coastguard Worker }
312*8975f5c5SAndroid Build Coastguard Worker
isExternalImageWithoutIndividualSync()313*8975f5c5SAndroid Build Coastguard Worker inline bool FramebufferAttachment::isExternalImageWithoutIndividualSync() const
314*8975f5c5SAndroid Build Coastguard Worker {
315*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
316*8975f5c5SAndroid Build Coastguard Worker return mResource->isExternalImageWithoutIndividualSync();
317*8975f5c5SAndroid Build Coastguard Worker }
318*8975f5c5SAndroid Build Coastguard Worker
hasFrontBufferUsage()319*8975f5c5SAndroid Build Coastguard Worker inline bool FramebufferAttachment::hasFrontBufferUsage() const
320*8975f5c5SAndroid Build Coastguard Worker {
321*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
322*8975f5c5SAndroid Build Coastguard Worker return mResource->hasFrontBufferUsage();
323*8975f5c5SAndroid Build Coastguard Worker }
324*8975f5c5SAndroid Build Coastguard Worker
hasFoveatedRendering()325*8975f5c5SAndroid Build Coastguard Worker inline bool FramebufferAttachment::hasFoveatedRendering() const
326*8975f5c5SAndroid Build Coastguard Worker {
327*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
328*8975f5c5SAndroid Build Coastguard Worker return mResource->hasFoveatedRendering();
329*8975f5c5SAndroid Build Coastguard Worker }
330*8975f5c5SAndroid Build Coastguard Worker
getFoveationState()331*8975f5c5SAndroid Build Coastguard Worker inline const gl::FoveationState *FramebufferAttachment::getFoveationState() const
332*8975f5c5SAndroid Build Coastguard Worker {
333*8975f5c5SAndroid Build Coastguard Worker ASSERT(mResource);
334*8975f5c5SAndroid Build Coastguard Worker return mResource->getFoveationState();
335*8975f5c5SAndroid Build Coastguard Worker }
336*8975f5c5SAndroid Build Coastguard Worker } // namespace gl
337*8975f5c5SAndroid Build Coastguard Worker
338*8975f5c5SAndroid Build Coastguard Worker #endif // LIBANGLE_FRAMEBUFFERATTACHMENT_H_
339