blob: db60ad273a3c98c396e92138f8cc6d165904066e [file] [log] [blame]
bsalomon@google.comf7fa8062012-02-14 14:09:57 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9#ifndef GrGLCaps_DEFINED
10#define GrGLCaps_DEFINED
11
mtklein3183a412016-01-08 12:11:39 -080012#include "glsl/GrGLSL.h"
bsalomoncdee0092016-01-08 13:20:12 -080013#include "GrCaps.h"
egdaniel8dc7c3a2015-04-16 11:22:42 -070014#include "GrGLStencilAttachment.h"
bsalomoncdee0092016-01-08 13:20:12 -080015#include "GrSwizzle.h"
piotaixre4b23142014-10-02 10:57:53 -070016#include "SkChecksum.h"
mtklein2aa1f7e2015-02-20 12:35:32 -080017#include "SkTHash.h"
robertphillips@google.coma2d71482012-08-01 20:08:47 +000018#include "SkTArray.h"
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000019
20class GrGLContextInfo;
jvanverthe9c0fc62015-04-29 11:18:05 -070021class GrGLSLCaps;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000022
23/**
24 * Stores some capabilities of a GL context. Most are determined by the GL
25 * version and the extensions string. It also tracks formats that have passed
26 * the FBO completeness test.
27 */
bsalomon4b91f762015-05-19 09:29:46 -070028class GrGLCaps : public GrCaps {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000029public:
egdaniel8dc7c3a2015-04-16 11:22:42 -070030 typedef GrGLStencilAttachment::Format StencilFormat;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000031
bsalomon30447372015-12-21 09:03:05 -080032 /** Provides information about the mappiing from GrPixelConfig to GL formats. */
33 struct ConfigFormats {
34 ConfigFormats() {
35 // Inits to known bad GL enum values.
36 memset(this, 0xAB, sizeof(ConfigFormats));
37 }
38 GrGLenum fBaseInternalFormat;
39 GrGLenum fSizedInternalFormat;
40 GrGLenum fExternalFormat;
41 GrGLenum fExternalType;
42
43 // The <format> parameter to use for glTexImage and glTexSubImage.
44 // This is usually the same as fExternalFormat except for kSRGBA on some GL contexts.
45 GrGLenum fExternalFormatForTexImage;
46 // Either the base or sized internal format depending on the GL and config.
47 GrGLenum fInternalFormatTexImage;
48 };
49
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000050 /**
51 * The type of MSAA for FBOs supported. Different extensions have different
52 * semantics of how / when a resolve is performed.
53 */
54 enum MSFBOType {
55 /**
56 * no support for MSAA FBOs
57 */
rmistry@google.comfbfcd562012-08-23 18:09:54 +000058 kNone_MSFBOType = 0,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000059 /**
skia.committer@gmail.com6fc1b492013-09-06 07:01:45 +000060 * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object).
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000061 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000062 kDesktop_ARB_MSFBOType,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000063 /**
64 * earlier GL_EXT_framebuffer* extensions
65 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000066 kDesktop_EXT_MSFBOType,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000067 /**
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +000068 * Similar to kDesktop_ARB but with additional restrictions on glBlitFramebuffer.
69 */
70 kES_3_0_MSFBOType,
71 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000072 * GL_APPLE_framebuffer_multisample ES extension
73 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000074 kES_Apple_MSFBOType,
bsalomon@google.comf3a60c02013-03-19 19:06:09 +000075 /**
bsalomon@google.com347c3822013-05-01 20:10:01 +000076 * GL_IMG_multisampled_render_to_texture. This variation does not have MSAA renderbuffers.
77 * Instead the texture is multisampled when bound to the FBO and then resolved automatically
78 * when read. It also defines an alternate value for GL_MAX_SAMPLES (which we call
79 * GR_GL_MAX_SAMPLES_IMG).
bsalomon@google.comf3a60c02013-03-19 19:06:09 +000080 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000081 kES_IMG_MsToTexture_MSFBOType,
82 /**
83 * GL_EXT_multisampled_render_to_texture. Same as the IMG one above but uses the standard
84 * GL_MAX_SAMPLES value.
85 */
86 kES_EXT_MsToTexture_MSFBOType,
vbuzinovdded6962015-06-12 08:59:45 -070087 /**
88 * GL_NV_framebuffer_mixed_samples.
89 */
90 kMixedSamples_MSFBOType,
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000091
vbuzinovdded6962015-06-12 08:59:45 -070092 kLast_MSFBOType = kMixedSamples_MSFBOType
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000093 };
94
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +000095 enum InvalidateFBType {
96 kNone_InvalidateFBType,
97 kDiscard_InvalidateFBType, //<! glDiscardFramebuffer()
98 kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer()
99
100 kLast_InvalidateFBType = kInvalidate_InvalidateFBType
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000101 };
102
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000103 enum MapBufferType {
104 kNone_MapBufferType,
105 kMapBuffer_MapBufferType, // glMapBuffer()
106 kMapBufferRange_MapBufferType, // glMapBufferRange()
107 kChromium_MapBufferType, // GL_CHROMIUM_map_sub
108
109 kLast_MapBufferType = kChromium_MapBufferType,
110 };
111
jvanverthd7a2c1f2015-12-07 07:36:44 -0800112 enum TransferBufferType {
113 kNone_TransferBufferType,
114 kPBO_TransferBufferType, // ARB_pixel_buffer_object
115 kChromium_TransferBufferType, // CHROMIUM_pixel_transfer_buffer_object
116
117 kLast_TransferBufferType = kChromium_TransferBufferType,
118 };
119
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000120 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000121 * Initializes the GrGLCaps to the set of features supported in the current
122 * OpenGL context accessible via ctxInfo.
123 */
bsalomon682c2692015-05-22 14:01:46 -0700124 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
125 const GrGLInterface* glInterface);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000126
bsalomon41e4384e2016-01-08 09:12:44 -0800127 bool isConfigTexturable(GrPixelConfig config) const override {
128 SkASSERT(kGrPixelConfigCnt > config);
129 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag);
130 }
131
132 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
133 SkASSERT(kGrPixelConfigCnt > config);
134 if (withMSAA) {
135 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag);
136 } else {
137 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag);
138 }
139 }
140
bsalomon30447372015-12-21 09:03:05 -0800141 /** Returns conversions to various GL format parameters for a GrPixelCfonig. */
142 const ConfigFormats& configGLFormats(GrPixelConfig config) const {
143 return fConfigTable[config].fFormats;
144 }
145
bsalomoncdee0092016-01-08 13:20:12 -0800146 /** Returns the mapping between GrPixelConfig components and GL internal format components. */
147 const GrSwizzle& configSwizzle(GrPixelConfig config) const {
148 return fConfigTable[config].fSwizzle;
149 }
150
bsalomon30447372015-12-21 09:03:05 -0800151 /**
152 * Gets an array of legal stencil formats. These formats are not guaranteed
153 * to be supported by the driver but are legal GLenum names given the GL
154 * version and extensions supported.
155 */
156 const SkTArray<StencilFormat, true>& stencilFormats() const {
157 return fStencilFormats;
158 }
159
160 /**
161 * Has a stencil format index been found for the config (or we've found that no format works).
162 */
163 bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const {
164 return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex;
165 }
166
167 /**
168 * Gets the stencil format index for the config. This assumes
169 * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if
170 * no stencil format is supported with the config. Otherwise, returned index refers to the array
171 * returned by stencilFormats().
172 */
173 int getStencilFormatIndexForConfig(GrPixelConfig config) const {
174 SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config));
175 return fConfigTable[config].fStencilFormatIndex;
176 }
177
178 /**
179 * If index is >= 0 this records an index into stencilFormats() as the best stencil format for
180 * the config. If < 0 it records that the config has no supported stencil format index.
181 */
182 void setStencilFormatIndexForConfig(GrPixelConfig config, int index) {
183 SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config));
184 if (index < 0) {
185 fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex;
186 } else {
187 fConfigTable[config].fStencilFormatIndex = index;
188 }
189 }
190
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000191 /**
192 * Call to note that a color config has been verified as a valid color
193 * attachment. This may save future calls to glCheckFramebufferStatus
194 * using isConfigVerifiedColorAttachment().
195 */
196 void markConfigAsValidColorAttachment(GrPixelConfig config) {
bsalomon480e8c02015-12-21 13:44:18 -0800197 fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000198 }
199
200 /**
201 * Call to check whether a config has been verified as a valid color
202 * attachment.
203 */
204 bool isConfigVerifiedColorAttachment(GrPixelConfig config) const {
bsalomon480e8c02015-12-21 13:44:18 -0800205 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColorAttachment_Flag);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000206 }
207
208 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000209 * Reports the type of MSAA FBO support.
210 */
211 MSFBOType msFBOType() const { return fMSFBOType; }
212
213 /**
bsalomon@google.com347c3822013-05-01 20:10:01 +0000214 * Does the supported MSAA FBO extension have MSAA renderbuffers?
215 */
216 bool usesMSAARenderBuffers() const {
217 return kNone_MSFBOType != fMSFBOType &&
218 kES_IMG_MsToTexture_MSFBOType != fMSFBOType &&
vbuzinovdded6962015-06-12 08:59:45 -0700219 kES_EXT_MsToTexture_MSFBOType != fMSFBOType &&
220 kMixedSamples_MSFBOType != fMSFBOType;
bsalomon@google.com347c3822013-05-01 20:10:01 +0000221 }
222
223 /**
224 * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and
225 * then implicitly resolved when read.
226 */
227 bool usesImplicitMSAAResolve() const {
228 return kES_IMG_MsToTexture_MSFBOType == fMSFBOType ||
229 kES_EXT_MsToTexture_MSFBOType == fMSFBOType;
230 }
231
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000232 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; }
233
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000234 /// What type of buffer mapping is supported?
235 MapBufferType mapBufferType() const { return fMapBufferType; }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000236
jvanverthd7a2c1f2015-12-07 07:36:44 -0800237 /// What type of transfer buffer is supported?
238 TransferBufferType transferBufferType() const { return fTransferBufferType; }
239
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000240 /// The maximum number of fragment uniform vectors (GLES has min. 16).
241 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; }
242
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000243 /// maximum number of attribute values per vertex
bsalomon@google.com60da4172012-06-01 19:25:00 +0000244 int maxVertexAttributes() const { return fMaxVertexAttributes; }
245
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000246 /// maximum number of texture units accessible in the fragment shader.
247 int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; }
248
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000249 /**
250 * Depending on the ES extensions present the BGRA external format may
bsalomon41e4384e2016-01-08 09:12:44 -0800251 * correspond to either a BGRA or RGBA internalFormat. On desktop GL it is
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000252 * RGBA.
253 */
bsalomon41e4384e2016-01-08 09:12:44 -0800254 bool bgraIsInternalFormat() const;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000255
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000256 /// Is there support for GL_UNPACK_ROW_LENGTH
257 bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; }
258
259 /// Is there support for GL_UNPACK_FLIP_Y
260 bool unpackFlipYSupport() const { return fUnpackFlipYSupport; }
261
262 /// Is there support for GL_PACK_ROW_LENGTH
263 bool packRowLengthSupport() const { return fPackRowLengthSupport; }
264
265 /// Is there support for GL_PACK_REVERSE_ROW_ORDER
266 bool packFlipYSupport() const { return fPackFlipYSupport; }
267
268 /// Is there support for texture parameter GL_TEXTURE_USAGE
269 bool textureUsageSupport() const { return fTextureUsageSupport; }
270
271 /// Is there support for glTexStorage
272 bool texStorageSupport() const { return fTexStorageSupport; }
273
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000274 /// Is there support for GL_RED and GL_R8
275 bool textureRedSupport() const { return fTextureRedSupport; }
276
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000277 /// Is GL_ARB_IMAGING supported
278 bool imagingSupport() const { return fImagingSupport; }
279
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000280 /// Is there support for Vertex Array Objects?
281 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; }
282
cdalton626e1ff2015-06-12 13:56:46 -0700283 /// Is there support for GL_EXT_direct_state_access?
284 bool directStateAccessSupport() const { return fDirectStateAccessSupport; }
285
286 /// Is there support for GL_KHR_debug?
287 bool debugSupport() const { return fDebugSupport; }
288
jvanverth3f801cb2014-12-16 09:49:38 -0800289 /// Is there support for ES2 compatability?
290 bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; }
291
cdaltond4727922015-11-10 12:49:06 -0800292 /// Can we call glDisable(GL_MULTISAMPLE)?
293 bool multisampleDisableSupport() const {
294 return fMultisampleDisableSupport;
295 }
296
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000297 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
bsalomon@google.com96966a52013-02-21 16:34:21 +0000298 bool useNonVBOVertexAndIndexDynamicData() const {
299 return fUseNonVBOVertexAndIndexDynamicData;
300 }
301
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000302 /// Does ReadPixels support the provided format/type combo?
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000303 bool readPixelsSupported(const GrGLInterface* intf,
bsalomon7928ef62016-01-05 10:26:39 -0800304 GrPixelConfig readConfig,
305 GrPixelConfig currFBOConfig) const;
skia.committer@gmail.com631cdcb2013-03-01 12:12:55 +0000306
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000307 bool isCoreProfile() const { return fIsCoreProfile; }
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000308
joshualittc1f56b52015-06-22 12:31:31 -0700309 bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; }
310
joshualitt7bdd70a2015-10-01 06:28:11 -0700311 bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; }
312
bsalomon7ea33f52015-11-22 14:51:00 -0800313 /// Are textures with GL_TEXTURE_EXTERNAL_OES type supported.
314 bool externalTextureSupport() const { return fExternalTextureSupport; }
315
bsalomoncdee0092016-01-08 13:20:12 -0800316 /// GL_ARB_texture_swizzle
317 bool textureSwizzleSupport() const { return fTextureSwizzleSupport; }
318
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000319 /**
bsalomon16921ec2015-07-30 15:34:56 -0700320 * Is there support for enabling/disabling sRGB writes for sRGB-capable color attachments?
321 * If false this does not mean sRGB is not supported but rather that if it is supported
322 * it cannot be turned off for configs that support it.
323 */
324 bool srgbWriteControl() const { return fSRGBWriteControl; }
325
326 /**
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000327 * Returns a string containing the caps info.
328 */
mtklein36352bf2015-03-25 18:17:31 -0700329 SkString dump() const override;
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000330
bsalomon88c7b982015-07-31 11:20:16 -0700331 bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
332 bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
333
egdanielf5294392015-10-21 07:14:17 -0700334 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
jvanverthe9c0fc62015-04-29 11:18:05 -0700335
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000336private:
cdalton4cd67132015-06-10 19:23:46 -0700337 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
egdaniel05ded892015-10-26 07:38:05 -0700338 void initGLSL(const GrGLContextInfo&);
kkinnunencfe62e32015-07-01 02:58:50 -0700339 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
bsalomon424cc262015-05-22 10:37:30 -0700340
egdanielb7e7d572015-11-04 04:23:53 -0800341 void onApplyOptionsOverrides(const GrContextOptions& options) override;
342
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000343 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
cdalton1dd05422015-06-12 09:01:18 -0700344 void initBlendEqationSupport(const GrGLContextInfo&);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000345 void initStencilFormats(const GrGLContextInfo&);
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000346 // This must be called after initFSAASupport().
bsalomoncdee0092016-01-08 13:20:12 -0800347 void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrGLSLCaps* glslCaps);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000348
jvanverthcba99b82015-06-24 06:59:57 -0700349 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
350 const GrGLInterface* intf,
351 GrGLSLCaps* glslCaps);
352
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000353 SkTArray<StencilFormat, true> fStencilFormats;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000354
355 int fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000356 int fMaxVertexAttributes;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000357 int fMaxFragmentTextureUnits;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000358
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000359 MSFBOType fMSFBOType;
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000360 InvalidateFBType fInvalidateFBType;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000361 MapBufferType fMapBufferType;
jvanverthd7a2c1f2015-12-07 07:36:44 -0800362 TransferBufferType fTransferBufferType;
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000363
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000364 bool fUnpackRowLengthSupport : 1;
365 bool fUnpackFlipYSupport : 1;
366 bool fPackRowLengthSupport : 1;
367 bool fPackFlipYSupport : 1;
368 bool fTextureUsageSupport : 1;
369 bool fTexStorageSupport : 1;
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000370 bool fTextureRedSupport : 1;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000371 bool fImagingSupport : 1;
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000372 bool fVertexArrayObjectSupport : 1;
cdalton626e1ff2015-06-12 13:56:46 -0700373 bool fDirectStateAccessSupport : 1;
374 bool fDebugSupport : 1;
jvanverth3f801cb2014-12-16 09:49:38 -0800375 bool fES2CompatibilitySupport : 1;
cdaltond4727922015-11-10 12:49:06 -0800376 bool fMultisampleDisableSupport : 1;
bsalomon@google.com96966a52013-02-21 16:34:21 +0000377 bool fUseNonVBOVertexAndIndexDynamicData : 1;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000378 bool fIsCoreProfile : 1;
joshualittc1f56b52015-06-22 12:31:31 -0700379 bool fBindFragDataLocationSupport : 1;
bsalomon16921ec2015-07-30 15:34:56 -0700380 bool fSRGBWriteControl : 1;
bsalomon88c7b982015-07-31 11:20:16 -0700381 bool fRGBA8888PixelsOpsAreSlow : 1;
382 bool fPartialFBOReadIsSlow : 1;
joshualitt7bdd70a2015-10-01 06:28:11 -0700383 bool fBindUniformLocationSupport : 1;
bsalomon7ea33f52015-11-22 14:51:00 -0800384 bool fExternalTextureSupport : 1;
bsalomoncdee0092016-01-08 13:20:12 -0800385 bool fTextureSwizzleSupport : 1;
joshualitt58162332014-08-01 06:44:53 -0700386
bsalomon7928ef62016-01-05 10:26:39 -0800387 /** Number type of the components (with out considering number of bits.) */
388 enum FormatType {
389 kNormalizedFixedPoint_FormatType,
390 kFloat_FormatType,
391 };
392
393 struct ReadPixelsFormat {
394 ReadPixelsFormat() : fFormat(0), fType(0) {}
395 GrGLenum fFormat;
396 GrGLenum fType;
397 };
398
bsalomon30447372015-12-21 09:03:05 -0800399 struct ConfigInfo {
bsalomon7928ef62016-01-05 10:26:39 -0800400 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
bsalomon30447372015-12-21 09:03:05 -0800401
402 ConfigFormats fFormats;
403
bsalomon7928ef62016-01-05 10:26:39 -0800404 FormatType fFormatType;
405
406 // On ES contexts there are restrictions on type type/format that may be used for
407 // ReadPixels. One is implicitly specified by the current FBO's format. The other is
408 // queryable. This stores the queried option (lazily).
409 ReadPixelsFormat fSecondReadPixelsFormat;
410
bsalomon30447372015-12-21 09:03:05 -0800411 enum {
412 // This indicates that a stencil format has not yet been determined for the config.
413 kUnknown_StencilIndex = -1,
414 // This indicates that there is no supported stencil format for the config.
415 kUnsupported_StencilFormatIndex = -2
416 };
bsalomon480e8c02015-12-21 13:44:18 -0800417
418 // Index fStencilFormats.
419 int fStencilFormatIndex;
420
421 enum {
bsalomon41e4384e2016-01-08 09:12:44 -0800422 kVerifiedColorAttachment_Flag = 0x1,
423 kTextureable_Flag = 0x2,
424 kRenderable_Flag = 0x4,
425 kRenderableWithMSAA_Flag = 0x8,
bsalomon480e8c02015-12-21 13:44:18 -0800426 };
427 uint32_t fFlags;
bsalomoncdee0092016-01-08 13:20:12 -0800428
429 GrSwizzle fSwizzle;
bsalomon30447372015-12-21 09:03:05 -0800430 };
431
432 ConfigInfo fConfigTable[kGrPixelConfigCnt];
433
bsalomon4b91f762015-05-19 09:29:46 -0700434 typedef GrCaps INHERITED;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000435};
436
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000437#endif