blob: c4f42701f11ee20e355d2f13084437a69c5da5f8 [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
bsalomone5286e02016-01-14 09:24:09 -0800300 /// Are textures with GL_TEXTURE_RECTANGLE type supported.
301 bool rectangleTextureSupport() const { return fRectangleTextureSupport; }
302
bsalomoncdee0092016-01-08 13:20:12 -0800303 /// GL_ARB_texture_swizzle
304 bool textureSwizzleSupport() const { return fTextureSwizzleSupport; }
305
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000306 /**
bsalomon16921ec2015-07-30 15:34:56 -0700307 * Is there support for enabling/disabling sRGB writes for sRGB-capable color attachments?
308 * If false this does not mean sRGB is not supported but rather that if it is supported
309 * it cannot be turned off for configs that support it.
310 */
311 bool srgbWriteControl() const { return fSRGBWriteControl; }
312
313 /**
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000314 * Returns a string containing the caps info.
315 */
mtklein36352bf2015-03-25 18:17:31 -0700316 SkString dump() const override;
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000317
bsalomon88c7b982015-07-31 11:20:16 -0700318 bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
319 bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
320
egdanielf5294392015-10-21 07:14:17 -0700321 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
jvanverthe9c0fc62015-04-29 11:18:05 -0700322
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000323private:
bsalomon76148af2016-01-12 11:13:47 -0800324 enum ExternalFormatUsage {
325 kTexImage_ExternalFormatUsage,
326 kOther_ExternalFormatUsage,
327
328 kLast_ExternalFormatUsage = kOther_ExternalFormatUsage
329 };
330 static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1;
331 bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig,
332 ExternalFormatUsage usage, GrGLenum* externalFormat,
333 GrGLenum* externalType) const;
334
cdalton4cd67132015-06-10 19:23:46 -0700335 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
egdaniel05ded892015-10-26 07:38:05 -0700336 void initGLSL(const GrGLContextInfo&);
kkinnunencfe62e32015-07-01 02:58:50 -0700337 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
bsalomon424cc262015-05-22 10:37:30 -0700338
egdanielb7e7d572015-11-04 04:23:53 -0800339 void onApplyOptionsOverrides(const GrContextOptions& options) override;
340
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000341 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
cdalton1dd05422015-06-12 09:01:18 -0700342 void initBlendEqationSupport(const GrGLContextInfo&);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000343 void initStencilFormats(const GrGLContextInfo&);
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000344 // This must be called after initFSAASupport().
bsalomoncdee0092016-01-08 13:20:12 -0800345 void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrGLSLCaps* glslCaps);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000346
jvanverthcba99b82015-06-24 06:59:57 -0700347 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
348 const GrGLInterface* intf,
349 GrGLSLCaps* glslCaps);
350
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000351 SkTArray<StencilFormat, true> fStencilFormats;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000352
353 int fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000354 int fMaxVertexAttributes;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000355 int fMaxFragmentTextureUnits;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000356
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000357 MSFBOType fMSFBOType;
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000358 InvalidateFBType fInvalidateFBType;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000359 MapBufferType fMapBufferType;
jvanverthd7a2c1f2015-12-07 07:36:44 -0800360 TransferBufferType fTransferBufferType;
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000361
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000362 bool fUnpackRowLengthSupport : 1;
363 bool fUnpackFlipYSupport : 1;
364 bool fPackRowLengthSupport : 1;
365 bool fPackFlipYSupport : 1;
366 bool fTextureUsageSupport : 1;
367 bool fTexStorageSupport : 1;
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000368 bool fTextureRedSupport : 1;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000369 bool fImagingSupport : 1;
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000370 bool fVertexArrayObjectSupport : 1;
cdalton626e1ff2015-06-12 13:56:46 -0700371 bool fDirectStateAccessSupport : 1;
372 bool fDebugSupport : 1;
jvanverth3f801cb2014-12-16 09:49:38 -0800373 bool fES2CompatibilitySupport : 1;
cdaltond4727922015-11-10 12:49:06 -0800374 bool fMultisampleDisableSupport : 1;
bsalomon@google.com96966a52013-02-21 16:34:21 +0000375 bool fUseNonVBOVertexAndIndexDynamicData : 1;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000376 bool fIsCoreProfile : 1;
joshualittc1f56b52015-06-22 12:31:31 -0700377 bool fBindFragDataLocationSupport : 1;
bsalomon16921ec2015-07-30 15:34:56 -0700378 bool fSRGBWriteControl : 1;
bsalomon88c7b982015-07-31 11:20:16 -0700379 bool fRGBA8888PixelsOpsAreSlow : 1;
380 bool fPartialFBOReadIsSlow : 1;
joshualitt7bdd70a2015-10-01 06:28:11 -0700381 bool fBindUniformLocationSupport : 1;
bsalomon7ea33f52015-11-22 14:51:00 -0800382 bool fExternalTextureSupport : 1;
bsalomone5286e02016-01-14 09:24:09 -0800383 bool fRectangleTextureSupport : 1;
bsalomoncdee0092016-01-08 13:20:12 -0800384 bool fTextureSwizzleSupport : 1;
joshualitt58162332014-08-01 06:44:53 -0700385
bsalomon7928ef62016-01-05 10:26:39 -0800386 /** Number type of the components (with out considering number of bits.) */
387 enum FormatType {
388 kNormalizedFixedPoint_FormatType,
389 kFloat_FormatType,
390 };
391
392 struct ReadPixelsFormat {
393 ReadPixelsFormat() : fFormat(0), fType(0) {}
394 GrGLenum fFormat;
395 GrGLenum fType;
396 };
397
bsalomon76148af2016-01-12 11:13:47 -0800398 struct ConfigFormats {
399 ConfigFormats() {
400 // Inits to known bad GL enum values.
401 memset(this, 0xAB, sizeof(ConfigFormats));
402 }
403 GrGLenum fBaseInternalFormat;
404 GrGLenum fSizedInternalFormat;
405
406 /** The external format and type are to be used when uploading/downloading data using this
407 config where both the CPU data and GrSurface are the same config. To get the external
408 format and type when converting between configs while copying to/from memory use
409 getExternalFormat().
410 The kTexImage external format is usually the same as kOther except for kSRGBA on some
411 GL contexts. */
412 GrGLenum fExternalFormat[kExternalFormatUsageCnt];
413 GrGLenum fExternalType;
414
415
416 // Either the base or sized internal format depending on the GL and config.
417 GrGLenum fInternalFormatTexImage;
418 GrGLenum fInternalFormatRenderbuffer;
419 };
420
bsalomon30447372015-12-21 09:03:05 -0800421 struct ConfigInfo {
bsalomon7928ef62016-01-05 10:26:39 -0800422 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
bsalomon30447372015-12-21 09:03:05 -0800423
424 ConfigFormats fFormats;
425
bsalomon7928ef62016-01-05 10:26:39 -0800426 FormatType fFormatType;
427
428 // On ES contexts there are restrictions on type type/format that may be used for
429 // ReadPixels. One is implicitly specified by the current FBO's format. The other is
430 // queryable. This stores the queried option (lazily).
431 ReadPixelsFormat fSecondReadPixelsFormat;
432
bsalomon30447372015-12-21 09:03:05 -0800433 enum {
434 // This indicates that a stencil format has not yet been determined for the config.
435 kUnknown_StencilIndex = -1,
436 // This indicates that there is no supported stencil format for the config.
437 kUnsupported_StencilFormatIndex = -2
438 };
bsalomon480e8c02015-12-21 13:44:18 -0800439
440 // Index fStencilFormats.
441 int fStencilFormatIndex;
442
443 enum {
bsalomon41e4384e2016-01-08 09:12:44 -0800444 kVerifiedColorAttachment_Flag = 0x1,
445 kTextureable_Flag = 0x2,
446 kRenderable_Flag = 0x4,
447 kRenderableWithMSAA_Flag = 0x8,
bsalomon480e8c02015-12-21 13:44:18 -0800448 };
449 uint32_t fFlags;
bsalomoncdee0092016-01-08 13:20:12 -0800450
451 GrSwizzle fSwizzle;
bsalomon30447372015-12-21 09:03:05 -0800452 };
453
454 ConfigInfo fConfigTable[kGrPixelConfigCnt];
455
bsalomon4b91f762015-05-19 09:29:46 -0700456 typedef GrCaps INHERITED;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000457};
458
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000459#endif