blob: b4287cced995447ef234f9a6c94d252199ae0dfc [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#include "GrGLCaps.h"
joshualittb4384b92014-10-21 12:53:15 -070010
robertphillips@google.com6177e692013-02-28 20:16:25 +000011#include "GrGLContext.h"
bsalomon@google.comc9668ec2012-04-11 18:16:41 +000012#include "SkTSearch.h"
bsalomon@google.com20f7f172013-05-17 19:05:03 +000013#include "SkTSort.h"
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000014
15GrGLCaps::GrGLCaps() {
16 this->reset();
17}
18
19void GrGLCaps::reset() {
bsalomon@google.combcce8922013-03-25 15:38:39 +000020 INHERITED::reset();
21
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000022 fVerifiedColorConfigs.reset();
23 fStencilFormats.reset();
24 fStencilVerifiedColorConfigs.reset();
25 fMSFBOType = kNone_MSFBOType;
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +000026 fInvalidateFBType = kNone_InvalidateFBType;
krajcevski3217c4a2014-06-09 09:10:04 -070027 fLATCAlias = kLATC_LATCAlias;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +000028 fMapBufferType = kNone_MapBufferType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000029 fMaxFragmentUniformVectors = 0;
bsalomon@google.com60da4172012-06-01 19:25:00 +000030 fMaxVertexAttributes = 0;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +000031 fMaxFragmentTextureUnits = 0;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000032 fRGBA8RenderbufferSupport = false;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000033 fBGRAIsInternalFormat = false;
34 fTextureSwizzleSupport = false;
35 fUnpackRowLengthSupport = false;
36 fUnpackFlipYSupport = false;
37 fPackRowLengthSupport = false;
38 fPackFlipYSupport = false;
39 fTextureUsageSupport = false;
40 fTexStorageSupport = false;
robertphillips@google.com443e5a52012-04-30 20:01:21 +000041 fTextureRedSupport = false;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +000042 fImagingSupport = false;
robertphillips@google.com1d89c932012-06-27 19:31:41 +000043 fTwoFormatLimit = false;
bsalomon@google.com706f6682012-10-23 14:53:55 +000044 fFragCoordsConventionSupport = false;
bsalomon@google.com07631cf2013-03-05 14:14:58 +000045 fVertexArrayObjectSupport = false;
jvanverth3f801cb2014-12-16 09:49:38 -080046 fES2CompatibilitySupport = false;
bsalomon@google.com96966a52013-02-21 16:34:21 +000047 fUseNonVBOVertexAndIndexDynamicData = false;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +000048 fIsCoreProfile = false;
robertphillips@google.com56ce48a2013-10-31 21:44:25 +000049 fFullClearIsFree = false;
commit-bot@chromium.org4362a382014-03-26 19:49:03 +000050 fDropsTileOnZeroDivide = false;
joshualitt58162332014-08-01 06:44:53 -070051 fFBFetchSupport = false;
joshualitt3c1096f2015-01-13 13:13:59 -080052 fFBFetchNeedsCustomOutput = false;
joshualitt58162332014-08-01 06:44:53 -070053 fFBFetchColorName = NULL;
54 fFBFetchExtensionString = NULL;
vbuzinov08b4d292015-04-01 06:29:49 -070055 fFBMixedSamplesSupport = false;
piotaixre4b23142014-10-02 10:57:53 -070056
57 fReadPixelsSupportedCache.reset();
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000058}
59
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000060GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000061 *this = caps;
62}
63
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +000064GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
bsalomon@google.combcce8922013-03-25 15:38:39 +000065 INHERITED::operator=(caps);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000066 fVerifiedColorConfigs = caps.fVerifiedColorConfigs;
67 fStencilFormats = caps.fStencilFormats;
68 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs;
krajcevski3217c4a2014-06-09 09:10:04 -070069 fLATCAlias = caps.fLATCAlias;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000070 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +000071 fMaxVertexAttributes = caps.fMaxVertexAttributes;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +000072 fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000073 fMSFBOType = caps.fMSFBOType;
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +000074 fInvalidateFBType = caps.fInvalidateFBType;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +000075 fMapBufferType = caps.fMapBufferType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000076 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000077 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat;
78 fTextureSwizzleSupport = caps.fTextureSwizzleSupport;
79 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport;
80 fUnpackFlipYSupport = caps.fUnpackFlipYSupport;
81 fPackRowLengthSupport = caps.fPackRowLengthSupport;
82 fPackFlipYSupport = caps.fPackFlipYSupport;
83 fTextureUsageSupport = caps.fTextureUsageSupport;
84 fTexStorageSupport = caps.fTexStorageSupport;
robertphillips@google.com443e5a52012-04-30 20:01:21 +000085 fTextureRedSupport = caps.fTextureRedSupport;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +000086 fImagingSupport = caps.fImagingSupport;
robertphillips@google.com1d89c932012-06-27 19:31:41 +000087 fTwoFormatLimit = caps.fTwoFormatLimit;
bsalomon@google.com706f6682012-10-23 14:53:55 +000088 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport;
bsalomon@google.com07631cf2013-03-05 14:14:58 +000089 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport;
jvanverth3f801cb2014-12-16 09:49:38 -080090 fES2CompatibilitySupport = caps.fES2CompatibilitySupport;
bsalomon@google.com96966a52013-02-21 16:34:21 +000091 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +000092 fIsCoreProfile = caps.fIsCoreProfile;
robertphillips@google.com56ce48a2013-10-31 21:44:25 +000093 fFullClearIsFree = caps.fFullClearIsFree;
commit-bot@chromium.org4362a382014-03-26 19:49:03 +000094 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
joshualitt58162332014-08-01 06:44:53 -070095 fFBFetchSupport = caps.fFBFetchSupport;
joshualitt3c1096f2015-01-13 13:13:59 -080096 fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput;
joshualitt58162332014-08-01 06:44:53 -070097 fFBFetchColorName = caps.fFBFetchColorName;
98 fFBFetchExtensionString = caps.fFBFetchExtensionString;
vbuzinov08b4d292015-04-01 06:29:49 -070099 fFBMixedSamplesSupport = caps.fFBMixedSamplesSupport;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000100
101 return *this;
102}
103
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000104bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000105
106 this->reset();
107 if (!ctxInfo.isInitialized()) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000108 return false;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000109 }
110
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000111 GrGLStandard standard = ctxInfo.standard();
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000112 GrGLVersion version = ctxInfo.version();
113
bsalomon@google.combcce8922013-03-25 15:38:39 +0000114 /**************************************************************************
115 * Caps specific to GrGLCaps
116 **************************************************************************/
117
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000118 if (kGLES_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000119 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
120 &fMaxFragmentUniformVectors);
121 } else {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000122 SkASSERT(kGL_GrGLStandard == standard);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000123 GrGLint max;
124 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max);
125 fMaxFragmentUniformVectors = max / 4;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000126 if (version >= GR_GL_VER(3, 2)) {
127 GrGLint profileMask;
128 GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
129 fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
130 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000131 }
bsalomon@google.com60da4172012-06-01 19:25:00 +0000132 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes);
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000133 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000134
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000135 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000136 fRGBA8RenderbufferSupport = true;
137 } else {
commit-bot@chromium.orgc5dffe42013-08-20 15:25:21 +0000138 fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) ||
139 ctxInfo.hasExtension("GL_OES_rgb8_rgba8") ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000140 ctxInfo.hasExtension("GL_ARM_rgba8");
141 }
142
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000143 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000144 fTextureSwizzleSupport = version >= GR_GL_VER(3,3) ||
145 ctxInfo.hasExtension("GL_ARB_texture_swizzle");
146 } else {
commit-bot@chromium.org6364b5e2013-08-20 20:22:52 +0000147 fTextureSwizzleSupport = version >= GR_GL_VER(3,0);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000148 }
149
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000150 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000151 fUnpackRowLengthSupport = true;
152 fUnpackFlipYSupport = false;
153 fPackRowLengthSupport = true;
154 fPackFlipYSupport = false;
155 } else {
commit-bot@chromium.orgdc3134c2013-08-16 16:12:23 +0000156 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) ||
157 ctxInfo.hasExtension("GL_EXT_unpack_subimage");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000158 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy");
commit-bot@chromium.orgdc3134c2013-08-16 16:12:23 +0000159 fPackRowLengthSupport = version >= GR_GL_VER(3,0) ||
160 ctxInfo.hasExtension("GL_NV_pack_subimage");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000161 fPackFlipYSupport =
162 ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order");
163 }
164
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000165 fTextureUsageSupport = (kGLES_GrGLStandard == standard) &&
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000166 ctxInfo.hasExtension("GL_ANGLE_texture_usage");
167
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000168 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org7a434a22013-08-21 14:01:56 +0000169 // The EXT version can apply to either GL or GLES.
170 fTexStorageSupport = version >= GR_GL_VER(4,2) ||
171 ctxInfo.hasExtension("GL_ARB_texture_storage") ||
172 ctxInfo.hasExtension("GL_EXT_texture_storage");
173 } else {
174 // Qualcomm Adreno drivers appear to have issues with texture storage.
175 fTexStorageSupport = (version >= GR_GL_VER(3,0) &&
176 kQualcomm_GrGLVendor != ctxInfo.vendor()) ||
177 ctxInfo.hasExtension("GL_EXT_texture_storage");
178 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000179
cdaltonfd4167d2015-04-21 11:45:56 -0700180 if (kGL_GrGLStandard == standard) {
181 fTextureBarrierSupport = version >= GR_GL_VER(4,5) ||
182 ctxInfo.hasExtension("GL_ARB_texture_barrier") ||
183 ctxInfo.hasExtension("GL_NV_texture_barrier");
184 } else {
185 fTextureBarrierSupport = ctxInfo.hasExtension("GL_NV_texture_barrier");
186 }
187
hendrikwa0d5ad72014-12-02 07:30:30 -0800188 // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support GL_RED
189 // and GL_RG on FBO textures.
190 if (!ctxInfo.isMesa()) {
191 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org459104c2013-06-14 14:42:56 +0000192 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
193 ctxInfo.hasExtension("GL_ARB_texture_rg");
hendrikwa0d5ad72014-12-02 07:30:30 -0800194 } else {
195 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
196 ctxInfo.hasExtension("GL_EXT_texture_rg");
commit-bot@chromium.org459104c2013-06-14 14:42:56 +0000197 }
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000198 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000199 fImagingSupport = kGL_GrGLStandard == standard &&
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000200 ctxInfo.hasExtension("GL_ARB_imaging");
201
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000202 // ES 2 only guarantees RGBA/uchar + one other format/type combo for
203 // ReadPixels. The other format has to checked at run-time since it
204 // can change based on which render target is bound
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000205 fTwoFormatLimit = kGLES_GrGLStandard == standard;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000206
rmistry63a9f842014-10-17 06:07:08 -0700207 // Frag Coords Convention support is not part of ES
bsalomon@google.com706f6682012-10-23 14:53:55 +0000208 // Known issue on at least some Intel platforms:
209 // http://code.google.com/p/skia/issues/detail?id=946
rmistry63a9f842014-10-17 06:07:08 -0700210 if (kIntel_GrGLVendor != ctxInfo.vendor() && kGLES_GrGLStandard != standard) {
bsalomon@google.com706f6682012-10-23 14:53:55 +0000211 fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration ||
212 ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions");
213 }
214
bsalomon@google.com3012ded2013-02-22 16:44:04 +0000215 // SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with
216 // frequently changing VBOs. We've measured a performance increase using non-VBO vertex
217 // data for dynamic content on these GPUs. Perhaps we should read the renderer string and
218 // limit this decision to specific GPU families rather than basing it on the vendor alone.
219 if (!GR_GL_MUST_USE_VBO &&
bsalomoned82c4e2014-09-02 07:54:47 -0700220 (kARM_GrGLVendor == ctxInfo.vendor() ||
221 kImagination_GrGLVendor == ctxInfo.vendor() ||
222 kQualcomm_GrGLVendor == ctxInfo.vendor())) {
bsalomon@google.com96966a52013-02-21 16:34:21 +0000223 fUseNonVBOVertexAndIndexDynamicData = true;
224 }
skia.committer@gmail.com631cdcb2013-03-01 12:12:55 +0000225
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000226 if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(4,3)) ||
skia.committer@gmail.coma9157722014-04-03 03:04:26 +0000227 (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) ||
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000228 ctxInfo.hasExtension("GL_ARB_invalidate_subdata")) {
229 fDiscardRenderTargetSupport = true;
230 fInvalidateFBType = kInvalidate_InvalidateFBType;
231 } else if (ctxInfo.hasExtension("GL_EXT_discard_framebuffer")) {
232 fDiscardRenderTargetSupport = true;
233 fInvalidateFBType = kDiscard_InvalidateFBType;
234 }
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000235
robertphillips@google.com56ce48a2013-10-31 21:44:25 +0000236 if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) {
237 fFullClearIsFree = true;
238 }
239
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000240 if (kGL_GrGLStandard == standard) {
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000241 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
tomhudson612e9262014-11-24 11:22:36 -0800242 ctxInfo.hasExtension("GL_ARB_vertex_array_object") ||
243 ctxInfo.hasExtension("GL_APPLE_vertex_array_object");
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000244 } else {
commit-bot@chromium.org2276c012013-08-16 15:53:33 +0000245 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
246 ctxInfo.hasExtension("GL_OES_vertex_array_object");
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000247 }
248
jvanverth3f801cb2014-12-16 09:49:38 -0800249 if (kGL_GrGLStandard == standard) {
250 fES2CompatibilitySupport = ctxInfo.hasExtension("GL_ARB_ES2_compatibility");
251 }
252 else {
253 fES2CompatibilitySupport = true;
254 }
255
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000256 if (kGLES_GrGLStandard == standard) {
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000257 if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
joshualitt3c1096f2015-01-13 13:13:59 -0800258 fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0));
joshualitt58162332014-08-01 06:44:53 -0700259 fFBFetchSupport = true;
260 fFBFetchColorName = "gl_LastFragData[0]";
261 fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch";
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000262 } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) {
joshualitt3c1096f2015-01-13 13:13:59 -0800263 // Actually, we haven't seen an ES3.0 device with this extension yet, so we don't know
264 fFBFetchNeedsCustomOutput = false;
joshualitt58162332014-08-01 06:44:53 -0700265 fFBFetchSupport = true;
266 fFBFetchColorName = "gl_LastFragData[0]";
267 fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch";
268 } else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) {
269 // The arm extension also requires an additional flag which we will set onResetContext
joshualitt3c1096f2015-01-13 13:13:59 -0800270 fFBFetchNeedsCustomOutput = false;
joshualitt58162332014-08-01 06:44:53 -0700271 fFBFetchSupport = true;
272 fFBFetchColorName = "gl_LastFragColorARM";
273 fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch";
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000274 }
275 }
276
commit-bot@chromium.org4362a382014-03-26 19:49:03 +0000277 // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader
278 fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor();
279
robertphillips@google.com6177e692013-02-28 20:16:25 +0000280 this->initFSAASupport(ctxInfo, gli);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000281 this->initStencilFormats(ctxInfo);
bsalomon@google.combcce8922013-03-25 15:38:39 +0000282
283 /**************************************************************************
bsalomon@google.comc26d94f2013-03-25 18:19:00 +0000284 * GrDrawTargetCaps fields
bsalomon@google.combcce8922013-03-25 15:38:39 +0000285 **************************************************************************/
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000286 if (kGL_GrGLStandard == standard) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000287 // we could also look for GL_ATI_separate_stencil extension or
288 // GL_EXT_stencil_two_side but they use different function signatures
289 // than GL2.0+ (and than each other).
290 fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0));
291 // supported on GL 1.4 and higher or by extension
292 fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) ||
293 ctxInfo.hasExtension("GL_EXT_stencil_wrap");
294 } else {
295 // ES 2 has two sided stencil and stencil wrap
296 fTwoSidedStencilSupport = true;
297 fStencilWrapOpsSupport = true;
298 }
299
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000300 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000301 fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the desktop VBO
302 // extension includes glMapBuffer.
303 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffer_range")) {
304 fMapBufferFlags |= kSubset_MapFlag;
305 fMapBufferType = kMapBufferRange_MapBufferType;
306 } else {
307 fMapBufferType = kMapBuffer_MapBufferType;
308 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000309 } else {
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000310 // Unextended GLES2 doesn't have any buffer mapping.
311 fMapBufferFlags = kNone_MapBufferType;
312 if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) {
313 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
314 fMapBufferType = kChromium_MapBufferType;
315 } else if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_map_buffer_range")) {
316 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
317 fMapBufferType = kMapBufferRange_MapBufferType;
318 } else if (ctxInfo.hasExtension("GL_OES_mapbuffer")) {
319 fMapBufferFlags = kCanMap_MapFlag;
320 fMapBufferType = kMapBuffer_MapBufferType;
321 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000322 }
323
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000324 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000325 SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) ||
326 ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two"));
327 fNPOTTextureTileSupport = true;
328 fMipMapSupport = true;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000329 } else {
330 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only
commit-bot@chromium.org22dd6b92013-08-16 18:13:48 +0000331 // ES3 has no limitations.
332 fNPOTTextureTileSupport = ctxInfo.version() >= GR_GL_VER(3,0) ||
333 ctxInfo.hasExtension("GL_OES_texture_npot");
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000334 // ES2 supports MIP mapping for POT textures but our caps don't allow for limited MIP
335 // support. The OES extension or ES 3.0 allow for MIPS on NPOT textures. So, apparently,
336 // does the undocumented GL_IMG_texture_npot extension. This extension does not seem to
337 // to alllow arbitrary wrap modes, however.
338 fMipMapSupport = fNPOTTextureTileSupport || ctxInfo.hasExtension("GL_IMG_texture_npot");
bsalomon@google.combcce8922013-03-25 15:38:39 +0000339 }
340
bsalomon@google.combcce8922013-03-25 15:38:39 +0000341 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_SIZE, &fMaxTextureSize);
342 GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize);
343 // Our render targets are always created with textures as the color
344 // attachment, hence this min:
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +0000345 fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize);
bsalomon@google.combcce8922013-03-25 15:38:39 +0000346
kkinnunen32b9a3b2014-07-02 22:56:35 -0700347 fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering");
348
349 if (fPathRenderingSupport) {
350 if (kGL_GrGLStandard == standard) {
jvanverth50530632015-04-27 10:36:27 -0700351 // We only support v1.3+ of GL_NV_path_rendering which allows us to
352 // set individual fragment inputs with ProgramPathFragmentInputGen. The API
353 // additions are detected by checking the existence of the function.
kkinnunen32b9a3b2014-07-02 22:56:35 -0700354 fPathRenderingSupport = ctxInfo.hasExtension("GL_EXT_direct_state_access") &&
jvanverth50530632015-04-27 10:36:27 -0700355 ((ctxInfo.version() >= GR_GL_VER(4,3) ||
356 ctxInfo.hasExtension("GL_ARB_program_interface_query")) &&
357 gli->fFunctions.fProgramPathFragmentInputGen);
kkinnunen32b9a3b2014-07-02 22:56:35 -0700358 } else {
kkinnunenec56e452014-08-25 22:21:16 -0700359 fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,1);
kkinnunen32b9a3b2014-07-02 22:56:35 -0700360 }
361 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000362
vbuzinov08b4d292015-04-01 06:29:49 -0700363 fFBMixedSamplesSupport = ctxInfo.hasExtension("GL_NV_framebuffer_mixed_samples");
364
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000365 fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker");
366
joshualitt58162332014-08-01 06:44:53 -0700367 // For now these two are equivalent but we could have dst read in shader via some other method
368 fDstReadInShaderSupport = fFBFetchSupport;
robertphillips@google.com8995b7b2013-11-01 15:03:34 +0000369
370 // Disable scratch texture reuse on Mali and Adreno devices
371 fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() &&
372 kQualcomm_GrGLVendor != ctxInfo.vendor();
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +0000373
bsalomon@google.combcce8922013-03-25 15:38:39 +0000374 // Enable supported shader-related caps
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000375 if (kGL_GrGLStandard == standard) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000376 fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) ||
377 ctxInfo.hasExtension("GL_ARB_blend_func_extended");
378 fShaderDerivativeSupport = true;
379 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
380 fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3,2) &&
381 ctxInfo.glslGeneration() >= k150_GrGLSLGeneration;
382 } else {
rmistry63a9f842014-10-17 06:07:08 -0700383 fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) ||
384 ctxInfo.hasExtension("GL_OES_standard_derivatives");
bsalomon@google.combcce8922013-03-25 15:38:39 +0000385 }
386
bsalomon@google.com347c3822013-05-01 20:10:01 +0000387 if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000388 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount);
389 } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) {
390 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
391 }
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000392
bsalomon63b21962014-11-05 07:05:34 -0800393 if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() ||
bsalomone702d972015-01-29 10:07:32 -0800394 kPowerVRRogue_GrGLRenderer == ctxInfo.renderer() ||
bsalomona8fcea02015-02-13 09:00:39 -0800395 kAdreno3xx_GrGLRenderer == ctxInfo.renderer()) {
bsalomon63b21962014-11-05 07:05:34 -0800396 fUseDrawInsteadOfClear = true;
397 }
398
bsalomond08ea5f2015-02-20 06:58:13 -0800399 if (kGL_GrGLStandard == standard) {
400 // ARB allows mixed size FBO attachments, EXT does not.
401 if (ctxInfo.version() >= GR_GL_VER(3, 0) ||
402 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
403 fOversizedStencilSupport = true;
404 } else {
405 SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object"));
406 }
407 } else {
408 // ES 3.0 supports mixed size FBO attachments, 2.0 does not.
409 fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0);
410 }
411
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000412 this->initConfigTexturableTable(ctxInfo, gli);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000413 this->initConfigRenderableTable(ctxInfo);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000414
bsalomon17168df2014-12-09 09:00:49 -0800415 this->initShaderPrecisionTable(ctxInfo, gli);
416
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000417 return true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000418}
419
420void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000421 // OpenGL < 3.0
422 // no support for render targets unless the GL_ARB_framebuffer_object
423 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
424 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
425 // probably don't get R8 in this case.
426
427 // OpenGL 3.0
428 // base color renderable: ALPHA, RED, RG, RGB, and RGBA
429 // sized derivatives: ALPHA8, R8, RGBA4, RGBA8
430
431 // >= OpenGL 3.1
432 // base color renderable: RED, RG, RGB, and RGBA
433 // sized derivatives: R8, RGBA4, RGBA8
434 // if the GL_ARB_compatibility extension is supported then we get back
435 // support for GL_ALPHA and ALPHA8
436
437 // GL_EXT_bgra adds BGRA render targets to any version
438
439 // ES 2.0
440 // color renderable: RGBA4, RGB5_A1, RGB565
441 // GL_EXT_texture_rg adds support for R8 as a color render target
442 // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
443 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support
444
445 // ES 3.0
446 // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
447 // below already account for this).
448
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000449 GrGLStandard standard = ctxInfo.standard();
450
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000451 enum {
452 kNo_MSAA = 0,
453 kYes_MSAA = 1,
454 };
455
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000456 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000457 // Post 3.0 we will get R8
458 // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
459 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
460 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000461 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true;
462 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000463 }
464 } else {
465 // On ES we can only hope for R8
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000466 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupport;
467 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000468 }
469
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000470 if (kGL_GrGLStandard != standard) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000471 // only available in ES
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000472 fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true;
473 fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000474 }
475
476 // we no longer support 444 as a render target
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000477 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false;
478 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000479
480 if (this->fRGBA8RenderbufferSupport) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000481 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
commit-bot@chromium.orgda3d69c2013-10-28 15:09:13 +0000482 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000483 }
484
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000485 if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000486 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true;
487 // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of
488 // configs that are color-renderable and can be passed to glRenderBufferStorageMultisample.
commit-bot@chromium.org4256d242013-10-17 16:29:41 +0000489 // Chromium may have an extension to allow BGRA renderbuffers to work on desktop platforms.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000490 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) {
commit-bot@chromium.org4256d242013-10-17 16:29:41 +0000491 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true;
492 } else {
493 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] =
494 !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers();
495 }
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000496 }
497
jvanverthfa1e8a72014-12-22 08:31:49 -0800498 if (this->fRGBA8RenderbufferSupport && this->isConfigTexturable(kSRGBA_8888_GrPixelConfig)) {
499 if (kGL_GrGLStandard == standard) {
500 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
501 ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
502 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
503 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
504 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
505 }
506 } else {
507 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
508 ctxInfo.hasExtension("GL_EXT_sRGB")) {
509 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
510 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
511 }
512 }
513 }
514
joshualittee5da552014-07-16 13:32:56 -0700515 if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
jvanverth28f9c602014-12-05 13:06:35 -0800516 if (kGL_GrGLStandard == standard) {
jvanvertha60b2ea2014-12-12 05:58:06 -0800517 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
jvanverth28f9c602014-12-05 13:06:35 -0800518 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true;
519 } else {
jvanvertha60b2ea2014-12-12 05:58:06 -0800520 if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) {
521 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
522 } else {
523 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false;
524 }
525 // for now we don't support floating point MSAA on ES
jvanverth28f9c602014-12-05 13:06:35 -0800526 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
527 }
joshualittee5da552014-07-16 13:32:56 -0700528 }
529
jvanverth28f9c602014-12-05 13:06:35 -0800530 if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) {
jvanverth28f9c602014-12-05 13:06:35 -0800531 if (kGL_GrGLStandard == standard) {
jvanvertha60b2ea2014-12-12 05:58:06 -0800532 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
jvanverth28f9c602014-12-05 13:06:35 -0800533 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true;
jvanverth1334c212014-12-18 05:44:55 -0800534 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
535 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
536 // for now we don't support floating point MSAA on ES
537 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
jvanverth28f9c602014-12-05 13:06:35 -0800538 } else {
jvanverth1334c212014-12-18 05:44:55 -0800539 if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float") && fTextureRedSupport) {
540 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
541 } else {
542 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false;
543 }
544 // for now we don't support floating point MSAA on ES
jvanverth28f9c602014-12-05 13:06:35 -0800545 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
546 }
547 }
548
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000549 // If we don't support MSAA then undo any places above where we set a config as renderable with
550 // msaa.
551 if (kNone_MSFBOType == fMSFBOType) {
552 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
553 fConfigRenderSupport[i][kYes_MSAA] = false;
554 }
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000555 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000556}
557
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000558void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000559 GrGLStandard standard = ctxInfo.standard();
560 GrGLVersion version = ctxInfo.version();
561
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000562 // Base texture support
563 fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
564 fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
565 fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
566 fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
567
568 // Check for 8-bit palette..
569 GrGLint numFormats;
570 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
571 if (numFormats) {
572 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
573 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
574 for (int i = 0; i < numFormats; ++i) {
575 if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
576 fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
577 break;
578 }
579 }
580 }
581
582 // Check for BGRA
583 if (kGL_GrGLStandard == standard) {
584 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
585 version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
586 } else {
587 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
588 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
589 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
590 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
591 fBGRAIsInternalFormat = true;
592 }
593 SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
594 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
595 }
596
jvanverthfa1e8a72014-12-22 08:31:49 -0800597 // Check for sRGBA
598 if (kGL_GrGLStandard == standard) {
599 fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
600 (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_texture_sRGB"));
601 } else {
602 fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
603 (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB"));
604 }
605
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000606 // Compressed texture support
607
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000608 // glCompressedTexImage2D is available on all OpenGL ES devices...
609 // however, it is only available on standard OpenGL after version 1.3
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000610 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000611
krajcevski786978162014-07-30 11:25:44 -0700612 fCompressedTexSubImageSupport =
bsalomon49f085d2014-09-05 13:34:00 -0700613 hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D);
krajcevski786978162014-07-30 11:25:44 -0700614
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000615 // Check for ETC1
616 bool hasETC1 = false;
617
618 // First check version for support
619 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000620 hasETC1 = hasCompressTex2D &&
joshualittee5da552014-07-16 13:32:56 -0700621 (version >= GR_GL_VER(4, 3) ||
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000622 ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000623 } else {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000624 hasETC1 = hasCompressTex2D &&
625 (version >= GR_GL_VER(3, 0) ||
626 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
627 // ETC2 is a superset of ETC1, so we can just check for that, too.
628 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
629 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000630 }
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000631 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000632
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000633 // Check for LATC under its various forms
634 LATCAlias alias = kLATC_LATCAlias;
635 bool hasLATC = hasCompressTex2D &&
636 (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
637 ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
638
639 // Check for RGTC
640 if (!hasLATC) {
641 // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
642 if (kGL_GrGLStandard == standard) {
643 hasLATC = version >= GR_GL_VER(3, 0);
644 }
645
646 if (!hasLATC) {
647 hasLATC =
648 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
649 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
650 }
651
652 if (hasLATC) {
653 alias = kRGTC_LATCAlias;
654 }
655 }
656
657 // Check for 3DC
658 if (!hasLATC) {
659 hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
660 if (hasLATC) {
661 alias = k3DC_LATCAlias;
662 }
663 }
664
665 fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
666 fLATCAlias = alias;
krajcevski238b4562014-06-30 09:09:22 -0700667
krajcevskib3abe902014-07-30 13:08:11 -0700668 // Check for R11_EAC ... We don't support R11_EAC on desktop, as most
669 // cards default to decompressing the textures in the driver, and is
670 // generally slower.
671 if (kGL_GrGLStandard != standard) {
krajcevski238b4562014-06-30 09:09:22 -0700672 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
673 }
joshualittee5da552014-07-16 13:32:56 -0700674
krajcevski7ef21622014-07-16 15:21:13 -0700675 // Check for ASTC
piotaixre4b23142014-10-02 10:57:53 -0700676 fConfigTextureSupport[kASTC_12x12_GrPixelConfig] =
krajcevski7ef21622014-07-16 15:21:13 -0700677 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
678 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
679 ctxInfo.hasExtension("GL_OES_texture_compression_astc");
680
joshualittee5da552014-07-16 13:32:56 -0700681 // Check for floating point texture support
682 // NOTE: We disallow floating point textures on ES devices if linear
683 // filtering modes are not supported. This is for simplicity, but a more
684 // granular approach is possible. Coincidentally, floating point textures became part of
685 // the standard in ES3.1 / OGL 3.1, hence the shorthand
686 bool hasFPTextures = version >= GR_GL_VER(3, 1);
687 if (!hasFPTextures) {
688 hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanvertha60b2ea2014-12-12 05:58:06 -0800689 (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
joshualittee5da552014-07-16 13:32:56 -0700690 ctxInfo.hasExtension("GL_OES_texture_float"));
691 }
692 fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
jvanverth28f9c602014-12-05 13:06:35 -0800693
694 // Check for fp16 texture support
695 // NOTE: We disallow floating point textures on ES devices if linear
696 // filtering modes are not supported. This is for simplicity, but a more
697 // granular approach is possible. Coincidentally, 16-bit floating point textures became part of
698 // the standard in ES3.1 / OGL 3.1, hence the shorthand
699 bool hasHalfFPTextures = version >= GR_GL_VER(3, 1);
700 if (!hasHalfFPTextures) {
701 hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanverth1334c212014-12-18 05:44:55 -0800702 (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
703 ctxInfo.hasExtension("GL_OES_texture_half_float"));
jvanverth28f9c602014-12-05 13:06:35 -0800704 }
jvanverth1334c212014-12-18 05:44:55 -0800705 fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000706}
707
piotaixre4b23142014-10-02 10:57:53 -0700708bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf,
709 GrGLenum format,
710 GrGLenum type) const {
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000711 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
712 // ES 2 guarantees this format is supported
robertphillips@google.comeca2dfb2012-06-27 20:13:49 +0000713 return true;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000714 }
715
716 if (!fTwoFormatLimit) {
717 // not limited by ES 2's constraints
718 return true;
719 }
720
bsalomon@google.com548a4332012-07-11 19:45:22 +0000721 GrGLint otherFormat = GR_GL_RGBA;
722 GrGLint otherType = GR_GL_UNSIGNED_BYTE;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000723
724 // The other supported format/type combo supported for ReadPixels
725 // can change based on which render target is bound
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000726 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000727 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT,
728 &otherFormat);
729
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000730 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000731 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE,
732 &otherType);
733
bsalomon@google.com548a4332012-07-11 19:45:22 +0000734 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000735}
736
piotaixre4b23142014-10-02 10:57:53 -0700737bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
738 GrGLenum format,
739 GrGLenum type,
740 GrGLenum currFboFormat) const {
mtklein2aa1f7e2015-02-20 12:35:32 -0800741 ReadPixelsSupportedFormat key = {format, type, currFboFormat};
742 if (const bool* supported = fReadPixelsSupportedCache.find(key)) {
743 return *supported;
piotaixre4b23142014-10-02 10:57:53 -0700744 }
mtklein2aa1f7e2015-02-20 12:35:32 -0800745 bool supported = this->doReadPixelsSupported(intf, format, type);
746 fReadPixelsSupportedCache.set(key, supported);
747 return supported;
piotaixre4b23142014-10-02 10:57:53 -0700748}
749
robertphillips@google.com6177e692013-02-28 20:16:25 +0000750void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000751
752 fMSFBOType = kNone_MSFBOType;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000753 if (kGL_GrGLStandard != ctxInfo.standard()) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000754 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed
755 // ES3 driver bugs on at least one device with a tiled GPU (N10).
756 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) {
757 fMSFBOType = kES_EXT_MsToTexture_MSFBOType;
758 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) {
759 fMSFBOType = kES_IMG_MsToTexture_MSFBOType;
commit-bot@chromium.org92b78842014-01-16 20:49:46 +0000760 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000761 fMSFBOType = GrGLCaps::kES_3_0_MSFBOType;
762 } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
763 // chrome's extension is equivalent to the EXT msaa
764 // and fbo_blit extensions.
765 fMSFBOType = kDesktop_EXT_MSFBOType;
766 } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
767 fMSFBOType = kES_Apple_MSFBOType;
768 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000769 } else {
770 if ((ctxInfo.version() >= GR_GL_VER(3,0)) ||
771 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000772 fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000773 } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") &&
774 ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000775 fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000776 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000777 }
778}
779
780namespace {
egdaniel8dc7c3a2015-04-16 11:22:42 -0700781const GrGLuint kUnknownBitCount = GrGLStencilAttachment::kUnknownBitCount;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000782}
783
784void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) {
785
786 // Build up list of legal stencil formats (though perhaps not supported on
787 // the particular gpu/driver) from most preferred to least.
788
789 // these consts are in order of most preferred to least preferred
790 // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
791
792 static const StencilFormat
793 // internal Format stencil bits total bits packed?
794 gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
795 gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
796 gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true },
797 gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false},
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000798 // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false},
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000799 gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true };
800
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000801 if (kGL_GrGLStandard == ctxInfo.standard()) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000802 bool supportsPackedDS =
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000803 ctxInfo.version() >= GR_GL_VER(3,0) ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000804 ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") ||
805 ctxInfo.hasExtension("GL_ARB_framebuffer_object");
806
807 // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we
808 // require FBO support we can expect these are legal formats and don't
809 // check. These also all support the unsized GL_STENCIL_INDEX.
810 fStencilFormats.push_back() = gS8;
811 fStencilFormats.push_back() = gS16;
812 if (supportsPackedDS) {
813 fStencilFormats.push_back() = gD24S8;
814 }
815 fStencilFormats.push_back() = gS4;
816 if (supportsPackedDS) {
817 fStencilFormats.push_back() = gDS;
818 }
819 } else {
820 // ES2 has STENCIL_INDEX8 without extensions but requires extensions
821 // for other formats.
822 // ES doesn't support using the unsized format.
823
824 fStencilFormats.push_back() = gS8;
825 //fStencilFormats.push_back() = gS16;
commit-bot@chromium.org04c500f2013-09-06 15:28:01 +0000826 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
827 ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000828 fStencilFormats.push_back() = gD24S8;
829 }
830 if (ctxInfo.hasExtension("GL_OES_stencil4")) {
831 fStencilFormats.push_back() = gS4;
832 }
833 }
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000834 SkASSERT(0 == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000835 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count());
836}
837
bsalomonc0bd6482014-12-09 10:04:14 -0800838static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
bsalomon17168df2014-12-09 09:00:49 -0800839 switch (p) {
bsalomonc0bd6482014-12-09 10:04:14 -0800840 case kLow_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800841 return GR_GL_LOW_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800842 case kMedium_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800843 return GR_GL_MEDIUM_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800844 case kHigh_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800845 return GR_GL_HIGH_FLOAT;
846 }
847 SkFAIL("Unknown precision.");
848 return -1;
849}
850
851static GrGLenum shader_type_to_gl_shader(GrShaderType type) {
852 switch (type) {
853 case kVertex_GrShaderType:
854 return GR_GL_VERTEX_SHADER;
855 case kGeometry_GrShaderType:
856 return GR_GL_GEOMETRY_SHADER;
857 case kFragment_GrShaderType:
858 return GR_GL_FRAGMENT_SHADER;
859 }
860 SkFAIL("Unknown shader type.");
861 return -1;
862}
863
864void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* intf) {
865 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4,1) ||
866 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
867 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800868 if (kGeometry_GrShaderType != s) {
bsalomon17168df2014-12-09 09:00:49 -0800869 GrShaderType shaderType = static_cast<GrShaderType>(s);
870 GrGLenum glShader = shader_type_to_gl_shader(shaderType);
871 PrecisionInfo* first = NULL;
872 fShaderPrecisionVaries = false;
bsalomonc0bd6482014-12-09 10:04:14 -0800873 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
874 GrSLPrecision precision = static_cast<GrSLPrecision>(p);
bsalomon17168df2014-12-09 09:00:49 -0800875 GrGLenum glPrecision = precision_to_gl_float_type(precision);
876 GrGLint range[2];
877 GrGLint bits;
878 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits);
879 if (bits) {
880 fFloatPrecisions[s][p].fLogRangeLow = range[0];
881 fFloatPrecisions[s][p].fLogRangeHigh = range[1];
882 fFloatPrecisions[s][p].fBits = bits;
883 if (!first) {
884 first = &fFloatPrecisions[s][p];
885 } else if (!fShaderPrecisionVaries) {
886 fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]);
887 }
888 }
889 }
890 }
891 }
892 } else {
893 // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
894 fShaderPrecisionVaries = false;
895 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800896 if (kGeometry_GrShaderType != s) {
bsalomonc0bd6482014-12-09 10:04:14 -0800897 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
bsalomon17168df2014-12-09 09:00:49 -0800898 fFloatPrecisions[s][p].fLogRangeLow = 127;
899 fFloatPrecisions[s][p].fLogRangeHigh = 127;
900 fFloatPrecisions[s][p].fBits = 23;
901 }
902 }
903 }
904 }
bsalomon06194c52014-12-09 11:16:12 -0800905 // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Assume they're
906 // the same as the vertex shader. Only fragment shaders were ever allowed to omit support for
907 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
908 // are recommended against.
909 if (fGeometryShaderSupport) {
910 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
911 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p];
912 }
913 }
bsalomon17168df2014-12-09 09:00:49 -0800914}
915
916
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000917void GrGLCaps::markColorConfigAndStencilFormatAsVerified(
918 GrPixelConfig config,
egdaniel8dc7c3a2015-04-16 11:22:42 -0700919 const GrGLStencilAttachment::Format& format) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000920#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
921 return;
922#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000923 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
924 SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000925 int count = fStencilFormats.count();
926 // we expect a really small number of possible formats so linear search
927 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000928 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000929 for (int i = 0; i < count; ++i) {
930 if (format.fInternalFormat ==
931 fStencilFormats[i].fInternalFormat) {
932 fStencilVerifiedColorConfigs[i].markVerified(config);
933 return;
934 }
935 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000936 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000937 "GrGLCaps doesn't know about.");
938}
939
940bool GrGLCaps::isColorConfigAndStencilFormatVerified(
941 GrPixelConfig config,
egdaniel8dc7c3a2015-04-16 11:22:42 -0700942 const GrGLStencilAttachment::Format& format) const {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000943#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
944 return false;
945#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000946 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000947 int count = fStencilFormats.count();
948 // we expect a really small number of possible formats so linear search
949 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000950 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000951 for (int i = 0; i < count; ++i) {
952 if (format.fInternalFormat ==
953 fStencilFormats[i].fInternalFormat) {
954 return fStencilVerifiedColorConfigs[i].isVerified(config);
955 }
956 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000957 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000958 "GLCaps doesn't know about.");
959 return false;
960}
961
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000962SkString GrGLCaps::dump() const {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000963
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000964 SkString r = INHERITED::dump();
bsalomon@google.combcce8922013-03-25 15:38:39 +0000965
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000966 r.appendf("--- GL-Specific ---\n");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000967 for (int i = 0; i < fStencilFormats.count(); ++i) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000968 r.appendf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000969 i,
970 fStencilFormats[i].fStencilBits,
971 fStencilFormats[i].fTotalBits);
972 }
973
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000974 static const char* kMSFBOExtStr[] = {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000975 "None",
976 "ARB",
977 "EXT",
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000978 "ES 3.0",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000979 "Apple",
bsalomon@google.com347c3822013-05-01 20:10:01 +0000980 "IMG MS To Texture",
981 "EXT MS To Texture",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000982 };
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000983 GR_STATIC_ASSERT(0 == kNone_MSFBOType);
984 GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType);
985 GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType);
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000986 GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType);
987 GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType);
988 GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType);
989 GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +0000990 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000991
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000992 static const char* kInvalidateFBTypeStr[] = {
993 "None",
994 "Discard",
995 "Invalidate",
996 };
997 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType);
998 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType);
999 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
1000 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +00001001
commit-bot@chromium.org160b4782014-05-05 12:32:37 +00001002 static const char* kMapBufferTypeStr[] = {
1003 "None",
1004 "MapBuffer",
1005 "MapBufferRange",
1006 "Chromium",
1007 };
1008 GR_STATIC_ASSERT(0 == kNone_MapBufferType);
1009 GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType);
1010 GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType);
1011 GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
1012 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
1013
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001014 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001015 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
joshualitt58162332014-08-01 06:44:53 -07001016 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +00001017 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]);
commit-bot@chromium.org160b4782014-05-05 12:32:37 +00001018 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001019 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
1020 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001021 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
1022 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001023 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO"));
1024 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO"));
1025 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO"));
1026 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO"));
1027 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO"));
1028 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO"));
bsalomon@google.combcce8922013-03-25 15:38:39 +00001029
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001030 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"));
1031 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"));
1032 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO"));
1033 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO"));
1034 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
1035 r.appendf("Fragment coord conventions support: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +00001036 (fFragCoordsConventionSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001037 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
1038 r.appendf("Use non-VBO for dynamic data: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +00001039 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001040 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO"));
commit-bot@chromium.org4362a382014-03-26 19:49:03 +00001041 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001042 return r;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +00001043}