bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 1 | /* |
| 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" |
joshualitt | b4384b9 | 2014-10-21 12:53:15 -0700 | [diff] [blame] | 10 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 11 | #include "GrGLContext.h" |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 12 | #include "SkTSearch.h" |
bsalomon@google.com | 20f7f17 | 2013-05-17 19:05:03 +0000 | [diff] [blame] | 13 | #include "SkTSort.h" |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 14 | |
| 15 | GrGLCaps::GrGLCaps() { |
| 16 | this->reset(); |
| 17 | } |
| 18 | |
| 19 | void GrGLCaps::reset() { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 20 | INHERITED::reset(); |
| 21 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 22 | fVerifiedColorConfigs.reset(); |
| 23 | fStencilFormats.reset(); |
| 24 | fStencilVerifiedColorConfigs.reset(); |
| 25 | fMSFBOType = kNone_MSFBOType; |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 26 | fInvalidateFBType = kNone_InvalidateFBType; |
krajcevski | 3217c4a | 2014-06-09 09:10:04 -0700 | [diff] [blame] | 27 | fLATCAlias = kLATC_LATCAlias; |
joshualitt | abb52a1 | 2015-01-13 15:02:10 -0800 | [diff] [blame] | 28 | fNvprSupport = kNone_NvprSupport; |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 29 | fMapBufferType = kNone_MapBufferType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 30 | fMaxFragmentUniformVectors = 0; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 31 | fMaxVertexAttributes = 0; |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 32 | fMaxFragmentTextureUnits = 0; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 33 | fMaxFixedFunctionTextureCoords = 0; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 34 | fRGBA8RenderbufferSupport = false; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 35 | fBGRAIsInternalFormat = false; |
| 36 | fTextureSwizzleSupport = false; |
| 37 | fUnpackRowLengthSupport = false; |
| 38 | fUnpackFlipYSupport = false; |
| 39 | fPackRowLengthSupport = false; |
| 40 | fPackFlipYSupport = false; |
| 41 | fTextureUsageSupport = false; |
| 42 | fTexStorageSupport = false; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 43 | fTextureRedSupport = false; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 44 | fImagingSupport = false; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 45 | fTwoFormatLimit = false; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 46 | fFragCoordsConventionSupport = false; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 47 | fVertexArrayObjectSupport = false; |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 48 | fES2CompatibilitySupport = false; |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 49 | fUseNonVBOVertexAndIndexDynamicData = false; |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 50 | fIsCoreProfile = false; |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 51 | fFullClearIsFree = false; |
commit-bot@chromium.org | 4362a38 | 2014-03-26 19:49:03 +0000 | [diff] [blame] | 52 | fDropsTileOnZeroDivide = false; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 53 | fFBFetchSupport = false; |
joshualitt | 3c1096f | 2015-01-13 13:13:59 -0800 | [diff] [blame] | 54 | fFBFetchNeedsCustomOutput = false; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 55 | fFBFetchColorName = NULL; |
| 56 | fFBFetchExtensionString = NULL; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 57 | |
| 58 | fReadPixelsSupportedCache.reset(); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 59 | } |
| 60 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 61 | GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 62 | *this = caps; |
| 63 | } |
| 64 | |
commit-bot@chromium.org | beb8b3a | 2014-04-15 15:37:51 +0000 | [diff] [blame] | 65 | GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 66 | INHERITED::operator=(caps); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 67 | fVerifiedColorConfigs = caps.fVerifiedColorConfigs; |
| 68 | fStencilFormats = caps.fStencilFormats; |
| 69 | fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; |
krajcevski | 3217c4a | 2014-06-09 09:10:04 -0700 | [diff] [blame] | 70 | fLATCAlias = caps.fLATCAlias; |
joshualitt | abb52a1 | 2015-01-13 15:02:10 -0800 | [diff] [blame] | 71 | fNvprSupport = caps.fNvprSupport; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 72 | fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 73 | fMaxVertexAttributes = caps.fMaxVertexAttributes; |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 74 | fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 75 | fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 76 | fMSFBOType = caps.fMSFBOType; |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 77 | fInvalidateFBType = caps.fInvalidateFBType; |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 78 | fMapBufferType = caps.fMapBufferType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 79 | fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 80 | fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat; |
| 81 | fTextureSwizzleSupport = caps.fTextureSwizzleSupport; |
| 82 | fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport; |
| 83 | fUnpackFlipYSupport = caps.fUnpackFlipYSupport; |
| 84 | fPackRowLengthSupport = caps.fPackRowLengthSupport; |
| 85 | fPackFlipYSupport = caps.fPackFlipYSupport; |
| 86 | fTextureUsageSupport = caps.fTextureUsageSupport; |
| 87 | fTexStorageSupport = caps.fTexStorageSupport; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 88 | fTextureRedSupport = caps.fTextureRedSupport; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 89 | fImagingSupport = caps.fImagingSupport; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 90 | fTwoFormatLimit = caps.fTwoFormatLimit; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 91 | fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 92 | fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 93 | fES2CompatibilitySupport = caps.fES2CompatibilitySupport; |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 94 | fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData; |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 95 | fIsCoreProfile = caps.fIsCoreProfile; |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 96 | fFullClearIsFree = caps.fFullClearIsFree; |
commit-bot@chromium.org | 4362a38 | 2014-03-26 19:49:03 +0000 | [diff] [blame] | 97 | fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 98 | fFBFetchSupport = caps.fFBFetchSupport; |
joshualitt | 3c1096f | 2015-01-13 13:13:59 -0800 | [diff] [blame] | 99 | fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 100 | fFBFetchColorName = caps.fFBFetchColorName; |
| 101 | fFBFetchExtensionString = caps.fFBFetchExtensionString; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 102 | |
| 103 | return *this; |
| 104 | } |
| 105 | |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 106 | bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 107 | |
| 108 | this->reset(); |
| 109 | if (!ctxInfo.isInitialized()) { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 110 | return false; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 111 | } |
| 112 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 113 | GrGLStandard standard = ctxInfo.standard(); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 114 | GrGLVersion version = ctxInfo.version(); |
| 115 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 116 | /************************************************************************** |
| 117 | * Caps specific to GrGLCaps |
| 118 | **************************************************************************/ |
| 119 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 120 | if (kGLES_GrGLStandard == standard) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 121 | GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, |
| 122 | &fMaxFragmentUniformVectors); |
| 123 | } else { |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 124 | SkASSERT(kGL_GrGLStandard == standard); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 125 | GrGLint max; |
| 126 | GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); |
| 127 | fMaxFragmentUniformVectors = max / 4; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 128 | if (version >= GR_GL_VER(3, 2)) { |
| 129 | GrGLint profileMask; |
| 130 | GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); |
| 131 | fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); |
| 132 | } |
| 133 | if (!fIsCoreProfile) { |
| 134 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_COORDS, &fMaxFixedFunctionTextureCoords); |
| 135 | // Sanity check |
| 136 | SkASSERT(fMaxFixedFunctionTextureCoords > 0 && fMaxFixedFunctionTextureCoords < 128); |
| 137 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 138 | } |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 139 | GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 140 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 141 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 142 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 143 | fRGBA8RenderbufferSupport = true; |
| 144 | } else { |
commit-bot@chromium.org | c5dffe4 | 2013-08-20 15:25:21 +0000 | [diff] [blame] | 145 | fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) || |
| 146 | ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 147 | ctxInfo.hasExtension("GL_ARM_rgba8"); |
| 148 | } |
| 149 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 150 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 151 | fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || |
| 152 | ctxInfo.hasExtension("GL_ARB_texture_swizzle"); |
| 153 | } else { |
commit-bot@chromium.org | 6364b5e | 2013-08-20 20:22:52 +0000 | [diff] [blame] | 154 | fTextureSwizzleSupport = version >= GR_GL_VER(3,0); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 155 | } |
| 156 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 157 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 158 | fUnpackRowLengthSupport = true; |
| 159 | fUnpackFlipYSupport = false; |
| 160 | fPackRowLengthSupport = true; |
| 161 | fPackFlipYSupport = false; |
| 162 | } else { |
commit-bot@chromium.org | dc3134c | 2013-08-16 16:12:23 +0000 | [diff] [blame] | 163 | fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || |
| 164 | ctxInfo.hasExtension("GL_EXT_unpack_subimage"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 165 | fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); |
commit-bot@chromium.org | dc3134c | 2013-08-16 16:12:23 +0000 | [diff] [blame] | 166 | fPackRowLengthSupport = version >= GR_GL_VER(3,0) || |
| 167 | ctxInfo.hasExtension("GL_NV_pack_subimage"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 168 | fPackFlipYSupport = |
| 169 | ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order"); |
| 170 | } |
| 171 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 172 | fTextureUsageSupport = (kGLES_GrGLStandard == standard) && |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 173 | ctxInfo.hasExtension("GL_ANGLE_texture_usage"); |
| 174 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 175 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 7a434a2 | 2013-08-21 14:01:56 +0000 | [diff] [blame] | 176 | // The EXT version can apply to either GL or GLES. |
| 177 | fTexStorageSupport = version >= GR_GL_VER(4,2) || |
| 178 | ctxInfo.hasExtension("GL_ARB_texture_storage") || |
| 179 | ctxInfo.hasExtension("GL_EXT_texture_storage"); |
| 180 | } else { |
| 181 | // Qualcomm Adreno drivers appear to have issues with texture storage. |
| 182 | fTexStorageSupport = (version >= GR_GL_VER(3,0) && |
| 183 | kQualcomm_GrGLVendor != ctxInfo.vendor()) || |
| 184 | ctxInfo.hasExtension("GL_EXT_texture_storage"); |
| 185 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 186 | |
hendrikw | a0d5ad7 | 2014-12-02 07:30:30 -0800 | [diff] [blame] | 187 | // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support GL_RED |
| 188 | // and GL_RG on FBO textures. |
| 189 | if (!ctxInfo.isMesa()) { |
| 190 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 459104c | 2013-06-14 14:42:56 +0000 | [diff] [blame] | 191 | fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 192 | ctxInfo.hasExtension("GL_ARB_texture_rg"); |
hendrikw | a0d5ad7 | 2014-12-02 07:30:30 -0800 | [diff] [blame] | 193 | } else { |
| 194 | fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 195 | ctxInfo.hasExtension("GL_EXT_texture_rg"); |
commit-bot@chromium.org | 459104c | 2013-06-14 14:42:56 +0000 | [diff] [blame] | 196 | } |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 197 | } |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 198 | fImagingSupport = kGL_GrGLStandard == standard && |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 199 | ctxInfo.hasExtension("GL_ARB_imaging"); |
| 200 | |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 201 | // ES 2 only guarantees RGBA/uchar + one other format/type combo for |
| 202 | // ReadPixels. The other format has to checked at run-time since it |
| 203 | // can change based on which render target is bound |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 204 | fTwoFormatLimit = kGLES_GrGLStandard == standard; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 205 | |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 206 | // Frag Coords Convention support is not part of ES |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 207 | // Known issue on at least some Intel platforms: |
| 208 | // http://code.google.com/p/skia/issues/detail?id=946 |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 209 | if (kIntel_GrGLVendor != ctxInfo.vendor() && kGLES_GrGLStandard != standard) { |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 210 | fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration || |
| 211 | ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions"); |
| 212 | } |
| 213 | |
bsalomon@google.com | 3012ded | 2013-02-22 16:44:04 +0000 | [diff] [blame] | 214 | // SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with |
| 215 | // frequently changing VBOs. We've measured a performance increase using non-VBO vertex |
| 216 | // data for dynamic content on these GPUs. Perhaps we should read the renderer string and |
| 217 | // limit this decision to specific GPU families rather than basing it on the vendor alone. |
| 218 | if (!GR_GL_MUST_USE_VBO && |
bsalomon | ed82c4e | 2014-09-02 07:54:47 -0700 | [diff] [blame] | 219 | (kARM_GrGLVendor == ctxInfo.vendor() || |
| 220 | kImagination_GrGLVendor == ctxInfo.vendor() || |
| 221 | kQualcomm_GrGLVendor == ctxInfo.vendor())) { |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 222 | fUseNonVBOVertexAndIndexDynamicData = true; |
| 223 | } |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 224 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 225 | if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(4,3)) || |
skia.committer@gmail.com | a915772 | 2014-04-03 03:04:26 +0000 | [diff] [blame] | 226 | (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) || |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 227 | ctxInfo.hasExtension("GL_ARB_invalidate_subdata")) { |
| 228 | fDiscardRenderTargetSupport = true; |
| 229 | fInvalidateFBType = kInvalidate_InvalidateFBType; |
| 230 | } else if (ctxInfo.hasExtension("GL_EXT_discard_framebuffer")) { |
| 231 | fDiscardRenderTargetSupport = true; |
| 232 | fInvalidateFBType = kDiscard_InvalidateFBType; |
| 233 | } |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 234 | |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 235 | if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) { |
| 236 | fFullClearIsFree = true; |
| 237 | } |
| 238 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 239 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 240 | fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
tomhudson | 612e926 | 2014-11-24 11:22:36 -0800 | [diff] [blame] | 241 | ctxInfo.hasExtension("GL_ARB_vertex_array_object") || |
| 242 | ctxInfo.hasExtension("GL_APPLE_vertex_array_object"); |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 243 | } else { |
commit-bot@chromium.org | 2276c01 | 2013-08-16 15:53:33 +0000 | [diff] [blame] | 244 | fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
| 245 | ctxInfo.hasExtension("GL_OES_vertex_array_object"); |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 246 | } |
| 247 | |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 248 | if (kGL_GrGLStandard == standard) { |
| 249 | fES2CompatibilitySupport = ctxInfo.hasExtension("GL_ARB_ES2_compatibility"); |
| 250 | } |
| 251 | else { |
| 252 | fES2CompatibilitySupport = true; |
| 253 | } |
| 254 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 255 | if (kGLES_GrGLStandard == standard) { |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 256 | if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) { |
joshualitt | 3c1096f | 2015-01-13 13:13:59 -0800 | [diff] [blame] | 257 | fFBFetchNeedsCustomOutput = (version >= GR_GL_VER(3, 0)); |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 258 | fFBFetchSupport = true; |
| 259 | fFBFetchColorName = "gl_LastFragData[0]"; |
| 260 | fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch"; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 261 | } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) { |
joshualitt | 3c1096f | 2015-01-13 13:13:59 -0800 | [diff] [blame] | 262 | // Actually, we haven't seen an ES3.0 device with this extension yet, so we don't know |
| 263 | fFBFetchNeedsCustomOutput = false; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 264 | fFBFetchSupport = true; |
| 265 | fFBFetchColorName = "gl_LastFragData[0]"; |
| 266 | fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch"; |
| 267 | } else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) { |
| 268 | // The arm extension also requires an additional flag which we will set onResetContext |
joshualitt | 3c1096f | 2015-01-13 13:13:59 -0800 | [diff] [blame] | 269 | fFBFetchNeedsCustomOutput = false; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 270 | fFBFetchSupport = true; |
| 271 | fFBFetchColorName = "gl_LastFragColorARM"; |
| 272 | fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch"; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | |
commit-bot@chromium.org | 4362a38 | 2014-03-26 19:49:03 +0000 | [diff] [blame] | 276 | // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader |
| 277 | fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor(); |
| 278 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 279 | this->initFSAASupport(ctxInfo, gli); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 280 | this->initStencilFormats(ctxInfo); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 281 | |
| 282 | /************************************************************************** |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 283 | * GrDrawTargetCaps fields |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 284 | **************************************************************************/ |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 285 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 286 | // we could also look for GL_ATI_separate_stencil extension or |
| 287 | // GL_EXT_stencil_two_side but they use different function signatures |
| 288 | // than GL2.0+ (and than each other). |
| 289 | fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0)); |
| 290 | // supported on GL 1.4 and higher or by extension |
| 291 | fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) || |
| 292 | ctxInfo.hasExtension("GL_EXT_stencil_wrap"); |
| 293 | } else { |
| 294 | // ES 2 has two sided stencil and stencil wrap |
| 295 | fTwoSidedStencilSupport = true; |
| 296 | fStencilWrapOpsSupport = true; |
| 297 | } |
| 298 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 299 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 300 | fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the desktop VBO |
| 301 | // extension includes glMapBuffer. |
| 302 | if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffer_range")) { |
| 303 | fMapBufferFlags |= kSubset_MapFlag; |
| 304 | fMapBufferType = kMapBufferRange_MapBufferType; |
| 305 | } else { |
| 306 | fMapBufferType = kMapBuffer_MapBufferType; |
| 307 | } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 308 | } else { |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 309 | // Unextended GLES2 doesn't have any buffer mapping. |
| 310 | fMapBufferFlags = kNone_MapBufferType; |
| 311 | if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) { |
| 312 | fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
| 313 | fMapBufferType = kChromium_MapBufferType; |
| 314 | } else if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_map_buffer_range")) { |
| 315 | fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
| 316 | fMapBufferType = kMapBufferRange_MapBufferType; |
| 317 | } else if (ctxInfo.hasExtension("GL_OES_mapbuffer")) { |
| 318 | fMapBufferFlags = kCanMap_MapFlag; |
| 319 | fMapBufferType = kMapBuffer_MapBufferType; |
| 320 | } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 321 | } |
| 322 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 323 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 4744231 | 2013-12-19 16:18:01 +0000 | [diff] [blame] | 324 | SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) || |
| 325 | ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")); |
| 326 | fNPOTTextureTileSupport = true; |
| 327 | fMipMapSupport = true; |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 328 | } else { |
| 329 | // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only |
commit-bot@chromium.org | 22dd6b9 | 2013-08-16 18:13:48 +0000 | [diff] [blame] | 330 | // ES3 has no limitations. |
| 331 | fNPOTTextureTileSupport = ctxInfo.version() >= GR_GL_VER(3,0) || |
| 332 | ctxInfo.hasExtension("GL_OES_texture_npot"); |
commit-bot@chromium.org | 4744231 | 2013-12-19 16:18:01 +0000 | [diff] [blame] | 333 | // ES2 supports MIP mapping for POT textures but our caps don't allow for limited MIP |
| 334 | // support. The OES extension or ES 3.0 allow for MIPS on NPOT textures. So, apparently, |
| 335 | // does the undocumented GL_IMG_texture_npot extension. This extension does not seem to |
| 336 | // to alllow arbitrary wrap modes, however. |
| 337 | fMipMapSupport = fNPOTTextureTileSupport || ctxInfo.hasExtension("GL_IMG_texture_npot"); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 338 | } |
| 339 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 340 | fHWAALineSupport = (kGL_GrGLStandard == standard); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 341 | |
| 342 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_SIZE, &fMaxTextureSize); |
| 343 | GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize); |
| 344 | // Our render targets are always created with textures as the color |
| 345 | // attachment, hence this min: |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 346 | fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 347 | |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 348 | fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering"); |
| 349 | |
| 350 | if (fPathRenderingSupport) { |
| 351 | if (kGL_GrGLStandard == standard) { |
| 352 | // We need one of the two possible texturing methods: using fixed function pipeline |
| 353 | // (PathTexGen, texcoords, ...) or using the newer NVPR API additions that support |
| 354 | // setting individual fragment inputs with ProgramPathFragmentInputGen. The API |
| 355 | // additions are detected by checking the existence of the function. Eventually we may |
| 356 | // choose to remove the fixed function codepath. |
| 357 | // Set fMaxFixedFunctionTextureCoords = 0 here if you want to force |
| 358 | // ProgramPathFragmentInputGen usage on desktop. |
| 359 | fPathRenderingSupport = ctxInfo.hasExtension("GL_EXT_direct_state_access") && |
| 360 | (fMaxFixedFunctionTextureCoords > 0 || |
| 361 | ((ctxInfo.version() >= GR_GL_VER(4,3) || |
| 362 | ctxInfo.hasExtension("GL_ARB_program_interface_query")) && |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 363 | gli->fFunctions.fProgramPathFragmentInputGen)); |
joshualitt | abb52a1 | 2015-01-13 15:02:10 -0800 | [diff] [blame] | 364 | if (fPathRenderingSupport) { |
| 365 | fNvprSupport = gli->fFunctions.fProgramPathFragmentInputGen ? kNormal_NvprSupport : |
| 366 | kLegacy_NvprSupport; |
| 367 | } |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 368 | } else { |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 369 | fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,1); |
joshualitt | abb52a1 | 2015-01-13 15:02:10 -0800 | [diff] [blame] | 370 | fNvprSupport = fPathRenderingSupport ? kNormal_NvprSupport : kNone_NvprSupport; |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 371 | } |
joshualitt | abb52a1 | 2015-01-13 15:02:10 -0800 | [diff] [blame] | 372 | } else { |
| 373 | fNvprSupport = kNone_NvprSupport; |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 374 | } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 375 | |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 376 | fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker"); |
| 377 | |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 378 | // For now these two are equivalent but we could have dst read in shader via some other method |
| 379 | fDstReadInShaderSupport = fFBFetchSupport; |
robertphillips@google.com | 8995b7b | 2013-11-01 15:03:34 +0000 | [diff] [blame] | 380 | |
| 381 | // Disable scratch texture reuse on Mali and Adreno devices |
| 382 | fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() && |
| 383 | kQualcomm_GrGLVendor != ctxInfo.vendor(); |
commit-bot@chromium.org | b835652 | 2013-07-18 22:26:39 +0000 | [diff] [blame] | 384 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 385 | // Enable supported shader-related caps |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 386 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 387 | fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) || |
| 388 | ctxInfo.hasExtension("GL_ARB_blend_func_extended"); |
| 389 | fShaderDerivativeSupport = true; |
| 390 | // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS |
| 391 | fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3,2) && |
| 392 | ctxInfo.glslGeneration() >= k150_GrGLSLGeneration; |
| 393 | } else { |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 394 | fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) || |
| 395 | ctxInfo.hasExtension("GL_OES_standard_derivatives"); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 396 | } |
| 397 | |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 398 | if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 399 | GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount); |
| 400 | } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) { |
| 401 | GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount); |
| 402 | } |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 403 | |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 404 | if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() || |
bsalomon | e702d97 | 2015-01-29 10:07:32 -0800 | [diff] [blame] | 405 | kPowerVRRogue_GrGLRenderer == ctxInfo.renderer() || |
bsalomon | a8fcea0 | 2015-02-13 09:00:39 -0800 | [diff] [blame] | 406 | kAdreno3xx_GrGLRenderer == ctxInfo.renderer()) { |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 407 | fUseDrawInsteadOfClear = true; |
| 408 | } |
| 409 | |
bsalomon | d08ea5f | 2015-02-20 06:58:13 -0800 | [diff] [blame^] | 410 | if (kGL_GrGLStandard == standard) { |
| 411 | // ARB allows mixed size FBO attachments, EXT does not. |
| 412 | if (ctxInfo.version() >= GR_GL_VER(3, 0) || |
| 413 | ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { |
| 414 | fOversizedStencilSupport = true; |
| 415 | } else { |
| 416 | SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object")); |
| 417 | } |
| 418 | } else { |
| 419 | // ES 3.0 supports mixed size FBO attachments, 2.0 does not. |
| 420 | fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0); |
| 421 | } |
| 422 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 423 | this->initConfigTexturableTable(ctxInfo, gli); |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 424 | this->initConfigRenderableTable(ctxInfo); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 425 | |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 426 | this->initShaderPrecisionTable(ctxInfo, gli); |
| 427 | |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 428 | return true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 432 | // OpenGL < 3.0 |
| 433 | // no support for render targets unless the GL_ARB_framebuffer_object |
| 434 | // extension is supported (in which case we get ALPHA, RED, RG, RGB, |
| 435 | // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we |
| 436 | // probably don't get R8 in this case. |
| 437 | |
| 438 | // OpenGL 3.0 |
| 439 | // base color renderable: ALPHA, RED, RG, RGB, and RGBA |
| 440 | // sized derivatives: ALPHA8, R8, RGBA4, RGBA8 |
| 441 | |
| 442 | // >= OpenGL 3.1 |
| 443 | // base color renderable: RED, RG, RGB, and RGBA |
| 444 | // sized derivatives: R8, RGBA4, RGBA8 |
| 445 | // if the GL_ARB_compatibility extension is supported then we get back |
| 446 | // support for GL_ALPHA and ALPHA8 |
| 447 | |
| 448 | // GL_EXT_bgra adds BGRA render targets to any version |
| 449 | |
| 450 | // ES 2.0 |
| 451 | // color renderable: RGBA4, RGB5_A1, RGB565 |
| 452 | // GL_EXT_texture_rg adds support for R8 as a color render target |
| 453 | // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8 |
| 454 | // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support |
| 455 | |
| 456 | // ES 3.0 |
| 457 | // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called |
| 458 | // below already account for this). |
| 459 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 460 | GrGLStandard standard = ctxInfo.standard(); |
| 461 | |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 462 | enum { |
| 463 | kNo_MSAA = 0, |
| 464 | kYes_MSAA = 1, |
| 465 | }; |
| 466 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 467 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 468 | // Post 3.0 we will get R8 |
| 469 | // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object) |
| 470 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 471 | ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 472 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true; |
| 473 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 474 | } |
| 475 | } else { |
| 476 | // On ES we can only hope for R8 |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 477 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupport; |
| 478 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 479 | } |
| 480 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 481 | if (kGL_GrGLStandard != standard) { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 482 | // only available in ES |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 483 | fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true; |
| 484 | fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | // we no longer support 444 as a render target |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 488 | fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false; |
| 489 | fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 490 | |
| 491 | if (this->fRGBA8RenderbufferSupport) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 492 | fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true; |
commit-bot@chromium.org | da3d69c | 2013-10-28 15:09:13 +0000 | [diff] [blame] | 493 | fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 494 | } |
| 495 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 496 | if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 497 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true; |
| 498 | // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of |
| 499 | // configs that are color-renderable and can be passed to glRenderBufferStorageMultisample. |
commit-bot@chromium.org | 4256d24 | 2013-10-17 16:29:41 +0000 | [diff] [blame] | 500 | // Chromium may have an extension to allow BGRA renderbuffers to work on desktop platforms. |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 501 | if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) { |
commit-bot@chromium.org | 4256d24 | 2013-10-17 16:29:41 +0000 | [diff] [blame] | 502 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true; |
| 503 | } else { |
| 504 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = |
| 505 | !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers(); |
| 506 | } |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 507 | } |
| 508 | |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 509 | if (this->fRGBA8RenderbufferSupport && this->isConfigTexturable(kSRGBA_8888_GrPixelConfig)) { |
| 510 | if (kGL_GrGLStandard == standard) { |
| 511 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 512 | ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || |
| 513 | ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { |
| 514 | fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true; |
| 515 | fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true; |
| 516 | } |
| 517 | } else { |
| 518 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 519 | ctxInfo.hasExtension("GL_EXT_sRGB")) { |
| 520 | fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true; |
| 521 | fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true; |
| 522 | } |
| 523 | } |
| 524 | } |
| 525 | |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 526 | if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) { |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 527 | if (kGL_GrGLStandard == standard) { |
jvanverth | a60b2ea | 2014-12-12 05:58:06 -0800 | [diff] [blame] | 528 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true; |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 529 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true; |
| 530 | } else { |
jvanverth | a60b2ea | 2014-12-12 05:58:06 -0800 | [diff] [blame] | 531 | if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) { |
| 532 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true; |
| 533 | } else { |
| 534 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false; |
| 535 | } |
| 536 | // for now we don't support floating point MSAA on ES |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 537 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false; |
| 538 | } |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 539 | } |
| 540 | |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 541 | if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) { |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 542 | if (kGL_GrGLStandard == standard) { |
jvanverth | a60b2ea | 2014-12-12 05:58:06 -0800 | [diff] [blame] | 543 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true; |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 544 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true; |
jvanverth | 1334c21 | 2014-12-18 05:44:55 -0800 | [diff] [blame] | 545 | } else if (ctxInfo.version() >= GR_GL_VER(3,0)) { |
| 546 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true; |
| 547 | // for now we don't support floating point MSAA on ES |
| 548 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false; |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 549 | } else { |
jvanverth | 1334c21 | 2014-12-18 05:44:55 -0800 | [diff] [blame] | 550 | if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float") && fTextureRedSupport) { |
| 551 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true; |
| 552 | } else { |
| 553 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false; |
| 554 | } |
| 555 | // for now we don't support floating point MSAA on ES |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 556 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false; |
| 557 | } |
| 558 | } |
| 559 | |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 560 | // If we don't support MSAA then undo any places above where we set a config as renderable with |
| 561 | // msaa. |
| 562 | if (kNone_MSFBOType == fMSFBOType) { |
| 563 | for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 564 | fConfigRenderSupport[i][kYes_MSAA] = false; |
| 565 | } |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 566 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 567 | } |
| 568 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 569 | void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 570 | GrGLStandard standard = ctxInfo.standard(); |
| 571 | GrGLVersion version = ctxInfo.version(); |
| 572 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 573 | // Base texture support |
| 574 | fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true; |
| 575 | fConfigTextureSupport[kRGB_565_GrPixelConfig] = true; |
| 576 | fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true; |
| 577 | fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true; |
| 578 | |
| 579 | // Check for 8-bit palette.. |
| 580 | GrGLint numFormats; |
| 581 | GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats); |
| 582 | if (numFormats) { |
| 583 | SkAutoSTMalloc<10, GrGLint> formats(numFormats); |
| 584 | GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); |
| 585 | for (int i = 0; i < numFormats; ++i) { |
| 586 | if (GR_GL_PALETTE8_RGBA8 == formats[i]) { |
| 587 | fConfigTextureSupport[kIndex_8_GrPixelConfig] = true; |
| 588 | break; |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | // Check for BGRA |
| 594 | if (kGL_GrGLStandard == standard) { |
| 595 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = |
| 596 | version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra"); |
| 597 | } else { |
| 598 | if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { |
| 599 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true; |
| 600 | } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { |
| 601 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true; |
| 602 | fBGRAIsInternalFormat = true; |
| 603 | } |
| 604 | SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] || |
| 605 | kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig); |
| 606 | } |
| 607 | |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 608 | // Check for sRGBA |
| 609 | if (kGL_GrGLStandard == standard) { |
| 610 | fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] = |
| 611 | (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_texture_sRGB")); |
| 612 | } else { |
| 613 | fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] = |
| 614 | (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB")); |
| 615 | } |
| 616 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 617 | // Compressed texture support |
| 618 | |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 619 | // glCompressedTexImage2D is available on all OpenGL ES devices... |
| 620 | // however, it is only available on standard OpenGL after version 1.3 |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 621 | bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3)); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 622 | |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 623 | fCompressedTexSubImageSupport = |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 624 | hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D); |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 625 | |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 626 | // Check for ETC1 |
| 627 | bool hasETC1 = false; |
| 628 | |
| 629 | // First check version for support |
| 630 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 631 | hasETC1 = hasCompressTex2D && |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 632 | (version >= GR_GL_VER(4, 3) || |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 633 | ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 634 | } else { |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 635 | hasETC1 = hasCompressTex2D && |
| 636 | (version >= GR_GL_VER(3, 0) || |
| 637 | ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || |
| 638 | // ETC2 is a superset of ETC1, so we can just check for that, too. |
| 639 | (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && |
| 640 | ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 641 | } |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 642 | fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 643 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 644 | // Check for LATC under its various forms |
| 645 | LATCAlias alias = kLATC_LATCAlias; |
| 646 | bool hasLATC = hasCompressTex2D && |
| 647 | (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") || |
| 648 | ctxInfo.hasExtension("GL_NV_texture_compression_latc")); |
| 649 | |
| 650 | // Check for RGTC |
| 651 | if (!hasLATC) { |
| 652 | // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format. |
| 653 | if (kGL_GrGLStandard == standard) { |
| 654 | hasLATC = version >= GR_GL_VER(3, 0); |
| 655 | } |
| 656 | |
| 657 | if (!hasLATC) { |
| 658 | hasLATC = |
| 659 | ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") || |
| 660 | ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc"); |
| 661 | } |
| 662 | |
| 663 | if (hasLATC) { |
| 664 | alias = kRGTC_LATCAlias; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | // Check for 3DC |
| 669 | if (!hasLATC) { |
| 670 | hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture"); |
| 671 | if (hasLATC) { |
| 672 | alias = k3DC_LATCAlias; |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC; |
| 677 | fLATCAlias = alias; |
krajcevski | 238b456 | 2014-06-30 09:09:22 -0700 | [diff] [blame] | 678 | |
krajcevski | b3abe90 | 2014-07-30 13:08:11 -0700 | [diff] [blame] | 679 | // Check for R11_EAC ... We don't support R11_EAC on desktop, as most |
| 680 | // cards default to decompressing the textures in the driver, and is |
| 681 | // generally slower. |
| 682 | if (kGL_GrGLStandard != standard) { |
krajcevski | 238b456 | 2014-06-30 09:09:22 -0700 | [diff] [blame] | 683 | fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0); |
| 684 | } |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 685 | |
krajcevski | 7ef2162 | 2014-07-16 15:21:13 -0700 | [diff] [blame] | 686 | // Check for ASTC |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 687 | fConfigTextureSupport[kASTC_12x12_GrPixelConfig] = |
krajcevski | 7ef2162 | 2014-07-16 15:21:13 -0700 | [diff] [blame] | 688 | ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || |
| 689 | ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || |
| 690 | ctxInfo.hasExtension("GL_OES_texture_compression_astc"); |
| 691 | |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 692 | // Check for floating point texture support |
| 693 | // NOTE: We disallow floating point textures on ES devices if linear |
| 694 | // filtering modes are not supported. This is for simplicity, but a more |
| 695 | // granular approach is possible. Coincidentally, floating point textures became part of |
| 696 | // the standard in ES3.1 / OGL 3.1, hence the shorthand |
| 697 | bool hasFPTextures = version >= GR_GL_VER(3, 1); |
| 698 | if (!hasFPTextures) { |
| 699 | hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || |
jvanverth | a60b2ea | 2014-12-12 05:58:06 -0800 | [diff] [blame] | 700 | (ctxInfo.hasExtension("GL_OES_texture_float_linear") && |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 701 | ctxInfo.hasExtension("GL_OES_texture_float")); |
| 702 | } |
| 703 | fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures; |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 704 | |
| 705 | // Check for fp16 texture support |
| 706 | // NOTE: We disallow floating point textures on ES devices if linear |
| 707 | // filtering modes are not supported. This is for simplicity, but a more |
| 708 | // granular approach is possible. Coincidentally, 16-bit floating point textures became part of |
| 709 | // the standard in ES3.1 / OGL 3.1, hence the shorthand |
| 710 | bool hasHalfFPTextures = version >= GR_GL_VER(3, 1); |
| 711 | if (!hasHalfFPTextures) { |
| 712 | hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || |
jvanverth | 1334c21 | 2014-12-18 05:44:55 -0800 | [diff] [blame] | 713 | (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") && |
| 714 | ctxInfo.hasExtension("GL_OES_texture_half_float")); |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 715 | } |
jvanverth | 1334c21 | 2014-12-18 05:44:55 -0800 | [diff] [blame] | 716 | fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 717 | } |
| 718 | |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 719 | bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf, |
| 720 | GrGLenum format, |
| 721 | GrGLenum type) const { |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 722 | if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { |
| 723 | // ES 2 guarantees this format is supported |
robertphillips@google.com | eca2dfb | 2012-06-27 20:13:49 +0000 | [diff] [blame] | 724 | return true; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 725 | } |
| 726 | |
| 727 | if (!fTwoFormatLimit) { |
| 728 | // not limited by ES 2's constraints |
| 729 | return true; |
| 730 | } |
| 731 | |
bsalomon@google.com | 548a433 | 2012-07-11 19:45:22 +0000 | [diff] [blame] | 732 | GrGLint otherFormat = GR_GL_RGBA; |
| 733 | GrGLint otherType = GR_GL_UNSIGNED_BYTE; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 734 | |
| 735 | // The other supported format/type combo supported for ReadPixels |
| 736 | // can change based on which render target is bound |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 737 | GR_GL_GetIntegerv(intf, |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 738 | GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, |
| 739 | &otherFormat); |
| 740 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 741 | GR_GL_GetIntegerv(intf, |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 742 | GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, |
| 743 | &otherType); |
| 744 | |
bsalomon@google.com | 548a433 | 2012-07-11 19:45:22 +0000 | [diff] [blame] | 745 | return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 746 | } |
| 747 | |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 748 | bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
| 749 | GrGLenum format, |
| 750 | GrGLenum type, |
| 751 | GrGLenum currFboFormat) const { |
| 752 | |
| 753 | ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat}; |
| 754 | |
| 755 | ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key); |
| 756 | |
| 757 | if (NULL == cachedValue) { |
| 758 | bool value = doReadPixelsSupported(intf, format, type); |
| 759 | ReadPixelsSupportedFormats newValue(key, value); |
| 760 | fReadPixelsSupportedCache.add(newValue); |
| 761 | |
| 762 | return newValue.value(); |
| 763 | } |
| 764 | |
| 765 | return cachedValue->value(); |
| 766 | } |
| 767 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 768 | void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 769 | |
| 770 | fMSFBOType = kNone_MSFBOType; |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 771 | if (kGL_GrGLStandard != ctxInfo.standard()) { |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 772 | // We prefer the EXT/IMG extension over ES3 MSAA because we've observed |
| 773 | // ES3 driver bugs on at least one device with a tiled GPU (N10). |
| 774 | if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { |
| 775 | fMSFBOType = kES_EXT_MsToTexture_MSFBOType; |
| 776 | } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) { |
| 777 | fMSFBOType = kES_IMG_MsToTexture_MSFBOType; |
commit-bot@chromium.org | 92b7884 | 2014-01-16 20:49:46 +0000 | [diff] [blame] | 778 | } else if (ctxInfo.version() >= GR_GL_VER(3,0)) { |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 779 | fMSFBOType = GrGLCaps::kES_3_0_MSFBOType; |
| 780 | } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { |
| 781 | // chrome's extension is equivalent to the EXT msaa |
| 782 | // and fbo_blit extensions. |
| 783 | fMSFBOType = kDesktop_EXT_MSFBOType; |
| 784 | } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) { |
| 785 | fMSFBOType = kES_Apple_MSFBOType; |
| 786 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 787 | } else { |
| 788 | if ((ctxInfo.version() >= GR_GL_VER(3,0)) || |
| 789 | ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 790 | fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 791 | } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") && |
| 792 | ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 793 | fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 794 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 795 | } |
| 796 | } |
| 797 | |
| 798 | namespace { |
| 799 | const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; |
| 800 | } |
| 801 | |
| 802 | void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) { |
| 803 | |
| 804 | // Build up list of legal stencil formats (though perhaps not supported on |
| 805 | // the particular gpu/driver) from most preferred to least. |
| 806 | |
| 807 | // these consts are in order of most preferred to least preferred |
| 808 | // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8 |
| 809 | |
| 810 | static const StencilFormat |
| 811 | // internal Format stencil bits total bits packed? |
| 812 | gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false}, |
| 813 | gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false}, |
| 814 | gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true }, |
| 815 | gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false}, |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 816 | // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false}, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 817 | gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true }; |
| 818 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 819 | if (kGL_GrGLStandard == ctxInfo.standard()) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 820 | bool supportsPackedDS = |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 821 | ctxInfo.version() >= GR_GL_VER(3,0) || |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 822 | ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") || |
| 823 | ctxInfo.hasExtension("GL_ARB_framebuffer_object"); |
| 824 | |
| 825 | // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we |
| 826 | // require FBO support we can expect these are legal formats and don't |
| 827 | // check. These also all support the unsized GL_STENCIL_INDEX. |
| 828 | fStencilFormats.push_back() = gS8; |
| 829 | fStencilFormats.push_back() = gS16; |
| 830 | if (supportsPackedDS) { |
| 831 | fStencilFormats.push_back() = gD24S8; |
| 832 | } |
| 833 | fStencilFormats.push_back() = gS4; |
| 834 | if (supportsPackedDS) { |
| 835 | fStencilFormats.push_back() = gDS; |
| 836 | } |
| 837 | } else { |
| 838 | // ES2 has STENCIL_INDEX8 without extensions but requires extensions |
| 839 | // for other formats. |
| 840 | // ES doesn't support using the unsized format. |
| 841 | |
| 842 | fStencilFormats.push_back() = gS8; |
| 843 | //fStencilFormats.push_back() = gS16; |
commit-bot@chromium.org | 04c500f | 2013-09-06 15:28:01 +0000 | [diff] [blame] | 844 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 845 | ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 846 | fStencilFormats.push_back() = gD24S8; |
| 847 | } |
| 848 | if (ctxInfo.hasExtension("GL_OES_stencil4")) { |
| 849 | fStencilFormats.push_back() = gS4; |
| 850 | } |
| 851 | } |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 852 | SkASSERT(0 == fStencilVerifiedColorConfigs.count()); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 853 | fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); |
| 854 | } |
| 855 | |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 856 | static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 857 | switch (p) { |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 858 | case kLow_GrSLPrecision: |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 859 | return GR_GL_LOW_FLOAT; |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 860 | case kMedium_GrSLPrecision: |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 861 | return GR_GL_MEDIUM_FLOAT; |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 862 | case kHigh_GrSLPrecision: |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 863 | return GR_GL_HIGH_FLOAT; |
| 864 | } |
| 865 | SkFAIL("Unknown precision."); |
| 866 | return -1; |
| 867 | } |
| 868 | |
| 869 | static GrGLenum shader_type_to_gl_shader(GrShaderType type) { |
| 870 | switch (type) { |
| 871 | case kVertex_GrShaderType: |
| 872 | return GR_GL_VERTEX_SHADER; |
| 873 | case kGeometry_GrShaderType: |
| 874 | return GR_GL_GEOMETRY_SHADER; |
| 875 | case kFragment_GrShaderType: |
| 876 | return GR_GL_FRAGMENT_SHADER; |
| 877 | } |
| 878 | SkFAIL("Unknown shader type."); |
| 879 | return -1; |
| 880 | } |
| 881 | |
| 882 | void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* intf) { |
| 883 | if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4,1) || |
| 884 | ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) { |
| 885 | for (int s = 0; s < kGrShaderTypeCount; ++s) { |
bsalomon | 06194c5 | 2014-12-09 11:16:12 -0800 | [diff] [blame] | 886 | if (kGeometry_GrShaderType != s) { |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 887 | GrShaderType shaderType = static_cast<GrShaderType>(s); |
| 888 | GrGLenum glShader = shader_type_to_gl_shader(shaderType); |
| 889 | PrecisionInfo* first = NULL; |
| 890 | fShaderPrecisionVaries = false; |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 891 | for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
| 892 | GrSLPrecision precision = static_cast<GrSLPrecision>(p); |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 893 | GrGLenum glPrecision = precision_to_gl_float_type(precision); |
| 894 | GrGLint range[2]; |
| 895 | GrGLint bits; |
| 896 | GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits); |
| 897 | if (bits) { |
| 898 | fFloatPrecisions[s][p].fLogRangeLow = range[0]; |
| 899 | fFloatPrecisions[s][p].fLogRangeHigh = range[1]; |
| 900 | fFloatPrecisions[s][p].fBits = bits; |
| 901 | if (!first) { |
| 902 | first = &fFloatPrecisions[s][p]; |
| 903 | } else if (!fShaderPrecisionVaries) { |
| 904 | fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]); |
| 905 | } |
| 906 | } |
| 907 | } |
| 908 | } |
| 909 | } |
| 910 | } else { |
| 911 | // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float. |
| 912 | fShaderPrecisionVaries = false; |
| 913 | for (int s = 0; s < kGrShaderTypeCount; ++s) { |
bsalomon | 06194c5 | 2014-12-09 11:16:12 -0800 | [diff] [blame] | 914 | if (kGeometry_GrShaderType != s) { |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 915 | for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 916 | fFloatPrecisions[s][p].fLogRangeLow = 127; |
| 917 | fFloatPrecisions[s][p].fLogRangeHigh = 127; |
| 918 | fFloatPrecisions[s][p].fBits = 23; |
| 919 | } |
| 920 | } |
| 921 | } |
| 922 | } |
bsalomon | 06194c5 | 2014-12-09 11:16:12 -0800 | [diff] [blame] | 923 | // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Assume they're |
| 924 | // the same as the vertex shader. Only fragment shaders were ever allowed to omit support for |
| 925 | // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that |
| 926 | // are recommended against. |
| 927 | if (fGeometryShaderSupport) { |
| 928 | for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
| 929 | fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p]; |
| 930 | } |
| 931 | } |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 935 | void GrGLCaps::markColorConfigAndStencilFormatAsVerified( |
| 936 | GrPixelConfig config, |
| 937 | const GrGLStencilBuffer::Format& format) { |
| 938 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 939 | return; |
| 940 | #endif |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 941 | SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
| 942 | SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count()); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 943 | int count = fStencilFormats.count(); |
| 944 | // we expect a really small number of possible formats so linear search |
| 945 | // should be OK |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 946 | SkASSERT(count < 16); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 947 | for (int i = 0; i < count; ++i) { |
| 948 | if (format.fInternalFormat == |
| 949 | fStencilFormats[i].fInternalFormat) { |
| 950 | fStencilVerifiedColorConfigs[i].markVerified(config); |
| 951 | return; |
| 952 | } |
| 953 | } |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 954 | SkFAIL("Why are we seeing a stencil format that " |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 955 | "GrGLCaps doesn't know about."); |
| 956 | } |
| 957 | |
| 958 | bool GrGLCaps::isColorConfigAndStencilFormatVerified( |
| 959 | GrPixelConfig config, |
| 960 | const GrGLStencilBuffer::Format& format) const { |
| 961 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 962 | return false; |
| 963 | #endif |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 964 | SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 965 | int count = fStencilFormats.count(); |
| 966 | // we expect a really small number of possible formats so linear search |
| 967 | // should be OK |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 968 | SkASSERT(count < 16); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 969 | for (int i = 0; i < count; ++i) { |
| 970 | if (format.fInternalFormat == |
| 971 | fStencilFormats[i].fInternalFormat) { |
| 972 | return fStencilVerifiedColorConfigs[i].isVerified(config); |
| 973 | } |
| 974 | } |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 975 | SkFAIL("Why are we seeing a stencil format that " |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 976 | "GLCaps doesn't know about."); |
| 977 | return false; |
| 978 | } |
| 979 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 980 | SkString GrGLCaps::dump() const { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 981 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 982 | SkString r = INHERITED::dump(); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 983 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 984 | r.appendf("--- GL-Specific ---\n"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 985 | for (int i = 0; i < fStencilFormats.count(); ++i) { |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 986 | r.appendf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 987 | i, |
| 988 | fStencilFormats[i].fStencilBits, |
| 989 | fStencilFormats[i].fTotalBits); |
| 990 | } |
| 991 | |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 992 | static const char* kMSFBOExtStr[] = { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 993 | "None", |
| 994 | "ARB", |
| 995 | "EXT", |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 996 | "ES 3.0", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 997 | "Apple", |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 998 | "IMG MS To Texture", |
| 999 | "EXT MS To Texture", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 1000 | }; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 1001 | GR_STATIC_ASSERT(0 == kNone_MSFBOType); |
| 1002 | GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType); |
| 1003 | GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType); |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 1004 | GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType); |
| 1005 | GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType); |
| 1006 | GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType); |
| 1007 | GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType); |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 1008 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1); |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 1009 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 1010 | static const char* kInvalidateFBTypeStr[] = { |
| 1011 | "None", |
| 1012 | "Discard", |
| 1013 | "Invalidate", |
| 1014 | }; |
| 1015 | GR_STATIC_ASSERT(0 == kNone_InvalidateFBType); |
| 1016 | GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType); |
| 1017 | GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType); |
| 1018 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1); |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 1019 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 1020 | static const char* kMapBufferTypeStr[] = { |
| 1021 | "None", |
| 1022 | "MapBuffer", |
| 1023 | "MapBufferRange", |
| 1024 | "Chromium", |
| 1025 | }; |
| 1026 | GR_STATIC_ASSERT(0 == kNone_MapBufferType); |
| 1027 | GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType); |
| 1028 | GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType); |
| 1029 | GR_STATIC_ASSERT(3 == kChromium_MapBufferType); |
| 1030 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1); |
| 1031 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1032 | r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1033 | r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 1034 | r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO")); |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 1035 | r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]); |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 1036 | r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1037 | r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
| 1038 | r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 1039 | if (!fIsCoreProfile) { |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1040 | r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords); |
commit-bot@chromium.org | 3628ad9 | 2013-08-30 19:43:47 +0000 | [diff] [blame] | 1041 | } |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1042 | r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
| 1043 | r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1044 | r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO")); |
| 1045 | r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO")); |
| 1046 | r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO")); |
| 1047 | r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")); |
| 1048 | r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO")); |
| 1049 | r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 1050 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1051 | r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")); |
| 1052 | r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO")); |
| 1053 | r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
| 1054 | r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
| 1055 | r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
| 1056 | r.appendf("Fragment coord conventions support: %s\n", |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 1057 | (fFragCoordsConventionSupport ? "YES": "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1058 | r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); |
| 1059 | r.appendf("Use non-VBO for dynamic data: %s\n", |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 1060 | (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1061 | r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO")); |
commit-bot@chromium.org | 4362a38 | 2014-03-26 19:49:03 +0000 | [diff] [blame] | 1062 | r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1063 | return r; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 1064 | } |