blob: b729820ca5fdd2efd9ef51a1f12edc5447df2f5f [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
jvanverthfa1e8a72014-12-22 08:31:49 -0800481 if (this->fRGBA8RenderbufferSupport && this->isConfigTexturable(kSRGBA_8888_GrPixelConfig)) {
482 if (kGL_GrGLStandard == standard) {
483 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
484 ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
485 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
486 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
487 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
488 }
489 } else {
490 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
491 ctxInfo.hasExtension("GL_EXT_sRGB")) {
492 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true;
493 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true;
494 }
495 }
496 }
497
joshualittee5da552014-07-16 13:32:56 -0700498 if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
jvanverth28f9c602014-12-05 13:06:35 -0800499 if (kGL_GrGLStandard == standard) {
jvanvertha60b2ea2014-12-12 05:58:06 -0800500 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
jvanverth28f9c602014-12-05 13:06:35 -0800501 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true;
502 } else {
jvanvertha60b2ea2014-12-12 05:58:06 -0800503 if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) {
504 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
505 } else {
506 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false;
507 }
508 // for now we don't support floating point MSAA on ES
jvanverth28f9c602014-12-05 13:06:35 -0800509 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
510 }
joshualittee5da552014-07-16 13:32:56 -0700511 }
512
jvanverth28f9c602014-12-05 13:06:35 -0800513 if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) {
jvanverth28f9c602014-12-05 13:06:35 -0800514 if (kGL_GrGLStandard == standard) {
jvanvertha60b2ea2014-12-12 05:58:06 -0800515 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
jvanverth28f9c602014-12-05 13:06:35 -0800516 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true;
jvanverth1334c212014-12-18 05:44:55 -0800517 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
518 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
519 // for now we don't support floating point MSAA on ES
520 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
jvanverth28f9c602014-12-05 13:06:35 -0800521 } else {
jvanverth1334c212014-12-18 05:44:55 -0800522 if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float") && fTextureRedSupport) {
523 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
524 } else {
525 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false;
526 }
527 // for now we don't support floating point MSAA on ES
jvanverth28f9c602014-12-05 13:06:35 -0800528 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
529 }
530 }
531
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000532 // If we don't support MSAA then undo any places above where we set a config as renderable with
533 // msaa.
534 if (kNone_MSFBOType == fMSFBOType) {
535 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
536 fConfigRenderSupport[i][kYes_MSAA] = false;
537 }
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000538 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000539}
540
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000541void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000542 GrGLStandard standard = ctxInfo.standard();
543 GrGLVersion version = ctxInfo.version();
544
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000545 // Base texture support
546 fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true;
547 fConfigTextureSupport[kRGB_565_GrPixelConfig] = true;
548 fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true;
549 fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true;
550
551 // Check for 8-bit palette..
552 GrGLint numFormats;
553 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats);
554 if (numFormats) {
555 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
556 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
557 for (int i = 0; i < numFormats; ++i) {
558 if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
559 fConfigTextureSupport[kIndex_8_GrPixelConfig] = true;
560 break;
561 }
562 }
563 }
564
565 // Check for BGRA
566 if (kGL_GrGLStandard == standard) {
567 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] =
568 version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra");
569 } else {
570 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
571 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
572 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
573 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true;
574 fBGRAIsInternalFormat = true;
575 }
576 SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] ||
577 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig);
578 }
579
jvanverthfa1e8a72014-12-22 08:31:49 -0800580 // Check for sRGBA
581 if (kGL_GrGLStandard == standard) {
582 fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
583 (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_texture_sRGB"));
584 } else {
585 fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] =
586 (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB"));
587 }
588
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000589 // Compressed texture support
590
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000591 // glCompressedTexImage2D is available on all OpenGL ES devices...
592 // however, it is only available on standard OpenGL after version 1.3
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000593 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000594
krajcevski786978162014-07-30 11:25:44 -0700595 fCompressedTexSubImageSupport =
bsalomon49f085d2014-09-05 13:34:00 -0700596 hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D);
krajcevski786978162014-07-30 11:25:44 -0700597
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000598 // Check for ETC1
599 bool hasETC1 = false;
600
601 // First check version for support
602 if (kGL_GrGLStandard == standard) {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000603 hasETC1 = hasCompressTex2D &&
joshualittee5da552014-07-16 13:32:56 -0700604 (version >= GR_GL_VER(4, 3) ||
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000605 ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000606 } else {
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000607 hasETC1 = hasCompressTex2D &&
608 (version >= GR_GL_VER(3, 0) ||
609 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
610 // ETC2 is a superset of ETC1, so we can just check for that, too.
611 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
612 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture")));
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000613 }
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000614 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000615
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000616 // Check for LATC under its various forms
617 LATCAlias alias = kLATC_LATCAlias;
618 bool hasLATC = hasCompressTex2D &&
619 (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
620 ctxInfo.hasExtension("GL_NV_texture_compression_latc"));
621
622 // Check for RGTC
623 if (!hasLATC) {
624 // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format.
625 if (kGL_GrGLStandard == standard) {
626 hasLATC = version >= GR_GL_VER(3, 0);
627 }
628
629 if (!hasLATC) {
630 hasLATC =
631 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
632 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc");
633 }
634
635 if (hasLATC) {
636 alias = kRGTC_LATCAlias;
637 }
638 }
639
640 // Check for 3DC
641 if (!hasLATC) {
642 hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture");
643 if (hasLATC) {
644 alias = k3DC_LATCAlias;
645 }
646 }
647
648 fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC;
649 fLATCAlias = alias;
krajcevski238b4562014-06-30 09:09:22 -0700650
krajcevskib3abe902014-07-30 13:08:11 -0700651 // Check for R11_EAC ... We don't support R11_EAC on desktop, as most
652 // cards default to decompressing the textures in the driver, and is
653 // generally slower.
654 if (kGL_GrGLStandard != standard) {
krajcevski238b4562014-06-30 09:09:22 -0700655 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
656 }
joshualittee5da552014-07-16 13:32:56 -0700657
krajcevski7ef21622014-07-16 15:21:13 -0700658 // Check for ASTC
piotaixre4b23142014-10-02 10:57:53 -0700659 fConfigTextureSupport[kASTC_12x12_GrPixelConfig] =
krajcevski7ef21622014-07-16 15:21:13 -0700660 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
661 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
662 ctxInfo.hasExtension("GL_OES_texture_compression_astc");
663
joshualittee5da552014-07-16 13:32:56 -0700664 // Check for floating point texture support
665 // NOTE: We disallow floating point textures on ES devices if linear
666 // filtering modes are not supported. This is for simplicity, but a more
667 // granular approach is possible. Coincidentally, floating point textures became part of
668 // the standard in ES3.1 / OGL 3.1, hence the shorthand
669 bool hasFPTextures = version >= GR_GL_VER(3, 1);
670 if (!hasFPTextures) {
671 hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanvertha60b2ea2014-12-12 05:58:06 -0800672 (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
joshualittee5da552014-07-16 13:32:56 -0700673 ctxInfo.hasExtension("GL_OES_texture_float"));
674 }
675 fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
jvanverth28f9c602014-12-05 13:06:35 -0800676
677 // Check for fp16 texture support
678 // NOTE: We disallow floating point textures on ES devices if linear
679 // filtering modes are not supported. This is for simplicity, but a more
680 // granular approach is possible. Coincidentally, 16-bit floating point textures became part of
681 // the standard in ES3.1 / OGL 3.1, hence the shorthand
682 bool hasHalfFPTextures = version >= GR_GL_VER(3, 1);
683 if (!hasHalfFPTextures) {
684 hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
jvanverth1334c212014-12-18 05:44:55 -0800685 (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
686 ctxInfo.hasExtension("GL_OES_texture_half_float"));
jvanverth28f9c602014-12-05 13:06:35 -0800687 }
jvanverth1334c212014-12-18 05:44:55 -0800688 fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures;
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000689}
690
piotaixre4b23142014-10-02 10:57:53 -0700691bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf,
692 GrGLenum format,
693 GrGLenum type) const {
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000694 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
695 // ES 2 guarantees this format is supported
robertphillips@google.comeca2dfb2012-06-27 20:13:49 +0000696 return true;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000697 }
698
699 if (!fTwoFormatLimit) {
700 // not limited by ES 2's constraints
701 return true;
702 }
703
bsalomon@google.com548a4332012-07-11 19:45:22 +0000704 GrGLint otherFormat = GR_GL_RGBA;
705 GrGLint otherType = GR_GL_UNSIGNED_BYTE;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000706
707 // The other supported format/type combo supported for ReadPixels
708 // can change based on which render target is bound
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000709 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000710 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT,
711 &otherFormat);
712
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000713 GR_GL_GetIntegerv(intf,
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000714 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE,
715 &otherType);
716
bsalomon@google.com548a4332012-07-11 19:45:22 +0000717 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
robertphillips@google.com1d89c932012-06-27 19:31:41 +0000718}
719
piotaixre4b23142014-10-02 10:57:53 -0700720bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
721 GrGLenum format,
722 GrGLenum type,
723 GrGLenum currFboFormat) const {
724
725 ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat};
726
727 ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key);
728
729 if (NULL == cachedValue) {
730 bool value = doReadPixelsSupported(intf, format, type);
731 ReadPixelsSupportedFormats newValue(key, value);
732 fReadPixelsSupportedCache.add(newValue);
733
734 return newValue.value();
735 }
736
737 return cachedValue->value();
738}
739
robertphillips@google.com6177e692013-02-28 20:16:25 +0000740void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000741
742 fMSFBOType = kNone_MSFBOType;
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000743 if (kGL_GrGLStandard != ctxInfo.standard()) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000744 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed
745 // ES3 driver bugs on at least one device with a tiled GPU (N10).
746 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) {
747 fMSFBOType = kES_EXT_MsToTexture_MSFBOType;
748 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) {
749 fMSFBOType = kES_IMG_MsToTexture_MSFBOType;
commit-bot@chromium.org92b78842014-01-16 20:49:46 +0000750 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) {
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000751 fMSFBOType = GrGLCaps::kES_3_0_MSFBOType;
752 } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) {
753 // chrome's extension is equivalent to the EXT msaa
754 // and fbo_blit extensions.
755 fMSFBOType = kDesktop_EXT_MSFBOType;
756 } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) {
757 fMSFBOType = kES_Apple_MSFBOType;
758 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000759 } else {
760 if ((ctxInfo.version() >= GR_GL_VER(3,0)) ||
761 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000762 fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000763 } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") &&
764 ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) {
bsalomon@google.com347c3822013-05-01 20:10:01 +0000765 fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000766 }
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000767 }
768}
769
770namespace {
771const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount;
772}
773
774void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) {
775
776 // Build up list of legal stencil formats (though perhaps not supported on
777 // the particular gpu/driver) from most preferred to least.
778
779 // these consts are in order of most preferred to least preferred
780 // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
781
782 static const StencilFormat
783 // internal Format stencil bits total bits packed?
784 gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
785 gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
786 gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true },
787 gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false},
caryclark@google.comcf6285b2012-06-06 12:09:01 +0000788 // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false},
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000789 gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true };
790
commit-bot@chromium.org9e90aed2014-01-16 16:35:09 +0000791 if (kGL_GrGLStandard == ctxInfo.standard()) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000792 bool supportsPackedDS =
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000793 ctxInfo.version() >= GR_GL_VER(3,0) ||
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000794 ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") ||
795 ctxInfo.hasExtension("GL_ARB_framebuffer_object");
796
797 // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we
798 // require FBO support we can expect these are legal formats and don't
799 // check. These also all support the unsized GL_STENCIL_INDEX.
800 fStencilFormats.push_back() = gS8;
801 fStencilFormats.push_back() = gS16;
802 if (supportsPackedDS) {
803 fStencilFormats.push_back() = gD24S8;
804 }
805 fStencilFormats.push_back() = gS4;
806 if (supportsPackedDS) {
807 fStencilFormats.push_back() = gDS;
808 }
809 } else {
810 // ES2 has STENCIL_INDEX8 without extensions but requires extensions
811 // for other formats.
812 // ES doesn't support using the unsized format.
813
814 fStencilFormats.push_back() = gS8;
815 //fStencilFormats.push_back() = gS16;
commit-bot@chromium.org04c500f2013-09-06 15:28:01 +0000816 if (ctxInfo.version() >= GR_GL_VER(3,0) ||
817 ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000818 fStencilFormats.push_back() = gD24S8;
819 }
820 if (ctxInfo.hasExtension("GL_OES_stencil4")) {
821 fStencilFormats.push_back() = gS4;
822 }
823 }
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000824 SkASSERT(0 == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000825 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count());
826}
827
bsalomonc0bd6482014-12-09 10:04:14 -0800828static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
bsalomon17168df2014-12-09 09:00:49 -0800829 switch (p) {
bsalomonc0bd6482014-12-09 10:04:14 -0800830 case kLow_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800831 return GR_GL_LOW_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800832 case kMedium_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800833 return GR_GL_MEDIUM_FLOAT;
bsalomonc0bd6482014-12-09 10:04:14 -0800834 case kHigh_GrSLPrecision:
bsalomon17168df2014-12-09 09:00:49 -0800835 return GR_GL_HIGH_FLOAT;
836 }
837 SkFAIL("Unknown precision.");
838 return -1;
839}
840
841static GrGLenum shader_type_to_gl_shader(GrShaderType type) {
842 switch (type) {
843 case kVertex_GrShaderType:
844 return GR_GL_VERTEX_SHADER;
845 case kGeometry_GrShaderType:
846 return GR_GL_GEOMETRY_SHADER;
847 case kFragment_GrShaderType:
848 return GR_GL_FRAGMENT_SHADER;
849 }
850 SkFAIL("Unknown shader type.");
851 return -1;
852}
853
854void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* intf) {
855 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4,1) ||
856 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
857 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800858 if (kGeometry_GrShaderType != s) {
bsalomon17168df2014-12-09 09:00:49 -0800859 GrShaderType shaderType = static_cast<GrShaderType>(s);
860 GrGLenum glShader = shader_type_to_gl_shader(shaderType);
861 PrecisionInfo* first = NULL;
862 fShaderPrecisionVaries = false;
bsalomonc0bd6482014-12-09 10:04:14 -0800863 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
864 GrSLPrecision precision = static_cast<GrSLPrecision>(p);
bsalomon17168df2014-12-09 09:00:49 -0800865 GrGLenum glPrecision = precision_to_gl_float_type(precision);
866 GrGLint range[2];
867 GrGLint bits;
868 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits);
869 if (bits) {
870 fFloatPrecisions[s][p].fLogRangeLow = range[0];
871 fFloatPrecisions[s][p].fLogRangeHigh = range[1];
872 fFloatPrecisions[s][p].fBits = bits;
873 if (!first) {
874 first = &fFloatPrecisions[s][p];
875 } else if (!fShaderPrecisionVaries) {
876 fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]);
877 }
878 }
879 }
880 }
881 }
882 } else {
883 // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float.
884 fShaderPrecisionVaries = false;
885 for (int s = 0; s < kGrShaderTypeCount; ++s) {
bsalomon06194c52014-12-09 11:16:12 -0800886 if (kGeometry_GrShaderType != s) {
bsalomonc0bd6482014-12-09 10:04:14 -0800887 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
bsalomon17168df2014-12-09 09:00:49 -0800888 fFloatPrecisions[s][p].fLogRangeLow = 127;
889 fFloatPrecisions[s][p].fLogRangeHigh = 127;
890 fFloatPrecisions[s][p].fBits = 23;
891 }
892 }
893 }
894 }
bsalomon06194c52014-12-09 11:16:12 -0800895 // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Assume they're
896 // the same as the vertex shader. Only fragment shaders were ever allowed to omit support for
897 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
898 // are recommended against.
899 if (fGeometryShaderSupport) {
900 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
901 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p];
902 }
903 }
bsalomon17168df2014-12-09 09:00:49 -0800904}
905
906
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000907void GrGLCaps::markColorConfigAndStencilFormatAsVerified(
908 GrPixelConfig config,
909 const GrGLStencilBuffer::Format& format) {
910#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
911 return;
912#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000913 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
914 SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count());
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000915 int count = fStencilFormats.count();
916 // we expect a really small number of possible formats so linear search
917 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000918 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000919 for (int i = 0; i < count; ++i) {
920 if (format.fInternalFormat ==
921 fStencilFormats[i].fInternalFormat) {
922 fStencilVerifiedColorConfigs[i].markVerified(config);
923 return;
924 }
925 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000926 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000927 "GrGLCaps doesn't know about.");
928}
929
930bool GrGLCaps::isColorConfigAndStencilFormatVerified(
931 GrPixelConfig config,
932 const GrGLStencilBuffer::Format& format) const {
933#if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
934 return false;
935#endif
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000936 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000937 int count = fStencilFormats.count();
938 // we expect a really small number of possible formats so linear search
939 // should be OK
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000940 SkASSERT(count < 16);
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000941 for (int i = 0; i < count; ++i) {
942 if (format.fInternalFormat ==
943 fStencilFormats[i].fInternalFormat) {
944 return fStencilVerifiedColorConfigs[i].isVerified(config);
945 }
946 }
commit-bot@chromium.org88cb22b2014-04-30 14:17:00 +0000947 SkFAIL("Why are we seeing a stencil format that "
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000948 "GLCaps doesn't know about.");
949 return false;
950}
951
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000952SkString GrGLCaps::dump() const {
bsalomon@google.combcce8922013-03-25 15:38:39 +0000953
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000954 SkString r = INHERITED::dump();
bsalomon@google.combcce8922013-03-25 15:38:39 +0000955
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000956 r.appendf("--- GL-Specific ---\n");
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000957 for (int i = 0; i < fStencilFormats.count(); ++i) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000958 r.appendf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000959 i,
960 fStencilFormats[i].fStencilBits,
961 fStencilFormats[i].fTotalBits);
962 }
963
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000964 static const char* kMSFBOExtStr[] = {
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000965 "None",
966 "ARB",
967 "EXT",
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000968 "ES 3.0",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000969 "Apple",
bsalomon@google.com347c3822013-05-01 20:10:01 +0000970 "IMG MS To Texture",
971 "EXT MS To Texture",
bsalomon@google.comf7fa8062012-02-14 14:09:57 +0000972 };
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000973 GR_STATIC_ASSERT(0 == kNone_MSFBOType);
974 GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType);
975 GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType);
commit-bot@chromium.orga8e5a062013-09-05 23:44:09 +0000976 GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType);
977 GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType);
978 GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType);
979 GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType);
commit-bot@chromium.org972f9cd2014-03-28 17:58:28 +0000980 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000981
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +0000982 static const char* kInvalidateFBTypeStr[] = {
983 "None",
984 "Discard",
985 "Invalidate",
986 };
987 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType);
988 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType);
989 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
990 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1);
bsalomon@google.com6b0cf022013-05-03 13:35:14 +0000991
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000992 static const char* kMapBufferTypeStr[] = {
993 "None",
994 "MapBuffer",
995 "MapBufferRange",
996 "Chromium",
997 };
998 GR_STATIC_ASSERT(0 == kNone_MapBufferType);
999 GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType);
1000 GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType);
1001 GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
1002 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
1003
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001004 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001005 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
joshualitt58162332014-08-01 06:44:53 -07001006 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
commit-bot@chromium.org52ffbf62014-04-02 16:19:33 +00001007 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]);
commit-bot@chromium.org160b4782014-05-05 12:32:37 +00001008 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001009 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
1010 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
commit-bot@chromium.org0a6fe712014-04-23 19:26:26 +00001011 if (!fIsCoreProfile) {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001012 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords);
commit-bot@chromium.org3628ad92013-08-30 19:43:47 +00001013 }
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001014 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
1015 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001016 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO"));
1017 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO"));
1018 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO"));
1019 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO"));
1020 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO"));
1021 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO"));
bsalomon@google.combcce8922013-03-25 15:38:39 +00001022
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001023 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"));
1024 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"));
1025 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO"));
1026 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO"));
1027 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
1028 r.appendf("Fragment coord conventions support: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +00001029 (fFragCoordsConventionSupport ? "YES": "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001030 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
1031 r.appendf("Use non-VBO for dynamic data: %s\n",
bsalomon@google.combcce8922013-03-25 15:38:39 +00001032 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001033 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO"));
commit-bot@chromium.org4362a382014-03-26 19:49:03 +00001034 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +00001035 return r;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +00001036}