blob: 376610d8b0d9636c299f0a4fee95174c89f3634f [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
bsalomon083617b2016-02-12 12:10:14 -080080 enum BlitFramebufferSupport {
81 kNone_BlitFramebufferSupport,
82 /**
83 * ANGLE exposes a limited blit framebuffer extension that does not allow for stretching
84 * or mirroring.
85 */
86 kNoScalingNoMirroring_BlitFramebufferSupport,
87 kFull_BlitFramebufferSupport
88 };
89
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +000090 enum InvalidateFBType {
91 kNone_InvalidateFBType,
92 kDiscard_InvalidateFBType, //<! glDiscardFramebuffer()
bsalomon083617b2016-02-12 12:10:14 -080093 kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer()
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +000094
95 kLast_InvalidateFBType = kInvalidate_InvalidateFBType
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000096 };
97
commit-bot@chromium.org160b4782014-05-05 12:32:37 +000098 enum MapBufferType {
99 kNone_MapBufferType,
100 kMapBuffer_MapBufferType, // glMapBuffer()
101 kMapBufferRange_MapBufferType, // glMapBufferRange()
102 kChromium_MapBufferType, // GL_CHROMIUM_map_sub
103
104 kLast_MapBufferType = kChromium_MapBufferType,
105 };
106
jvanverthd7a2c1f2015-12-07 07:36:44 -0800107 enum TransferBufferType {
108 kNone_TransferBufferType,
109 kPBO_TransferBufferType, // ARB_pixel_buffer_object
110 kChromium_TransferBufferType, // CHROMIUM_pixel_transfer_buffer_object
111
112 kLast_TransferBufferType = kChromium_TransferBufferType,
113 };
114
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000115 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000116 * Initializes the GrGLCaps to the set of features supported in the current
117 * OpenGL context accessible via ctxInfo.
118 */
bsalomon682c2692015-05-22 14:01:46 -0700119 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
120 const GrGLInterface* glInterface);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000121
bsalomon41e4384e2016-01-08 09:12:44 -0800122 bool isConfigTexturable(GrPixelConfig config) const override {
brianosmanc571c002016-03-17 13:01:26 -0700123 SkASSERT(kGrPixelConfigCnt > config);
bsalomon41e4384e2016-01-08 09:12:44 -0800124 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag);
125 }
126
127 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
brianosmanc571c002016-03-17 13:01:26 -0700128 SkASSERT(kGrPixelConfigCnt > config);
bsalomon41e4384e2016-01-08 09:12:44 -0800129 if (withMSAA) {
130 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag);
131 } else {
132 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag);
133 }
134 }
135
cblume790d5132016-02-29 11:13:29 -0800136 bool isConfigTexSupportEnabled(GrPixelConfig config) const {
brianosmanc571c002016-03-17 13:01:26 -0700137 SkASSERT(kGrPixelConfigCnt > config);
cblume790d5132016-02-29 11:13:29 -0800138 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseTexStorage_Flag);
139 }
140
bsalomoncdee0092016-01-08 13:20:12 -0800141 /** Returns the mapping between GrPixelConfig components and GL internal format components. */
142 const GrSwizzle& configSwizzle(GrPixelConfig config) const {
143 return fConfigTable[config].fSwizzle;
144 }
145
bsalomon76148af2016-01-12 11:13:47 -0800146 bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
147 GrGLenum* internalFormat, GrGLenum* externalFormat,
148 GrGLenum* externalType) const;
149
150 bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const;
151
152 bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
153 GrGLenum* externalFormat, GrGLenum* externalType) const;
154
155 bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const;
156
bsalomon30447372015-12-21 09:03:05 -0800157 /**
158 * Gets an array of legal stencil formats. These formats are not guaranteed
159 * to be supported by the driver but are legal GLenum names given the GL
160 * version and extensions supported.
161 */
162 const SkTArray<StencilFormat, true>& stencilFormats() const {
163 return fStencilFormats;
164 }
165
166 /**
167 * Has a stencil format index been found for the config (or we've found that no format works).
168 */
169 bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const {
170 return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex;
171 }
172
173 /**
174 * Gets the stencil format index for the config. This assumes
175 * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if
176 * no stencil format is supported with the config. Otherwise, returned index refers to the array
177 * returned by stencilFormats().
178 */
179 int getStencilFormatIndexForConfig(GrPixelConfig config) const {
180 SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config));
181 return fConfigTable[config].fStencilFormatIndex;
182 }
183
184 /**
185 * If index is >= 0 this records an index into stencilFormats() as the best stencil format for
186 * the config. If < 0 it records that the config has no supported stencil format index.
187 */
188 void setStencilFormatIndexForConfig(GrPixelConfig config, int index) {
189 SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config));
190 if (index < 0) {
191 fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex;
192 } else {
193 fConfigTable[config].fStencilFormatIndex = index;
194 }
195 }
196
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000197 /**
198 * Call to note that a color config has been verified as a valid color
199 * attachment. This may save future calls to glCheckFramebufferStatus
200 * using isConfigVerifiedColorAttachment().
201 */
202 void markConfigAsValidColorAttachment(GrPixelConfig config) {
bsalomon480e8c02015-12-21 13:44:18 -0800203 fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000204 }
205
206 /**
207 * Call to check whether a config has been verified as a valid color
208 * attachment.
209 */
210 bool isConfigVerifiedColorAttachment(GrPixelConfig config) const {
bsalomon480e8c02015-12-21 13:44:18 -0800211 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColorAttachment_Flag);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000212 }
213
214 /**
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000215 * Reports the type of MSAA FBO support.
216 */
217 MSFBOType msFBOType() const { return fMSFBOType; }
218
219 /**
bsalomon083617b2016-02-12 12:10:14 -0800220 * Does the preferred MSAA FBO extension have MSAA renderbuffers?
bsalomon@google.com347c3822013-05-01 20:10:01 +0000221 */
222 bool usesMSAARenderBuffers() const {
223 return kNone_MSFBOType != fMSFBOType &&
224 kES_IMG_MsToTexture_MSFBOType != fMSFBOType &&
vbuzinovdded6962015-06-12 08:59:45 -0700225 kES_EXT_MsToTexture_MSFBOType != fMSFBOType &&
226 kMixedSamples_MSFBOType != fMSFBOType;
bsalomon@google.com347c3822013-05-01 20:10:01 +0000227 }
228
229 /**
bsalomon083617b2016-02-12 12:10:14 -0800230 * What functionality is supported by glBlitFramebuffer.
231 */
232 BlitFramebufferSupport blitFramebufferSupport() const { return fBlitFramebufferSupport; }
233
234 /**
bsalomon@google.com347c3822013-05-01 20:10:01 +0000235 * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and
236 * then implicitly resolved when read.
237 */
238 bool usesImplicitMSAAResolve() const {
239 return kES_IMG_MsToTexture_MSFBOType == fMSFBOType ||
240 kES_EXT_MsToTexture_MSFBOType == fMSFBOType;
241 }
242
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000243 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; }
244
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000245 /// What type of buffer mapping is supported?
246 MapBufferType mapBufferType() const { return fMapBufferType; }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000247
jvanverthd7a2c1f2015-12-07 07:36:44 -0800248 /// What type of transfer buffer is supported?
249 TransferBufferType transferBufferType() const { return fTransferBufferType; }
250
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000251 /// The maximum number of fragment uniform vectors (GLES has min. 16).
252 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; }
253
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000254 /// maximum number of attribute values per vertex
bsalomon@google.com60da4172012-06-01 19:25:00 +0000255 int maxVertexAttributes() const { return fMaxVertexAttributes; }
256
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000257 /**
258 * Depending on the ES extensions present the BGRA external format may
bsalomon41e4384e2016-01-08 09:12:44 -0800259 * correspond to either a BGRA or RGBA internalFormat. On desktop GL it is
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000260 * RGBA.
261 */
bsalomon41e4384e2016-01-08 09:12:44 -0800262 bool bgraIsInternalFormat() const;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000263
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000264 /// Is there support for GL_UNPACK_ROW_LENGTH
265 bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; }
266
267 /// Is there support for GL_UNPACK_FLIP_Y
268 bool unpackFlipYSupport() const { return fUnpackFlipYSupport; }
269
270 /// Is there support for GL_PACK_ROW_LENGTH
271 bool packRowLengthSupport() const { return fPackRowLengthSupport; }
272
273 /// Is there support for GL_PACK_REVERSE_ROW_ORDER
274 bool packFlipYSupport() const { return fPackFlipYSupport; }
275
276 /// Is there support for texture parameter GL_TEXTURE_USAGE
277 bool textureUsageSupport() const { return fTextureUsageSupport; }
278
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000279 /// Is there support for GL_RED and GL_R8
280 bool textureRedSupport() const { return fTextureRedSupport; }
281
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000282 /// Is GL_ARB_IMAGING supported
283 bool imagingSupport() const { return fImagingSupport; }
284
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000285 /// Is there support for Vertex Array Objects?
286 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; }
287
cdalton626e1ff2015-06-12 13:56:46 -0700288 /// Is there support for GL_EXT_direct_state_access?
289 bool directStateAccessSupport() const { return fDirectStateAccessSupport; }
290
291 /// Is there support for GL_KHR_debug?
292 bool debugSupport() const { return fDebugSupport; }
293
jvanverth3f801cb2014-12-16 09:49:38 -0800294 /// Is there support for ES2 compatability?
295 bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; }
296
cdaltond4727922015-11-10 12:49:06 -0800297 /// Can we call glDisable(GL_MULTISAMPLE)?
bsalomon76148af2016-01-12 11:13:47 -0800298 bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
cdaltond4727922015-11-10 12:49:06 -0800299
cdalton06604b92016-02-05 10:09:51 -0800300 /// Is there support for glDraw*Indirect? Note that the baseInstance fields of indirect draw
301 /// commands cannot be used unless we have base instance support.
302 bool drawIndirectSupport() const { return fDrawIndirectSupport; }
303
304 /// Is there support for glMultiDraw*Indirect? Note that the baseInstance fields of indirect
305 /// draw commands cannot be used unless we have base instance support.
306 bool multiDrawIndirectSupport() const { return fMultiDrawIndirectSupport; }
307
308 /// Are the baseInstance fields supported in indirect draw commands?
309 bool baseInstanceSupport() const { return fBaseInstanceSupport; }
310
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000311 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
bsalomon76148af2016-01-12 11:13:47 -0800312 bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
bsalomon@google.com96966a52013-02-21 16:34:21 +0000313
bsalomon1aa20292016-01-22 08:16:09 -0800314 /// Does ReadPixels support reading readConfig pixels from a FBO that is renderTargetConfig?
315 bool readPixelsSupported(GrPixelConfig renderTargetConfig,
bsalomon7928ef62016-01-05 10:26:39 -0800316 GrPixelConfig readConfig,
bsalomon1aa20292016-01-22 08:16:09 -0800317 std::function<void (GrGLenum, GrGLint*)> getIntegerv,
318 std::function<bool ()> bindRenderTarget) const;
skia.committer@gmail.com631cdcb2013-03-01 12:12:55 +0000319
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000320 bool isCoreProfile() const { return fIsCoreProfile; }
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000321
joshualittc1f56b52015-06-22 12:31:31 -0700322 bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; }
323
joshualitt7bdd70a2015-10-01 06:28:11 -0700324 bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; }
325
bsalomone5286e02016-01-14 09:24:09 -0800326 /// Are textures with GL_TEXTURE_RECTANGLE type supported.
327 bool rectangleTextureSupport() const { return fRectangleTextureSupport; }
328
bsalomoncdee0092016-01-08 13:20:12 -0800329 /// GL_ARB_texture_swizzle
330 bool textureSwizzleSupport() const { return fTextureSwizzleSupport; }
331
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000332 /**
bsalomon16921ec2015-07-30 15:34:56 -0700333 * Is there support for enabling/disabling sRGB writes for sRGB-capable color attachments?
334 * If false this does not mean sRGB is not supported but rather that if it is supported
335 * it cannot be turned off for configs that support it.
336 */
337 bool srgbWriteControl() const { return fSRGBWriteControl; }
338
cblume09bd2c02016-03-01 14:08:28 -0800339 bool mipMapLevelAndLodControlSupport() const { return fMipMapLevelAndLodControlSupport; }
340
bsalomon16921ec2015-07-30 15:34:56 -0700341 /**
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000342 * Returns a string containing the caps info.
343 */
mtklein36352bf2015-03-25 18:17:31 -0700344 SkString dump() const override;
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +0000345
bsalomon88c7b982015-07-31 11:20:16 -0700346 bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
347 bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
ericrkb4ecabd2016-03-11 15:18:20 -0800348 bool rgbaToBgraReadbackConversionsAreSlow() const {
349 return fRGBAToBGRAReadbackConversionsAreSlow;
350 }
bsalomon88c7b982015-07-31 11:20:16 -0700351
egdanielf5294392015-10-21 07:14:17 -0700352 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
jvanverthe9c0fc62015-04-29 11:18:05 -0700353
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000354private:
bsalomon76148af2016-01-12 11:13:47 -0800355 enum ExternalFormatUsage {
356 kTexImage_ExternalFormatUsage,
357 kOther_ExternalFormatUsage,
358
359 kLast_ExternalFormatUsage = kOther_ExternalFormatUsage
360 };
361 static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1;
362 bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig,
363 ExternalFormatUsage usage, GrGLenum* externalFormat,
364 GrGLenum* externalType) const;
365
cdalton4cd67132015-06-10 19:23:46 -0700366 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
egdaniel05ded892015-10-26 07:38:05 -0700367 void initGLSL(const GrGLContextInfo&);
kkinnunencfe62e32015-07-01 02:58:50 -0700368 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
bsalomon424cc262015-05-22 10:37:30 -0700369
egdanielb7e7d572015-11-04 04:23:53 -0800370 void onApplyOptionsOverrides(const GrContextOptions& options) override;
371
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000372 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*);
cdalton1dd05422015-06-12 09:01:18 -0700373 void initBlendEqationSupport(const GrGLContextInfo&);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000374 void initStencilFormats(const GrGLContextInfo&);
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000375 // This must be called after initFSAASupport().
bsalomoncdee0092016-01-08 13:20:12 -0800376 void initConfigTable(const GrGLContextInfo&, const GrGLInterface* gli, GrGLSLCaps* glslCaps);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000377
jvanverthcba99b82015-06-24 06:59:57 -0700378 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
379 const GrGLInterface* intf,
380 GrGLSLCaps* glslCaps);
381
bsalomon1aa20292016-01-22 08:16:09 -0800382 GrGLStandard fStandard;
383
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000384 SkTArray<StencilFormat, true> fStencilFormats;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000385
386 int fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +0000387 int fMaxVertexAttributes;
388
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000389 MSFBOType fMSFBOType;
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000390 InvalidateFBType fInvalidateFBType;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000391 MapBufferType fMapBufferType;
jvanverthd7a2c1f2015-12-07 07:36:44 -0800392 TransferBufferType fTransferBufferType;
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000393
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000394 bool fUnpackRowLengthSupport : 1;
395 bool fUnpackFlipYSupport : 1;
396 bool fPackRowLengthSupport : 1;
397 bool fPackFlipYSupport : 1;
398 bool fTextureUsageSupport : 1;
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000399 bool fTextureRedSupport : 1;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000400 bool fImagingSupport : 1;
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000401 bool fVertexArrayObjectSupport : 1;
cdalton626e1ff2015-06-12 13:56:46 -0700402 bool fDirectStateAccessSupport : 1;
403 bool fDebugSupport : 1;
jvanverth3f801cb2014-12-16 09:49:38 -0800404 bool fES2CompatibilitySupport : 1;
cdaltond4727922015-11-10 12:49:06 -0800405 bool fMultisampleDisableSupport : 1;
cdalton06604b92016-02-05 10:09:51 -0800406 bool fDrawIndirectSupport : 1;
407 bool fMultiDrawIndirectSupport : 1;
408 bool fBaseInstanceSupport : 1;
bsalomon@google.com96966a52013-02-21 16:34:21 +0000409 bool fUseNonVBOVertexAndIndexDynamicData : 1;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +0000410 bool fIsCoreProfile : 1;
joshualittc1f56b52015-06-22 12:31:31 -0700411 bool fBindFragDataLocationSupport : 1;
bsalomon16921ec2015-07-30 15:34:56 -0700412 bool fSRGBWriteControl : 1;
bsalomon88c7b982015-07-31 11:20:16 -0700413 bool fRGBA8888PixelsOpsAreSlow : 1;
414 bool fPartialFBOReadIsSlow : 1;
joshualitt7bdd70a2015-10-01 06:28:11 -0700415 bool fBindUniformLocationSupport : 1;
bsalomone5286e02016-01-14 09:24:09 -0800416 bool fRectangleTextureSupport : 1;
bsalomoncdee0092016-01-08 13:20:12 -0800417 bool fTextureSwizzleSupport : 1;
cblume09bd2c02016-03-01 14:08:28 -0800418 bool fMipMapLevelAndLodControlSupport : 1;
ericrkb4ecabd2016-03-11 15:18:20 -0800419 bool fRGBAToBGRAReadbackConversionsAreSlow : 1;
joshualitt58162332014-08-01 06:44:53 -0700420
bsalomon083617b2016-02-12 12:10:14 -0800421 BlitFramebufferSupport fBlitFramebufferSupport;
422
bsalomon7928ef62016-01-05 10:26:39 -0800423 /** Number type of the components (with out considering number of bits.) */
424 enum FormatType {
425 kNormalizedFixedPoint_FormatType,
426 kFloat_FormatType,
427 };
428
429 struct ReadPixelsFormat {
430 ReadPixelsFormat() : fFormat(0), fType(0) {}
431 GrGLenum fFormat;
432 GrGLenum fType;
433 };
434
bsalomon76148af2016-01-12 11:13:47 -0800435 struct ConfigFormats {
436 ConfigFormats() {
437 // Inits to known bad GL enum values.
438 memset(this, 0xAB, sizeof(ConfigFormats));
439 }
440 GrGLenum fBaseInternalFormat;
441 GrGLenum fSizedInternalFormat;
442
443 /** The external format and type are to be used when uploading/downloading data using this
444 config where both the CPU data and GrSurface are the same config. To get the external
445 format and type when converting between configs while copying to/from memory use
446 getExternalFormat().
447 The kTexImage external format is usually the same as kOther except for kSRGBA on some
448 GL contexts. */
449 GrGLenum fExternalFormat[kExternalFormatUsageCnt];
450 GrGLenum fExternalType;
451
452
453 // Either the base or sized internal format depending on the GL and config.
454 GrGLenum fInternalFormatTexImage;
455 GrGLenum fInternalFormatRenderbuffer;
456 };
457
bsalomon30447372015-12-21 09:03:05 -0800458 struct ConfigInfo {
bsalomon7928ef62016-01-05 10:26:39 -0800459 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
bsalomon30447372015-12-21 09:03:05 -0800460
461 ConfigFormats fFormats;
462
bsalomon7928ef62016-01-05 10:26:39 -0800463 FormatType fFormatType;
464
465 // On ES contexts there are restrictions on type type/format that may be used for
466 // ReadPixels. One is implicitly specified by the current FBO's format. The other is
467 // queryable. This stores the queried option (lazily).
468 ReadPixelsFormat fSecondReadPixelsFormat;
469
bsalomon30447372015-12-21 09:03:05 -0800470 enum {
471 // This indicates that a stencil format has not yet been determined for the config.
472 kUnknown_StencilIndex = -1,
473 // This indicates that there is no supported stencil format for the config.
474 kUnsupported_StencilFormatIndex = -2
475 };
bsalomon480e8c02015-12-21 13:44:18 -0800476
477 // Index fStencilFormats.
478 int fStencilFormatIndex;
479
480 enum {
bsalomon41e4384e2016-01-08 09:12:44 -0800481 kVerifiedColorAttachment_Flag = 0x1,
482 kTextureable_Flag = 0x2,
483 kRenderable_Flag = 0x4,
484 kRenderableWithMSAA_Flag = 0x8,
cblume790d5132016-02-29 11:13:29 -0800485 kCanUseTexStorage_Flag = 0x10,
bsalomon480e8c02015-12-21 13:44:18 -0800486 };
487 uint32_t fFlags;
bsalomoncdee0092016-01-08 13:20:12 -0800488
489 GrSwizzle fSwizzle;
bsalomon30447372015-12-21 09:03:05 -0800490 };
491
492 ConfigInfo fConfigTable[kGrPixelConfigCnt];
493
bsalomon4b91f762015-05-19 09:29:46 -0700494 typedef GrCaps INHERITED;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000495};
496
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000497#endif