blob: 1f50f8d1e18a6be82b834529ecadee5b6af431f6 [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;
joshualittabb52a12015-01-13 15:02:10 -080028 fNvprSupport = kNone_NvprSupport;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +000029 fMapBufferType = kNone_MapBufferType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000030 fMaxFragmentUniformVectors = 0;
bsalomon@google.com60da4172012-06-01 19:25:00 +000031 fMaxVertexAttributes = 0;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +000032 fMaxFragmentTextureUnits = 0;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +000033 fMaxFixedFunctionTextureCoords = 0;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000034 fRGBA8RenderbufferSupport = false;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000035 fBGRAIsInternalFormat = false;
36 fTextureSwizzleSupport = false;
37 fUnpackRowLengthSupport = false;
38 fUnpackFlipYSupport = false;
39 fPackRowLengthSupport = false;
40 fPackFlipYSupport = false;
41 fTextureUsageSupport = false;
42 fTexStorageSupport = false;
robertphillips@google.com443e5a52012-04-30 20:01:21 +000043 fTextureRedSupport = false;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +000044 fImagingSupport = false;
robertphillips@google.com1d89c932012-06-27 19:31:41 +000045 fTwoFormatLimit = false;
bsalomon@google.com706f6682012-10-23 14:53:55 +000046 fFragCoordsConventionSupport = false;
bsalomon@google.com07631cf2013-03-05 14:14:58 +000047 fVertexArrayObjectSupport = false;
jvanverth3f801cb2014-12-16 09:49:38 -080048 fES2CompatibilitySupport = false;
bsalomon@google.com96966a52013-02-21 16:34:21 +000049 fUseNonVBOVertexAndIndexDynamicData = false;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +000050 fIsCoreProfile = false;
robertphillips@google.com56ce48a2013-10-31 21:44:25 +000051 fFullClearIsFree = false;
commit-bot@chromium.org4362a382014-03-26 19:49:03 +000052 fDropsTileOnZeroDivide = false;
joshualitt58162332014-08-01 06:44:53 -070053 fFBFetchSupport = false;
joshualitt3c1096f2015-01-13 13:13:59 -080054 fFBFetchNeedsCustomOutput = false;
joshualitt58162332014-08-01 06:44:53 -070055 fFBFetchColorName = NULL;
56 fFBFetchExtensionString = NULL;
piotaixre4b23142014-10-02 10:57:53 -070057
58 fReadPixelsSupportedCache.reset();
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000059}
60
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000061GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000062 *this = caps;
63}
64
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +000065GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
bsalomon@google.combcce8922013-03-25 15:38:39 +000066 INHERITED::operator=(caps);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000067 fVerifiedColorConfigs = caps.fVerifiedColorConfigs;
68 fStencilFormats = caps.fStencilFormats;
69 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs;
krajcevski3217c4a2014-06-09 09:10:04 -070070 fLATCAlias = caps.fLATCAlias;
joshualittabb52a12015-01-13 15:02:10 -080071 fNvprSupport = caps.fNvprSupport;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000072 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +000073 fMaxVertexAttributes = caps.fMaxVertexAttributes;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +000074 fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +000075 fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000076 fMSFBOType = caps.fMSFBOType;
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +000077 fInvalidateFBType = caps.fInvalidateFBType;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +000078 fMapBufferType = caps.fMapBufferType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000079 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000080 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat;
81 fTextureSwizzleSupport = caps.fTextureSwizzleSupport;
82 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport;
83 fUnpackFlipYSupport = caps.fUnpackFlipYSupport;
84 fPackRowLengthSupport = caps.fPackRowLengthSupport;
85 fPackFlipYSupport = caps.fPackFlipYSupport;
86 fTextureUsageSupport = caps.fTextureUsageSupport;
87 fTexStorageSupport = caps.fTexStorageSupport;
robertphillips@google.com443e5a52012-04-30 20:01:21 +000088 fTextureRedSupport = caps.fTextureRedSupport;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +000089 fImagingSupport = caps.fImagingSupport;
robertphillips@google.com1d89c932012-06-27 19:31:41 +000090 fTwoFormatLimit = caps.fTwoFormatLimit;
bsalomon@google.com706f6682012-10-23 14:53:55 +000091 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport;
bsalomon@google.com07631cf2013-03-05 14:14:58 +000092 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport;
jvanverth3f801cb2014-12-16 09:49:38 -080093 fES2CompatibilitySupport = caps.fES2CompatibilitySupport;
bsalomon@google.com96966a52013-02-21 16:34:21 +000094 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +000095 fIsCoreProfile = caps.fIsCoreProfile;
robertphillips@google.com56ce48a2013-10-31 21:44:25 +000096 fFullClearIsFree = caps.fFullClearIsFree;
commit-bot@chromium.org4362a382014-03-26 19:49:03 +000097 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
joshualitt58162332014-08-01 06:44:53 -070098 fFBFetchSupport = caps.fFBFetchSupport;
joshualitt3c1096f2015-01-13 13:13:59 -080099 fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput;
joshualitt58162332014-08-01 06:44:53 -0700100 fFBFetchColorName = caps.fFBFetchColorName;
101 fFBFetchExtensionString = caps.fFBFetchExtensionString;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000102
103 return *this;
104}
105
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000106bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000107
108 this->reset();
109 if (!ctxInfo.isInitialized()) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000110 return false;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000111 }
112
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000113 GrGLStandard standard = ctxInfo.standard();
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000114 GrGLVersion version = ctxInfo.version();
115
bsalomon@google.combcce8922013-03-25 15:38:39 +0000116 /**************************************************************************
117 * Caps specific to GrGLCaps
118 **************************************************************************/
119
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000120 if (kGLES_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000121 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
122 &fMaxFragmentUniformVectors);
123 } else {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000124 SkASSERT(kGL_GrGLStandard == standard);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000125 GrGLint max;
126 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max);
127 fMaxFragmentUniformVectors = max / 4;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000128 if (version >= GR_GL_VER(3, 2)) {
129 GrGLint profileMask;
130 GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
131 fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
132 }
133 if (!fIsCoreProfile) {
134 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_COORDS, &fMaxFixedFunctionTextureCoords);
135 // Sanity check
136 SkASSERT(fMaxFixedFunctionTextureCoords > 0 && fMaxFixedFunctionTextureCoords < 128);
137 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000138 }
bsalomon@google.com60da4172012-06-01 19:25:00 +0000139 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes);
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000140 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000141
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000142 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000143 fRGBA8RenderbufferSupport = true;
144 } else {
commit-bot@chromium.orgc5dffe42013-08-20 15:25:21 +0000145 fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) ||
146 ctxInfo.hasExtension("GL_OES_rgb8_rgba8") ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000147 ctxInfo.hasExtension("GL_ARM_rgba8");
148 }
149
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000150 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000151 fTextureSwizzleSupport = version >= GR_GL_VER(3,3) ||
152 ctxInfo.hasExtension("GL_ARB_texture_swizzle");
153 } else {
commit-bot@chromium.org6364b5e2013-08-20 20:22:52 +0000154 fTextureSwizzleSupport = version >= GR_GL_VER(3,0);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000155 }
156
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000157 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000158 fUnpackRowLengthSupport = true;
159 fUnpackFlipYSupport = false;
160 fPackRowLengthSupport = true;
161 fPackFlipYSupport = false;
162 } else {
commit-bot@chromium.orgdc3134c2013-08-16 16:12:23 +0000163 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) ||
164 ctxInfo.hasExtension("GL_EXT_unpack_subimage");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000165 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy");
commit-bot@chromium.orgdc3134c2013-08-16 16:12:23 +0000166 fPackRowLengthSupport = version >= GR_GL_VER(3,0) ||
167 ctxInfo.hasExtension("GL_NV_pack_subimage");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000168 fPackFlipYSupport =
169 ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order");
170 }
171
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000172 fTextureUsageSupport = (kGLES_GrGLStandard == standard) &&
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000173 ctxInfo.hasExtension("GL_ANGLE_texture_usage");
174
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000175 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org7a434a22013-08-21 14:01:56 +0000176 // The EXT version can apply to either GL or GLES.
177 fTexStorageSupport = version >= GR_GL_VER(4,2) ||
178 ctxInfo.hasExtension("GL_ARB_texture_storage") ||
179 ctxInfo.hasExtension("GL_EXT_texture_storage");
180 } else {
181 // Qualcomm Adreno drivers appear to have issues with texture storage.
182 fTexStorageSupport = (version >= GR_GL_VER(3,0) &&
183 kQualcomm_GrGLVendor != ctxInfo.vendor()) ||
184 ctxInfo.hasExtension("GL_EXT_texture_storage");
185 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000186
hendrikwa0d5ad72014-12-02 07:30:30 -0800187 // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support GL_RED
188 // and GL_RG on FBO textures.
189 if (!ctxInfo.isMesa()) {
190 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org459104c2013-06-14 14:42:56 +0000191 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
192 ctxInfo.hasExtension("GL_ARB_texture_rg");
hendrikwa0d5ad72014-12-02 07:30:30 -0800193 } else {
194 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
195 ctxInfo.hasExtension("GL_EXT_texture_rg");
commit-bot@chromium.org459104c2013-06-14 14:42:56 +0000196 }
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000197 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000198 fImagingSupport = kGL_GrGLStandard == standard &&
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000199 ctxInfo.hasExtension("GL_ARB_imaging");
200
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000201 // ES 2 only guarantees RGBA/uchar + one other format/type combo for
202 // ReadPixels. The other format has to checked at run-time since it
203 // can change based on which render target is bound
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000204 fTwoFormatLimit = kGLES_GrGLStandard == standard;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000205
rmistry63a9f842014-10-17 06:07:08 -0700206 // Frag Coords Convention support is not part of ES
bsalomon@google.com706f6682012-10-23 14:53:55 +0000207 // Known issue on at least some Intel platforms:
208 // http://code.google.com/p/skia/issues/detail?id=946
rmistry63a9f842014-10-17 06:07:08 -0700209 if (kIntel_GrGLVendor != ctxInfo.vendor() && kGLES_GrGLStandard != standard) {
bsalomon@google.com706f6682012-10-23 14:53:55 +0000210 fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration ||
211 ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions");
212 }
213
bsalomon@google.com3012ded2013-02-22 16:44:04 +0000214 // SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with
215 // frequently changing VBOs. We've measured a performance increase using non-VBO vertex
216 // data for dynamic content on these GPUs. Perhaps we should read the renderer string and
217 // limit this decision to specific GPU families rather than basing it on the vendor alone.
218 if (!GR_GL_MUST_USE_VBO &&
bsalomoned82c4e2014-09-02 07:54:47 -0700219 (kARM_GrGLVendor == ctxInfo.vendor() ||
220 kImagination_GrGLVendor == ctxInfo.vendor() ||
221 kQualcomm_GrGLVendor == ctxInfo.vendor())) {
bsalomon@google.com96966a52013-02-21 16:34:21 +0000222 fUseNonVBOVertexAndIndexDynamicData = true;
223 }
skia.committer@gmail.com631cdcb2013-03-01 12:12:55 +0000224
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000225 if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(4,3)) ||
skia.committer@gmail.coma9157722014-04-03 03:04:26 +0000226 (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) ||
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000227 ctxInfo.hasExtension("GL_ARB_invalidate_subdata")) {
228 fDiscardRenderTargetSupport = true;
229 fInvalidateFBType = kInvalidate_InvalidateFBType;
230 } else if (ctxInfo.hasExtension("GL_EXT_discard_framebuffer")) {
231 fDiscardRenderTargetSupport = true;
232 fInvalidateFBType = kDiscard_InvalidateFBType;
233 }
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000234
robertphillips@google.com56ce48a2013-10-31 21:44:25 +0000235 if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) {
236 fFullClearIsFree = true;
237 }
238
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000239 if (kGL_GrGLStandard == standard) {
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000240 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
tomhudson612e9262014-11-24 11:22:36 -0800241 ctxInfo.hasExtension("GL_ARB_vertex_array_object") ||
242 ctxInfo.hasExtension("GL_APPLE_vertex_array_object");
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000243 } else {
commit-bot@chromium.org2276c012013-08-16 15:53:33 +0000244 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
245 ctxInfo.hasExtension("GL_OES_vertex_array_object");
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000246 }
247
jvanverth3f801cb2014-12-16 09:49:38 -0800248 if (kGL_GrGLStandard == standard) {
249 fES2CompatibilitySupport = ctxInfo.hasExtension("GL_ARB_ES2_compatibility");
250 }
251 else {
252 fES2CompatibilitySupport = true;
253 }
254
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000255 if (kGLES_GrGLStandard == standard) {
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000256 if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
joshualitt3c1096f2015-01-13 13:13:59 -0800257 fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0));
joshualitt58162332014-08-01 06:44:53 -0700258 fFBFetchSupport = true;
259 fFBFetchColorName = "gl_LastFragData[0]";
260 fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch";
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000261 } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) {
joshualitt3c1096f2015-01-13 13:13:59 -0800262 // Actually, we haven't seen an ES3.0 device with this extension yet, so we don't know
263 fFBFetchNeedsCustomOutput = false;
joshualitt58162332014-08-01 06:44:53 -0700264 fFBFetchSupport = true;
265 fFBFetchColorName = "gl_LastFragData[0]";
266 fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch";
267 } else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) {
268 // The arm extension also requires an additional flag which we will set onResetContext
joshualitt3c1096f2015-01-13 13:13:59 -0800269 fFBFetchNeedsCustomOutput = false;
joshualitt58162332014-08-01 06:44:53 -0700270 fFBFetchSupport = true;
271 fFBFetchColorName = "gl_LastFragColorARM";
272 fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch";
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000273 }
274 }
275
commit-bot@chromium.org4362a382014-03-26 19:49:03 +0000276 // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader
277 fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor();
278
robertphillips@google.com6177e692013-02-28 20:16:25 +0000279 this->initFSAASupport(ctxInfo, gli);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000280 this->initStencilFormats(ctxInfo);
bsalomon@google.combcce8922013-03-25 15:38:39 +0000281
282 /**************************************************************************
bsalomon@google.comc26d94f2013-03-25 18:19:00 +0000283 * GrDrawTargetCaps fields
bsalomon@google.combcce8922013-03-25 15:38:39 +0000284 **************************************************************************/
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000285 if (kGL_GrGLStandard == standard) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000286 // we could also look for GL_ATI_separate_stencil extension or
287 // GL_EXT_stencil_two_side but they use different function signatures
288 // than GL2.0+ (and than each other).
289 fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0));
290 // supported on GL 1.4 and higher or by extension
291 fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) ||
292 ctxInfo.hasExtension("GL_EXT_stencil_wrap");
293 } else {
294 // ES 2 has two sided stencil and stencil wrap
295 fTwoSidedStencilSupport = true;
296 fStencilWrapOpsSupport = true;
297 }
298
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000299 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000300 fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the desktop VBO
301 // extension includes glMapBuffer.
302 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffer_range")) {
303 fMapBufferFlags |= kSubset_MapFlag;
304 fMapBufferType = kMapBufferRange_MapBufferType;
305 } else {
306 fMapBufferType = kMapBuffer_MapBufferType;
307 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000308 } else {
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000309 // Unextended GLES2 doesn't have any buffer mapping.
310 fMapBufferFlags = kNone_MapBufferType;
311 if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) {
312 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
313 fMapBufferType = kChromium_MapBufferType;
314 } else if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_map_buffer_range")) {
315 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
316 fMapBufferType = kMapBufferRange_MapBufferType;
317 } else if (ctxInfo.hasExtension("GL_OES_mapbuffer")) {
318 fMapBufferFlags = kCanMap_MapFlag;
319 fMapBufferType = kMapBuffer_MapBufferType;
320 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000321 }
322
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000323 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000324 SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) ||
325 ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two"));
326 fNPOTTextureTileSupport = true;
327 fMipMapSupport = true;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000328 } else {
329 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only
commit-bot@chromium.org22dd6b92013-08-16 18:13:48 +0000330 // ES3 has no limitations.
331 fNPOTTextureTileSupport = ctxInfo.version() >= GR_GL_VER(3,0) ||
332 ctxInfo.hasExtension("GL_OES_texture_npot");
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000333 // ES2 supports MIP mapping for POT textures but our caps don't allow for limited MIP
334 // support. The OES extension or ES 3.0 allow for MIPS on NPOT textures. So, apparently,
335 // does the undocumented GL_IMG_texture_npot extension. This extension does not seem to
336 // to alllow arbitrary wrap modes, however.
337 fMipMapSupport = fNPOTTextureTileSupport || ctxInfo.hasExtension("GL_IMG_texture_npot");
bsalomon@google.combcce8922013-03-25 15:38:39 +0000338 }
339
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000340 fHWAALineSupport = (kGL_GrGLStandard == standard);
bsalomon@google.combcce8922013-03-25 15:38:39 +0000341
342 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_SIZE, &fMaxTextureSize);
343 GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize);
344 // Our render targets are always created with textures as the color
345 // attachment, hence this min:
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +0000346 fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize);
bsalomon@google.combcce8922013-03-25 15:38:39 +0000347
kkinnunen32b9a3b2014-07-02 22:56:35 -0700348 fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering");
349
350 if (fPathRenderingSupport) {
351 if (kGL_GrGLStandard == standard) {
352 // We need one of the two possible texturing methods: using fixed function pipeline
353 // (PathTexGen, texcoords, ...) or using the newer NVPR API additions that support
354 // setting individual fragment inputs with ProgramPathFragmentInputGen. The API
355 // additions are detected by checking the existence of the function. Eventually we may
356 // choose to remove the fixed function codepath.
357 // Set fMaxFixedFunctionTextureCoords = 0 here if you want to force
358 // ProgramPathFragmentInputGen usage on desktop.
359 fPathRenderingSupport = ctxInfo.hasExtension("GL_EXT_direct_state_access") &&
360 (fMaxFixedFunctionTextureCoords > 0 ||
361 ((ctxInfo.version() >= GR_GL_VER(4,3) ||
362 ctxInfo.hasExtension("GL_ARB_program_interface_query")) &&
bsalomon49f085d2014-09-05 13:34:00 -0700363 gli->fFunctions.fProgramPathFragmentInputGen));
joshualittabb52a12015-01-13 15:02:10 -0800364 if (fPathRenderingSupport) {
365 fNvprSupport = gli->fFunctions.fProgramPathFragmentInputGen ? kNormal_NvprSupport :
366 kLegacy_NvprSupport;
367 }
kkinnunen32b9a3b2014-07-02 22:56:35 -0700368 } else {
kkinnunenec56e452014-08-25 22:21:16 -0700369 fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,1);
joshualittabb52a12015-01-13 15:02:10 -0800370 fNvprSupport = fPathRenderingSupport ? kNormal_NvprSupport : kNone_NvprSupport;
kkinnunen32b9a3b2014-07-02 22:56:35 -0700371 }
joshualittabb52a12015-01-13 15:02:10 -0800372 } else {
373 fNvprSupport = kNone_NvprSupport;
kkinnunen32b9a3b2014-07-02 22:56:35 -0700374 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000375
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000376 fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker");
377
joshualitt58162332014-08-01 06:44:53 -0700378 // For now these two are equivalent but we could have dst read in shader via some other method
379 fDstReadInShaderSupport = fFBFetchSupport;
robertphillips@google.com8995b7b2013-11-01 15:03:34 +0000380
381 // Disable scratch texture reuse on Mali and Adreno devices
382 fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() &&
383 kQualcomm_GrGLVendor != ctxInfo.vendor();
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +0000384
bsalomon@google.combcce8922013-03-25 15:38:39 +0000385 // Enable supported shader-related caps
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000386 if (kGL_GrGLStandard == standard) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000387 fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) ||
388 ctxInfo.hasExtension("GL_ARB_blend_func_extended");
389 fShaderDerivativeSupport = true;
390 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
391 fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3,2) &&
392 ctxInfo.glslGeneration() >= k150_GrGLSLGeneration;
393 } else {
rmistry63a9f842014-10-17 06:07:08 -0700394 fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) ||
395 ctxInfo.hasExtension("GL_OES_standard_derivatives");
bsalomon@google.combcce8922013-03-25 15:38:39 +0000396 }
397
bsalomon@google.com347c3822013-05-01 20:10:01 +0000398 if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000399 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount);
400 } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) {
401 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
402 }
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000403
bsalomon63b21962014-11-05 07:05:34 -0800404 if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() ||
bsalomone702d972015-01-29 10:07:32 -0800405 kPowerVRRogue_GrGLRenderer == ctxInfo.renderer() ||
bsalomona8fcea02015-02-13 09:00:39 -0800406 kAdreno3xx_GrGLRenderer == ctxInfo.renderer()) {
bsalomon63b21962014-11-05 07:05:34 -0800407 fUseDrawInsteadOfClear = true;
408 }
409
bsalomond08ea5f2015-02-20 06:58:13 -0800410 if (kGL_GrGLStandard == standard) {
411 // ARB allows mixed size FBO attachments, EXT does not.
412 if (ctxInfo.version() >= GR_GL_VER(3, 0) ||
413 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
414 fOversizedStencilSupport = true;
415 } else {
416 SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object"));
417 }
418 } else {
419 // ES 3.0 supports mixed size FBO attachments, 2.0 does not.
420 fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0);
421 }
422
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000423 this->initConfigTexturableTable(ctxInfo, gli);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000424 this->initConfigRenderableTable(ctxInfo);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000425
bsalomon17168df2014-12-09 09:00:49 -0800426 this->initShaderPrecisionTable(ctxInfo, gli);
427
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000428 return true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000429}
430
431void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000432 // OpenGL < 3.0
433 // no support for render targets unless the GL_ARB_framebuffer_object
434 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
435 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
436 // probably don't get R8 in this case.
437
438 // OpenGL 3.0
439 // base color renderable: ALPHA, RED, RG, RGB, and RGBA
440 // sized derivatives: ALPHA8, R8, RGBA4, RGBA8
441
442 // >= OpenGL 3.1
443 // base color renderable: RED, RG, RGB, and RGBA
444 // sized derivatives: R8, RGBA4, RGBA8
445 // if the GL_ARB_compatibility extension is supported then we get back
446 // support for GL_ALPHA and ALPHA8
447
448 // GL_EXT_bgra adds BGRA render targets to any version
449
450 // ES 2.0
451 // color renderable: RGBA4, RGB5_A1, RGB565
452 // GL_EXT_texture_rg adds support for R8 as a color render target
453 // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
454 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support
455
456 // ES 3.0
457 // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
458 // below already account for this).
459
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000460 GrGLStandard standard = ctxInfo.standard();
461
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000462 enum {
463 kNo_MSAA = 0,
464 kYes_MSAA = 1,
465 };
466
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000467 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000468 // Post 3.0 we will get R8
469 // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
470 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
471 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000472 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true;
473 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000474 }
475 } else {
476 // On ES we can only hope for R8
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000477 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupport;
478 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000479 }
480
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000481 if (kGL_GrGLStandard != standard) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000482 // only available in ES
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000483 fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true;
484 fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000485 }
486
487 // we no longer support 444 as a render target
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000488 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false;
489 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000490
491 if (this->fRGBA8RenderbufferSupport) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000492 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
commit-bot@chromium.orgda3d69c2013-10-28 15:09:13 +0000493 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000494 }
495
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000496 if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000497 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true;
498 // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of
499 // configs that are color-renderable and can be passed to glRenderBufferStorageMultisample.
commit-bot@chromium.org4256d242013-10-17 16:29:41 +0000500 // Chromium may have an extension to allow BGRA renderbuffers to work on desktop platforms.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000501 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) {
commit-bot@chromium.org4256d242013-10-17 16:29:41 +0000502 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true;
503 } else {
504 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] =
505 !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers();
506 }
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000507 }
508
jvanverthfa1e8a72014-12-22 08:31:49 -0800509 if (this->fRGBA8RenderbufferSupport && this->isConfigTexturable(kSRGBA_8888_GrPixelConfig)) {
510 if (kGL_GrGLStandard == standard) {
511 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
512 ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
513 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
514 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
515 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
516 }
517 } else {
518 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
519 ctxInfo.hasExtension("GL_EXT_sRGB")) {
520 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
521 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
522 }
523 }
524 }
525
joshualittee5da552014-07-16 13:32:56 -0700526 if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
jvanverth28f9c602014-12-05 13:06:35 -0800527 if (kGL_GrGLStandard == standard) {
jvanvertha60b2ea2014-12-12 05:58:06 -0800528 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
jvanverth28f9c602014-12-05 13:06:35 -0800529 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true;
530 } else {
jvanvertha60b2ea2014-12-12 05:58:06 -0800531 if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) {
532 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
533 } else {
534 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false;
535 }
536 // for now we don't support floating point MSAA on ES
jvanverth28f9c602014-12-05 13:06:35 -0800537 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
538 }
joshualittee5da552014-07-16 13:32:56 -0700539 }
540
jvanverth28f9c602014-12-05 13:06:35 -0800541 if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) {
jvanverth28f9c602014-12-05 13:06:35 -0800542 if (kGL_GrGLStandard == standard) {
jvanvertha60b2ea2014-12-12 05:58:06 -0800543 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
jvanverth28f9c602014-12-05 13:06:35 -0800544 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true;
jvanverth1334c212014-12-18 05:44:55 -0800545 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
546 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
547 // for now we don't support floating point MSAA on ES
548 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
jvanverth28f9c602014-12-05 13:06:35 -0800549 } else {
jvanverth1334c212014-12-18 05:44:55 -0800550 if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float") && fTextureRedSupport) {
551 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
552 } else {
553 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false;
554 }
555 // for now we don't support floating point MSAA on ES
jvanverth28f9c602014-12-05 13:06:35 -0800556 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
557 }
558 }
559
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000560 // If we don't support MSAA then undo any places above where we set a config as renderable with
561 // msaa.
562 if (kNone_MSFBOType == fMSFBOType) {
563 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
564 fConfigRenderSupport[i][kYes_MSAA] = false;
565 }
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000566 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000567}
568
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000569void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000570 GrGLStandard standard = ctxInfo.standard();
571 GrGLVersion version = ctxInfo.version();
572
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000573 // Base texture support
574 fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
575 fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
576 fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
577 fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
578
579 // Check for 8-bit palette..
580 GrGLint numFormats;
581 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
582 if (numFormats) {
583 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
584 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
585 for (int i = 0; i < numFormats; ++i) {
586 if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
587 fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
588 break;
589 }
590 }
591 }
592
593 // Check for BGRA
594 if (kGL_GrGLStandard == standard) {
595 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
596 version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
597 } else {
598 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
599 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
600 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
601 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
602 fBGRAIsInternalFormat = true;
603 }
604 SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
605 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
606 }
607
jvanverthfa1e8a72014-12-22 08:31:49 -0800608 // Check for sRGBA
609 if (kGL_GrGLStandard == standard) {
610 fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
611 (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_texture_sRGB"));
612 } else {
613 fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
614 (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB"));
615 }
616
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000617 // Compressed texture support
618
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000619 // glCompressedTexImage2D is available on all OpenGL ES devices...
620 // however, it is only available on standard OpenGL after version 1.3
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000621 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000622
krajcevski786978162014-07-30 11:25:44 -0700623 fCompressedTexSubImageSupport =
bsalomon49f085d2014-09-05 13:34:00 -0700624 hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D);
krajcevski786978162014-07-30 11:25:44 -0700625
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000626 // Check for ETC1
627 bool hasETC1 = false;
628
629 // First check version for support
630 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000631 hasETC1 = hasCompressTex2D &&
joshualittee5da552014-07-16 13:32:56 -0700632 (version >= GR_GL_VER(4, 3) ||
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000633 ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000634 } else {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000635 hasETC1 = hasCompressTex2D &&
636 (version >= GR_GL_VER(3, 0) ||
637 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
638 // ETC2 is a superset of ETC1, so we can just check for that, too.
639 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
640 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000641 }
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000642 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000643
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000644 // Check for LATC under its various forms
645 LATCAlias alias = kLATC_LATCAlias;
646 bool hasLATC = hasCompressTex2D &&
647 (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
648 ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
649
650 // Check for RGTC
651 if (!hasLATC) {
652 // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
653 if (kGL_GrGLStandard == standard) {
654 hasLATC = version >= GR_GL_VER(3, 0);
655 }
656
657 if (!hasLATC) {
658 hasLATC =
659 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
660 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
661 }
662
663 if (hasLATC) {
664 alias = kRGTC_LATCAlias;
665 }
666 }
667
668 // Check for 3DC
669 if (!hasLATC) {
670 hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
671 if (hasLATC) {
672 alias = k3DC_LATCAlias;
673 }
674 }
675
676 fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
677 fLATCAlias = alias;
krajcevski238b4562014-06-30 09:09:22 -0700678
krajcevskib3abe902014-07-30 13:08:11 -0700679 // Check for R11_EAC ... We don't support R11_EAC on desktop, as most
680 // cards default to decompressing the textures in the driver, and is
681 // generally slower.
682 if (kGL_GrGLStandard != standard) {
krajcevski238b4562014-06-30 09:09:22 -0700683 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
684 }
joshualittee5da552014-07-16 13:32:56 -0700685
krajcevski7ef21622014-07-16 15:21:13 -0700686 // Check for ASTC
piotaixre4b23142014-10-02 10:57:53 -0700687 fConfigTextureSupport[kASTC_12x12_GrPixelConfig] =
krajcevski7ef21622014-07-16 15:21:13 -0700688 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
689 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
690 ctxInfo.hasExtension("GL_OES_texture_compression_astc");
691
joshualittee5da552014-07-16 13:32:56 -0700692 // Check for floating point texture support
693 // NOTE: We disallow floating point textures on ES devices if linear
694 // filtering modes are not supported. This is for simplicity, but a more
695 // granular approach is possible. Coincidentally, floating point textures became part of
696 // the standard in ES3.1 / OGL 3.1, hence the shorthand
697 bool hasFPTextures = version >= GR_GL_VER(3, 1);
698 if (!hasFPTextures) {
699 hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanvertha60b2ea2014-12-12 05:58:06 -0800700 (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
joshualittee5da552014-07-16 13:32:56 -0700701 ctxInfo.hasExtension("GL_OES_texture_float"));
702 }
703 fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
jvanverth28f9c602014-12-05 13:06:35 -0800704
705 // Check for fp16 texture support
706 // NOTE: We disallow floating point textures on ES devices if linear
707 // filtering modes are not supported. This is for simplicity, but a more
708 // granular approach is possible. Coincidentally, 16-bit floating point textures became part of
709 // the standard in ES3.1 / OGL 3.1, hence the shorthand
710 bool hasHalfFPTextures = version >= GR_GL_VER(3, 1);
711 if (!hasHalfFPTextures) {
712 hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanverth1334c212014-12-18 05:44:55 -0800713 (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
714 ctxInfo.hasExtension("GL_OES_texture_half_float"));
jvanverth28f9c602014-12-05 13:06:35 -0800715 }
jvanverth1334c212014-12-18 05:44:55 -0800716 fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000717}
718
piotaixre4b23142014-10-02 10:57:53 -0700719bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf,
720 GrGLenum format,
721 GrGLenum type) const {
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000722 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
723 // ES 2 guarantees this format is supported
robertphillips@google.comeca2dfb2012-06-27 20:13:49 +0000724 return true;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000725 }
726
727 if (!fTwoFormatLimit) {
728 // not limited by ES 2's constraints
729 return true;
730 }
731
bsalomon@google.com548a4332012-07-11 19:45:22 +0000732 GrGLint otherFormat = GR_GL_RGBA;
733 GrGLint otherType = GR_GL_UNSIGNED_BYTE;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000734
735 // The other supported format/type combo supported for ReadPixels
736 // can change based on which render target is bound
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000737 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000738 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT,
739 &otherFormat);
740
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000741 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000742 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE,
743 &otherType);
744
bsalomon@google.com548a4332012-07-11 19:45:22 +0000745 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000746}
747
piotaixre4b23142014-10-02 10:57:53 -0700748bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
749 GrGLenum format,
750 GrGLenum type,
751 GrGLenum currFboFormat) const {
752
753 ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat};
754
755 ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key);
756
757 if (NULL == cachedValue) {
758 bool value = doReadPixelsSupported(intf, format, type);
759 ReadPixelsSupportedFormats newValue(key, value);
760 fReadPixelsSupportedCache.add(newValue);
761
762 return newValue.value();
763 }
764
765 return cachedValue->value();
766}
767
robertphillips@google.com6177e692013-02-28 20:16:25 +0000768void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000769
770 fMSFBOType = kNone_MSFBOType;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000771 if (kGL_GrGLStandard != ctxInfo.standard()) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000772 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed
773 // ES3 driver bugs on at least one device with a tiled GPU (N10).
774 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) {
775 fMSFBOType = kES_EXT_MsToTexture_MSFBOType;
776 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) {
777 fMSFBOType = kES_IMG_MsToTexture_MSFBOType;
commit-bot@chromium.org92b78842014-01-16 20:49:46 +0000778 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000779 fMSFBOType = GrGLCaps::kES_3_0_MSFBOType;
780 } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
781 // chrome's extension is equivalent to the EXT msaa
782 // and fbo_blit extensions.
783 fMSFBOType = kDesktop_EXT_MSFBOType;
784 } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
785 fMSFBOType = kES_Apple_MSFBOType;
786 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000787 } else {
788 if ((ctxInfo.version() >= GR_GL_VER(3,0)) ||
789 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000790 fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000791 } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") &&
792 ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000793 fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000794 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000795 }
796}
797
798namespace {
799const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount;
800}
801
802void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) {
803
804 // Build up list of legal stencil formats (though perhaps not supported on
805 // the particular gpu/driver) from most preferred to least.
806
807 // these consts are in order of most preferred to least preferred
808 // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
809
810 static const StencilFormat
811 // internal Format stencil bits total bits packed?
812 gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
813 gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
814 gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true },
815 gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false},
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000816 // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false},
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000817 gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true };
818
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000819 if (kGL_GrGLStandard == ctxInfo.standard()) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000820 bool supportsPackedDS =
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000821 ctxInfo.version() >= GR_GL_VER(3,0) ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000822 ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") ||
823 ctxInfo.hasExtension("GL_ARB_framebuffer_object");
824
825 // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we
826 // require FBO support we can expect these are legal formats and don't
827 // check. These also all support the unsized GL_STENCIL_INDEX.
828 fStencilFormats.push_back() = gS8;
829 fStencilFormats.push_back() = gS16;
830 if (supportsPackedDS) {
831 fStencilFormats.push_back() = gD24S8;
832 }
833 fStencilFormats.push_back() = gS4;
834 if (supportsPackedDS) {
835 fStencilFormats.push_back() = gDS;
836 }
837 } else {
838 // ES2 has STENCIL_INDEX8 without extensions but requires extensions
839 // for other formats.
840 // ES doesn't support using the unsized format.
841
842 fStencilFormats.push_back() = gS8;
843 //fStencilFormats.push_back() = gS16;
commit-bot@chromium.org04c500f2013-09-06 15:28:01 +0000844 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
845 ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000846 fStencilFormats.push_back() = gD24S8;
847 }
848 if (ctxInfo.hasExtension("GL_OES_stencil4")) {
849 fStencilFormats.push_back() = gS4;
850 }
851 }
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000852 SkASSERT(0 == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000853 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count());
854}
855
bsalomonc0bd6482014-12-09 10:04:14 -0800856static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
bsalomon17168df2014-12-09 09:00:49 -0800857 switch (p) {
bsalomonc0bd6482014-12-09 10:04:14 -0800858 case kLow_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800859 return GR_GL_LOW_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800860 case kMedium_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800861 return GR_GL_MEDIUM_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800862 case kHigh_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800863 return GR_GL_HIGH_FLOAT;
864 }
865 SkFAIL("Unknown precision.");
866 return -1;
867}
868
869static GrGLenum shader_type_to_gl_shader(GrShaderType type) {
870 switch (type) {
871 case kVertex_GrShaderType:
872 return GR_GL_VERTEX_SHADER;
873 case kGeometry_GrShaderType:
874 return GR_GL_GEOMETRY_SHADER;
875 case kFragment_GrShaderType:
876 return GR_GL_FRAGMENT_SHADER;
877 }
878 SkFAIL("Unknown shader type.");
879 return -1;
880}
881
882void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* intf) {
883 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4,1) ||
884 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
885 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800886 if (kGeometry_GrShaderType != s) {
bsalomon17168df2014-12-09 09:00:49 -0800887 GrShaderType shaderType = static_cast<GrShaderType>(s);
888 GrGLenum glShader = shader_type_to_gl_shader(shaderType);
889 PrecisionInfo* first = NULL;
890 fShaderPrecisionVaries = false;
bsalomonc0bd6482014-12-09 10:04:14 -0800891 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
892 GrSLPrecision precision = static_cast<GrSLPrecision>(p);
bsalomon17168df2014-12-09 09:00:49 -0800893 GrGLenum glPrecision = precision_to_gl_float_type(precision);
894 GrGLint range[2];
895 GrGLint bits;
896 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits);
897 if (bits) {
898 fFloatPrecisions[s][p].fLogRangeLow = range[0];
899 fFloatPrecisions[s][p].fLogRangeHigh = range[1];
900 fFloatPrecisions[s][p].fBits = bits;
901 if (!first) {
902 first = &fFloatPrecisions[s][p];
903 } else if (!fShaderPrecisionVaries) {
904 fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]);
905 }
906 }
907 }
908 }
909 }
910 } else {
911 // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
912 fShaderPrecisionVaries = false;
913 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800914 if (kGeometry_GrShaderType != s) {
bsalomonc0bd6482014-12-09 10:04:14 -0800915 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
bsalomon17168df2014-12-09 09:00:49 -0800916 fFloatPrecisions[s][p].fLogRangeLow = 127;
917 fFloatPrecisions[s][p].fLogRangeHigh = 127;
918 fFloatPrecisions[s][p].fBits = 23;
919 }
920 }
921 }
922 }
bsalomon06194c52014-12-09 11:16:12 -0800923 // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Assume they're
924 // the same as the vertex shader. Only fragment shaders were ever allowed to omit support for
925 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
926 // are recommended against.
927 if (fGeometryShaderSupport) {
928 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
929 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p];
930 }
931 }
bsalomon17168df2014-12-09 09:00:49 -0800932}
933
934
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000935void GrGLCaps::markColorConfigAndStencilFormatAsVerified(
936 GrPixelConfig config,
937 const GrGLStencilBuffer::Format& format) {
938#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
939 return;
940#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000941 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
942 SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000943 int count = fStencilFormats.count();
944 // we expect a really small number of possible formats so linear search
945 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000946 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000947 for (int i = 0; i < count; ++i) {
948 if (format.fInternalFormat ==
949 fStencilFormats[i].fInternalFormat) {
950 fStencilVerifiedColorConfigs[i].markVerified(config);
951 return;
952 }
953 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000954 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000955 "GrGLCaps doesn't know about.");
956}
957
958bool GrGLCaps::isColorConfigAndStencilFormatVerified(
959 GrPixelConfig config,
960 const GrGLStencilBuffer::Format& format) const {
961#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
962 return false;
963#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000964 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000965 int count = fStencilFormats.count();
966 // we expect a really small number of possible formats so linear search
967 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000968 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000969 for (int i = 0; i < count; ++i) {
970 if (format.fInternalFormat ==
971 fStencilFormats[i].fInternalFormat) {
972 return fStencilVerifiedColorConfigs[i].isVerified(config);
973 }
974 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000975 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000976 "GLCaps doesn't know about.");
977 return false;
978}
979
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000980SkString GrGLCaps::dump() const {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000981
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000982 SkString r = INHERITED::dump();
bsalomon@google.combcce8922013-03-25 15:38:39 +0000983
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000984 r.appendf("--- GL-Specific ---\n");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000985 for (int i = 0; i < fStencilFormats.count(); ++i) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000986 r.appendf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000987 i,
988 fStencilFormats[i].fStencilBits,
989 fStencilFormats[i].fTotalBits);
990 }
991
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000992 static const char* kMSFBOExtStr[] = {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000993 "None",
994 "ARB",
995 "EXT",
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000996 "ES 3.0",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000997 "Apple",
bsalomon@google.com347c3822013-05-01 20:10:01 +0000998 "IMG MS To Texture",
999 "EXT MS To Texture",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +00001000 };
bsalomon@google.com6b0cf022013-05-03 13:35:14 +00001001 GR_STATIC_ASSERT(0 == kNone_MSFBOType);
1002 GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType);
1003 GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType);
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +00001004 GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType);
1005 GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType);
1006 GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType);
1007 GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +00001008 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +00001009
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +00001010 static const char* kInvalidateFBTypeStr[] = {
1011 "None",
1012 "Discard",
1013 "Invalidate",
1014 };
1015 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType);
1016 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType);
1017 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
1018 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +00001019
commit-bot@chromium.org160b4782014-05-05 12:32:37 +00001020 static const char* kMapBufferTypeStr[] = {
1021 "None",
1022 "MapBuffer",
1023 "MapBufferRange",
1024 "Chromium",
1025 };
1026 GR_STATIC_ASSERT(0 == kNone_MapBufferType);
1027 GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType);
1028 GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType);
1029 GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
1030 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
1031
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001032 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001033 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
joshualitt58162332014-08-01 06:44:53 -07001034 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +00001035 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]);
commit-bot@chromium.org160b4782014-05-05 12:32:37 +00001036 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001037 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
1038 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +00001039 if (!fIsCoreProfile) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001040 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords);
commit-bot@chromium.org3628ad92013-08-30 19:43:47 +00001041 }
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001042 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
1043 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001044 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO"));
1045 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO"));
1046 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO"));
1047 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO"));
1048 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO"));
1049 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO"));
bsalomon@google.combcce8922013-03-25 15:38:39 +00001050
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001051 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"));
1052 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"));
1053 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO"));
1054 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO"));
1055 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
1056 r.appendf("Fragment coord conventions support: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +00001057 (fFragCoordsConventionSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001058 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
1059 r.appendf("Use non-VBO for dynamic data: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +00001060 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001061 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO"));
commit-bot@chromium.org4362a382014-03-26 19:49:03 +00001062 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001063 return r;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +00001064}