xref: /aosp_15_r20/external/angle/src/libANGLE/Texture.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2002 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 // Texture.h: Defines the gl::Texture class [OpenGL ES 2.0.24] section 3.7 page 63.
8*8975f5c5SAndroid Build Coastguard Worker 
9*8975f5c5SAndroid Build Coastguard Worker #ifndef LIBANGLE_TEXTURE_H_
10*8975f5c5SAndroid Build Coastguard Worker #define LIBANGLE_TEXTURE_H_
11*8975f5c5SAndroid Build Coastguard Worker 
12*8975f5c5SAndroid Build Coastguard Worker #include <map>
13*8975f5c5SAndroid Build Coastguard Worker #include <vector>
14*8975f5c5SAndroid Build Coastguard Worker 
15*8975f5c5SAndroid Build Coastguard Worker #include "angle_gl.h"
16*8975f5c5SAndroid Build Coastguard Worker #include "common/Optional.h"
17*8975f5c5SAndroid Build Coastguard Worker #include "common/debug.h"
18*8975f5c5SAndroid Build Coastguard Worker #include "common/utilities.h"
19*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Caps.h"
20*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Constants.h"
21*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Debug.h"
22*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Error.h"
23*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/FramebufferAttachment.h"
24*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Image.h"
25*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Observer.h"
26*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Stream.h"
27*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/angletypes.h"
28*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/formatutils.h"
29*8975f5c5SAndroid Build Coastguard Worker 
30*8975f5c5SAndroid Build Coastguard Worker namespace egl
31*8975f5c5SAndroid Build Coastguard Worker {
32*8975f5c5SAndroid Build Coastguard Worker class Surface;
33*8975f5c5SAndroid Build Coastguard Worker class Stream;
34*8975f5c5SAndroid Build Coastguard Worker }  // namespace egl
35*8975f5c5SAndroid Build Coastguard Worker 
36*8975f5c5SAndroid Build Coastguard Worker namespace rx
37*8975f5c5SAndroid Build Coastguard Worker {
38*8975f5c5SAndroid Build Coastguard Worker class GLImplFactory;
39*8975f5c5SAndroid Build Coastguard Worker class TextureImpl;
40*8975f5c5SAndroid Build Coastguard Worker class TextureGL;
41*8975f5c5SAndroid Build Coastguard Worker }  // namespace rx
42*8975f5c5SAndroid Build Coastguard Worker 
43*8975f5c5SAndroid Build Coastguard Worker namespace gl
44*8975f5c5SAndroid Build Coastguard Worker {
45*8975f5c5SAndroid Build Coastguard Worker class Framebuffer;
46*8975f5c5SAndroid Build Coastguard Worker class MemoryObject;
47*8975f5c5SAndroid Build Coastguard Worker class Sampler;
48*8975f5c5SAndroid Build Coastguard Worker class State;
49*8975f5c5SAndroid Build Coastguard Worker class Texture;
50*8975f5c5SAndroid Build Coastguard Worker 
51*8975f5c5SAndroid Build Coastguard Worker constexpr GLuint kInitialMaxLevel = 1000;
52*8975f5c5SAndroid Build Coastguard Worker 
53*8975f5c5SAndroid Build Coastguard Worker bool IsMipmapFiltered(GLenum minFilterMode);
54*8975f5c5SAndroid Build Coastguard Worker 
55*8975f5c5SAndroid Build Coastguard Worker // Convert a given filter mode to nearest filtering.
56*8975f5c5SAndroid Build Coastguard Worker GLenum ConvertToNearestFilterMode(GLenum filterMode);
57*8975f5c5SAndroid Build Coastguard Worker 
58*8975f5c5SAndroid Build Coastguard Worker // Convert a given filter mode to nearest mip filtering.
59*8975f5c5SAndroid Build Coastguard Worker GLenum ConvertToNearestMipFilterMode(GLenum filterMode);
60*8975f5c5SAndroid Build Coastguard Worker 
61*8975f5c5SAndroid Build Coastguard Worker struct ImageDesc final
62*8975f5c5SAndroid Build Coastguard Worker {
63*8975f5c5SAndroid Build Coastguard Worker     ImageDesc();
64*8975f5c5SAndroid Build Coastguard Worker     ImageDesc(const Extents &size, const Format &format, const InitState initState);
65*8975f5c5SAndroid Build Coastguard Worker     ImageDesc(const Extents &size,
66*8975f5c5SAndroid Build Coastguard Worker               const Format &format,
67*8975f5c5SAndroid Build Coastguard Worker               const GLsizei samples,
68*8975f5c5SAndroid Build Coastguard Worker               const bool fixedSampleLocations,
69*8975f5c5SAndroid Build Coastguard Worker               const InitState initState);
70*8975f5c5SAndroid Build Coastguard Worker 
71*8975f5c5SAndroid Build Coastguard Worker     ImageDesc(const ImageDesc &other)            = default;
72*8975f5c5SAndroid Build Coastguard Worker     ImageDesc &operator=(const ImageDesc &other) = default;
73*8975f5c5SAndroid Build Coastguard Worker 
74*8975f5c5SAndroid Build Coastguard Worker     GLint getMemorySize() const;
75*8975f5c5SAndroid Build Coastguard Worker 
76*8975f5c5SAndroid Build Coastguard Worker     Extents size;
77*8975f5c5SAndroid Build Coastguard Worker     Format format;
78*8975f5c5SAndroid Build Coastguard Worker     GLsizei samples;
79*8975f5c5SAndroid Build Coastguard Worker     bool fixedSampleLocations;
80*8975f5c5SAndroid Build Coastguard Worker 
81*8975f5c5SAndroid Build Coastguard Worker     // Needed for robust resource initialization.
82*8975f5c5SAndroid Build Coastguard Worker     InitState initState;
83*8975f5c5SAndroid Build Coastguard Worker };
84*8975f5c5SAndroid Build Coastguard Worker 
85*8975f5c5SAndroid Build Coastguard Worker struct SwizzleState final
86*8975f5c5SAndroid Build Coastguard Worker {
87*8975f5c5SAndroid Build Coastguard Worker     SwizzleState();
88*8975f5c5SAndroid Build Coastguard Worker     SwizzleState(GLenum red, GLenum green, GLenum blue, GLenum alpha);
89*8975f5c5SAndroid Build Coastguard Worker     SwizzleState(const SwizzleState &other)            = default;
90*8975f5c5SAndroid Build Coastguard Worker     SwizzleState &operator=(const SwizzleState &other) = default;
91*8975f5c5SAndroid Build Coastguard Worker 
92*8975f5c5SAndroid Build Coastguard Worker     bool swizzleRequired() const;
93*8975f5c5SAndroid Build Coastguard Worker 
94*8975f5c5SAndroid Build Coastguard Worker     bool operator==(const SwizzleState &other) const;
95*8975f5c5SAndroid Build Coastguard Worker     bool operator!=(const SwizzleState &other) const;
96*8975f5c5SAndroid Build Coastguard Worker 
97*8975f5c5SAndroid Build Coastguard Worker     GLenum swizzleRed;
98*8975f5c5SAndroid Build Coastguard Worker     GLenum swizzleGreen;
99*8975f5c5SAndroid Build Coastguard Worker     GLenum swizzleBlue;
100*8975f5c5SAndroid Build Coastguard Worker     GLenum swizzleAlpha;
101*8975f5c5SAndroid Build Coastguard Worker };
102*8975f5c5SAndroid Build Coastguard Worker 
103*8975f5c5SAndroid Build Coastguard Worker // State from Table 6.9 (state per texture object) in the OpenGL ES 3.0.2 spec.
104*8975f5c5SAndroid Build Coastguard Worker class TextureState final : private angle::NonCopyable
105*8975f5c5SAndroid Build Coastguard Worker {
106*8975f5c5SAndroid Build Coastguard Worker   public:
107*8975f5c5SAndroid Build Coastguard Worker     TextureState(TextureType type);
108*8975f5c5SAndroid Build Coastguard Worker     ~TextureState();
109*8975f5c5SAndroid Build Coastguard Worker 
110*8975f5c5SAndroid Build Coastguard Worker     bool swizzleRequired() const;
111*8975f5c5SAndroid Build Coastguard Worker     GLuint getEffectiveBaseLevel() const;
112*8975f5c5SAndroid Build Coastguard Worker     GLuint getEffectiveMaxLevel() const;
113*8975f5c5SAndroid Build Coastguard Worker 
114*8975f5c5SAndroid Build Coastguard Worker     // Returns the value called "q" in the GLES 3.0.4 spec section 3.8.10.
115*8975f5c5SAndroid Build Coastguard Worker     GLuint getMipmapMaxLevel() const;
116*8975f5c5SAndroid Build Coastguard Worker 
117*8975f5c5SAndroid Build Coastguard Worker     // Returns true if base level changed.
118*8975f5c5SAndroid Build Coastguard Worker     bool setBaseLevel(GLuint baseLevel);
getBaseLevel()119*8975f5c5SAndroid Build Coastguard Worker     GLuint getBaseLevel() const { return mBaseLevel; }
120*8975f5c5SAndroid Build Coastguard Worker     bool setMaxLevel(GLuint maxLevel);
getMaxLevel()121*8975f5c5SAndroid Build Coastguard Worker     GLuint getMaxLevel() const { return mMaxLevel; }
122*8975f5c5SAndroid Build Coastguard Worker 
123*8975f5c5SAndroid Build Coastguard Worker     bool isCubeComplete() const;
124*8975f5c5SAndroid Build Coastguard Worker 
compatibleWithSamplerFormatForWebGL(SamplerFormat format,const SamplerState & samplerState)125*8975f5c5SAndroid Build Coastguard Worker     ANGLE_INLINE bool compatibleWithSamplerFormatForWebGL(SamplerFormat format,
126*8975f5c5SAndroid Build Coastguard Worker                                                           const SamplerState &samplerState) const
127*8975f5c5SAndroid Build Coastguard Worker     {
128*8975f5c5SAndroid Build Coastguard Worker         if (!mCachedSamplerFormatValid ||
129*8975f5c5SAndroid Build Coastguard Worker             mCachedSamplerCompareMode != samplerState.getCompareMode())
130*8975f5c5SAndroid Build Coastguard Worker         {
131*8975f5c5SAndroid Build Coastguard Worker             mCachedSamplerFormat      = computeRequiredSamplerFormat(samplerState);
132*8975f5c5SAndroid Build Coastguard Worker             mCachedSamplerCompareMode = samplerState.getCompareMode();
133*8975f5c5SAndroid Build Coastguard Worker             mCachedSamplerFormatValid = true;
134*8975f5c5SAndroid Build Coastguard Worker         }
135*8975f5c5SAndroid Build Coastguard Worker         // Incomplete textures are compatible with any sampler format.
136*8975f5c5SAndroid Build Coastguard Worker         return mCachedSamplerFormat == SamplerFormat::InvalidEnum || format == mCachedSamplerFormat;
137*8975f5c5SAndroid Build Coastguard Worker     }
138*8975f5c5SAndroid Build Coastguard Worker 
139*8975f5c5SAndroid Build Coastguard Worker     const ImageDesc &getImageDesc(TextureTarget target, size_t level) const;
140*8975f5c5SAndroid Build Coastguard Worker     const ImageDesc &getImageDesc(const ImageIndex &imageIndex) const;
141*8975f5c5SAndroid Build Coastguard Worker 
getType()142*8975f5c5SAndroid Build Coastguard Worker     TextureType getType() const { return mType; }
getSwizzleState()143*8975f5c5SAndroid Build Coastguard Worker     const SwizzleState &getSwizzleState() const { return mSwizzleState; }
getSamplerState()144*8975f5c5SAndroid Build Coastguard Worker     const SamplerState &getSamplerState() const { return mSamplerState; }
getUsage()145*8975f5c5SAndroid Build Coastguard Worker     GLenum getUsage() const { return mUsage; }
hasProtectedContent()146*8975f5c5SAndroid Build Coastguard Worker     bool hasProtectedContent() const { return mHasProtectedContent; }
renderabilityValidation()147*8975f5c5SAndroid Build Coastguard Worker     bool renderabilityValidation() const { return mRenderabilityValidation; }
getDepthStencilTextureMode()148*8975f5c5SAndroid Build Coastguard Worker     GLenum getDepthStencilTextureMode() const { return mDepthStencilTextureMode; }
149*8975f5c5SAndroid Build Coastguard Worker 
hasBeenBoundAsImage()150*8975f5c5SAndroid Build Coastguard Worker     bool hasBeenBoundAsImage() const { return mHasBeenBoundAsImage; }
hasBeenBoundAsAttachment()151*8975f5c5SAndroid Build Coastguard Worker     bool hasBeenBoundAsAttachment() const { return mHasBeenBoundAsAttachment; }
hasBeenBoundToMSRTTFramebuffer()152*8975f5c5SAndroid Build Coastguard Worker     bool hasBeenBoundToMSRTTFramebuffer() const { return mHasBeenBoundToMSRTTFramebuffer; }
153*8975f5c5SAndroid Build Coastguard Worker 
getSRGBOverride()154*8975f5c5SAndroid Build Coastguard Worker     gl::SrgbOverride getSRGBOverride() const { return mSrgbOverride; }
155*8975f5c5SAndroid Build Coastguard Worker 
156*8975f5c5SAndroid Build Coastguard Worker     // Returns the desc of the base level. Only valid for cube-complete/mip-complete textures.
157*8975f5c5SAndroid Build Coastguard Worker     const ImageDesc &getBaseLevelDesc() const;
158*8975f5c5SAndroid Build Coastguard Worker     const ImageDesc &getLevelZeroDesc() const;
159*8975f5c5SAndroid Build Coastguard Worker 
160*8975f5c5SAndroid Build Coastguard Worker     // This helper is used by backends that require special setup to read stencil data
isStencilMode()161*8975f5c5SAndroid Build Coastguard Worker     bool isStencilMode() const
162*8975f5c5SAndroid Build Coastguard Worker     {
163*8975f5c5SAndroid Build Coastguard Worker         const GLenum format =
164*8975f5c5SAndroid Build Coastguard Worker             getImageDesc(getBaseImageTarget(), getEffectiveBaseLevel()).format.info->format;
165*8975f5c5SAndroid Build Coastguard Worker         return (format == GL_DEPTH_STENCIL) ? (mDepthStencilTextureMode == GL_STENCIL_INDEX)
166*8975f5c5SAndroid Build Coastguard Worker                                             : (format == GL_STENCIL_INDEX);
167*8975f5c5SAndroid Build Coastguard Worker     }
168*8975f5c5SAndroid Build Coastguard Worker 
169*8975f5c5SAndroid Build Coastguard Worker     // GLES1 emulation: For GL_OES_draw_texture
170*8975f5c5SAndroid Build Coastguard Worker     void setCrop(const Rectangle &rect);
171*8975f5c5SAndroid Build Coastguard Worker     const Rectangle &getCrop() const;
172*8975f5c5SAndroid Build Coastguard Worker 
173*8975f5c5SAndroid Build Coastguard Worker     // GLES1 emulation: Auto-mipmap generation is a texparameter
174*8975f5c5SAndroid Build Coastguard Worker     void setGenerateMipmapHint(GLenum hint);
175*8975f5c5SAndroid Build Coastguard Worker     GLenum getGenerateMipmapHint() const;
176*8975f5c5SAndroid Build Coastguard Worker 
177*8975f5c5SAndroid Build Coastguard Worker     // Return the enabled mipmap level count.
178*8975f5c5SAndroid Build Coastguard Worker     GLuint getEnabledLevelCount() const;
179*8975f5c5SAndroid Build Coastguard Worker 
getImmutableFormat()180*8975f5c5SAndroid Build Coastguard Worker     bool getImmutableFormat() const { return mImmutableFormat; }
getImmutableLevels()181*8975f5c5SAndroid Build Coastguard Worker     GLuint getImmutableLevels() const { return mImmutableLevels; }
182*8975f5c5SAndroid Build Coastguard Worker 
getImageDescs()183*8975f5c5SAndroid Build Coastguard Worker     const std::vector<ImageDesc> &getImageDescs() const { return mImageDescs; }
184*8975f5c5SAndroid Build Coastguard Worker 
getInitState()185*8975f5c5SAndroid Build Coastguard Worker     InitState getInitState() const { return mInitState; }
186*8975f5c5SAndroid Build Coastguard Worker 
getBuffer()187*8975f5c5SAndroid Build Coastguard Worker     const OffsetBindingPointer<Buffer> &getBuffer() const { return mBuffer; }
188*8975f5c5SAndroid Build Coastguard Worker 
getLabel()189*8975f5c5SAndroid Build Coastguard Worker     const std::string &getLabel() const { return mLabel; }
190*8975f5c5SAndroid Build Coastguard Worker 
getTilingMode()191*8975f5c5SAndroid Build Coastguard Worker     gl::TilingMode getTilingMode() const { return mTilingMode; }
192*8975f5c5SAndroid Build Coastguard Worker 
isInternalIncompleteTexture()193*8975f5c5SAndroid Build Coastguard Worker     bool isInternalIncompleteTexture() const { return mIsInternalIncompleteTexture; }
194*8975f5c5SAndroid Build Coastguard Worker 
getFoveationState()195*8975f5c5SAndroid Build Coastguard Worker     const FoveationState &getFoveationState() const { return mFoveationState; }
196*8975f5c5SAndroid Build Coastguard Worker 
getSurfaceCompressionFixedRate()197*8975f5c5SAndroid Build Coastguard Worker     GLenum getSurfaceCompressionFixedRate() const { return mCompressionFixedRate; }
198*8975f5c5SAndroid Build Coastguard Worker 
199*8975f5c5SAndroid Build Coastguard Worker   private:
200*8975f5c5SAndroid Build Coastguard Worker     // Texture needs access to the ImageDesc functions.
201*8975f5c5SAndroid Build Coastguard Worker     friend class Texture;
202*8975f5c5SAndroid Build Coastguard Worker     friend bool operator==(const TextureState &a, const TextureState &b);
203*8975f5c5SAndroid Build Coastguard Worker 
204*8975f5c5SAndroid Build Coastguard Worker     bool computeSamplerCompleteness(const SamplerState &samplerState, const State &state) const;
205*8975f5c5SAndroid Build Coastguard Worker     bool computeSamplerCompletenessForCopyImage(const SamplerState &samplerState,
206*8975f5c5SAndroid Build Coastguard Worker                                                 const State &state) const;
207*8975f5c5SAndroid Build Coastguard Worker 
208*8975f5c5SAndroid Build Coastguard Worker     bool computeMipmapCompleteness() const;
209*8975f5c5SAndroid Build Coastguard Worker     bool computeLevelCompleteness(TextureTarget target, size_t level) const;
210*8975f5c5SAndroid Build Coastguard Worker     SamplerFormat computeRequiredSamplerFormat(const SamplerState &samplerState) const;
211*8975f5c5SAndroid Build Coastguard Worker 
212*8975f5c5SAndroid Build Coastguard Worker     TextureTarget getBaseImageTarget() const;
213*8975f5c5SAndroid Build Coastguard Worker 
214*8975f5c5SAndroid Build Coastguard Worker     void setImageDesc(TextureTarget target, size_t level, const ImageDesc &desc);
215*8975f5c5SAndroid Build Coastguard Worker     void setImageDescChain(GLuint baselevel,
216*8975f5c5SAndroid Build Coastguard Worker                            GLuint maxLevel,
217*8975f5c5SAndroid Build Coastguard Worker                            Extents baseSize,
218*8975f5c5SAndroid Build Coastguard Worker                            const Format &format,
219*8975f5c5SAndroid Build Coastguard Worker                            InitState initState);
220*8975f5c5SAndroid Build Coastguard Worker     void setImageDescChainMultisample(Extents baseSize,
221*8975f5c5SAndroid Build Coastguard Worker                                       const Format &format,
222*8975f5c5SAndroid Build Coastguard Worker                                       GLsizei samples,
223*8975f5c5SAndroid Build Coastguard Worker                                       bool fixedSampleLocations,
224*8975f5c5SAndroid Build Coastguard Worker                                       InitState initState);
225*8975f5c5SAndroid Build Coastguard Worker 
226*8975f5c5SAndroid Build Coastguard Worker     void clearImageDesc(TextureTarget target, size_t level);
227*8975f5c5SAndroid Build Coastguard Worker     void clearImageDescs();
228*8975f5c5SAndroid Build Coastguard Worker 
229*8975f5c5SAndroid Build Coastguard Worker     const TextureType mType;
230*8975f5c5SAndroid Build Coastguard Worker 
231*8975f5c5SAndroid Build Coastguard Worker     SwizzleState mSwizzleState;
232*8975f5c5SAndroid Build Coastguard Worker 
233*8975f5c5SAndroid Build Coastguard Worker     SamplerState mSamplerState;
234*8975f5c5SAndroid Build Coastguard Worker 
235*8975f5c5SAndroid Build Coastguard Worker     SrgbOverride mSrgbOverride;
236*8975f5c5SAndroid Build Coastguard Worker 
237*8975f5c5SAndroid Build Coastguard Worker     GLuint mBaseLevel;
238*8975f5c5SAndroid Build Coastguard Worker     GLuint mMaxLevel;
239*8975f5c5SAndroid Build Coastguard Worker 
240*8975f5c5SAndroid Build Coastguard Worker     GLenum mDepthStencilTextureMode;
241*8975f5c5SAndroid Build Coastguard Worker 
242*8975f5c5SAndroid Build Coastguard Worker     // Distinguish internally created textures.  The Vulkan backend avoids initializing them from an
243*8975f5c5SAndroid Build Coastguard Worker     // unlocked tail call because they are lazily created on draw, and we don't want to add the
244*8975f5c5SAndroid Build Coastguard Worker     // overhead of tail-call checks to draw calls.
245*8975f5c5SAndroid Build Coastguard Worker     bool mIsInternalIncompleteTexture;
246*8975f5c5SAndroid Build Coastguard Worker 
247*8975f5c5SAndroid Build Coastguard Worker     bool mHasBeenBoundAsImage;
248*8975f5c5SAndroid Build Coastguard Worker     bool mHasBeenBoundAsAttachment;
249*8975f5c5SAndroid Build Coastguard Worker     bool mHasBeenBoundToMSRTTFramebuffer;
250*8975f5c5SAndroid Build Coastguard Worker 
251*8975f5c5SAndroid Build Coastguard Worker     bool mImmutableFormat;
252*8975f5c5SAndroid Build Coastguard Worker     GLuint mImmutableLevels;
253*8975f5c5SAndroid Build Coastguard Worker 
254*8975f5c5SAndroid Build Coastguard Worker     // From GL_ANGLE_texture_usage
255*8975f5c5SAndroid Build Coastguard Worker     GLenum mUsage;
256*8975f5c5SAndroid Build Coastguard Worker 
257*8975f5c5SAndroid Build Coastguard Worker     // GL_EXT_protected_textures
258*8975f5c5SAndroid Build Coastguard Worker     bool mHasProtectedContent;
259*8975f5c5SAndroid Build Coastguard Worker 
260*8975f5c5SAndroid Build Coastguard Worker     bool mRenderabilityValidation;
261*8975f5c5SAndroid Build Coastguard Worker 
262*8975f5c5SAndroid Build Coastguard Worker     // GL_EXT_memory_object
263*8975f5c5SAndroid Build Coastguard Worker     gl::TilingMode mTilingMode;
264*8975f5c5SAndroid Build Coastguard Worker 
265*8975f5c5SAndroid Build Coastguard Worker     std::vector<ImageDesc> mImageDescs;
266*8975f5c5SAndroid Build Coastguard Worker 
267*8975f5c5SAndroid Build Coastguard Worker     // GLES1 emulation: Texture crop rectangle
268*8975f5c5SAndroid Build Coastguard Worker     // For GL_OES_draw_texture
269*8975f5c5SAndroid Build Coastguard Worker     Rectangle mCropRect;
270*8975f5c5SAndroid Build Coastguard Worker 
271*8975f5c5SAndroid Build Coastguard Worker     // GLES1 emulation: Generate-mipmap hint per texture
272*8975f5c5SAndroid Build Coastguard Worker     GLenum mGenerateMipmapHint;
273*8975f5c5SAndroid Build Coastguard Worker 
274*8975f5c5SAndroid Build Coastguard Worker     // GL_OES_texture_buffer / GLES3.2
275*8975f5c5SAndroid Build Coastguard Worker     OffsetBindingPointer<Buffer> mBuffer;
276*8975f5c5SAndroid Build Coastguard Worker 
277*8975f5c5SAndroid Build Coastguard Worker     InitState mInitState;
278*8975f5c5SAndroid Build Coastguard Worker 
279*8975f5c5SAndroid Build Coastguard Worker     mutable SamplerFormat mCachedSamplerFormat;
280*8975f5c5SAndroid Build Coastguard Worker     mutable GLenum mCachedSamplerCompareMode;
281*8975f5c5SAndroid Build Coastguard Worker     mutable bool mCachedSamplerFormatValid;
282*8975f5c5SAndroid Build Coastguard Worker     std::string mLabel;
283*8975f5c5SAndroid Build Coastguard Worker 
284*8975f5c5SAndroid Build Coastguard Worker     // GL_QCOM_texture_foveated
285*8975f5c5SAndroid Build Coastguard Worker     FoveationState mFoveationState;
286*8975f5c5SAndroid Build Coastguard Worker 
287*8975f5c5SAndroid Build Coastguard Worker     // GL_EXT_texture_storage_compression
288*8975f5c5SAndroid Build Coastguard Worker     GLenum mCompressionFixedRate;
289*8975f5c5SAndroid Build Coastguard Worker };
290*8975f5c5SAndroid Build Coastguard Worker 
291*8975f5c5SAndroid Build Coastguard Worker bool operator==(const TextureState &a, const TextureState &b);
292*8975f5c5SAndroid Build Coastguard Worker bool operator!=(const TextureState &a, const TextureState &b);
293*8975f5c5SAndroid Build Coastguard Worker 
294*8975f5c5SAndroid Build Coastguard Worker class TextureBufferContentsObservers final : angle::NonCopyable
295*8975f5c5SAndroid Build Coastguard Worker {
296*8975f5c5SAndroid Build Coastguard Worker   public:
297*8975f5c5SAndroid Build Coastguard Worker     TextureBufferContentsObservers(Texture *texture);
298*8975f5c5SAndroid Build Coastguard Worker     void enableForBuffer(Buffer *buffer);
299*8975f5c5SAndroid Build Coastguard Worker     void disableForBuffer(Buffer *buffer);
300*8975f5c5SAndroid Build Coastguard Worker     bool isEnabledForBuffer(Buffer *buffer);
301*8975f5c5SAndroid Build Coastguard Worker 
302*8975f5c5SAndroid Build Coastguard Worker   private:
303*8975f5c5SAndroid Build Coastguard Worker     Texture *mTexture;
304*8975f5c5SAndroid Build Coastguard Worker };
305*8975f5c5SAndroid Build Coastguard Worker 
306*8975f5c5SAndroid Build Coastguard Worker class Texture final : public RefCountObject<TextureID>,
307*8975f5c5SAndroid Build Coastguard Worker                       public egl::ImageSibling,
308*8975f5c5SAndroid Build Coastguard Worker                       public LabeledObject
309*8975f5c5SAndroid Build Coastguard Worker {
310*8975f5c5SAndroid Build Coastguard Worker   public:
311*8975f5c5SAndroid Build Coastguard Worker     Texture(rx::GLImplFactory *factory, TextureID id, TextureType type);
312*8975f5c5SAndroid Build Coastguard Worker     ~Texture() override;
313*8975f5c5SAndroid Build Coastguard Worker 
314*8975f5c5SAndroid Build Coastguard Worker     void onDestroy(const Context *context) override;
315*8975f5c5SAndroid Build Coastguard Worker 
316*8975f5c5SAndroid Build Coastguard Worker     angle::Result setLabel(const Context *context, const std::string &label) override;
317*8975f5c5SAndroid Build Coastguard Worker 
318*8975f5c5SAndroid Build Coastguard Worker     const std::string &getLabel() const override;
319*8975f5c5SAndroid Build Coastguard Worker 
getType()320*8975f5c5SAndroid Build Coastguard Worker     TextureType getType() const { return mState.mType; }
321*8975f5c5SAndroid Build Coastguard Worker 
322*8975f5c5SAndroid Build Coastguard Worker     void setSwizzleRed(const Context *context, GLenum swizzleRed);
323*8975f5c5SAndroid Build Coastguard Worker     GLenum getSwizzleRed() const;
324*8975f5c5SAndroid Build Coastguard Worker 
325*8975f5c5SAndroid Build Coastguard Worker     void setSwizzleGreen(const Context *context, GLenum swizzleGreen);
326*8975f5c5SAndroid Build Coastguard Worker     GLenum getSwizzleGreen() const;
327*8975f5c5SAndroid Build Coastguard Worker 
328*8975f5c5SAndroid Build Coastguard Worker     void setSwizzleBlue(const Context *context, GLenum swizzleBlue);
329*8975f5c5SAndroid Build Coastguard Worker     GLenum getSwizzleBlue() const;
330*8975f5c5SAndroid Build Coastguard Worker 
331*8975f5c5SAndroid Build Coastguard Worker     void setSwizzleAlpha(const Context *context, GLenum swizzleAlpha);
332*8975f5c5SAndroid Build Coastguard Worker     GLenum getSwizzleAlpha() const;
333*8975f5c5SAndroid Build Coastguard Worker 
334*8975f5c5SAndroid Build Coastguard Worker     void setMinFilter(const Context *context, GLenum minFilter);
335*8975f5c5SAndroid Build Coastguard Worker     GLenum getMinFilter() const;
336*8975f5c5SAndroid Build Coastguard Worker 
337*8975f5c5SAndroid Build Coastguard Worker     void setMagFilter(const Context *context, GLenum magFilter);
338*8975f5c5SAndroid Build Coastguard Worker     GLenum getMagFilter() const;
339*8975f5c5SAndroid Build Coastguard Worker 
340*8975f5c5SAndroid Build Coastguard Worker     void setWrapS(const Context *context, GLenum wrapS);
341*8975f5c5SAndroid Build Coastguard Worker     GLenum getWrapS() const;
342*8975f5c5SAndroid Build Coastguard Worker 
343*8975f5c5SAndroid Build Coastguard Worker     void setWrapT(const Context *context, GLenum wrapT);
344*8975f5c5SAndroid Build Coastguard Worker     GLenum getWrapT() const;
345*8975f5c5SAndroid Build Coastguard Worker 
346*8975f5c5SAndroid Build Coastguard Worker     void setWrapR(const Context *context, GLenum wrapR);
347*8975f5c5SAndroid Build Coastguard Worker     GLenum getWrapR() const;
348*8975f5c5SAndroid Build Coastguard Worker 
349*8975f5c5SAndroid Build Coastguard Worker     void setMaxAnisotropy(const Context *context, float maxAnisotropy);
350*8975f5c5SAndroid Build Coastguard Worker     float getMaxAnisotropy() const;
351*8975f5c5SAndroid Build Coastguard Worker 
352*8975f5c5SAndroid Build Coastguard Worker     void setMinLod(const Context *context, GLfloat minLod);
353*8975f5c5SAndroid Build Coastguard Worker     GLfloat getMinLod() const;
354*8975f5c5SAndroid Build Coastguard Worker 
355*8975f5c5SAndroid Build Coastguard Worker     void setMaxLod(const Context *context, GLfloat maxLod);
356*8975f5c5SAndroid Build Coastguard Worker     GLfloat getMaxLod() const;
357*8975f5c5SAndroid Build Coastguard Worker 
358*8975f5c5SAndroid Build Coastguard Worker     void setCompareMode(const Context *context, GLenum compareMode);
359*8975f5c5SAndroid Build Coastguard Worker     GLenum getCompareMode() const;
360*8975f5c5SAndroid Build Coastguard Worker 
361*8975f5c5SAndroid Build Coastguard Worker     void setCompareFunc(const Context *context, GLenum compareFunc);
362*8975f5c5SAndroid Build Coastguard Worker     GLenum getCompareFunc() const;
363*8975f5c5SAndroid Build Coastguard Worker 
364*8975f5c5SAndroid Build Coastguard Worker     void setSRGBDecode(const Context *context, GLenum sRGBDecode);
365*8975f5c5SAndroid Build Coastguard Worker     GLenum getSRGBDecode() const;
366*8975f5c5SAndroid Build Coastguard Worker 
367*8975f5c5SAndroid Build Coastguard Worker     void setSRGBOverride(const Context *context, GLenum sRGBOverride);
368*8975f5c5SAndroid Build Coastguard Worker     GLenum getSRGBOverride() const;
369*8975f5c5SAndroid Build Coastguard Worker 
370*8975f5c5SAndroid Build Coastguard Worker     const SamplerState &getSamplerState() const;
371*8975f5c5SAndroid Build Coastguard Worker 
372*8975f5c5SAndroid Build Coastguard Worker     angle::Result setBaseLevel(const Context *context, GLuint baseLevel);
373*8975f5c5SAndroid Build Coastguard Worker     GLuint getBaseLevel() const;
374*8975f5c5SAndroid Build Coastguard Worker 
375*8975f5c5SAndroid Build Coastguard Worker     void setMaxLevel(const Context *context, GLuint maxLevel);
376*8975f5c5SAndroid Build Coastguard Worker     GLuint getMaxLevel() const;
377*8975f5c5SAndroid Build Coastguard Worker 
378*8975f5c5SAndroid Build Coastguard Worker     void setDepthStencilTextureMode(const Context *context, GLenum mode);
379*8975f5c5SAndroid Build Coastguard Worker     GLenum getDepthStencilTextureMode() const;
380*8975f5c5SAndroid Build Coastguard Worker 
381*8975f5c5SAndroid Build Coastguard Worker     bool getImmutableFormat() const;
382*8975f5c5SAndroid Build Coastguard Worker 
383*8975f5c5SAndroid Build Coastguard Worker     GLuint getImmutableLevels() const;
384*8975f5c5SAndroid Build Coastguard Worker 
385*8975f5c5SAndroid Build Coastguard Worker     void setUsage(const Context *context, GLenum usage);
386*8975f5c5SAndroid Build Coastguard Worker     GLenum getUsage() const;
387*8975f5c5SAndroid Build Coastguard Worker 
388*8975f5c5SAndroid Build Coastguard Worker     void setProtectedContent(Context *context, bool hasProtectedContent);
389*8975f5c5SAndroid Build Coastguard Worker     bool hasProtectedContent() const override;
hasFoveatedRendering()390*8975f5c5SAndroid Build Coastguard Worker     bool hasFoveatedRendering() const override { return isFoveationEnabled(); }
getFoveationState()391*8975f5c5SAndroid Build Coastguard Worker     const gl::FoveationState *getFoveationState() const override { return &mState.mFoveationState; }
392*8975f5c5SAndroid Build Coastguard Worker 
393*8975f5c5SAndroid Build Coastguard Worker     void setRenderabilityValidation(Context *context, bool renderabilityValidation);
394*8975f5c5SAndroid Build Coastguard Worker 
395*8975f5c5SAndroid Build Coastguard Worker     void setTilingMode(Context *context, GLenum tilingMode);
396*8975f5c5SAndroid Build Coastguard Worker     GLenum getTilingMode() const;
397*8975f5c5SAndroid Build Coastguard Worker 
getState()398*8975f5c5SAndroid Build Coastguard Worker     const TextureState &getState() const { return mState; }
399*8975f5c5SAndroid Build Coastguard Worker 
400*8975f5c5SAndroid Build Coastguard Worker     void setBorderColor(const Context *context, const ColorGeneric &color);
401*8975f5c5SAndroid Build Coastguard Worker     const ColorGeneric &getBorderColor() const;
402*8975f5c5SAndroid Build Coastguard Worker 
403*8975f5c5SAndroid Build Coastguard Worker     angle::Result setBuffer(const Context *context, gl::Buffer *buffer, GLenum internalFormat);
404*8975f5c5SAndroid Build Coastguard Worker     angle::Result setBufferRange(const Context *context,
405*8975f5c5SAndroid Build Coastguard Worker                                  gl::Buffer *buffer,
406*8975f5c5SAndroid Build Coastguard Worker                                  GLenum internalFormat,
407*8975f5c5SAndroid Build Coastguard Worker                                  GLintptr offset,
408*8975f5c5SAndroid Build Coastguard Worker                                  GLsizeiptr size);
409*8975f5c5SAndroid Build Coastguard Worker     const OffsetBindingPointer<Buffer> &getBuffer() const;
410*8975f5c5SAndroid Build Coastguard Worker 
411*8975f5c5SAndroid Build Coastguard Worker     GLint getRequiredTextureImageUnits(const Context *context) const;
412*8975f5c5SAndroid Build Coastguard Worker 
413*8975f5c5SAndroid Build Coastguard Worker     const TextureState &getTextureState() const;
414*8975f5c5SAndroid Build Coastguard Worker 
415*8975f5c5SAndroid Build Coastguard Worker     const Extents &getExtents(TextureTarget target, size_t level) const;
416*8975f5c5SAndroid Build Coastguard Worker     size_t getWidth(TextureTarget target, size_t level) const;
417*8975f5c5SAndroid Build Coastguard Worker     size_t getHeight(TextureTarget target, size_t level) const;
418*8975f5c5SAndroid Build Coastguard Worker     size_t getDepth(TextureTarget target, size_t level) const;
419*8975f5c5SAndroid Build Coastguard Worker     GLsizei getSamples(TextureTarget target, size_t level) const;
420*8975f5c5SAndroid Build Coastguard Worker     bool getFixedSampleLocations(TextureTarget target, size_t level) const;
421*8975f5c5SAndroid Build Coastguard Worker     const Format &getFormat(TextureTarget target, size_t level) const;
422*8975f5c5SAndroid Build Coastguard Worker 
423*8975f5c5SAndroid Build Coastguard Worker     // Returns the value called "q" in the GLES 3.0.4 spec section 3.8.10.
424*8975f5c5SAndroid Build Coastguard Worker     GLuint getMipmapMaxLevel() const;
425*8975f5c5SAndroid Build Coastguard Worker 
426*8975f5c5SAndroid Build Coastguard Worker     bool isMipmapComplete() const;
427*8975f5c5SAndroid Build Coastguard Worker 
428*8975f5c5SAndroid Build Coastguard Worker     void setFoveatedFeatureBits(const GLuint features);
429*8975f5c5SAndroid Build Coastguard Worker     GLuint getFoveatedFeatureBits() const;
430*8975f5c5SAndroid Build Coastguard Worker     bool isFoveationEnabled() const;
431*8975f5c5SAndroid Build Coastguard Worker     GLuint getSupportedFoveationFeatures() const;
432*8975f5c5SAndroid Build Coastguard Worker 
getNumFocalPoints()433*8975f5c5SAndroid Build Coastguard Worker     GLuint getNumFocalPoints() const { return mState.mFoveationState.getMaxNumFocalPoints(); }
434*8975f5c5SAndroid Build Coastguard Worker     void setMinPixelDensity(const GLfloat density);
435*8975f5c5SAndroid Build Coastguard Worker     GLfloat getMinPixelDensity() const;
436*8975f5c5SAndroid Build Coastguard Worker     void setFocalPoint(uint32_t layer,
437*8975f5c5SAndroid Build Coastguard Worker                        uint32_t focalPointIndex,
438*8975f5c5SAndroid Build Coastguard Worker                        float focalX,
439*8975f5c5SAndroid Build Coastguard Worker                        float focalY,
440*8975f5c5SAndroid Build Coastguard Worker                        float gainX,
441*8975f5c5SAndroid Build Coastguard Worker                        float gainY,
442*8975f5c5SAndroid Build Coastguard Worker                        float foveaArea);
443*8975f5c5SAndroid Build Coastguard Worker     const FocalPoint &getFocalPoint(uint32_t layer, uint32_t focalPoint) const;
444*8975f5c5SAndroid Build Coastguard Worker 
445*8975f5c5SAndroid Build Coastguard Worker     GLint getImageCompressionRate(const Context *context) const;
446*8975f5c5SAndroid Build Coastguard Worker     GLint getFormatSupportedCompressionRates(const Context *context,
447*8975f5c5SAndroid Build Coastguard Worker                                              GLenum internalformat,
448*8975f5c5SAndroid Build Coastguard Worker                                              GLsizei bufSize,
449*8975f5c5SAndroid Build Coastguard Worker                                              GLint *rates) const;
450*8975f5c5SAndroid Build Coastguard Worker 
451*8975f5c5SAndroid Build Coastguard Worker     angle::Result setImage(Context *context,
452*8975f5c5SAndroid Build Coastguard Worker                            const PixelUnpackState &unpackState,
453*8975f5c5SAndroid Build Coastguard Worker                            Buffer *unpackBuffer,
454*8975f5c5SAndroid Build Coastguard Worker                            TextureTarget target,
455*8975f5c5SAndroid Build Coastguard Worker                            GLint level,
456*8975f5c5SAndroid Build Coastguard Worker                            GLenum internalFormat,
457*8975f5c5SAndroid Build Coastguard Worker                            const Extents &size,
458*8975f5c5SAndroid Build Coastguard Worker                            GLenum format,
459*8975f5c5SAndroid Build Coastguard Worker                            GLenum type,
460*8975f5c5SAndroid Build Coastguard Worker                            const uint8_t *pixels);
461*8975f5c5SAndroid Build Coastguard Worker     angle::Result setSubImage(Context *context,
462*8975f5c5SAndroid Build Coastguard Worker                               const PixelUnpackState &unpackState,
463*8975f5c5SAndroid Build Coastguard Worker                               Buffer *unpackBuffer,
464*8975f5c5SAndroid Build Coastguard Worker                               TextureTarget target,
465*8975f5c5SAndroid Build Coastguard Worker                               GLint level,
466*8975f5c5SAndroid Build Coastguard Worker                               const Box &area,
467*8975f5c5SAndroid Build Coastguard Worker                               GLenum format,
468*8975f5c5SAndroid Build Coastguard Worker                               GLenum type,
469*8975f5c5SAndroid Build Coastguard Worker                               const uint8_t *pixels);
470*8975f5c5SAndroid Build Coastguard Worker 
471*8975f5c5SAndroid Build Coastguard Worker     angle::Result setCompressedImage(Context *context,
472*8975f5c5SAndroid Build Coastguard Worker                                      const PixelUnpackState &unpackState,
473*8975f5c5SAndroid Build Coastguard Worker                                      TextureTarget target,
474*8975f5c5SAndroid Build Coastguard Worker                                      GLint level,
475*8975f5c5SAndroid Build Coastguard Worker                                      GLenum internalFormat,
476*8975f5c5SAndroid Build Coastguard Worker                                      const Extents &size,
477*8975f5c5SAndroid Build Coastguard Worker                                      size_t imageSize,
478*8975f5c5SAndroid Build Coastguard Worker                                      const uint8_t *pixels);
479*8975f5c5SAndroid Build Coastguard Worker     angle::Result setCompressedSubImage(const Context *context,
480*8975f5c5SAndroid Build Coastguard Worker                                         const PixelUnpackState &unpackState,
481*8975f5c5SAndroid Build Coastguard Worker                                         TextureTarget target,
482*8975f5c5SAndroid Build Coastguard Worker                                         GLint level,
483*8975f5c5SAndroid Build Coastguard Worker                                         const Box &area,
484*8975f5c5SAndroid Build Coastguard Worker                                         GLenum format,
485*8975f5c5SAndroid Build Coastguard Worker                                         size_t imageSize,
486*8975f5c5SAndroid Build Coastguard Worker                                         const uint8_t *pixels);
487*8975f5c5SAndroid Build Coastguard Worker 
488*8975f5c5SAndroid Build Coastguard Worker     angle::Result copyImage(Context *context,
489*8975f5c5SAndroid Build Coastguard Worker                             TextureTarget target,
490*8975f5c5SAndroid Build Coastguard Worker                             GLint level,
491*8975f5c5SAndroid Build Coastguard Worker                             const Rectangle &sourceArea,
492*8975f5c5SAndroid Build Coastguard Worker                             GLenum internalFormat,
493*8975f5c5SAndroid Build Coastguard Worker                             Framebuffer *source);
494*8975f5c5SAndroid Build Coastguard Worker     angle::Result copySubImage(Context *context,
495*8975f5c5SAndroid Build Coastguard Worker                                const ImageIndex &index,
496*8975f5c5SAndroid Build Coastguard Worker                                const Offset &destOffset,
497*8975f5c5SAndroid Build Coastguard Worker                                const Rectangle &sourceArea,
498*8975f5c5SAndroid Build Coastguard Worker                                Framebuffer *source);
499*8975f5c5SAndroid Build Coastguard Worker 
500*8975f5c5SAndroid Build Coastguard Worker     angle::Result copyRenderbufferSubData(Context *context,
501*8975f5c5SAndroid Build Coastguard Worker                                           const gl::Renderbuffer *srcBuffer,
502*8975f5c5SAndroid Build Coastguard Worker                                           GLint srcLevel,
503*8975f5c5SAndroid Build Coastguard Worker                                           GLint srcX,
504*8975f5c5SAndroid Build Coastguard Worker                                           GLint srcY,
505*8975f5c5SAndroid Build Coastguard Worker                                           GLint srcZ,
506*8975f5c5SAndroid Build Coastguard Worker                                           GLint dstLevel,
507*8975f5c5SAndroid Build Coastguard Worker                                           GLint dstX,
508*8975f5c5SAndroid Build Coastguard Worker                                           GLint dstY,
509*8975f5c5SAndroid Build Coastguard Worker                                           GLint dstZ,
510*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei srcWidth,
511*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei srcHeight,
512*8975f5c5SAndroid Build Coastguard Worker                                           GLsizei srcDepth);
513*8975f5c5SAndroid Build Coastguard Worker 
514*8975f5c5SAndroid Build Coastguard Worker     angle::Result copyTextureSubData(Context *context,
515*8975f5c5SAndroid Build Coastguard Worker                                      const gl::Texture *srcTexture,
516*8975f5c5SAndroid Build Coastguard Worker                                      GLint srcLevel,
517*8975f5c5SAndroid Build Coastguard Worker                                      GLint srcX,
518*8975f5c5SAndroid Build Coastguard Worker                                      GLint srcY,
519*8975f5c5SAndroid Build Coastguard Worker                                      GLint srcZ,
520*8975f5c5SAndroid Build Coastguard Worker                                      GLint dstLevel,
521*8975f5c5SAndroid Build Coastguard Worker                                      GLint dstX,
522*8975f5c5SAndroid Build Coastguard Worker                                      GLint dstY,
523*8975f5c5SAndroid Build Coastguard Worker                                      GLint dstZ,
524*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei srcWidth,
525*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei srcHeight,
526*8975f5c5SAndroid Build Coastguard Worker                                      GLsizei srcDepth);
527*8975f5c5SAndroid Build Coastguard Worker 
528*8975f5c5SAndroid Build Coastguard Worker     angle::Result copyTexture(Context *context,
529*8975f5c5SAndroid Build Coastguard Worker                               TextureTarget target,
530*8975f5c5SAndroid Build Coastguard Worker                               GLint level,
531*8975f5c5SAndroid Build Coastguard Worker                               GLenum internalFormat,
532*8975f5c5SAndroid Build Coastguard Worker                               GLenum type,
533*8975f5c5SAndroid Build Coastguard Worker                               GLint sourceLevel,
534*8975f5c5SAndroid Build Coastguard Worker                               bool unpackFlipY,
535*8975f5c5SAndroid Build Coastguard Worker                               bool unpackPremultiplyAlpha,
536*8975f5c5SAndroid Build Coastguard Worker                               bool unpackUnmultiplyAlpha,
537*8975f5c5SAndroid Build Coastguard Worker                               Texture *source);
538*8975f5c5SAndroid Build Coastguard Worker     angle::Result copySubTexture(const Context *context,
539*8975f5c5SAndroid Build Coastguard Worker                                  TextureTarget target,
540*8975f5c5SAndroid Build Coastguard Worker                                  GLint level,
541*8975f5c5SAndroid Build Coastguard Worker                                  const Offset &destOffset,
542*8975f5c5SAndroid Build Coastguard Worker                                  GLint sourceLevel,
543*8975f5c5SAndroid Build Coastguard Worker                                  const Box &sourceBox,
544*8975f5c5SAndroid Build Coastguard Worker                                  bool unpackFlipY,
545*8975f5c5SAndroid Build Coastguard Worker                                  bool unpackPremultiplyAlpha,
546*8975f5c5SAndroid Build Coastguard Worker                                  bool unpackUnmultiplyAlpha,
547*8975f5c5SAndroid Build Coastguard Worker                                  Texture *source);
548*8975f5c5SAndroid Build Coastguard Worker     angle::Result copyCompressedTexture(Context *context, const Texture *source);
549*8975f5c5SAndroid Build Coastguard Worker 
550*8975f5c5SAndroid Build Coastguard Worker     angle::Result setStorage(Context *context,
551*8975f5c5SAndroid Build Coastguard Worker                              TextureType type,
552*8975f5c5SAndroid Build Coastguard Worker                              GLsizei levels,
553*8975f5c5SAndroid Build Coastguard Worker                              GLenum internalFormat,
554*8975f5c5SAndroid Build Coastguard Worker                              const Extents &size);
555*8975f5c5SAndroid Build Coastguard Worker 
556*8975f5c5SAndroid Build Coastguard Worker     angle::Result setStorageMultisample(Context *context,
557*8975f5c5SAndroid Build Coastguard Worker                                         TextureType type,
558*8975f5c5SAndroid Build Coastguard Worker                                         GLsizei samplesIn,
559*8975f5c5SAndroid Build Coastguard Worker                                         GLint internalformat,
560*8975f5c5SAndroid Build Coastguard Worker                                         const Extents &size,
561*8975f5c5SAndroid Build Coastguard Worker                                         bool fixedSampleLocations);
562*8975f5c5SAndroid Build Coastguard Worker 
563*8975f5c5SAndroid Build Coastguard Worker     angle::Result setStorageExternalMemory(Context *context,
564*8975f5c5SAndroid Build Coastguard Worker                                            TextureType type,
565*8975f5c5SAndroid Build Coastguard Worker                                            GLsizei levels,
566*8975f5c5SAndroid Build Coastguard Worker                                            GLenum internalFormat,
567*8975f5c5SAndroid Build Coastguard Worker                                            const Extents &size,
568*8975f5c5SAndroid Build Coastguard Worker                                            MemoryObject *memoryObject,
569*8975f5c5SAndroid Build Coastguard Worker                                            GLuint64 offset,
570*8975f5c5SAndroid Build Coastguard Worker                                            GLbitfield createFlags,
571*8975f5c5SAndroid Build Coastguard Worker                                            GLbitfield usageFlags,
572*8975f5c5SAndroid Build Coastguard Worker                                            const void *imageCreateInfoPNext);
573*8975f5c5SAndroid Build Coastguard Worker 
574*8975f5c5SAndroid Build Coastguard Worker     angle::Result setImageExternal(Context *context,
575*8975f5c5SAndroid Build Coastguard Worker                                    TextureTarget target,
576*8975f5c5SAndroid Build Coastguard Worker                                    GLint level,
577*8975f5c5SAndroid Build Coastguard Worker                                    GLenum internalFormat,
578*8975f5c5SAndroid Build Coastguard Worker                                    const Extents &size,
579*8975f5c5SAndroid Build Coastguard Worker                                    GLenum format,
580*8975f5c5SAndroid Build Coastguard Worker                                    GLenum type);
581*8975f5c5SAndroid Build Coastguard Worker 
582*8975f5c5SAndroid Build Coastguard Worker     angle::Result setEGLImageTarget(Context *context, TextureType type, egl::Image *imageTarget);
583*8975f5c5SAndroid Build Coastguard Worker 
584*8975f5c5SAndroid Build Coastguard Worker     angle::Result setStorageEGLImageTarget(Context *context,
585*8975f5c5SAndroid Build Coastguard Worker                                            TextureType type,
586*8975f5c5SAndroid Build Coastguard Worker                                            egl::Image *image,
587*8975f5c5SAndroid Build Coastguard Worker                                            const GLint *attrib_list);
588*8975f5c5SAndroid Build Coastguard Worker 
589*8975f5c5SAndroid Build Coastguard Worker     angle::Result setStorageAttribs(Context *context,
590*8975f5c5SAndroid Build Coastguard Worker                                     TextureType type,
591*8975f5c5SAndroid Build Coastguard Worker                                     GLsizei levels,
592*8975f5c5SAndroid Build Coastguard Worker                                     GLenum internalFormat,
593*8975f5c5SAndroid Build Coastguard Worker                                     const Extents &size,
594*8975f5c5SAndroid Build Coastguard Worker                                     const GLint *attribList);
595*8975f5c5SAndroid Build Coastguard Worker 
596*8975f5c5SAndroid Build Coastguard Worker     angle::Result generateMipmap(Context *context);
597*8975f5c5SAndroid Build Coastguard Worker 
598*8975f5c5SAndroid Build Coastguard Worker     angle::Result clearImage(Context *context,
599*8975f5c5SAndroid Build Coastguard Worker                              GLint level,
600*8975f5c5SAndroid Build Coastguard Worker                              GLenum format,
601*8975f5c5SAndroid Build Coastguard Worker                              GLenum type,
602*8975f5c5SAndroid Build Coastguard Worker                              const uint8_t *data);
603*8975f5c5SAndroid Build Coastguard Worker     angle::Result clearSubImage(Context *context,
604*8975f5c5SAndroid Build Coastguard Worker                                 GLint level,
605*8975f5c5SAndroid Build Coastguard Worker                                 const Box &area,
606*8975f5c5SAndroid Build Coastguard Worker                                 GLenum format,
607*8975f5c5SAndroid Build Coastguard Worker                                 GLenum type,
608*8975f5c5SAndroid Build Coastguard Worker                                 const uint8_t *data);
609*8975f5c5SAndroid Build Coastguard Worker 
610*8975f5c5SAndroid Build Coastguard Worker     void onBindAsImageTexture();
611*8975f5c5SAndroid Build Coastguard Worker 
612*8975f5c5SAndroid Build Coastguard Worker     egl::Surface *getBoundSurface() const;
613*8975f5c5SAndroid Build Coastguard Worker     egl::Stream *getBoundStream() const;
614*8975f5c5SAndroid Build Coastguard Worker 
615*8975f5c5SAndroid Build Coastguard Worker     GLint getMemorySize() const;
616*8975f5c5SAndroid Build Coastguard Worker     GLint getLevelMemorySize(TextureTarget target, GLint level) const;
617*8975f5c5SAndroid Build Coastguard Worker 
618*8975f5c5SAndroid Build Coastguard Worker     void signalDirtyStorage(InitState initState);
619*8975f5c5SAndroid Build Coastguard Worker 
620*8975f5c5SAndroid Build Coastguard Worker     bool isSamplerComplete(const Context *context, const Sampler *optionalSampler);
621*8975f5c5SAndroid Build Coastguard Worker     bool isSamplerCompleteForCopyImage(const Context *context,
622*8975f5c5SAndroid Build Coastguard Worker                                        const Sampler *optionalSampler) const;
623*8975f5c5SAndroid Build Coastguard Worker 
624*8975f5c5SAndroid Build Coastguard Worker     GLenum getImplementationColorReadFormat(const Context *context) const;
625*8975f5c5SAndroid Build Coastguard Worker     GLenum getImplementationColorReadType(const Context *context) const;
626*8975f5c5SAndroid Build Coastguard Worker 
627*8975f5c5SAndroid Build Coastguard Worker     // We pass the pack buffer and state explicitly so they can be overridden during capture.
628*8975f5c5SAndroid Build Coastguard Worker     angle::Result getTexImage(const Context *context,
629*8975f5c5SAndroid Build Coastguard Worker                               const PixelPackState &packState,
630*8975f5c5SAndroid Build Coastguard Worker                               Buffer *packBuffer,
631*8975f5c5SAndroid Build Coastguard Worker                               TextureTarget target,
632*8975f5c5SAndroid Build Coastguard Worker                               GLint level,
633*8975f5c5SAndroid Build Coastguard Worker                               GLenum format,
634*8975f5c5SAndroid Build Coastguard Worker                               GLenum type,
635*8975f5c5SAndroid Build Coastguard Worker                               void *pixels);
636*8975f5c5SAndroid Build Coastguard Worker 
637*8975f5c5SAndroid Build Coastguard Worker     angle::Result getCompressedTexImage(const Context *context,
638*8975f5c5SAndroid Build Coastguard Worker                                         const PixelPackState &packState,
639*8975f5c5SAndroid Build Coastguard Worker                                         Buffer *packBuffer,
640*8975f5c5SAndroid Build Coastguard Worker                                         TextureTarget target,
641*8975f5c5SAndroid Build Coastguard Worker                                         GLint level,
642*8975f5c5SAndroid Build Coastguard Worker                                         void *pixels);
643*8975f5c5SAndroid Build Coastguard Worker 
getImplementation()644*8975f5c5SAndroid Build Coastguard Worker     rx::TextureImpl *getImplementation() const { return mTexture; }
645*8975f5c5SAndroid Build Coastguard Worker 
646*8975f5c5SAndroid Build Coastguard Worker     // FramebufferAttachmentObject implementation
647*8975f5c5SAndroid Build Coastguard Worker     Extents getAttachmentSize(const ImageIndex &imageIndex) const override;
648*8975f5c5SAndroid Build Coastguard Worker     Format getAttachmentFormat(GLenum binding, const ImageIndex &imageIndex) const override;
649*8975f5c5SAndroid Build Coastguard Worker     GLsizei getAttachmentSamples(const ImageIndex &imageIndex) const override;
650*8975f5c5SAndroid Build Coastguard Worker     bool isRenderable(const Context *context,
651*8975f5c5SAndroid Build Coastguard Worker                       GLenum binding,
652*8975f5c5SAndroid Build Coastguard Worker                       const ImageIndex &imageIndex) const override;
653*8975f5c5SAndroid Build Coastguard Worker 
654*8975f5c5SAndroid Build Coastguard Worker     bool getAttachmentFixedSampleLocations(const ImageIndex &imageIndex) const;
655*8975f5c5SAndroid Build Coastguard Worker 
656*8975f5c5SAndroid Build Coastguard Worker     // GLES1 emulation
657*8975f5c5SAndroid Build Coastguard Worker     void setCrop(const Rectangle &rect);
658*8975f5c5SAndroid Build Coastguard Worker     const Rectangle &getCrop() const;
659*8975f5c5SAndroid Build Coastguard Worker     void setGenerateMipmapHint(GLenum generate);
660*8975f5c5SAndroid Build Coastguard Worker     GLenum getGenerateMipmapHint() const;
661*8975f5c5SAndroid Build Coastguard Worker 
662*8975f5c5SAndroid Build Coastguard Worker     void onAttach(const Context *context, rx::UniqueSerial framebufferSerial) override;
663*8975f5c5SAndroid Build Coastguard Worker     void onDetach(const Context *context, rx::UniqueSerial framebufferSerial) override;
664*8975f5c5SAndroid Build Coastguard Worker 
665*8975f5c5SAndroid Build Coastguard Worker     // Used specifically for FramebufferAttachmentObject.
666*8975f5c5SAndroid Build Coastguard Worker     GLuint getId() const override;
667*8975f5c5SAndroid Build Coastguard Worker 
668*8975f5c5SAndroid Build Coastguard Worker     GLuint getNativeID() const;
669*8975f5c5SAndroid Build Coastguard Worker 
670*8975f5c5SAndroid Build Coastguard Worker     // Needed for robust resource init.
671*8975f5c5SAndroid Build Coastguard Worker     angle::Result ensureInitialized(const Context *context);
672*8975f5c5SAndroid Build Coastguard Worker     InitState initState(GLenum binding, const ImageIndex &imageIndex) const override;
initState()673*8975f5c5SAndroid Build Coastguard Worker     InitState initState() const { return mState.mInitState; }
674*8975f5c5SAndroid Build Coastguard Worker     void setInitState(GLenum binding, const ImageIndex &imageIndex, InitState initState) override;
675*8975f5c5SAndroid Build Coastguard Worker     void setInitState(InitState initState);
676*8975f5c5SAndroid Build Coastguard Worker 
isBoundToFramebuffer(rx::UniqueSerial framebufferSerial)677*8975f5c5SAndroid Build Coastguard Worker     bool isBoundToFramebuffer(rx::UniqueSerial framebufferSerial) const
678*8975f5c5SAndroid Build Coastguard Worker     {
679*8975f5c5SAndroid Build Coastguard Worker         for (size_t index = 0; index < mBoundFramebufferSerials.size(); ++index)
680*8975f5c5SAndroid Build Coastguard Worker         {
681*8975f5c5SAndroid Build Coastguard Worker             if (mBoundFramebufferSerials[index] == framebufferSerial)
682*8975f5c5SAndroid Build Coastguard Worker                 return true;
683*8975f5c5SAndroid Build Coastguard Worker         }
684*8975f5c5SAndroid Build Coastguard Worker 
685*8975f5c5SAndroid Build Coastguard Worker         return false;
686*8975f5c5SAndroid Build Coastguard Worker     }
687*8975f5c5SAndroid Build Coastguard Worker 
isDepthOrStencil()688*8975f5c5SAndroid Build Coastguard Worker     bool isDepthOrStencil() const
689*8975f5c5SAndroid Build Coastguard Worker     {
690*8975f5c5SAndroid Build Coastguard Worker         return mState.getBaseLevelDesc().format.info->isDepthOrStencil();
691*8975f5c5SAndroid Build Coastguard Worker     }
692*8975f5c5SAndroid Build Coastguard Worker 
693*8975f5c5SAndroid Build Coastguard Worker     enum DirtyBitType
694*8975f5c5SAndroid Build Coastguard Worker     {
695*8975f5c5SAndroid Build Coastguard Worker         // Sampler state
696*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_MIN_FILTER,
697*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_MAG_FILTER,
698*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_WRAP_S,
699*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_WRAP_T,
700*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_WRAP_R,
701*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_MAX_ANISOTROPY,
702*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_MIN_LOD,
703*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_MAX_LOD,
704*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_COMPARE_MODE,
705*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_COMPARE_FUNC,
706*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_SRGB_DECODE,
707*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_SRGB_OVERRIDE,
708*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_BORDER_COLOR,
709*8975f5c5SAndroid Build Coastguard Worker 
710*8975f5c5SAndroid Build Coastguard Worker         // Texture state
711*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_SWIZZLE_RED,
712*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_SWIZZLE_GREEN,
713*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_SWIZZLE_BLUE,
714*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_SWIZZLE_ALPHA,
715*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_BASE_LEVEL,
716*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_MAX_LEVEL,
717*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_DEPTH_STENCIL_TEXTURE_MODE,
718*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_RENDERABILITY_VALIDATION_ANGLE,
719*8975f5c5SAndroid Build Coastguard Worker 
720*8975f5c5SAndroid Build Coastguard Worker         // Image state
721*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_BOUND_AS_IMAGE,
722*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_BOUND_AS_ATTACHMENT,
723*8975f5c5SAndroid Build Coastguard Worker 
724*8975f5c5SAndroid Build Coastguard Worker         // Bound to MSRTT Framebuffer
725*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_BOUND_TO_MSRTT_FRAMEBUFFER,
726*8975f5c5SAndroid Build Coastguard Worker 
727*8975f5c5SAndroid Build Coastguard Worker         // Misc
728*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_USAGE,
729*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_IMPLEMENTATION,
730*8975f5c5SAndroid Build Coastguard Worker 
731*8975f5c5SAndroid Build Coastguard Worker         DIRTY_BIT_COUNT,
732*8975f5c5SAndroid Build Coastguard Worker     };
733*8975f5c5SAndroid Build Coastguard Worker     using DirtyBits = angle::BitSet<DIRTY_BIT_COUNT>;
734*8975f5c5SAndroid Build Coastguard Worker 
735*8975f5c5SAndroid Build Coastguard Worker     angle::Result syncState(const Context *context, Command source);
hasAnyDirtyBit()736*8975f5c5SAndroid Build Coastguard Worker     bool hasAnyDirtyBit() const { return mDirtyBits.any(); }
hasAnyDirtyBitExcludingBoundAsAttachmentBit()737*8975f5c5SAndroid Build Coastguard Worker     bool hasAnyDirtyBitExcludingBoundAsAttachmentBit() const
738*8975f5c5SAndroid Build Coastguard Worker     {
739*8975f5c5SAndroid Build Coastguard Worker         static constexpr DirtyBits kBoundAsAttachment = DirtyBits({DIRTY_BIT_BOUND_AS_ATTACHMENT});
740*8975f5c5SAndroid Build Coastguard Worker         return mDirtyBits.any() && mDirtyBits != kBoundAsAttachment;
741*8975f5c5SAndroid Build Coastguard Worker     }
742*8975f5c5SAndroid Build Coastguard Worker 
743*8975f5c5SAndroid Build Coastguard Worker     // ObserverInterface implementation.
744*8975f5c5SAndroid Build Coastguard Worker     void onSubjectStateChange(angle::SubjectIndex index, angle::SubjectMessage message) override;
745*8975f5c5SAndroid Build Coastguard Worker 
746*8975f5c5SAndroid Build Coastguard Worker     // Texture buffer updates.
747*8975f5c5SAndroid Build Coastguard Worker     void onBufferContentsChange();
748*8975f5c5SAndroid Build Coastguard Worker 
markInternalIncompleteTexture()749*8975f5c5SAndroid Build Coastguard Worker     void markInternalIncompleteTexture() { mState.mIsInternalIncompleteTexture = true; }
750*8975f5c5SAndroid Build Coastguard Worker 
751*8975f5c5SAndroid Build Coastguard Worker     // Texture bound to MSRTT framebuffer.
752*8975f5c5SAndroid Build Coastguard Worker     void onBindToMSRTTFramebuffer();
753*8975f5c5SAndroid Build Coastguard Worker 
754*8975f5c5SAndroid Build Coastguard Worker   private:
755*8975f5c5SAndroid Build Coastguard Worker     rx::FramebufferAttachmentObjectImpl *getAttachmentImpl() const override;
756*8975f5c5SAndroid Build Coastguard Worker 
757*8975f5c5SAndroid Build Coastguard Worker     // ANGLE-only method, used internally
758*8975f5c5SAndroid Build Coastguard Worker     friend class egl::Surface;
759*8975f5c5SAndroid Build Coastguard Worker     angle::Result bindTexImageFromSurface(Context *context, egl::Surface *surface);
760*8975f5c5SAndroid Build Coastguard Worker     angle::Result releaseTexImageFromSurface(const Context *context);
761*8975f5c5SAndroid Build Coastguard Worker 
762*8975f5c5SAndroid Build Coastguard Worker     // ANGLE-only methods, used internally
763*8975f5c5SAndroid Build Coastguard Worker     friend class egl::Stream;
764*8975f5c5SAndroid Build Coastguard Worker     void bindStream(egl::Stream *stream);
765*8975f5c5SAndroid Build Coastguard Worker     void releaseStream();
766*8975f5c5SAndroid Build Coastguard Worker     angle::Result acquireImageFromStream(const Context *context,
767*8975f5c5SAndroid Build Coastguard Worker                                          const egl::Stream::GLTextureDescription &desc);
768*8975f5c5SAndroid Build Coastguard Worker     angle::Result releaseImageFromStream(const Context *context);
769*8975f5c5SAndroid Build Coastguard Worker 
770*8975f5c5SAndroid Build Coastguard Worker     void invalidateCompletenessCache() const;
771*8975f5c5SAndroid Build Coastguard Worker     angle::Result releaseTexImageInternal(Context *context);
772*8975f5c5SAndroid Build Coastguard Worker 
773*8975f5c5SAndroid Build Coastguard Worker     bool doesSubImageNeedInit(const Context *context,
774*8975f5c5SAndroid Build Coastguard Worker                               const ImageIndex &imageIndex,
775*8975f5c5SAndroid Build Coastguard Worker                               const Box &area) const;
776*8975f5c5SAndroid Build Coastguard Worker     angle::Result ensureSubImageInitialized(const Context *context,
777*8975f5c5SAndroid Build Coastguard Worker                                             const ImageIndex &imageIndex,
778*8975f5c5SAndroid Build Coastguard Worker                                             const Box &area);
779*8975f5c5SAndroid Build Coastguard Worker 
780*8975f5c5SAndroid Build Coastguard Worker     angle::Result handleMipmapGenerationHint(Context *context, int level);
781*8975f5c5SAndroid Build Coastguard Worker 
782*8975f5c5SAndroid Build Coastguard Worker     angle::Result setEGLImageTargetImpl(Context *context,
783*8975f5c5SAndroid Build Coastguard Worker                                         TextureType type,
784*8975f5c5SAndroid Build Coastguard Worker                                         GLuint levels,
785*8975f5c5SAndroid Build Coastguard Worker                                         egl::Image *imageTarget);
786*8975f5c5SAndroid Build Coastguard Worker 
787*8975f5c5SAndroid Build Coastguard Worker     void signalDirtyState(size_t dirtyBit);
788*8975f5c5SAndroid Build Coastguard Worker 
789*8975f5c5SAndroid Build Coastguard Worker     TextureState mState;
790*8975f5c5SAndroid Build Coastguard Worker     DirtyBits mDirtyBits;
791*8975f5c5SAndroid Build Coastguard Worker     rx::TextureImpl *mTexture;
792*8975f5c5SAndroid Build Coastguard Worker     angle::ObserverBinding mImplObserver;
793*8975f5c5SAndroid Build Coastguard Worker     // For EXT_texture_buffer, observes buffer changes.
794*8975f5c5SAndroid Build Coastguard Worker     angle::ObserverBinding mBufferObserver;
795*8975f5c5SAndroid Build Coastguard Worker 
796*8975f5c5SAndroid Build Coastguard Worker     egl::Surface *mBoundSurface;
797*8975f5c5SAndroid Build Coastguard Worker     egl::Stream *mBoundStream;
798*8975f5c5SAndroid Build Coastguard Worker 
799*8975f5c5SAndroid Build Coastguard Worker     // We track all the serials of the Framebuffers this texture is attached to. Note that this
800*8975f5c5SAndroid Build Coastguard Worker     // allows duplicates because different ranges of a Texture can be bound to the same Framebuffer.
801*8975f5c5SAndroid Build Coastguard Worker     // For the purposes of depth-stencil loops, a simple "isBound" check works fine. For color
802*8975f5c5SAndroid Build Coastguard Worker     // attachment Feedback Loop checks we then need to check further to see when a Texture is bound
803*8975f5c5SAndroid Build Coastguard Worker     // to mulitple bindings that the bindings don't overlap.
804*8975f5c5SAndroid Build Coastguard Worker     static constexpr uint32_t kFastFramebufferSerialCount = 8;
805*8975f5c5SAndroid Build Coastguard Worker     angle::FastVector<rx::UniqueSerial, kFastFramebufferSerialCount> mBoundFramebufferSerials;
806*8975f5c5SAndroid Build Coastguard Worker 
807*8975f5c5SAndroid Build Coastguard Worker     struct SamplerCompletenessCache
808*8975f5c5SAndroid Build Coastguard Worker     {
809*8975f5c5SAndroid Build Coastguard Worker         SamplerCompletenessCache();
810*8975f5c5SAndroid Build Coastguard Worker 
811*8975f5c5SAndroid Build Coastguard Worker         // Context used to generate this cache entry
812*8975f5c5SAndroid Build Coastguard Worker         ContextID context;
813*8975f5c5SAndroid Build Coastguard Worker 
814*8975f5c5SAndroid Build Coastguard Worker         // All values that affect sampler completeness that are not stored within
815*8975f5c5SAndroid Build Coastguard Worker         // the texture itself
816*8975f5c5SAndroid Build Coastguard Worker         SamplerState samplerState;
817*8975f5c5SAndroid Build Coastguard Worker 
818*8975f5c5SAndroid Build Coastguard Worker         // Result of the sampler completeness with the above parameters
819*8975f5c5SAndroid Build Coastguard Worker         bool samplerComplete;
820*8975f5c5SAndroid Build Coastguard Worker     };
821*8975f5c5SAndroid Build Coastguard Worker 
822*8975f5c5SAndroid Build Coastguard Worker     mutable SamplerCompletenessCache mCompletenessCache;
823*8975f5c5SAndroid Build Coastguard Worker     TextureBufferContentsObservers mBufferContentsObservers;
824*8975f5c5SAndroid Build Coastguard Worker };
825*8975f5c5SAndroid Build Coastguard Worker 
826*8975f5c5SAndroid Build Coastguard Worker inline bool operator==(const TextureState &a, const TextureState &b)
827*8975f5c5SAndroid Build Coastguard Worker {
828*8975f5c5SAndroid Build Coastguard Worker     return a.mSwizzleState == b.mSwizzleState && a.mSamplerState == b.mSamplerState &&
829*8975f5c5SAndroid Build Coastguard Worker            a.mBaseLevel == b.mBaseLevel && a.mMaxLevel == b.mMaxLevel &&
830*8975f5c5SAndroid Build Coastguard Worker            a.mImmutableFormat == b.mImmutableFormat && a.mImmutableLevels == b.mImmutableLevels &&
831*8975f5c5SAndroid Build Coastguard Worker            a.mUsage == b.mUsage;
832*8975f5c5SAndroid Build Coastguard Worker }
833*8975f5c5SAndroid Build Coastguard Worker 
834*8975f5c5SAndroid Build Coastguard Worker inline bool operator!=(const TextureState &a, const TextureState &b)
835*8975f5c5SAndroid Build Coastguard Worker {
836*8975f5c5SAndroid Build Coastguard Worker     return !(a == b);
837*8975f5c5SAndroid Build Coastguard Worker }
838*8975f5c5SAndroid Build Coastguard Worker }  // namespace gl
839*8975f5c5SAndroid Build Coastguard Worker 
840*8975f5c5SAndroid Build Coastguard Worker #endif  // LIBANGLE_TEXTURE_H_
841