blob: cfb9558c76cdf41af061f12820e32490d09c3894 [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;
jvanverth1334c212014-12-18 05:44:55 -0800500 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
501 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
502 // for now we don't support floating point MSAA on ES
503 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
jvanverth28f9c602014-12-05 13:06:35 -0800504 } else {
jvanverth1334c212014-12-18 05:44:55 -0800505 if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float") && fTextureRedSupport) {
506 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
507 } else {
508 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false;
509 }
510 // for now we don't support floating point MSAA on ES
jvanverth28f9c602014-12-05 13:06:35 -0800511 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
512 }
513 }
514
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000515 // If we don't support MSAA then undo any places above where we set a config as renderable with
516 // msaa.
517 if (kNone_MSFBOType == fMSFBOType) {
518 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
519 fConfigRenderSupport[i][kYes_MSAA] = false;
520 }
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000521 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000522}
523
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000524void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000525 GrGLStandard standard = ctxInfo.standard();
526 GrGLVersion version = ctxInfo.version();
527
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000528 // Base texture support
529 fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
530 fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
531 fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
532 fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
533
534 // Check for 8-bit palette..
535 GrGLint numFormats;
536 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
537 if (numFormats) {
538 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
539 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
540 for (int i = 0; i < numFormats; ++i) {
541 if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
542 fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
543 break;
544 }
545 }
546 }
547
548 // Check for BGRA
549 if (kGL_GrGLStandard == standard) {
550 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
551 version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
552 } else {
553 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
554 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
555 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
556 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
557 fBGRAIsInternalFormat = true;
558 }
559 SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
560 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
561 }
562
563 // Compressed texture support
564
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000565 // glCompressedTexImage2D is available on all OpenGL ES devices...
566 // however, it is only available on standard OpenGL after version 1.3
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000567 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000568
krajcevski786978162014-07-30 11:25:44 -0700569 fCompressedTexSubImageSupport =
bsalomon49f085d2014-09-05 13:34:00 -0700570 hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D);
krajcevski786978162014-07-30 11:25:44 -0700571
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000572 // Check for ETC1
573 bool hasETC1 = false;
574
575 // First check version for support
576 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000577 hasETC1 = hasCompressTex2D &&
joshualittee5da552014-07-16 13:32:56 -0700578 (version >= GR_GL_VER(4, 3) ||
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000579 ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000580 } else {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000581 hasETC1 = hasCompressTex2D &&
582 (version >= GR_GL_VER(3, 0) ||
583 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
584 // ETC2 is a superset of ETC1, so we can just check for that, too.
585 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
586 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000587 }
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000588 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000589
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000590 // Check for LATC under its various forms
591 LATCAlias alias = kLATC_LATCAlias;
592 bool hasLATC = hasCompressTex2D &&
593 (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
594 ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
595
596 // Check for RGTC
597 if (!hasLATC) {
598 // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
599 if (kGL_GrGLStandard == standard) {
600 hasLATC = version >= GR_GL_VER(3, 0);
601 }
602
603 if (!hasLATC) {
604 hasLATC =
605 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
606 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
607 }
608
609 if (hasLATC) {
610 alias = kRGTC_LATCAlias;
611 }
612 }
613
614 // Check for 3DC
615 if (!hasLATC) {
616 hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
617 if (hasLATC) {
618 alias = k3DC_LATCAlias;
619 }
620 }
621
622 fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
623 fLATCAlias = alias;
krajcevski238b4562014-06-30 09:09:22 -0700624
krajcevskib3abe902014-07-30 13:08:11 -0700625 // Check for R11_EAC ... We don't support R11_EAC on desktop, as most
626 // cards default to decompressing the textures in the driver, and is
627 // generally slower.
628 if (kGL_GrGLStandard != standard) {
krajcevski238b4562014-06-30 09:09:22 -0700629 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
630 }
joshualittee5da552014-07-16 13:32:56 -0700631
krajcevski7ef21622014-07-16 15:21:13 -0700632 // Check for ASTC
piotaixre4b23142014-10-02 10:57:53 -0700633 fConfigTextureSupport[kASTC_12x12_GrPixelConfig] =
krajcevski7ef21622014-07-16 15:21:13 -0700634 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
635 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
636 ctxInfo.hasExtension("GL_OES_texture_compression_astc");
637
joshualittee5da552014-07-16 13:32:56 -0700638 // Check for floating point texture support
639 // NOTE: We disallow floating point textures on ES devices if linear
640 // filtering modes are not supported. This is for simplicity, but a more
641 // granular approach is possible. Coincidentally, floating point textures became part of
642 // the standard in ES3.1 / OGL 3.1, hence the shorthand
643 bool hasFPTextures = version >= GR_GL_VER(3, 1);
644 if (!hasFPTextures) {
645 hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanvertha60b2ea2014-12-12 05:58:06 -0800646 (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
joshualittee5da552014-07-16 13:32:56 -0700647 ctxInfo.hasExtension("GL_OES_texture_float"));
648 }
649 fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
jvanverth28f9c602014-12-05 13:06:35 -0800650
651 // Check for fp16 texture support
652 // NOTE: We disallow floating point textures on ES devices if linear
653 // filtering modes are not supported. This is for simplicity, but a more
654 // granular approach is possible. Coincidentally, 16-bit floating point textures became part of
655 // the standard in ES3.1 / OGL 3.1, hence the shorthand
656 bool hasHalfFPTextures = version >= GR_GL_VER(3, 1);
657 if (!hasHalfFPTextures) {
658 hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanverth1334c212014-12-18 05:44:55 -0800659 (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
660 ctxInfo.hasExtension("GL_OES_texture_half_float"));
jvanverth28f9c602014-12-05 13:06:35 -0800661 }
jvanverth1334c212014-12-18 05:44:55 -0800662 fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000663}
664
piotaixre4b23142014-10-02 10:57:53 -0700665bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf,
666 GrGLenum format,
667 GrGLenum type) const {
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000668 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
669 // ES 2 guarantees this format is supported
robertphillips@google.comeca2dfb2012-06-27 20:13:49 +0000670 return true;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000671 }
672
673 if (!fTwoFormatLimit) {
674 // not limited by ES 2's constraints
675 return true;
676 }
677
bsalomon@google.com548a4332012-07-11 19:45:22 +0000678 GrGLint otherFormat = GR_GL_RGBA;
679 GrGLint otherType = GR_GL_UNSIGNED_BYTE;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000680
681 // The other supported format/type combo supported for ReadPixels
682 // can change based on which render target is bound
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000683 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000684 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT,
685 &otherFormat);
686
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000687 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000688 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE,
689 &otherType);
690
bsalomon@google.com548a4332012-07-11 19:45:22 +0000691 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000692}
693
piotaixre4b23142014-10-02 10:57:53 -0700694bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
695 GrGLenum format,
696 GrGLenum type,
697 GrGLenum currFboFormat) const {
698
699 ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat};
700
701 ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key);
702
703 if (NULL == cachedValue) {
704 bool value = doReadPixelsSupported(intf, format, type);
705 ReadPixelsSupportedFormats newValue(key, value);
706 fReadPixelsSupportedCache.add(newValue);
707
708 return newValue.value();
709 }
710
711 return cachedValue->value();
712}
713
robertphillips@google.com6177e692013-02-28 20:16:25 +0000714void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000715
716 fMSFBOType = kNone_MSFBOType;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000717 if (kGL_GrGLStandard != ctxInfo.standard()) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000718 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed
719 // ES3 driver bugs on at least one device with a tiled GPU (N10).
720 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) {
721 fMSFBOType = kES_EXT_MsToTexture_MSFBOType;
722 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) {
723 fMSFBOType = kES_IMG_MsToTexture_MSFBOType;
commit-bot@chromium.org92b78842014-01-16 20:49:46 +0000724 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000725 fMSFBOType = GrGLCaps::kES_3_0_MSFBOType;
726 } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
727 // chrome's extension is equivalent to the EXT msaa
728 // and fbo_blit extensions.
729 fMSFBOType = kDesktop_EXT_MSFBOType;
730 } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
731 fMSFBOType = kES_Apple_MSFBOType;
732 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000733 } else {
734 if ((ctxInfo.version() >= GR_GL_VER(3,0)) ||
735 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000736 fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000737 } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") &&
738 ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000739 fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000740 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000741 }
742}
743
744namespace {
745const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount;
746}
747
748void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) {
749
750 // Build up list of legal stencil formats (though perhaps not supported on
751 // the particular gpu/driver) from most preferred to least.
752
753 // these consts are in order of most preferred to least preferred
754 // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
755
756 static const StencilFormat
757 // internal Format stencil bits total bits packed?
758 gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
759 gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
760 gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true },
761 gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false},
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000762 // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false},
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000763 gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true };
764
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000765 if (kGL_GrGLStandard == ctxInfo.standard()) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000766 bool supportsPackedDS =
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000767 ctxInfo.version() >= GR_GL_VER(3,0) ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000768 ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") ||
769 ctxInfo.hasExtension("GL_ARB_framebuffer_object");
770
771 // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we
772 // require FBO support we can expect these are legal formats and don't
773 // check. These also all support the unsized GL_STENCIL_INDEX.
774 fStencilFormats.push_back() = gS8;
775 fStencilFormats.push_back() = gS16;
776 if (supportsPackedDS) {
777 fStencilFormats.push_back() = gD24S8;
778 }
779 fStencilFormats.push_back() = gS4;
780 if (supportsPackedDS) {
781 fStencilFormats.push_back() = gDS;
782 }
783 } else {
784 // ES2 has STENCIL_INDEX8 without extensions but requires extensions
785 // for other formats.
786 // ES doesn't support using the unsized format.
787
788 fStencilFormats.push_back() = gS8;
789 //fStencilFormats.push_back() = gS16;
commit-bot@chromium.org04c500f2013-09-06 15:28:01 +0000790 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
791 ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000792 fStencilFormats.push_back() = gD24S8;
793 }
794 if (ctxInfo.hasExtension("GL_OES_stencil4")) {
795 fStencilFormats.push_back() = gS4;
796 }
797 }
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000798 SkASSERT(0 == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000799 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count());
800}
801
bsalomonc0bd6482014-12-09 10:04:14 -0800802static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
bsalomon17168df2014-12-09 09:00:49 -0800803 switch (p) {
bsalomonc0bd6482014-12-09 10:04:14 -0800804 case kLow_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800805 return GR_GL_LOW_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800806 case kMedium_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800807 return GR_GL_MEDIUM_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800808 case kHigh_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800809 return GR_GL_HIGH_FLOAT;
810 }
811 SkFAIL("Unknown precision.");
812 return -1;
813}
814
815static GrGLenum shader_type_to_gl_shader(GrShaderType type) {
816 switch (type) {
817 case kVertex_GrShaderType:
818 return GR_GL_VERTEX_SHADER;
819 case kGeometry_GrShaderType:
820 return GR_GL_GEOMETRY_SHADER;
821 case kFragment_GrShaderType:
822 return GR_GL_FRAGMENT_SHADER;
823 }
824 SkFAIL("Unknown shader type.");
825 return -1;
826}
827
828void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* intf) {
829 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4,1) ||
830 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
831 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800832 if (kGeometry_GrShaderType != s) {
bsalomon17168df2014-12-09 09:00:49 -0800833 GrShaderType shaderType = static_cast<GrShaderType>(s);
834 GrGLenum glShader = shader_type_to_gl_shader(shaderType);
835 PrecisionInfo* first = NULL;
836 fShaderPrecisionVaries = false;
bsalomonc0bd6482014-12-09 10:04:14 -0800837 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
838 GrSLPrecision precision = static_cast<GrSLPrecision>(p);
bsalomon17168df2014-12-09 09:00:49 -0800839 GrGLenum glPrecision = precision_to_gl_float_type(precision);
840 GrGLint range[2];
841 GrGLint bits;
842 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits);
843 if (bits) {
844 fFloatPrecisions[s][p].fLogRangeLow = range[0];
845 fFloatPrecisions[s][p].fLogRangeHigh = range[1];
846 fFloatPrecisions[s][p].fBits = bits;
847 if (!first) {
848 first = &fFloatPrecisions[s][p];
849 } else if (!fShaderPrecisionVaries) {
850 fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]);
851 }
852 }
853 }
854 }
855 }
856 } else {
857 // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
858 fShaderPrecisionVaries = false;
859 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800860 if (kGeometry_GrShaderType != s) {
bsalomonc0bd6482014-12-09 10:04:14 -0800861 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
bsalomon17168df2014-12-09 09:00:49 -0800862 fFloatPrecisions[s][p].fLogRangeLow = 127;
863 fFloatPrecisions[s][p].fLogRangeHigh = 127;
864 fFloatPrecisions[s][p].fBits = 23;
865 }
866 }
867 }
868 }
bsalomon06194c52014-12-09 11:16:12 -0800869 // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Assume they're
870 // the same as the vertex shader. Only fragment shaders were ever allowed to omit support for
871 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
872 // are recommended against.
873 if (fGeometryShaderSupport) {
874 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
875 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p];
876 }
877 }
bsalomon17168df2014-12-09 09:00:49 -0800878}
879
880
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000881void GrGLCaps::markColorConfigAndStencilFormatAsVerified(
882 GrPixelConfig config,
883 const GrGLStencilBuffer::Format& format) {
884#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
885 return;
886#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000887 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
888 SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000889 int count = fStencilFormats.count();
890 // we expect a really small number of possible formats so linear search
891 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000892 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000893 for (int i = 0; i < count; ++i) {
894 if (format.fInternalFormat ==
895 fStencilFormats[i].fInternalFormat) {
896 fStencilVerifiedColorConfigs[i].markVerified(config);
897 return;
898 }
899 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000900 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000901 "GrGLCaps doesn't know about.");
902}
903
904bool GrGLCaps::isColorConfigAndStencilFormatVerified(
905 GrPixelConfig config,
906 const GrGLStencilBuffer::Format& format) const {
907#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
908 return false;
909#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000910 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000911 int count = fStencilFormats.count();
912 // we expect a really small number of possible formats so linear search
913 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000914 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000915 for (int i = 0; i < count; ++i) {
916 if (format.fInternalFormat ==
917 fStencilFormats[i].fInternalFormat) {
918 return fStencilVerifiedColorConfigs[i].isVerified(config);
919 }
920 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000921 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000922 "GLCaps doesn't know about.");
923 return false;
924}
925
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000926SkString GrGLCaps::dump() const {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000927
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000928 SkString r = INHERITED::dump();
bsalomon@google.combcce8922013-03-25 15:38:39 +0000929
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000930 r.appendf("--- GL-Specific ---\n");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000931 for (int i = 0; i < fStencilFormats.count(); ++i) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000932 r.appendf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000933 i,
934 fStencilFormats[i].fStencilBits,
935 fStencilFormats[i].fTotalBits);
936 }
937
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000938 static const char* kMSFBOExtStr[] = {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000939 "None",
940 "ARB",
941 "EXT",
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000942 "ES 3.0",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000943 "Apple",
bsalomon@google.com347c3822013-05-01 20:10:01 +0000944 "IMG MS To Texture",
945 "EXT MS To Texture",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000946 };
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000947 GR_STATIC_ASSERT(0 == kNone_MSFBOType);
948 GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType);
949 GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType);
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000950 GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType);
951 GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType);
952 GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType);
953 GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +0000954 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000955
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000956 static const char* kInvalidateFBTypeStr[] = {
957 "None",
958 "Discard",
959 "Invalidate",
960 };
961 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType);
962 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType);
963 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
964 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000965
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000966 static const char* kMapBufferTypeStr[] = {
967 "None",
968 "MapBuffer",
969 "MapBufferRange",
970 "Chromium",
971 };
972 GR_STATIC_ASSERT(0 == kNone_MapBufferType);
973 GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType);
974 GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType);
975 GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
976 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
977
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000978 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000979 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
joshualitt58162332014-08-01 06:44:53 -0700980 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000981 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]);
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000982 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000983 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
984 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +0000985 if (!fIsCoreProfile) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000986 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords);
commit-bot@chromium.org3628ad92013-08-30 19:43:47 +0000987 }
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000988 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
989 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000990 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO"));
991 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO"));
992 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO"));
993 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO"));
994 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO"));
995 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO"));
bsalomon@google.combcce8922013-03-25 15:38:39 +0000996
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000997 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"));
998 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"));
999 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO"));
1000 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO"));
1001 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
1002 r.appendf("Fragment coord conventions support: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +00001003 (fFragCoordsConventionSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001004 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
1005 r.appendf("Use non-VBO for dynamic data: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +00001006 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001007 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO"));
commit-bot@chromium.org4362a382014-03-26 19:49:03 +00001008 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001009 return r;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +00001010}