blob: c51dce173787af71e2d40c03063c4fdcfdf6fe95 [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
32 /**
33 * The type of MSAA for FBOs supported. Different extensions have different
34 * semantics of how / when a resolve is performed.
35 */
36 enum MSFBOType {
37 /**
38 * no support for MSAA FBOs
39 */
rmistry@google.comfbfcd562012-08-23 18:09:54 +000040 kNone_MSFBOType = 0,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000041 /**
skia.committer@gmail.com6fc1b492013-09-06 07:01:45 +000042 * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object).
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000043 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000044 kDesktop_ARB_MSFBOType,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000045 /**
46 * earlier GL_EXT_framebuffer* extensions
47 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000048 kDesktop_EXT_MSFBOType,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000049 /**
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +000050 * Similar to kDesktop_ARB but with additional restrictions on glBlitFramebuffer.
51 */
52 kES_3_0_MSFBOType,
53 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000054 * GL_APPLE_framebuffer_multisample ES extension
55 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000056 kES_Apple_MSFBOType,
bsalomon@google.comf3a60c02013-03-19 19:06:09 +000057 /**
bsalomon@google.com347c3822013-05-01 20:10:01 +000058 * GL_IMG_multisampled_render_to_texture. This variation does not have MSAA renderbuffers.
59 * Instead the texture is multisampled when bound to the FBO and then resolved automatically
60 * when read. It also defines an alternate value for GL_MAX_SAMPLES (which we call
61 * GR_GL_MAX_SAMPLES_IMG).
bsalomon@google.comf3a60c02013-03-19 19:06:09 +000062 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000063 kES_IMG_MsToTexture_MSFBOType,
64 /**
65 * GL_EXT_multisampled_render_to_texture. Same as the IMG one above but uses the standard
66 * GL_MAX_SAMPLES value.
67 */
68 kES_EXT_MsToTexture_MSFBOType,
vbuzinovdded6962015-06-12 08:59:45 -070069 /**
70 * GL_NV_framebuffer_mixed_samples.
71 */
72 kMixedSamples_MSFBOType,
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000073
vbuzinovdded6962015-06-12 08:59:45 -070074 kLast_MSFBOType = kMixedSamples_MSFBOType
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000075 };
76
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +000077 enum InvalidateFBType {
78 kNone_InvalidateFBType,
79 kDiscard_InvalidateFBType, //<! glDiscardFramebuffer()
80 kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer()
81
82 kLast_InvalidateFBType = kInvalidate_InvalidateFBType
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000083 };
84
commit-bot@chromium.org160b4782014-05-05 12:32:37 +000085 enum MapBufferType {
86 kNone_MapBufferType,
87 kMapBuffer_MapBufferType, // glMapBuffer()
88 kMapBufferRange_MapBufferType, // glMapBufferRange()
89 kChromium_MapBufferType, // GL_CHROMIUM_map_sub
90
91 kLast_MapBufferType = kChromium_MapBufferType,
92 };
93
jvanverthd7a2c1f2015-12-07 07:36:44 -080094 enum TransferBufferType {
95 kNone_TransferBufferType,
96 kPBO_TransferBufferType, // ARB_pixel_buffer_object
97 kChromium_TransferBufferType, // CHROMIUM_pixel_transfer_buffer_object
98
99 kLast_TransferBufferType = kChromium_TransferBufferType,
100 };
101
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000102 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000103 * Initializes the GrGLCaps to the set of features supported in the current
104 * OpenGL context accessible via ctxInfo.
105 */
bsalomon682c2692015-05-22 14:01:46 -0700106 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
107 const GrGLInterface* glInterface);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000108
bsalomon41e4384e2016-01-08 09:12:44 -0800109 bool isConfigTexturable(GrPixelConfig config) const override {
110 SkASSERT(kGrPixelConfigCnt > config);
111 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag);
112 }
113
114 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
115 SkASSERT(kGrPixelConfigCnt > config);
116 if (withMSAA) {
117 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag);
118 } else {
119 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag);
120 }
121 }
122
bsalomoncdee0092016-01-08 13:20:12 -0800123 /** Returns the mapping between GrPixelConfig components and GL internal format components. */
124 const GrSwizzle& configSwizzle(GrPixelConfig config) const {
125 return fConfigTable[config].fSwizzle;
126 }
127
bsalomon76148af2016-01-12 11:13:47 -0800128 bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
129 GrGLenum* internalFormat, GrGLenum* externalFormat,
130 GrGLenum* externalType) const;
131
132 bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const;
133
134 bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
135 GrGLenum* externalFormat, GrGLenum* externalType) const;
136
137 bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const;
138
bsalomon30447372015-12-21 09:03:05 -0800139 /**
140 * Gets an array of legal stencil formats. These formats are not guaranteed
141 * to be supported by the driver but are legal GLenum names given the GL
142 * version and extensions supported.
143 */
144 const SkTArray<StencilFormat, true>& stencilFormats() const {
145 return fStencilFormats;
146 }
147
148 /**
149 * Has a stencil format index been found for the config (or we've found that no format works).
150 */
151 bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const {
152 return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex;
153 }
154
155 /**
156 * Gets the stencil format index for the config. This assumes
157 * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if
158 * no stencil format is supported with the config. Otherwise, returned index refers to the array
159 * returned by stencilFormats().
160 */
161 int getStencilFormatIndexForConfig(GrPixelConfig config) const {
162 SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config));
163 return fConfigTable[config].fStencilFormatIndex;
164 }
165
166 /**
167 * If index is >= 0 this records an index into stencilFormats() as the best stencil format for
168 * the config. If < 0 it records that the config has no supported stencil format index.
169 */
170 void setStencilFormatIndexForConfig(GrPixelConfig config, int index) {
171 SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config));
172 if (index < 0) {
173 fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex;
174 } else {
175 fConfigTable[config].fStencilFormatIndex = index;
176 }
177 }
178
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000179 /**
180 * Call to note that a color config has been verified as a valid color
181 * attachment. This may save future calls to glCheckFramebufferStatus
182 * using isConfigVerifiedColorAttachment().
183 */
184 void markConfigAsValidColorAttachment(GrPixelConfig config) {
bsalomon480e8c02015-12-21 13:44:18 -0800185 fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000186 }
187
188 /**
189 * Call to check whether a config has been verified as a valid color
190 * attachment.
191 */
192 bool isConfigVerifiedColorAttachment(GrPixelConfig config) const {
bsalomon480e8c02015-12-21 13:44:18 -0800193 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColorAttachment_Flag);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000194 }
195
196 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000197 * Reports the type of MSAA FBO support.
198 */
199 MSFBOType msFBOType() const { return fMSFBOType; }
200
201 /**
bsalomon@google.com347c3822013-05-01 20:10:01 +0000202 * Does the supported MSAA FBO extension have MSAA renderbuffers?
203 */
204 bool usesMSAARenderBuffers() const {
205 return kNone_MSFBOType != fMSFBOType &&
206 kES_IMG_MsToTexture_MSFBOType != fMSFBOType &&
vbuzinovdded6962015-06-12 08:59:45 -0700207 kES_EXT_MsToTexture_MSFBOType != fMSFBOType &&
208 kMixedSamples_MSFBOType != fMSFBOType;
bsalomon@google.com347c3822013-05-01 20:10:01 +0000209 }
210
211 /**
212 * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and
213 * then implicitly resolved when read.
214 */
215 bool usesImplicitMSAAResolve() const {
216 return kES_IMG_MsToTexture_MSFBOType == fMSFBOType ||
217 kES_EXT_MsToTexture_MSFBOType == fMSFBOType;
218 }
219
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000220 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; }
221
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000222 /// What type of buffer mapping is supported?
223 MapBufferType mapBufferType() const { return fMapBufferType; }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000224
jvanverthd7a2c1f2015-12-07 07:36:44 -0800225 /// What type of transfer buffer is supported?
226 TransferBufferType transferBufferType() const { return fTransferBufferType; }
227
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000228 /// The maximum number of fragment uniform vectors (GLES has min. 16).
229 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; }
230
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000231 /// maximum number of attribute values per vertex
bsalomon@google.com60da4172012-06-01 19:25:00 +0000232 int maxVertexAttributes() const { return fMaxVertexAttributes; }
233
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000234 /// maximum number of texture units accessible in the fragment shader.
235 int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; }
236
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000237 /**
238 * Depending on the ES extensions present the BGRA external format may
bsalomon41e4384e2016-01-08 09:12:44 -0800239 * correspond to either a BGRA or RGBA internalFormat. On desktop GL it is
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000240 * RGBA.
241 */
bsalomon41e4384e2016-01-08 09:12:44 -0800242 bool bgraIsInternalFormat() const;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000243
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000244 /// Is there support for GL_UNPACK_ROW_LENGTH
245 bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; }
246
247 /// Is there support for GL_UNPACK_FLIP_Y
248 bool unpackFlipYSupport() const { return fUnpackFlipYSupport; }
249
250 /// Is there support for GL_PACK_ROW_LENGTH
251 bool packRowLengthSupport() const { return fPackRowLengthSupport; }
252
253 /// Is there support for GL_PACK_REVERSE_ROW_ORDER
254 bool packFlipYSupport() const { return fPackFlipYSupport; }
255
256 /// Is there support for texture parameter GL_TEXTURE_USAGE
257 bool textureUsageSupport() const { return fTextureUsageSupport; }
258
259 /// Is there support for glTexStorage
260 bool texStorageSupport() const { return fTexStorageSupport; }
261
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000262 /// Is there support for GL_RED and GL_R8
263 bool textureRedSupport() const { return fTextureRedSupport; }
264
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000265 /// Is GL_ARB_IMAGING supported
266 bool imagingSupport() const { return fImagingSupport; }
267
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000268 /// Is there support for Vertex Array Objects?
269 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; }
270
cdalton626e1ff2015-06-12 13:56:46 -0700271 /// Is there support for GL_EXT_direct_state_access?
272 bool directStateAccessSupport() const { return fDirectStateAccessSupport; }
273
274 /// Is there support for GL_KHR_debug?
275 bool debugSupport() const { return fDebugSupport; }
276
jvanverth3f801cb2014-12-16 09:49:38 -0800277 /// Is there support for ES2 compatability?
278 bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; }
279
cdaltond4727922015-11-10 12:49:06 -0800280 /// Can we call glDisable(GL_MULTISAMPLE)?
bsalomon76148af2016-01-12 11:13:47 -0800281 bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
cdaltond4727922015-11-10 12:49:06 -0800282
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000283 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
bsalomon76148af2016-01-12 11:13:47 -0800284 bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
bsalomon@google.com96966a52013-02-21 16:34:21 +0000285
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000286 /// Does ReadPixels support the provided format/type combo?
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000287 bool readPixelsSupported(const GrGLInterface* intf,
bsalomon7928ef62016-01-05 10:26:39 -0800288 GrPixelConfig readConfig,
289 GrPixelConfig currFBOConfig) const;
skia.committer@gmail.com631cdcb2013-03-01 12:12:55 +0000290
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000291 bool isCoreProfile() const { return fIsCoreProfile; }
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000292
joshualittc1f56b52015-06-22 12:31:31 -0700293 bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; }
294
joshualitt7bdd70a2015-10-01 06:28:11 -0700295 bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; }
296
bsalomon7ea33f52015-11-22 14:51:00 -0800297 /// Are textures with GL_TEXTURE_EXTERNAL_OES type supported.
298 bool externalTextureSupport() const { return fExternalTextureSupport; }
299
bsalomoncdee0092016-01-08 13:20:12 -0800300 /// GL_ARB_texture_swizzle
301 bool textureSwizzleSupport() const { return fTextureSwizzleSupport; }
302
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000303 /**
bsalomon16921ec2015-07-30 15:34:56 -0700304 * Is there support for enabling/disabling sRGB writes for sRGB-capable color attachments?
305 * If false this does not mean sRGB is not supported but rather that if it is supported
306 * it cannot be turned off for configs that support it.
307 */
308 bool srgbWriteControl() const { return fSRGBWriteControl; }
309
310 /**
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000311 * Returns a string containing the caps info.
312 */
mtklein36352bf2015-03-25 18:17:31 -0700313 SkString dump() const override;
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000314
bsalomon88c7b982015-07-31 11:20:16 -0700315 bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
316 bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
317
egdanielf5294392015-10-21 07:14:17 -0700318 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
jvanverthe9c0fc62015-04-29 11:18:05 -0700319
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000320private:
bsalomon76148af2016-01-12 11:13:47 -0800321 enum ExternalFormatUsage {
322 kTexImage_ExternalFormatUsage,
323 kOther_ExternalFormatUsage,
324
325 kLast_ExternalFormatUsage = kOther_ExternalFormatUsage
326 };
327 static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1;
328 bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig,
329 ExternalFormatUsage usage, GrGLenum* externalFormat,
330 GrGLenum* externalType) const;
331
cdalton4cd67132015-06-10 19:23:46 -0700332 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
egdaniel05ded892015-10-26 07:38:05 -0700333 void initGLSL(const GrGLContextInfo&);
kkinnunencfe62e32015-07-01 02:58:50 -0700334 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
bsalomon424cc262015-05-22 10:37:30 -0700335
egdanielb7e7d572015-11-04 04:23:53 -0800336 void onApplyOptionsOverrides(const GrContextOptions& options) override;
337
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000338 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
cdalton1dd05422015-06-12 09:01:18 -0700339 void initBlendEqationSupport(const GrGLContextInfo&);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000340 void initStencilFormats(const GrGLContextInfo&);
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000341 // This must be called after initFSAASupport().
bsalomoncdee0092016-01-08 13:20:12 -0800342 void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrGLSLCaps* glslCaps);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000343
jvanverthcba99b82015-06-24 06:59:57 -0700344 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
345 const GrGLInterface* intf,
346 GrGLSLCaps* glslCaps);
347
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000348 SkTArray<StencilFormat, true> fStencilFormats;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000349
350 int fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000351 int fMaxVertexAttributes;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000352 int fMaxFragmentTextureUnits;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000353
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000354 MSFBOType fMSFBOType;
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000355 InvalidateFBType fInvalidateFBType;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000356 MapBufferType fMapBufferType;
jvanverthd7a2c1f2015-12-07 07:36:44 -0800357 TransferBufferType fTransferBufferType;
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000358
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000359 bool fUnpackRowLengthSupport : 1;
360 bool fUnpackFlipYSupport : 1;
361 bool fPackRowLengthSupport : 1;
362 bool fPackFlipYSupport : 1;
363 bool fTextureUsageSupport : 1;
364 bool fTexStorageSupport : 1;
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000365 bool fTextureRedSupport : 1;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000366 bool fImagingSupport : 1;
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000367 bool fVertexArrayObjectSupport : 1;
cdalton626e1ff2015-06-12 13:56:46 -0700368 bool fDirectStateAccessSupport : 1;
369 bool fDebugSupport : 1;
jvanverth3f801cb2014-12-16 09:49:38 -0800370 bool fES2CompatibilitySupport : 1;
cdaltond4727922015-11-10 12:49:06 -0800371 bool fMultisampleDisableSupport : 1;
bsalomon@google.com96966a52013-02-21 16:34:21 +0000372 bool fUseNonVBOVertexAndIndexDynamicData : 1;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000373 bool fIsCoreProfile : 1;
joshualittc1f56b52015-06-22 12:31:31 -0700374 bool fBindFragDataLocationSupport : 1;
bsalomon16921ec2015-07-30 15:34:56 -0700375 bool fSRGBWriteControl : 1;
bsalomon88c7b982015-07-31 11:20:16 -0700376 bool fRGBA8888PixelsOpsAreSlow : 1;
377 bool fPartialFBOReadIsSlow : 1;
joshualitt7bdd70a2015-10-01 06:28:11 -0700378 bool fBindUniformLocationSupport : 1;
bsalomon7ea33f52015-11-22 14:51:00 -0800379 bool fExternalTextureSupport : 1;
bsalomoncdee0092016-01-08 13:20:12 -0800380 bool fTextureSwizzleSupport : 1;
joshualitt58162332014-08-01 06:44:53 -0700381
bsalomon7928ef62016-01-05 10:26:39 -0800382 /** Number type of the components (with out considering number of bits.) */
383 enum FormatType {
384 kNormalizedFixedPoint_FormatType,
385 kFloat_FormatType,
386 };
387
388 struct ReadPixelsFormat {
389 ReadPixelsFormat() : fFormat(0), fType(0) {}
390 GrGLenum fFormat;
391 GrGLenum fType;
392 };
393
bsalomon76148af2016-01-12 11:13:47 -0800394 struct ConfigFormats {
395 ConfigFormats() {
396 // Inits to known bad GL enum values.
397 memset(this, 0xAB, sizeof(ConfigFormats));
398 }
399 GrGLenum fBaseInternalFormat;
400 GrGLenum fSizedInternalFormat;
401
402 /** The external format and type are to be used when uploading/downloading data using this
403 config where both the CPU data and GrSurface are the same config. To get the external
404 format and type when converting between configs while copying to/from memory use
405 getExternalFormat().
406 The kTexImage external format is usually the same as kOther except for kSRGBA on some
407 GL contexts. */
408 GrGLenum fExternalFormat[kExternalFormatUsageCnt];
409 GrGLenum fExternalType;
410
411
412 // Either the base or sized internal format depending on the GL and config.
413 GrGLenum fInternalFormatTexImage;
414 GrGLenum fInternalFormatRenderbuffer;
415 };
416
bsalomon30447372015-12-21 09:03:05 -0800417 struct ConfigInfo {
bsalomon7928ef62016-01-05 10:26:39 -0800418 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
bsalomon30447372015-12-21 09:03:05 -0800419
420 ConfigFormats fFormats;
421
bsalomon7928ef62016-01-05 10:26:39 -0800422 FormatType fFormatType;
423
424 // On ES contexts there are restrictions on type type/format that may be used for
425 // ReadPixels. One is implicitly specified by the current FBO's format. The other is
426 // queryable. This stores the queried option (lazily).
427 ReadPixelsFormat fSecondReadPixelsFormat;
428
bsalomon30447372015-12-21 09:03:05 -0800429 enum {
430 // This indicates that a stencil format has not yet been determined for the config.
431 kUnknown_StencilIndex = -1,
432 // This indicates that there is no supported stencil format for the config.
433 kUnsupported_StencilFormatIndex = -2
434 };
bsalomon480e8c02015-12-21 13:44:18 -0800435
436 // Index fStencilFormats.
437 int fStencilFormatIndex;
438
439 enum {
bsalomon41e4384e2016-01-08 09:12:44 -0800440 kVerifiedColorAttachment_Flag = 0x1,
441 kTextureable_Flag = 0x2,
442 kRenderable_Flag = 0x4,
443 kRenderableWithMSAA_Flag = 0x8,
bsalomon480e8c02015-12-21 13:44:18 -0800444 };
445 uint32_t fFlags;
bsalomoncdee0092016-01-08 13:20:12 -0800446
447 GrSwizzle fSwizzle;
bsalomon30447372015-12-21 09:03:05 -0800448 };
449
450 ConfigInfo fConfigTable[kGrPixelConfigCnt];
451
bsalomon4b91f762015-05-19 09:29:46 -0700452 typedef GrCaps INHERITED;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000453};
454
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000455#endif