blob: 044ecce81438c5f67494b008abd16e890baeb8a4 [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
bsalomon1aa20292016-01-22 08:16:09 -080012#include <functional>
13
mtklein3183a412016-01-08 12:11:39 -080014#include "glsl/GrGLSL.h"
bsalomoncdee0092016-01-08 13:20:12 -080015#include "GrCaps.h"
egdaniel8dc7c3a2015-04-16 11:22:42 -070016#include "GrGLStencilAttachment.h"
bsalomoncdee0092016-01-08 13:20:12 -080017#include "GrSwizzle.h"
piotaixre4b23142014-10-02 10:57:53 -070018#include "SkChecksum.h"
mtklein2aa1f7e2015-02-20 12:35:32 -080019#include "SkTHash.h"
robertphillips@google.coma2d71482012-08-01 20:08:47 +000020#include "SkTArray.h"
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000021
22class GrGLContextInfo;
jvanverthe9c0fc62015-04-29 11:18:05 -070023class GrGLSLCaps;
bsalomon1aa20292016-01-22 08:16:09 -080024class GrGLRenderTarget;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000025
26/**
27 * Stores some capabilities of a GL context. Most are determined by the GL
28 * version and the extensions string. It also tracks formats that have passed
29 * the FBO completeness test.
30 */
bsalomon4b91f762015-05-19 09:29:46 -070031class GrGLCaps : public GrCaps {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000032public:
egdaniel8dc7c3a2015-04-16 11:22:42 -070033 typedef GrGLStencilAttachment::Format StencilFormat;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000034
35 /**
36 * The type of MSAA for FBOs supported. Different extensions have different
37 * semantics of how / when a resolve is performed.
38 */
39 enum MSFBOType {
40 /**
41 * no support for MSAA FBOs
42 */
rmistry@google.comfbfcd562012-08-23 18:09:54 +000043 kNone_MSFBOType = 0,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000044 /**
skia.committer@gmail.com6fc1b492013-09-06 07:01:45 +000045 * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object).
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000046 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000047 kDesktop_ARB_MSFBOType,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000048 /**
49 * earlier GL_EXT_framebuffer* extensions
50 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000051 kDesktop_EXT_MSFBOType,
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000052 /**
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +000053 * Similar to kDesktop_ARB but with additional restrictions on glBlitFramebuffer.
54 */
55 kES_3_0_MSFBOType,
56 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000057 * GL_APPLE_framebuffer_multisample ES extension
58 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000059 kES_Apple_MSFBOType,
bsalomon@google.comf3a60c02013-03-19 19:06:09 +000060 /**
bsalomon@google.com347c3822013-05-01 20:10:01 +000061 * GL_IMG_multisampled_render_to_texture. This variation does not have MSAA renderbuffers.
62 * Instead the texture is multisampled when bound to the FBO and then resolved automatically
63 * when read. It also defines an alternate value for GL_MAX_SAMPLES (which we call
64 * GR_GL_MAX_SAMPLES_IMG).
bsalomon@google.comf3a60c02013-03-19 19:06:09 +000065 */
bsalomon@google.com347c3822013-05-01 20:10:01 +000066 kES_IMG_MsToTexture_MSFBOType,
67 /**
68 * GL_EXT_multisampled_render_to_texture. Same as the IMG one above but uses the standard
69 * GL_MAX_SAMPLES value.
70 */
71 kES_EXT_MsToTexture_MSFBOType,
vbuzinovdded6962015-06-12 08:59:45 -070072 /**
73 * GL_NV_framebuffer_mixed_samples.
74 */
75 kMixedSamples_MSFBOType,
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000076
vbuzinovdded6962015-06-12 08:59:45 -070077 kLast_MSFBOType = kMixedSamples_MSFBOType
bsalomon@google.com6b0cf022013-05-03 13:35:14 +000078 };
79
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +000080 enum InvalidateFBType {
81 kNone_InvalidateFBType,
82 kDiscard_InvalidateFBType, //<! glDiscardFramebuffer()
83 kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer()
84
85 kLast_InvalidateFBType = kInvalidate_InvalidateFBType
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000086 };
87
commit-bot@chromium.org160b4782014-05-05 12:32:37 +000088 enum MapBufferType {
89 kNone_MapBufferType,
90 kMapBuffer_MapBufferType, // glMapBuffer()
91 kMapBufferRange_MapBufferType, // glMapBufferRange()
92 kChromium_MapBufferType, // GL_CHROMIUM_map_sub
93
94 kLast_MapBufferType = kChromium_MapBufferType,
95 };
96
jvanverthd7a2c1f2015-12-07 07:36:44 -080097 enum TransferBufferType {
98 kNone_TransferBufferType,
99 kPBO_TransferBufferType, // ARB_pixel_buffer_object
100 kChromium_TransferBufferType, // CHROMIUM_pixel_transfer_buffer_object
101
102 kLast_TransferBufferType = kChromium_TransferBufferType,
103 };
104
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000105 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000106 * Initializes the GrGLCaps to the set of features supported in the current
107 * OpenGL context accessible via ctxInfo.
108 */
bsalomon682c2692015-05-22 14:01:46 -0700109 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
110 const GrGLInterface* glInterface);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000111
bsalomon41e4384e2016-01-08 09:12:44 -0800112 bool isConfigTexturable(GrPixelConfig config) const override {
113 SkASSERT(kGrPixelConfigCnt > config);
114 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag);
115 }
116
117 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
118 SkASSERT(kGrPixelConfigCnt > config);
119 if (withMSAA) {
120 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag);
121 } else {
122 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag);
123 }
124 }
125
bsalomoncdee0092016-01-08 13:20:12 -0800126 /** Returns the mapping between GrPixelConfig components and GL internal format components. */
127 const GrSwizzle& configSwizzle(GrPixelConfig config) const {
128 return fConfigTable[config].fSwizzle;
129 }
130
bsalomon76148af2016-01-12 11:13:47 -0800131 bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
132 GrGLenum* internalFormat, GrGLenum* externalFormat,
133 GrGLenum* externalType) const;
134
135 bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const;
136
137 bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
138 GrGLenum* externalFormat, GrGLenum* externalType) const;
139
140 bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const;
141
bsalomon30447372015-12-21 09:03:05 -0800142 /**
143 * Gets an array of legal stencil formats. These formats are not guaranteed
144 * to be supported by the driver but are legal GLenum names given the GL
145 * version and extensions supported.
146 */
147 const SkTArray<StencilFormat, true>& stencilFormats() const {
148 return fStencilFormats;
149 }
150
151 /**
152 * Has a stencil format index been found for the config (or we've found that no format works).
153 */
154 bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const {
155 return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex;
156 }
157
158 /**
159 * Gets the stencil format index for the config. This assumes
160 * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if
161 * no stencil format is supported with the config. Otherwise, returned index refers to the array
162 * returned by stencilFormats().
163 */
164 int getStencilFormatIndexForConfig(GrPixelConfig config) const {
165 SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config));
166 return fConfigTable[config].fStencilFormatIndex;
167 }
168
169 /**
170 * If index is >= 0 this records an index into stencilFormats() as the best stencil format for
171 * the config. If < 0 it records that the config has no supported stencil format index.
172 */
173 void setStencilFormatIndexForConfig(GrPixelConfig config, int index) {
174 SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config));
175 if (index < 0) {
176 fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex;
177 } else {
178 fConfigTable[config].fStencilFormatIndex = index;
179 }
180 }
181
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000182 /**
183 * Call to note that a color config has been verified as a valid color
184 * attachment. This may save future calls to glCheckFramebufferStatus
185 * using isConfigVerifiedColorAttachment().
186 */
187 void markConfigAsValidColorAttachment(GrPixelConfig config) {
bsalomon480e8c02015-12-21 13:44:18 -0800188 fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000189 }
190
191 /**
192 * Call to check whether a config has been verified as a valid color
193 * attachment.
194 */
195 bool isConfigVerifiedColorAttachment(GrPixelConfig config) const {
bsalomon480e8c02015-12-21 13:44:18 -0800196 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColorAttachment_Flag);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000197 }
198
199 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000200 * Reports the type of MSAA FBO support.
201 */
202 MSFBOType msFBOType() const { return fMSFBOType; }
203
204 /**
bsalomon@google.com347c3822013-05-01 20:10:01 +0000205 * Does the supported MSAA FBO extension have MSAA renderbuffers?
206 */
207 bool usesMSAARenderBuffers() const {
208 return kNone_MSFBOType != fMSFBOType &&
209 kES_IMG_MsToTexture_MSFBOType != fMSFBOType &&
vbuzinovdded6962015-06-12 08:59:45 -0700210 kES_EXT_MsToTexture_MSFBOType != fMSFBOType &&
211 kMixedSamples_MSFBOType != fMSFBOType;
bsalomon@google.com347c3822013-05-01 20:10:01 +0000212 }
213
214 /**
215 * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and
216 * then implicitly resolved when read.
217 */
218 bool usesImplicitMSAAResolve() const {
219 return kES_IMG_MsToTexture_MSFBOType == fMSFBOType ||
220 kES_EXT_MsToTexture_MSFBOType == fMSFBOType;
221 }
222
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000223 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; }
224
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000225 /// What type of buffer mapping is supported?
226 MapBufferType mapBufferType() const { return fMapBufferType; }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000227
jvanverthd7a2c1f2015-12-07 07:36:44 -0800228 /// What type of transfer buffer is supported?
229 TransferBufferType transferBufferType() const { return fTransferBufferType; }
230
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000231 /// The maximum number of fragment uniform vectors (GLES has min. 16).
232 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; }
233
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000234 /// maximum number of attribute values per vertex
bsalomon@google.com60da4172012-06-01 19:25:00 +0000235 int maxVertexAttributes() const { return fMaxVertexAttributes; }
236
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000237 /// maximum number of texture units accessible in the fragment shader.
238 int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; }
239
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000240 /**
241 * Depending on the ES extensions present the BGRA external format may
bsalomon41e4384e2016-01-08 09:12:44 -0800242 * correspond to either a BGRA or RGBA internalFormat. On desktop GL it is
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000243 * RGBA.
244 */
bsalomon41e4384e2016-01-08 09:12:44 -0800245 bool bgraIsInternalFormat() const;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000246
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000247 /// Is there support for GL_UNPACK_ROW_LENGTH
248 bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; }
249
250 /// Is there support for GL_UNPACK_FLIP_Y
251 bool unpackFlipYSupport() const { return fUnpackFlipYSupport; }
252
253 /// Is there support for GL_PACK_ROW_LENGTH
254 bool packRowLengthSupport() const { return fPackRowLengthSupport; }
255
256 /// Is there support for GL_PACK_REVERSE_ROW_ORDER
257 bool packFlipYSupport() const { return fPackFlipYSupport; }
258
259 /// Is there support for texture parameter GL_TEXTURE_USAGE
260 bool textureUsageSupport() const { return fTextureUsageSupport; }
261
262 /// Is there support for glTexStorage
263 bool texStorageSupport() const { return fTexStorageSupport; }
264
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000265 /// Is there support for GL_RED and GL_R8
266 bool textureRedSupport() const { return fTextureRedSupport; }
267
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000268 /// Is GL_ARB_IMAGING supported
269 bool imagingSupport() const { return fImagingSupport; }
270
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000271 /// Is there support for Vertex Array Objects?
272 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; }
273
cdalton626e1ff2015-06-12 13:56:46 -0700274 /// Is there support for GL_EXT_direct_state_access?
275 bool directStateAccessSupport() const { return fDirectStateAccessSupport; }
276
277 /// Is there support for GL_KHR_debug?
278 bool debugSupport() const { return fDebugSupport; }
279
jvanverth3f801cb2014-12-16 09:49:38 -0800280 /// Is there support for ES2 compatability?
281 bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; }
282
cdaltond4727922015-11-10 12:49:06 -0800283 /// Can we call glDisable(GL_MULTISAMPLE)?
bsalomon76148af2016-01-12 11:13:47 -0800284 bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
cdaltond4727922015-11-10 12:49:06 -0800285
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000286 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
bsalomon76148af2016-01-12 11:13:47 -0800287 bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
bsalomon@google.com96966a52013-02-21 16:34:21 +0000288
bsalomon1aa20292016-01-22 08:16:09 -0800289 /// Does ReadPixels support reading readConfig pixels from a FBO that is renderTargetConfig?
290 bool readPixelsSupported(GrPixelConfig renderTargetConfig,
bsalomon7928ef62016-01-05 10:26:39 -0800291 GrPixelConfig readConfig,
bsalomon1aa20292016-01-22 08:16:09 -0800292 std::function<void (GrGLenum, GrGLint*)> getIntegerv,
293 std::function<bool ()> bindRenderTarget) const;
skia.committer@gmail.com631cdcb2013-03-01 12:12:55 +0000294
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000295 bool isCoreProfile() const { return fIsCoreProfile; }
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000296
joshualittc1f56b52015-06-22 12:31:31 -0700297 bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; }
298
joshualitt7bdd70a2015-10-01 06:28:11 -0700299 bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; }
300
bsalomon7ea33f52015-11-22 14:51:00 -0800301 /// Are textures with GL_TEXTURE_EXTERNAL_OES type supported.
302 bool externalTextureSupport() const { return fExternalTextureSupport; }
303
bsalomone5286e02016-01-14 09:24:09 -0800304 /// Are textures with GL_TEXTURE_RECTANGLE type supported.
305 bool rectangleTextureSupport() const { return fRectangleTextureSupport; }
306
bsalomoncdee0092016-01-08 13:20:12 -0800307 /// GL_ARB_texture_swizzle
308 bool textureSwizzleSupport() const { return fTextureSwizzleSupport; }
309
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000310 /**
bsalomon16921ec2015-07-30 15:34:56 -0700311 * Is there support for enabling/disabling sRGB writes for sRGB-capable color attachments?
312 * If false this does not mean sRGB is not supported but rather that if it is supported
313 * it cannot be turned off for configs that support it.
314 */
315 bool srgbWriteControl() const { return fSRGBWriteControl; }
316
317 /**
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000318 * Returns a string containing the caps info.
319 */
mtklein36352bf2015-03-25 18:17:31 -0700320 SkString dump() const override;
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000321
bsalomon88c7b982015-07-31 11:20:16 -0700322 bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
323 bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
324
egdanielf5294392015-10-21 07:14:17 -0700325 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
jvanverthe9c0fc62015-04-29 11:18:05 -0700326
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000327private:
bsalomon76148af2016-01-12 11:13:47 -0800328 enum ExternalFormatUsage {
329 kTexImage_ExternalFormatUsage,
330 kOther_ExternalFormatUsage,
331
332 kLast_ExternalFormatUsage = kOther_ExternalFormatUsage
333 };
334 static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1;
335 bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig,
336 ExternalFormatUsage usage, GrGLenum* externalFormat,
337 GrGLenum* externalType) const;
338
cdalton4cd67132015-06-10 19:23:46 -0700339 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
egdaniel05ded892015-10-26 07:38:05 -0700340 void initGLSL(const GrGLContextInfo&);
kkinnunencfe62e32015-07-01 02:58:50 -0700341 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
bsalomon424cc262015-05-22 10:37:30 -0700342
egdanielb7e7d572015-11-04 04:23:53 -0800343 void onApplyOptionsOverrides(const GrContextOptions& options) override;
344
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000345 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
cdalton1dd05422015-06-12 09:01:18 -0700346 void initBlendEqationSupport(const GrGLContextInfo&);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000347 void initStencilFormats(const GrGLContextInfo&);
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000348 // This must be called after initFSAASupport().
bsalomoncdee0092016-01-08 13:20:12 -0800349 void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrGLSLCaps* glslCaps);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000350
jvanverthcba99b82015-06-24 06:59:57 -0700351 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
352 const GrGLInterface* intf,
353 GrGLSLCaps* glslCaps);
354
bsalomon1aa20292016-01-22 08:16:09 -0800355 GrGLStandard fStandard;
356
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000357 SkTArray<StencilFormat, true> fStencilFormats;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000358
359 int fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000360 int fMaxVertexAttributes;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000361 int fMaxFragmentTextureUnits;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000362
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000363 MSFBOType fMSFBOType;
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000364 InvalidateFBType fInvalidateFBType;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000365 MapBufferType fMapBufferType;
jvanverthd7a2c1f2015-12-07 07:36:44 -0800366 TransferBufferType fTransferBufferType;
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000367
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000368 bool fUnpackRowLengthSupport : 1;
369 bool fUnpackFlipYSupport : 1;
370 bool fPackRowLengthSupport : 1;
371 bool fPackFlipYSupport : 1;
372 bool fTextureUsageSupport : 1;
373 bool fTexStorageSupport : 1;
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000374 bool fTextureRedSupport : 1;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000375 bool fImagingSupport : 1;
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000376 bool fVertexArrayObjectSupport : 1;
cdalton626e1ff2015-06-12 13:56:46 -0700377 bool fDirectStateAccessSupport : 1;
378 bool fDebugSupport : 1;
jvanverth3f801cb2014-12-16 09:49:38 -0800379 bool fES2CompatibilitySupport : 1;
cdaltond4727922015-11-10 12:49:06 -0800380 bool fMultisampleDisableSupport : 1;
bsalomon@google.com96966a52013-02-21 16:34:21 +0000381 bool fUseNonVBOVertexAndIndexDynamicData : 1;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000382 bool fIsCoreProfile : 1;
joshualittc1f56b52015-06-22 12:31:31 -0700383 bool fBindFragDataLocationSupport : 1;
bsalomon16921ec2015-07-30 15:34:56 -0700384 bool fSRGBWriteControl : 1;
bsalomon88c7b982015-07-31 11:20:16 -0700385 bool fRGBA8888PixelsOpsAreSlow : 1;
386 bool fPartialFBOReadIsSlow : 1;
joshualitt7bdd70a2015-10-01 06:28:11 -0700387 bool fBindUniformLocationSupport : 1;
bsalomon7ea33f52015-11-22 14:51:00 -0800388 bool fExternalTextureSupport : 1;
bsalomone5286e02016-01-14 09:24:09 -0800389 bool fRectangleTextureSupport : 1;
bsalomoncdee0092016-01-08 13:20:12 -0800390 bool fTextureSwizzleSupport : 1;
joshualitt58162332014-08-01 06:44:53 -0700391
bsalomon7928ef62016-01-05 10:26:39 -0800392 /** Number type of the components (with out considering number of bits.) */
393 enum FormatType {
394 kNormalizedFixedPoint_FormatType,
395 kFloat_FormatType,
396 };
397
398 struct ReadPixelsFormat {
399 ReadPixelsFormat() : fFormat(0), fType(0) {}
400 GrGLenum fFormat;
401 GrGLenum fType;
402 };
403
bsalomon76148af2016-01-12 11:13:47 -0800404 struct ConfigFormats {
405 ConfigFormats() {
406 // Inits to known bad GL enum values.
407 memset(this, 0xAB, sizeof(ConfigFormats));
408 }
409 GrGLenum fBaseInternalFormat;
410 GrGLenum fSizedInternalFormat;
411
412 /** The external format and type are to be used when uploading/downloading data using this
413 config where both the CPU data and GrSurface are the same config. To get the external
414 format and type when converting between configs while copying to/from memory use
415 getExternalFormat().
416 The kTexImage external format is usually the same as kOther except for kSRGBA on some
417 GL contexts. */
418 GrGLenum fExternalFormat[kExternalFormatUsageCnt];
419 GrGLenum fExternalType;
420
421
422 // Either the base or sized internal format depending on the GL and config.
423 GrGLenum fInternalFormatTexImage;
424 GrGLenum fInternalFormatRenderbuffer;
425 };
426
bsalomon30447372015-12-21 09:03:05 -0800427 struct ConfigInfo {
bsalomon7928ef62016-01-05 10:26:39 -0800428 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
bsalomon30447372015-12-21 09:03:05 -0800429
430 ConfigFormats fFormats;
431
bsalomon7928ef62016-01-05 10:26:39 -0800432 FormatType fFormatType;
433
434 // On ES contexts there are restrictions on type type/format that may be used for
435 // ReadPixels. One is implicitly specified by the current FBO's format. The other is
436 // queryable. This stores the queried option (lazily).
437 ReadPixelsFormat fSecondReadPixelsFormat;
438
bsalomon30447372015-12-21 09:03:05 -0800439 enum {
440 // This indicates that a stencil format has not yet been determined for the config.
441 kUnknown_StencilIndex = -1,
442 // This indicates that there is no supported stencil format for the config.
443 kUnsupported_StencilFormatIndex = -2
444 };
bsalomon480e8c02015-12-21 13:44:18 -0800445
446 // Index fStencilFormats.
447 int fStencilFormatIndex;
448
449 enum {
bsalomon41e4384e2016-01-08 09:12:44 -0800450 kVerifiedColorAttachment_Flag = 0x1,
451 kTextureable_Flag = 0x2,
452 kRenderable_Flag = 0x4,
453 kRenderableWithMSAA_Flag = 0x8,
bsalomon480e8c02015-12-21 13:44:18 -0800454 };
455 uint32_t fFlags;
bsalomoncdee0092016-01-08 13:20:12 -0800456
457 GrSwizzle fSwizzle;
bsalomon30447372015-12-21 09:03:05 -0800458 };
459
460 ConfigInfo fConfigTable[kGrPixelConfigCnt];
461
bsalomon4b91f762015-05-19 09:29:46 -0700462 typedef GrCaps INHERITED;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000463};
464
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000465#endif