blob: c1eb6e10e254020ad96955596a169e59cd7e9910 [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;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +000032 fMaxFixedFunctionTextureCoords = 0;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000033 fRGBA8RenderbufferSupport = false;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000034 fBGRAIsInternalFormat = false;
35 fTextureSwizzleSupport = false;
36 fUnpackRowLengthSupport = false;
37 fUnpackFlipYSupport = false;
38 fPackRowLengthSupport = false;
39 fPackFlipYSupport = false;
40 fTextureUsageSupport = false;
41 fTexStorageSupport = false;
robertphillips@google.com443e5a52012-04-30 20:01:21 +000042 fTextureRedSupport = false;
bsalomon@google.come76b7cc2012-06-18 12:47:06 +000043 fImagingSupport = false;
robertphillips@google.com1d89c932012-06-27 19:31:41 +000044 fTwoFormatLimit = false;
bsalomon@google.com706f6682012-10-23 14:53:55 +000045 fFragCoordsConventionSupport = false;
bsalomon@google.com07631cf2013-03-05 14:14:58 +000046 fVertexArrayObjectSupport = false;
jvanverth3f801cb2014-12-16 09:49:38 -080047 fES2CompatibilitySupport = false;
bsalomon@google.com96966a52013-02-21 16:34:21 +000048 fUseNonVBOVertexAndIndexDynamicData = false;
bsalomon@google.com2b1b8c02013-02-28 22:06:02 +000049 fIsCoreProfile = false;
robertphillips@google.com56ce48a2013-10-31 21:44:25 +000050 fFullClearIsFree = false;
commit-bot@chromium.org4362a382014-03-26 19:49:03 +000051 fDropsTileOnZeroDivide = false;
joshualitt58162332014-08-01 06:44:53 -070052 fFBFetchSupport = false;
53 fFBFetchColorName = NULL;
54 fFBFetchExtensionString = NULL;
piotaixre4b23142014-10-02 10:57:53 -070055
56 fReadPixelsSupportedCache.reset();
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000057}
58
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000059GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000060 *this = caps;
61}
62
commit-bot@chromium.orgbeb8b3a2014-04-15 15:37:51 +000063GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
bsalomon@google.combcce8922013-03-25 15:38:39 +000064 INHERITED::operator=(caps);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000065 fVerifiedColorConfigs = caps.fVerifiedColorConfigs;
66 fStencilFormats = caps.fStencilFormats;
67 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs;
krajcevski3217c4a2014-06-09 09:10:04 -070068 fLATCAlias = caps.fLATCAlias;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000069 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors;
bsalomon@google.com60da4172012-06-01 19:25:00 +000070 fMaxVertexAttributes = caps.fMaxVertexAttributes;
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +000071 fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +000072 fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords;
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;
96 fFBFetchColorName = caps.fFBFetchColorName;
97 fFBFetchExtensionString = caps.fFBFetchExtensionString;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000098
99 return *this;
100}
101
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000102bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000103
104 this->reset();
105 if (!ctxInfo.isInitialized()) {
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000106 return false;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000107 }
108
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000109 GrGLStandard standard = ctxInfo.standard();
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000110 GrGLVersion version = ctxInfo.version();
111
bsalomon@google.combcce8922013-03-25 15:38:39 +0000112 /**************************************************************************
113 * Caps specific to GrGLCaps
114 **************************************************************************/
115
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000116 if (kGLES_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000117 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
118 &fMaxFragmentUniformVectors);
119 } else {
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000120 SkASSERT(kGL_GrGLStandard == standard);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000121 GrGLint max;
122 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max);
123 fMaxFragmentUniformVectors = max / 4;
commit-bot@chromium.org46fbfe02013-08-30 15:52:12 +0000124 if (version >= GR_GL_VER(3, 2)) {
125 GrGLint profileMask;
126 GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
127 fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT);
128 }
129 if (!fIsCoreProfile) {
130 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_COORDS, &fMaxFixedFunctionTextureCoords);
131 // Sanity check
132 SkASSERT(fMaxFixedFunctionTextureCoords > 0 && fMaxFixedFunctionTextureCoords < 128);
133 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000134 }
bsalomon@google.com60da4172012-06-01 19:25:00 +0000135 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes);
commit-bot@chromium.orga15f7e52013-06-05 23:29:25 +0000136 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000137
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000138 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000139 fRGBA8RenderbufferSupport = true;
140 } else {
commit-bot@chromium.orgc5dffe42013-08-20 15:25:21 +0000141 fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) ||
142 ctxInfo.hasExtension("GL_OES_rgb8_rgba8") ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000143 ctxInfo.hasExtension("GL_ARM_rgba8");
144 }
145
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000146 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000147 fTextureSwizzleSupport = version >= GR_GL_VER(3,3) ||
148 ctxInfo.hasExtension("GL_ARB_texture_swizzle");
149 } else {
commit-bot@chromium.org6364b5e2013-08-20 20:22:52 +0000150 fTextureSwizzleSupport = version >= GR_GL_VER(3,0);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000151 }
152
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000153 if (kGL_GrGLStandard == standard) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000154 fUnpackRowLengthSupport = true;
155 fUnpackFlipYSupport = false;
156 fPackRowLengthSupport = true;
157 fPackFlipYSupport = false;
158 } else {
commit-bot@chromium.orgdc3134c2013-08-16 16:12:23 +0000159 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) ||
160 ctxInfo.hasExtension("GL_EXT_unpack_subimage");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000161 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy");
commit-bot@chromium.orgdc3134c2013-08-16 16:12:23 +0000162 fPackRowLengthSupport = version >= GR_GL_VER(3,0) ||
163 ctxInfo.hasExtension("GL_NV_pack_subimage");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000164 fPackFlipYSupport =
165 ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order");
166 }
167
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000168 fTextureUsageSupport = (kGLES_GrGLStandard == standard) &&
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000169 ctxInfo.hasExtension("GL_ANGLE_texture_usage");
170
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000171 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org7a434a22013-08-21 14:01:56 +0000172 // The EXT version can apply to either GL or GLES.
173 fTexStorageSupport = version >= GR_GL_VER(4,2) ||
174 ctxInfo.hasExtension("GL_ARB_texture_storage") ||
175 ctxInfo.hasExtension("GL_EXT_texture_storage");
176 } else {
177 // Qualcomm Adreno drivers appear to have issues with texture storage.
178 fTexStorageSupport = (version >= GR_GL_VER(3,0) &&
179 kQualcomm_GrGLVendor != ctxInfo.vendor()) ||
180 ctxInfo.hasExtension("GL_EXT_texture_storage");
181 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000182
hendrikwa0d5ad72014-12-02 07:30:30 -0800183 // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support GL_RED
184 // and GL_RG on FBO textures.
185 if (!ctxInfo.isMesa()) {
186 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org459104c2013-06-14 14:42:56 +0000187 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
188 ctxInfo.hasExtension("GL_ARB_texture_rg");
hendrikwa0d5ad72014-12-02 07:30:30 -0800189 } else {
190 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
191 ctxInfo.hasExtension("GL_EXT_texture_rg");
commit-bot@chromium.org459104c2013-06-14 14:42:56 +0000192 }
robertphillips@google.com443e5a52012-04-30 20:01:21 +0000193 }
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000194 fImagingSupport = kGL_GrGLStandard == standard &&
bsalomon@google.come76b7cc2012-06-18 12:47:06 +0000195 ctxInfo.hasExtension("GL_ARB_imaging");
196
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000197 // ES 2 only guarantees RGBA/uchar + one other format/type combo for
198 // ReadPixels. The other format has to checked at run-time since it
199 // can change based on which render target is bound
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000200 fTwoFormatLimit = kGLES_GrGLStandard == standard;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000201
rmistry63a9f842014-10-17 06:07:08 -0700202 // Frag Coords Convention support is not part of ES
bsalomon@google.com706f6682012-10-23 14:53:55 +0000203 // Known issue on at least some Intel platforms:
204 // http://code.google.com/p/skia/issues/detail?id=946
rmistry63a9f842014-10-17 06:07:08 -0700205 if (kIntel_GrGLVendor != ctxInfo.vendor() && kGLES_GrGLStandard != standard) {
bsalomon@google.com706f6682012-10-23 14:53:55 +0000206 fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration ||
207 ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions");
208 }
209
bsalomon@google.com3012ded2013-02-22 16:44:04 +0000210 // SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with
211 // frequently changing VBOs. We've measured a performance increase using non-VBO vertex
212 // data for dynamic content on these GPUs. Perhaps we should read the renderer string and
213 // limit this decision to specific GPU families rather than basing it on the vendor alone.
214 if (!GR_GL_MUST_USE_VBO &&
bsalomoned82c4e2014-09-02 07:54:47 -0700215 (kARM_GrGLVendor == ctxInfo.vendor() ||
216 kImagination_GrGLVendor == ctxInfo.vendor() ||
217 kQualcomm_GrGLVendor == ctxInfo.vendor())) {
bsalomon@google.com96966a52013-02-21 16:34:21 +0000218 fUseNonVBOVertexAndIndexDynamicData = true;
219 }
skia.committer@gmail.com631cdcb2013-03-01 12:12:55 +0000220
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000221 if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(4,3)) ||
skia.committer@gmail.coma9157722014-04-03 03:04:26 +0000222 (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) ||
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000223 ctxInfo.hasExtension("GL_ARB_invalidate_subdata")) {
224 fDiscardRenderTargetSupport = true;
225 fInvalidateFBType = kInvalidate_InvalidateFBType;
226 } else if (ctxInfo.hasExtension("GL_EXT_discard_framebuffer")) {
227 fDiscardRenderTargetSupport = true;
228 fInvalidateFBType = kDiscard_InvalidateFBType;
229 }
robertphillips@google.coma6ffb582013-04-29 16:50:17 +0000230
robertphillips@google.com56ce48a2013-10-31 21:44:25 +0000231 if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) {
232 fFullClearIsFree = true;
233 }
234
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000235 if (kGL_GrGLStandard == standard) {
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000236 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
tomhudson612e9262014-11-24 11:22:36 -0800237 ctxInfo.hasExtension("GL_ARB_vertex_array_object") ||
238 ctxInfo.hasExtension("GL_APPLE_vertex_array_object");
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000239 } else {
commit-bot@chromium.org2276c012013-08-16 15:53:33 +0000240 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
241 ctxInfo.hasExtension("GL_OES_vertex_array_object");
bsalomon@google.com07631cf2013-03-05 14:14:58 +0000242 }
243
jvanverth3f801cb2014-12-16 09:49:38 -0800244 if (kGL_GrGLStandard == standard) {
245 fES2CompatibilitySupport = ctxInfo.hasExtension("GL_ARB_ES2_compatibility");
246 }
247 else {
248 fES2CompatibilitySupport = true;
249 }
250
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000251 if (kGLES_GrGLStandard == standard) {
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000252 if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
joshualitt58162332014-08-01 06:44:53 -0700253 fFBFetchSupport = true;
254 fFBFetchColorName = "gl_LastFragData[0]";
255 fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch";
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000256 } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) {
joshualitt58162332014-08-01 06:44:53 -0700257 fFBFetchSupport = true;
258 fFBFetchColorName = "gl_LastFragData[0]";
259 fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch";
260 } else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) {
261 // The arm extension also requires an additional flag which we will set onResetContext
262 // This is all temporary.
263 fFBFetchSupport = true;
264 fFBFetchColorName = "gl_LastFragColorARM";
265 fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch";
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000266 }
267 }
268
commit-bot@chromium.org4362a382014-03-26 19:49:03 +0000269 // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader
270 fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor();
271
robertphillips@google.com6177e692013-02-28 20:16:25 +0000272 this->initFSAASupport(ctxInfo, gli);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000273 this->initStencilFormats(ctxInfo);
bsalomon@google.combcce8922013-03-25 15:38:39 +0000274
275 /**************************************************************************
bsalomon@google.comc26d94f2013-03-25 18:19:00 +0000276 * GrDrawTargetCaps fields
bsalomon@google.combcce8922013-03-25 15:38:39 +0000277 **************************************************************************/
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000278 if (kGL_GrGLStandard == standard) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000279 // we could also look for GL_ATI_separate_stencil extension or
280 // GL_EXT_stencil_two_side but they use different function signatures
281 // than GL2.0+ (and than each other).
282 fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0));
283 // supported on GL 1.4 and higher or by extension
284 fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) ||
285 ctxInfo.hasExtension("GL_EXT_stencil_wrap");
286 } else {
287 // ES 2 has two sided stencil and stencil wrap
288 fTwoSidedStencilSupport = true;
289 fStencilWrapOpsSupport = true;
290 }
291
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000292 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000293 fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the desktop VBO
294 // extension includes glMapBuffer.
295 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffer_range")) {
296 fMapBufferFlags |= kSubset_MapFlag;
297 fMapBufferType = kMapBufferRange_MapBufferType;
298 } else {
299 fMapBufferType = kMapBuffer_MapBufferType;
300 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000301 } else {
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000302 // Unextended GLES2 doesn't have any buffer mapping.
303 fMapBufferFlags = kNone_MapBufferType;
304 if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) {
305 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
306 fMapBufferType = kChromium_MapBufferType;
307 } else if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_map_buffer_range")) {
308 fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag;
309 fMapBufferType = kMapBufferRange_MapBufferType;
310 } else if (ctxInfo.hasExtension("GL_OES_mapbuffer")) {
311 fMapBufferFlags = kCanMap_MapFlag;
312 fMapBufferType = kMapBuffer_MapBufferType;
313 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000314 }
315
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000316 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000317 SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) ||
318 ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two"));
319 fNPOTTextureTileSupport = true;
320 fMipMapSupport = true;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000321 } else {
322 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only
commit-bot@chromium.org22dd6b92013-08-16 18:13:48 +0000323 // ES3 has no limitations.
324 fNPOTTextureTileSupport = ctxInfo.version() >= GR_GL_VER(3,0) ||
325 ctxInfo.hasExtension("GL_OES_texture_npot");
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000326 // ES2 supports MIP mapping for POT textures but our caps don't allow for limited MIP
327 // support. The OES extension or ES 3.0 allow for MIPS on NPOT textures. So, apparently,
328 // does the undocumented GL_IMG_texture_npot extension. This extension does not seem to
329 // to alllow arbitrary wrap modes, however.
330 fMipMapSupport = fNPOTTextureTileSupport || ctxInfo.hasExtension("GL_IMG_texture_npot");
bsalomon@google.combcce8922013-03-25 15:38:39 +0000331 }
332
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000333 fHWAALineSupport = (kGL_GrGLStandard == standard);
bsalomon@google.combcce8922013-03-25 15:38:39 +0000334
335 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_SIZE, &fMaxTextureSize);
336 GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize);
337 // Our render targets are always created with textures as the color
338 // attachment, hence this min:
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +0000339 fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize);
bsalomon@google.combcce8922013-03-25 15:38:39 +0000340
kkinnunen32b9a3b2014-07-02 22:56:35 -0700341 fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering");
342
343 if (fPathRenderingSupport) {
344 if (kGL_GrGLStandard == standard) {
345 // We need one of the two possible texturing methods: using fixed function pipeline
346 // (PathTexGen, texcoords, ...) or using the newer NVPR API additions that support
347 // setting individual fragment inputs with ProgramPathFragmentInputGen. The API
348 // additions are detected by checking the existence of the function. Eventually we may
349 // choose to remove the fixed function codepath.
350 // Set fMaxFixedFunctionTextureCoords = 0 here if you want to force
351 // ProgramPathFragmentInputGen usage on desktop.
352 fPathRenderingSupport = ctxInfo.hasExtension("GL_EXT_direct_state_access") &&
353 (fMaxFixedFunctionTextureCoords > 0 ||
354 ((ctxInfo.version() >= GR_GL_VER(4,3) ||
355 ctxInfo.hasExtension("GL_ARB_program_interface_query")) &&
bsalomon49f085d2014-09-05 13:34:00 -0700356 gli->fFunctions.fProgramPathFragmentInputGen));
kkinnunen32b9a3b2014-07-02 22:56:35 -0700357 } else {
kkinnunenec56e452014-08-25 22:21:16 -0700358 fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,1);
kkinnunen32b9a3b2014-07-02 22:56:35 -0700359 }
360 }
bsalomon@google.combcce8922013-03-25 15:38:39 +0000361
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000362 fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker");
363
joshualitt58162332014-08-01 06:44:53 -0700364 // For now these two are equivalent but we could have dst read in shader via some other method
365 fDstReadInShaderSupport = fFBFetchSupport;
robertphillips@google.com8995b7b2013-11-01 15:03:34 +0000366
367 // Disable scratch texture reuse on Mali and Adreno devices
368 fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() &&
369 kQualcomm_GrGLVendor != ctxInfo.vendor();
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +0000370
bsalomon@google.combcce8922013-03-25 15:38:39 +0000371 // Enable supported shader-related caps
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000372 if (kGL_GrGLStandard == standard) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000373 fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) ||
374 ctxInfo.hasExtension("GL_ARB_blend_func_extended");
375 fShaderDerivativeSupport = true;
376 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
377 fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3,2) &&
378 ctxInfo.glslGeneration() >= k150_GrGLSLGeneration;
379 } else {
rmistry63a9f842014-10-17 06:07:08 -0700380 fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) ||
381 ctxInfo.hasExtension("GL_OES_standard_derivatives");
bsalomon@google.combcce8922013-03-25 15:38:39 +0000382 }
383
bsalomon@google.com347c3822013-05-01 20:10:01 +0000384 if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000385 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount);
386 } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) {
387 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
388 }
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000389
bsalomon63b21962014-11-05 07:05:34 -0800390 if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() ||
391 kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) {
392 fUseDrawInsteadOfClear = true;
393 }
394
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000395 this->initConfigTexturableTable(ctxInfo, gli);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000396 this->initConfigRenderableTable(ctxInfo);
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000397
bsalomon17168df2014-12-09 09:00:49 -0800398 this->initShaderPrecisionTable(ctxInfo, gli);
399
commit-bot@chromium.orgf4e67e32014-04-30 01:26:04 +0000400 return true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000401}
402
403void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000404 // OpenGL < 3.0
405 // no support for render targets unless the GL_ARB_framebuffer_object
406 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
407 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
408 // probably don't get R8 in this case.
409
410 // OpenGL 3.0
411 // base color renderable: ALPHA, RED, RG, RGB, and RGBA
412 // sized derivatives: ALPHA8, R8, RGBA4, RGBA8
413
414 // >= OpenGL 3.1
415 // base color renderable: RED, RG, RGB, and RGBA
416 // sized derivatives: R8, RGBA4, RGBA8
417 // if the GL_ARB_compatibility extension is supported then we get back
418 // support for GL_ALPHA and ALPHA8
419
420 // GL_EXT_bgra adds BGRA render targets to any version
421
422 // ES 2.0
423 // color renderable: RGBA4, RGB5_A1, RGB565
424 // GL_EXT_texture_rg adds support for R8 as a color render target
425 // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8
426 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support
427
428 // ES 3.0
429 // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called
430 // below already account for this).
431
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000432 GrGLStandard standard = ctxInfo.standard();
433
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000434 enum {
435 kNo_MSAA = 0,
436 kYes_MSAA = 1,
437 };
438
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000439 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000440 // Post 3.0 we will get R8
441 // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object)
442 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
443 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000444 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true;
445 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000446 }
447 } else {
448 // On ES we can only hope for R8
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000449 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupport;
450 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000451 }
452
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000453 if (kGL_GrGLStandard != standard) {
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000454 // only available in ES
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000455 fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true;
456 fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000457 }
458
459 // we no longer support 444 as a render target
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000460 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false;
461 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000462
463 if (this->fRGBA8RenderbufferSupport) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000464 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
commit-bot@chromium.orgda3d69c2013-10-28 15:09:13 +0000465 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000466 }
467
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000468 if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) {
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000469 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true;
470 // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of
471 // configs that are color-renderable and can be passed to glRenderBufferStorageMultisample.
commit-bot@chromium.org4256d242013-10-17 16:29:41 +0000472 // Chromium may have an extension to allow BGRA renderbuffers to work on desktop platforms.
commit-bot@chromium.org90313cc2014-01-17 15:05:38 +0000473 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) {
commit-bot@chromium.org4256d242013-10-17 16:29:41 +0000474 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true;
475 } else {
476 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] =
477 !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers();
478 }
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000479 }
480
joshualittee5da552014-07-16 13:32:56 -0700481 if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
jvanverth28f9c602014-12-05 13:06:35 -0800482 if (kGL_GrGLStandard == standard) {
jvanvertha60b2ea2014-12-12 05:58:06 -0800483 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
jvanverth28f9c602014-12-05 13:06:35 -0800484 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true;
485 } else {
jvanvertha60b2ea2014-12-12 05:58:06 -0800486 if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) {
487 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
488 } else {
489 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false;
490 }
491 // for now we don't support floating point MSAA on ES
jvanverth28f9c602014-12-05 13:06:35 -0800492 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
493 }
joshualittee5da552014-07-16 13:32:56 -0700494 }
495
jvanverth28f9c602014-12-05 13:06:35 -0800496 if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) {
jvanverth28f9c602014-12-05 13:06:35 -0800497 if (kGL_GrGLStandard == standard) {
jvanvertha60b2ea2014-12-12 05:58:06 -0800498 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
jvanverth28f9c602014-12-05 13:06:35 -0800499 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true;
500 } else {
jvanvertha60b2ea2014-12-12 05:58:06 -0800501 // in theory, check for "GL_EXT_color_buffer_half_float"
502 // for now we don't support half float alpha render target on ES
503 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false;
jvanverth28f9c602014-12-05 13:06:35 -0800504 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
505 }
506 }
507
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000508 // If we don't support MSAA then undo any places above where we set a config as renderable with
509 // msaa.
510 if (kNone_MSFBOType == fMSFBOType) {
511 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
512 fConfigRenderSupport[i][kYes_MSAA] = false;
513 }
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000514 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000515}
516
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000517void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000518 GrGLStandard standard = ctxInfo.standard();
519 GrGLVersion version = ctxInfo.version();
520
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000521 // Base texture support
522 fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
523 fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
524 fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
525 fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
526
527 // Check for 8-bit palette..
528 GrGLint numFormats;
529 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
530 if (numFormats) {
531 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
532 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
533 for (int i = 0; i < numFormats; ++i) {
534 if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
535 fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
536 break;
537 }
538 }
539 }
540
541 // Check for BGRA
542 if (kGL_GrGLStandard == standard) {
543 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
544 version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
545 } else {
546 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
547 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
548 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
549 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
550 fBGRAIsInternalFormat = true;
551 }
552 SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
553 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
554 }
555
556 // Compressed texture support
557
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000558 // glCompressedTexImage2D is available on all OpenGL ES devices...
559 // however, it is only available on standard OpenGL after version 1.3
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000560 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000561
krajcevski786978162014-07-30 11:25:44 -0700562 fCompressedTexSubImageSupport =
bsalomon49f085d2014-09-05 13:34:00 -0700563 hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D);
krajcevski786978162014-07-30 11:25:44 -0700564
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000565 // Check for ETC1
566 bool hasETC1 = false;
567
568 // First check version for support
569 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000570 hasETC1 = hasCompressTex2D &&
joshualittee5da552014-07-16 13:32:56 -0700571 (version >= GR_GL_VER(4, 3) ||
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000572 ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000573 } else {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000574 hasETC1 = hasCompressTex2D &&
575 (version >= GR_GL_VER(3, 0) ||
576 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
577 // ETC2 is a superset of ETC1, so we can just check for that, too.
578 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
579 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000580 }
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000581 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000582
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000583 // Check for LATC under its various forms
584 LATCAlias alias = kLATC_LATCAlias;
585 bool hasLATC = hasCompressTex2D &&
586 (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
587 ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
588
589 // Check for RGTC
590 if (!hasLATC) {
591 // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
592 if (kGL_GrGLStandard == standard) {
593 hasLATC = version >= GR_GL_VER(3, 0);
594 }
595
596 if (!hasLATC) {
597 hasLATC =
598 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
599 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
600 }
601
602 if (hasLATC) {
603 alias = kRGTC_LATCAlias;
604 }
605 }
606
607 // Check for 3DC
608 if (!hasLATC) {
609 hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
610 if (hasLATC) {
611 alias = k3DC_LATCAlias;
612 }
613 }
614
615 fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
616 fLATCAlias = alias;
krajcevski238b4562014-06-30 09:09:22 -0700617
krajcevskib3abe902014-07-30 13:08:11 -0700618 // Check for R11_EAC ... We don't support R11_EAC on desktop, as most
619 // cards default to decompressing the textures in the driver, and is
620 // generally slower.
621 if (kGL_GrGLStandard != standard) {
krajcevski238b4562014-06-30 09:09:22 -0700622 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
623 }
joshualittee5da552014-07-16 13:32:56 -0700624
krajcevski7ef21622014-07-16 15:21:13 -0700625 // Check for ASTC
piotaixre4b23142014-10-02 10:57:53 -0700626 fConfigTextureSupport[kASTC_12x12_GrPixelConfig] =
krajcevski7ef21622014-07-16 15:21:13 -0700627 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
628 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
629 ctxInfo.hasExtension("GL_OES_texture_compression_astc");
630
joshualittee5da552014-07-16 13:32:56 -0700631 // Check for floating point texture support
632 // NOTE: We disallow floating point textures on ES devices if linear
633 // filtering modes are not supported. This is for simplicity, but a more
634 // granular approach is possible. Coincidentally, floating point textures became part of
635 // the standard in ES3.1 / OGL 3.1, hence the shorthand
636 bool hasFPTextures = version >= GR_GL_VER(3, 1);
637 if (!hasFPTextures) {
638 hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanvertha60b2ea2014-12-12 05:58:06 -0800639 (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
joshualittee5da552014-07-16 13:32:56 -0700640 ctxInfo.hasExtension("GL_OES_texture_float"));
641 }
642 fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
jvanverth28f9c602014-12-05 13:06:35 -0800643
644 // Check for fp16 texture support
645 // NOTE: We disallow floating point textures on ES devices if linear
646 // filtering modes are not supported. This is for simplicity, but a more
647 // granular approach is possible. Coincidentally, 16-bit floating point textures became part of
648 // the standard in ES3.1 / OGL 3.1, hence the shorthand
649 bool hasHalfFPTextures = version >= GR_GL_VER(3, 1);
650 if (!hasHalfFPTextures) {
651 hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanvertha60b2ea2014-12-12 05:58:06 -0800652 (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
jvanverth28f9c602014-12-05 13:06:35 -0800653 ctxInfo.hasExtension("GL_OES_texture_half_float"));
654 }
655 fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures && fTextureRedSupport;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000656}
657
piotaixre4b23142014-10-02 10:57:53 -0700658bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf,
659 GrGLenum format,
660 GrGLenum type) const {
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000661 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
662 // ES 2 guarantees this format is supported
robertphillips@google.comeca2dfb2012-06-27 20:13:49 +0000663 return true;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000664 }
665
666 if (!fTwoFormatLimit) {
667 // not limited by ES 2's constraints
668 return true;
669 }
670
bsalomon@google.com548a4332012-07-11 19:45:22 +0000671 GrGLint otherFormat = GR_GL_RGBA;
672 GrGLint otherType = GR_GL_UNSIGNED_BYTE;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000673
674 // The other supported format/type combo supported for ReadPixels
675 // can change based on which render target is bound
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000676 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000677 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT,
678 &otherFormat);
679
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000680 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000681 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE,
682 &otherType);
683
bsalomon@google.com548a4332012-07-11 19:45:22 +0000684 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000685}
686
piotaixre4b23142014-10-02 10:57:53 -0700687bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
688 GrGLenum format,
689 GrGLenum type,
690 GrGLenum currFboFormat) const {
691
692 ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat};
693
694 ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key);
695
696 if (NULL == cachedValue) {
697 bool value = doReadPixelsSupported(intf, format, type);
698 ReadPixelsSupportedFormats newValue(key, value);
699 fReadPixelsSupportedCache.add(newValue);
700
701 return newValue.value();
702 }
703
704 return cachedValue->value();
705}
706
robertphillips@google.com6177e692013-02-28 20:16:25 +0000707void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000708
709 fMSFBOType = kNone_MSFBOType;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000710 if (kGL_GrGLStandard != ctxInfo.standard()) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000711 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed
712 // ES3 driver bugs on at least one device with a tiled GPU (N10).
713 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) {
714 fMSFBOType = kES_EXT_MsToTexture_MSFBOType;
715 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) {
716 fMSFBOType = kES_IMG_MsToTexture_MSFBOType;
commit-bot@chromium.org92b78842014-01-16 20:49:46 +0000717 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000718 fMSFBOType = GrGLCaps::kES_3_0_MSFBOType;
719 } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
720 // chrome's extension is equivalent to the EXT msaa
721 // and fbo_blit extensions.
722 fMSFBOType = kDesktop_EXT_MSFBOType;
723 } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
724 fMSFBOType = kES_Apple_MSFBOType;
725 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000726 } else {
727 if ((ctxInfo.version() >= GR_GL_VER(3,0)) ||
728 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000729 fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000730 } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") &&
731 ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000732 fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000733 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000734 }
735}
736
737namespace {
738const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount;
739}
740
741void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) {
742
743 // Build up list of legal stencil formats (though perhaps not supported on
744 // the particular gpu/driver) from most preferred to least.
745
746 // these consts are in order of most preferred to least preferred
747 // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
748
749 static const StencilFormat
750 // internal Format stencil bits total bits packed?
751 gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
752 gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
753 gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true },
754 gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false},
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000755 // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false},
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000756 gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true };
757
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000758 if (kGL_GrGLStandard == ctxInfo.standard()) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000759 bool supportsPackedDS =
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000760 ctxInfo.version() >= GR_GL_VER(3,0) ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000761 ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") ||
762 ctxInfo.hasExtension("GL_ARB_framebuffer_object");
763
764 // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we
765 // require FBO support we can expect these are legal formats and don't
766 // check. These also all support the unsized GL_STENCIL_INDEX.
767 fStencilFormats.push_back() = gS8;
768 fStencilFormats.push_back() = gS16;
769 if (supportsPackedDS) {
770 fStencilFormats.push_back() = gD24S8;
771 }
772 fStencilFormats.push_back() = gS4;
773 if (supportsPackedDS) {
774 fStencilFormats.push_back() = gDS;
775 }
776 } else {
777 // ES2 has STENCIL_INDEX8 without extensions but requires extensions
778 // for other formats.
779 // ES doesn't support using the unsized format.
780
781 fStencilFormats.push_back() = gS8;
782 //fStencilFormats.push_back() = gS16;
commit-bot@chromium.org04c500f2013-09-06 15:28:01 +0000783 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
784 ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000785 fStencilFormats.push_back() = gD24S8;
786 }
787 if (ctxInfo.hasExtension("GL_OES_stencil4")) {
788 fStencilFormats.push_back() = gS4;
789 }
790 }
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000791 SkASSERT(0 == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000792 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count());
793}
794
bsalomonc0bd6482014-12-09 10:04:14 -0800795static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
bsalomon17168df2014-12-09 09:00:49 -0800796 switch (p) {
bsalomonc0bd6482014-12-09 10:04:14 -0800797 case kLow_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800798 return GR_GL_LOW_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800799 case kMedium_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800800 return GR_GL_MEDIUM_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800801 case kHigh_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800802 return GR_GL_HIGH_FLOAT;
803 }
804 SkFAIL("Unknown precision.");
805 return -1;
806}
807
808static GrGLenum shader_type_to_gl_shader(GrShaderType type) {
809 switch (type) {
810 case kVertex_GrShaderType:
811 return GR_GL_VERTEX_SHADER;
812 case kGeometry_GrShaderType:
813 return GR_GL_GEOMETRY_SHADER;
814 case kFragment_GrShaderType:
815 return GR_GL_FRAGMENT_SHADER;
816 }
817 SkFAIL("Unknown shader type.");
818 return -1;
819}
820
821void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* intf) {
822 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4,1) ||
823 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
824 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800825 if (kGeometry_GrShaderType != s) {
bsalomon17168df2014-12-09 09:00:49 -0800826 GrShaderType shaderType = static_cast<GrShaderType>(s);
827 GrGLenum glShader = shader_type_to_gl_shader(shaderType);
828 PrecisionInfo* first = NULL;
829 fShaderPrecisionVaries = false;
bsalomonc0bd6482014-12-09 10:04:14 -0800830 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
831 GrSLPrecision precision = static_cast<GrSLPrecision>(p);
bsalomon17168df2014-12-09 09:00:49 -0800832 GrGLenum glPrecision = precision_to_gl_float_type(precision);
833 GrGLint range[2];
834 GrGLint bits;
835 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits);
836 if (bits) {
837 fFloatPrecisions[s][p].fLogRangeLow = range[0];
838 fFloatPrecisions[s][p].fLogRangeHigh = range[1];
839 fFloatPrecisions[s][p].fBits = bits;
840 if (!first) {
841 first = &fFloatPrecisions[s][p];
842 } else if (!fShaderPrecisionVaries) {
843 fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]);
844 }
845 }
846 }
847 }
848 }
849 } else {
850 // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
851 fShaderPrecisionVaries = false;
852 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800853 if (kGeometry_GrShaderType != s) {
bsalomonc0bd6482014-12-09 10:04:14 -0800854 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
bsalomon17168df2014-12-09 09:00:49 -0800855 fFloatPrecisions[s][p].fLogRangeLow = 127;
856 fFloatPrecisions[s][p].fLogRangeHigh = 127;
857 fFloatPrecisions[s][p].fBits = 23;
858 }
859 }
860 }
861 }
bsalomon06194c52014-12-09 11:16:12 -0800862 // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Assume they're
863 // the same as the vertex shader. Only fragment shaders were ever allowed to omit support for
864 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
865 // are recommended against.
866 if (fGeometryShaderSupport) {
867 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
868 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p];
869 }
870 }
bsalomon17168df2014-12-09 09:00:49 -0800871}
872
873
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000874void GrGLCaps::markColorConfigAndStencilFormatAsVerified(
875 GrPixelConfig config,
876 const GrGLStencilBuffer::Format& format) {
877#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
878 return;
879#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000880 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
881 SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000882 int count = fStencilFormats.count();
883 // we expect a really small number of possible formats so linear search
884 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000885 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000886 for (int i = 0; i < count; ++i) {
887 if (format.fInternalFormat ==
888 fStencilFormats[i].fInternalFormat) {
889 fStencilVerifiedColorConfigs[i].markVerified(config);
890 return;
891 }
892 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000893 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000894 "GrGLCaps doesn't know about.");
895}
896
897bool GrGLCaps::isColorConfigAndStencilFormatVerified(
898 GrPixelConfig config,
899 const GrGLStencilBuffer::Format& format) const {
900#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
901 return false;
902#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000903 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000904 int count = fStencilFormats.count();
905 // we expect a really small number of possible formats so linear search
906 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000907 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000908 for (int i = 0; i < count; ++i) {
909 if (format.fInternalFormat ==
910 fStencilFormats[i].fInternalFormat) {
911 return fStencilVerifiedColorConfigs[i].isVerified(config);
912 }
913 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000914 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000915 "GLCaps doesn't know about.");
916 return false;
917}
918
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000919SkString GrGLCaps::dump() const {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000920
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000921 SkString r = INHERITED::dump();
bsalomon@google.combcce8922013-03-25 15:38:39 +0000922
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000923 r.appendf("--- GL-Specific ---\n");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000924 for (int i = 0; i < fStencilFormats.count(); ++i) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000925 r.appendf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000926 i,
927 fStencilFormats[i].fStencilBits,
928 fStencilFormats[i].fTotalBits);
929 }
930
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000931 static const char* kMSFBOExtStr[] = {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000932 "None",
933 "ARB",
934 "EXT",
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000935 "ES 3.0",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000936 "Apple",
bsalomon@google.com347c3822013-05-01 20:10:01 +0000937 "IMG MS To Texture",
938 "EXT MS To Texture",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000939 };
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000940 GR_STATIC_ASSERT(0 == kNone_MSFBOType);
941 GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType);
942 GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType);
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000943 GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType);
944 GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType);
945 GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType);
946 GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +0000947 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000948
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000949 static const char* kInvalidateFBTypeStr[] = {
950 "None",
951 "Discard",
952 "Invalidate",
953 };
954 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType);
955 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType);
956 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
957 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000958
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000959 static const char* kMapBufferTypeStr[] = {
960 "None",
961 "MapBuffer",
962 "MapBufferRange",
963 "Chromium",
964 };
965 GR_STATIC_ASSERT(0 == kNone_MapBufferType);
966 GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType);
967 GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType);
968 GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
969 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
970
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000971 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000972 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
joshualitt58162332014-08-01 06:44:53 -0700973 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000974 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]);
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000975 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000976 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
977 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +0000978 if (!fIsCoreProfile) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000979 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords);
commit-bot@chromium.org3628ad92013-08-30 19:43:47 +0000980 }
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000981 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
982 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000983 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO"));
984 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO"));
985 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO"));
986 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO"));
987 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO"));
988 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO"));
bsalomon@google.combcce8922013-03-25 15:38:39 +0000989
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000990 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"));
991 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"));
992 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO"));
993 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO"));
994 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
995 r.appendf("Fragment coord conventions support: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +0000996 (fFragCoordsConventionSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000997 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
998 r.appendf("Use non-VBO for dynamic data: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +0000999 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001000 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO"));
commit-bot@chromium.org4362a382014-03-26 19:49:03 +00001001 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001002 return r;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +00001003}