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() || |
| 406 | kQualcomm_GrGLVendor == ctxInfo.vendor()) { |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 407 | fUseDrawInsteadOfClear = true; |
| 408 | } |
| 409 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 410 | this->initConfigTexturableTable(ctxInfo, gli); |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 411 | this->initConfigRenderableTable(ctxInfo); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 412 | |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 413 | this->initShaderPrecisionTable(ctxInfo, gli); |
| 414 | |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 415 | return true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 419 | // OpenGL < 3.0 |
| 420 | // no support for render targets unless the GL_ARB_framebuffer_object |
| 421 | // extension is supported (in which case we get ALPHA, RED, RG, RGB, |
| 422 | // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we |
| 423 | // probably don't get R8 in this case. |
| 424 | |
| 425 | // OpenGL 3.0 |
| 426 | // base color renderable: ALPHA, RED, RG, RGB, and RGBA |
| 427 | // sized derivatives: ALPHA8, R8, RGBA4, RGBA8 |
| 428 | |
| 429 | // >= OpenGL 3.1 |
| 430 | // base color renderable: RED, RG, RGB, and RGBA |
| 431 | // sized derivatives: R8, RGBA4, RGBA8 |
| 432 | // if the GL_ARB_compatibility extension is supported then we get back |
| 433 | // support for GL_ALPHA and ALPHA8 |
| 434 | |
| 435 | // GL_EXT_bgra adds BGRA render targets to any version |
| 436 | |
| 437 | // ES 2.0 |
| 438 | // color renderable: RGBA4, RGB5_A1, RGB565 |
| 439 | // GL_EXT_texture_rg adds support for R8 as a color render target |
| 440 | // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8 |
| 441 | // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support |
| 442 | |
| 443 | // ES 3.0 |
| 444 | // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called |
| 445 | // below already account for this). |
| 446 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 447 | GrGLStandard standard = ctxInfo.standard(); |
| 448 | |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 449 | enum { |
| 450 | kNo_MSAA = 0, |
| 451 | kYes_MSAA = 1, |
| 452 | }; |
| 453 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 454 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 455 | // Post 3.0 we will get R8 |
| 456 | // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object) |
| 457 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 458 | ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 459 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true; |
| 460 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 461 | } |
| 462 | } else { |
| 463 | // On ES we can only hope for R8 |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 464 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupport; |
| 465 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 466 | } |
| 467 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 468 | if (kGL_GrGLStandard != standard) { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 469 | // only available in ES |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 470 | fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true; |
| 471 | fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | // we no longer support 444 as a render target |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 475 | fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false; |
| 476 | fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 477 | |
| 478 | if (this->fRGBA8RenderbufferSupport) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 479 | fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true; |
commit-bot@chromium.org | da3d69c | 2013-10-28 15:09:13 +0000 | [diff] [blame] | 480 | fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 481 | } |
| 482 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 483 | if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 484 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true; |
| 485 | // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of |
| 486 | // 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] | 487 | // 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] | 488 | if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) { |
commit-bot@chromium.org | 4256d24 | 2013-10-17 16:29:41 +0000 | [diff] [blame] | 489 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true; |
| 490 | } else { |
| 491 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = |
| 492 | !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers(); |
| 493 | } |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 494 | } |
| 495 | |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 496 | if (this->fRGBA8RenderbufferSupport && this->isConfigTexturable(kSRGBA_8888_GrPixelConfig)) { |
| 497 | if (kGL_GrGLStandard == standard) { |
| 498 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 499 | ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || |
| 500 | ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { |
| 501 | fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true; |
| 502 | fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true; |
| 503 | } |
| 504 | } else { |
| 505 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 506 | ctxInfo.hasExtension("GL_EXT_sRGB")) { |
| 507 | fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true; |
| 508 | fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true; |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 513 | if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) { |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 514 | if (kGL_GrGLStandard == standard) { |
jvanverth | a60b2ea | 2014-12-12 05:58:06 -0800 | [diff] [blame] | 515 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true; |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 516 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true; |
| 517 | } else { |
jvanverth | a60b2ea | 2014-12-12 05:58:06 -0800 | [diff] [blame] | 518 | if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) { |
| 519 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true; |
| 520 | } else { |
| 521 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false; |
| 522 | } |
| 523 | // for now we don't support floating point MSAA on ES |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 524 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false; |
| 525 | } |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 526 | } |
| 527 | |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 528 | if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) { |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 529 | if (kGL_GrGLStandard == standard) { |
jvanverth | a60b2ea | 2014-12-12 05:58:06 -0800 | [diff] [blame] | 530 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true; |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 531 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true; |
jvanverth | 1334c21 | 2014-12-18 05:44:55 -0800 | [diff] [blame] | 532 | } else if (ctxInfo.version() >= GR_GL_VER(3,0)) { |
| 533 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true; |
| 534 | // for now we don't support floating point MSAA on ES |
| 535 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false; |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 536 | } else { |
jvanverth | 1334c21 | 2014-12-18 05:44:55 -0800 | [diff] [blame] | 537 | if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float") && fTextureRedSupport) { |
| 538 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true; |
| 539 | } else { |
| 540 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false; |
| 541 | } |
| 542 | // for now we don't support floating point MSAA on ES |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 543 | fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false; |
| 544 | } |
| 545 | } |
| 546 | |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 547 | // If we don't support MSAA then undo any places above where we set a config as renderable with |
| 548 | // msaa. |
| 549 | if (kNone_MSFBOType == fMSFBOType) { |
| 550 | for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 551 | fConfigRenderSupport[i][kYes_MSAA] = false; |
| 552 | } |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 553 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 554 | } |
| 555 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 556 | void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 557 | GrGLStandard standard = ctxInfo.standard(); |
| 558 | GrGLVersion version = ctxInfo.version(); |
| 559 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 560 | // Base texture support |
| 561 | fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true; |
| 562 | fConfigTextureSupport[kRGB_565_GrPixelConfig] = true; |
| 563 | fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true; |
| 564 | fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true; |
| 565 | |
| 566 | // Check for 8-bit palette.. |
| 567 | GrGLint numFormats; |
| 568 | GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats); |
| 569 | if (numFormats) { |
| 570 | SkAutoSTMalloc<10, GrGLint> formats(numFormats); |
| 571 | GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); |
| 572 | for (int i = 0; i < numFormats; ++i) { |
| 573 | if (GR_GL_PALETTE8_RGBA8 == formats[i]) { |
| 574 | fConfigTextureSupport[kIndex_8_GrPixelConfig] = true; |
| 575 | break; |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | // Check for BGRA |
| 581 | if (kGL_GrGLStandard == standard) { |
| 582 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = |
| 583 | version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra"); |
| 584 | } else { |
| 585 | if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { |
| 586 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true; |
| 587 | } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { |
| 588 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true; |
| 589 | fBGRAIsInternalFormat = true; |
| 590 | } |
| 591 | SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] || |
| 592 | kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig); |
| 593 | } |
| 594 | |
jvanverth | fa1e8a7 | 2014-12-22 08:31:49 -0800 | [diff] [blame] | 595 | // Check for sRGBA |
| 596 | if (kGL_GrGLStandard == standard) { |
| 597 | fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] = |
| 598 | (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_texture_sRGB")); |
| 599 | } else { |
| 600 | fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] = |
| 601 | (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_sRGB")); |
| 602 | } |
| 603 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 604 | // Compressed texture support |
| 605 | |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 606 | // glCompressedTexImage2D is available on all OpenGL ES devices... |
| 607 | // 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] | 608 | 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] | 609 | |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 610 | fCompressedTexSubImageSupport = |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 611 | hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D); |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 612 | |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 613 | // Check for ETC1 |
| 614 | bool hasETC1 = false; |
| 615 | |
| 616 | // First check version for support |
| 617 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 618 | hasETC1 = hasCompressTex2D && |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 619 | (version >= GR_GL_VER(4, 3) || |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 620 | ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 621 | } else { |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 622 | hasETC1 = hasCompressTex2D && |
| 623 | (version >= GR_GL_VER(3, 0) || |
| 624 | ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || |
| 625 | // ETC2 is a superset of ETC1, so we can just check for that, too. |
| 626 | (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && |
| 627 | ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 628 | } |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 629 | fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 630 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 631 | // Check for LATC under its various forms |
| 632 | LATCAlias alias = kLATC_LATCAlias; |
| 633 | bool hasLATC = hasCompressTex2D && |
| 634 | (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") || |
| 635 | ctxInfo.hasExtension("GL_NV_texture_compression_latc")); |
| 636 | |
| 637 | // Check for RGTC |
| 638 | if (!hasLATC) { |
| 639 | // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format. |
| 640 | if (kGL_GrGLStandard == standard) { |
| 641 | hasLATC = version >= GR_GL_VER(3, 0); |
| 642 | } |
| 643 | |
| 644 | if (!hasLATC) { |
| 645 | hasLATC = |
| 646 | ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") || |
| 647 | ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc"); |
| 648 | } |
| 649 | |
| 650 | if (hasLATC) { |
| 651 | alias = kRGTC_LATCAlias; |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | // Check for 3DC |
| 656 | if (!hasLATC) { |
| 657 | hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture"); |
| 658 | if (hasLATC) { |
| 659 | alias = k3DC_LATCAlias; |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC; |
| 664 | fLATCAlias = alias; |
krajcevski | 238b456 | 2014-06-30 09:09:22 -0700 | [diff] [blame] | 665 | |
krajcevski | b3abe90 | 2014-07-30 13:08:11 -0700 | [diff] [blame] | 666 | // Check for R11_EAC ... We don't support R11_EAC on desktop, as most |
| 667 | // cards default to decompressing the textures in the driver, and is |
| 668 | // generally slower. |
| 669 | if (kGL_GrGLStandard != standard) { |
krajcevski | 238b456 | 2014-06-30 09:09:22 -0700 | [diff] [blame] | 670 | fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0); |
| 671 | } |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 672 | |
krajcevski | 7ef2162 | 2014-07-16 15:21:13 -0700 | [diff] [blame] | 673 | // Check for ASTC |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 674 | fConfigTextureSupport[kASTC_12x12_GrPixelConfig] = |
krajcevski | 7ef2162 | 2014-07-16 15:21:13 -0700 | [diff] [blame] | 675 | ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || |
| 676 | ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || |
| 677 | ctxInfo.hasExtension("GL_OES_texture_compression_astc"); |
| 678 | |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 679 | // Check for floating point texture support |
| 680 | // NOTE: We disallow floating point textures on ES devices if linear |
| 681 | // filtering modes are not supported. This is for simplicity, but a more |
| 682 | // granular approach is possible. Coincidentally, floating point textures became part of |
| 683 | // the standard in ES3.1 / OGL 3.1, hence the shorthand |
| 684 | bool hasFPTextures = version >= GR_GL_VER(3, 1); |
| 685 | if (!hasFPTextures) { |
| 686 | hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || |
jvanverth | a60b2ea | 2014-12-12 05:58:06 -0800 | [diff] [blame] | 687 | (ctxInfo.hasExtension("GL_OES_texture_float_linear") && |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 688 | ctxInfo.hasExtension("GL_OES_texture_float")); |
| 689 | } |
| 690 | fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures; |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 691 | |
| 692 | // Check for fp16 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, 16-bit floating point textures became part of |
| 696 | // the standard in ES3.1 / OGL 3.1, hence the shorthand |
| 697 | bool hasHalfFPTextures = version >= GR_GL_VER(3, 1); |
| 698 | if (!hasHalfFPTextures) { |
| 699 | hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || |
jvanverth | 1334c21 | 2014-12-18 05:44:55 -0800 | [diff] [blame] | 700 | (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") && |
| 701 | ctxInfo.hasExtension("GL_OES_texture_half_float")); |
jvanverth | 28f9c60 | 2014-12-05 13:06:35 -0800 | [diff] [blame] | 702 | } |
jvanverth | 1334c21 | 2014-12-18 05:44:55 -0800 | [diff] [blame] | 703 | fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 704 | } |
| 705 | |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 706 | bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf, |
| 707 | GrGLenum format, |
| 708 | GrGLenum type) const { |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 709 | if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { |
| 710 | // ES 2 guarantees this format is supported |
robertphillips@google.com | eca2dfb | 2012-06-27 20:13:49 +0000 | [diff] [blame] | 711 | return true; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | if (!fTwoFormatLimit) { |
| 715 | // not limited by ES 2's constraints |
| 716 | return true; |
| 717 | } |
| 718 | |
bsalomon@google.com | 548a433 | 2012-07-11 19:45:22 +0000 | [diff] [blame] | 719 | GrGLint otherFormat = GR_GL_RGBA; |
| 720 | GrGLint otherType = GR_GL_UNSIGNED_BYTE; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 721 | |
| 722 | // The other supported format/type combo supported for ReadPixels |
| 723 | // can change based on which render target is bound |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 724 | GR_GL_GetIntegerv(intf, |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 725 | GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, |
| 726 | &otherFormat); |
| 727 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 728 | GR_GL_GetIntegerv(intf, |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 729 | GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, |
| 730 | &otherType); |
| 731 | |
bsalomon@google.com | 548a433 | 2012-07-11 19:45:22 +0000 | [diff] [blame] | 732 | return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 733 | } |
| 734 | |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 735 | bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
| 736 | GrGLenum format, |
| 737 | GrGLenum type, |
| 738 | GrGLenum currFboFormat) const { |
| 739 | |
| 740 | ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat}; |
| 741 | |
| 742 | ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key); |
| 743 | |
| 744 | if (NULL == cachedValue) { |
| 745 | bool value = doReadPixelsSupported(intf, format, type); |
| 746 | ReadPixelsSupportedFormats newValue(key, value); |
| 747 | fReadPixelsSupportedCache.add(newValue); |
| 748 | |
| 749 | return newValue.value(); |
| 750 | } |
| 751 | |
| 752 | return cachedValue->value(); |
| 753 | } |
| 754 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 755 | void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 756 | |
| 757 | fMSFBOType = kNone_MSFBOType; |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 758 | if (kGL_GrGLStandard != ctxInfo.standard()) { |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 759 | // We prefer the EXT/IMG extension over ES3 MSAA because we've observed |
| 760 | // ES3 driver bugs on at least one device with a tiled GPU (N10). |
| 761 | if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { |
| 762 | fMSFBOType = kES_EXT_MsToTexture_MSFBOType; |
| 763 | } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) { |
| 764 | fMSFBOType = kES_IMG_MsToTexture_MSFBOType; |
commit-bot@chromium.org | 92b7884 | 2014-01-16 20:49:46 +0000 | [diff] [blame] | 765 | } else if (ctxInfo.version() >= GR_GL_VER(3,0)) { |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 766 | fMSFBOType = GrGLCaps::kES_3_0_MSFBOType; |
| 767 | } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { |
| 768 | // chrome's extension is equivalent to the EXT msaa |
| 769 | // and fbo_blit extensions. |
| 770 | fMSFBOType = kDesktop_EXT_MSFBOType; |
| 771 | } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) { |
| 772 | fMSFBOType = kES_Apple_MSFBOType; |
| 773 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 774 | } else { |
| 775 | if ((ctxInfo.version() >= GR_GL_VER(3,0)) || |
| 776 | ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 777 | fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 778 | } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") && |
| 779 | ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 780 | fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 781 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 782 | } |
| 783 | } |
| 784 | |
| 785 | namespace { |
| 786 | const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; |
| 787 | } |
| 788 | |
| 789 | void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) { |
| 790 | |
| 791 | // Build up list of legal stencil formats (though perhaps not supported on |
| 792 | // the particular gpu/driver) from most preferred to least. |
| 793 | |
| 794 | // these consts are in order of most preferred to least preferred |
| 795 | // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8 |
| 796 | |
| 797 | static const StencilFormat |
| 798 | // internal Format stencil bits total bits packed? |
| 799 | gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false}, |
| 800 | gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false}, |
| 801 | gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true }, |
| 802 | gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false}, |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 803 | // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false}, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 804 | gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true }; |
| 805 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 806 | if (kGL_GrGLStandard == ctxInfo.standard()) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 807 | bool supportsPackedDS = |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 808 | ctxInfo.version() >= GR_GL_VER(3,0) || |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 809 | ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") || |
| 810 | ctxInfo.hasExtension("GL_ARB_framebuffer_object"); |
| 811 | |
| 812 | // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we |
| 813 | // require FBO support we can expect these are legal formats and don't |
| 814 | // check. These also all support the unsized GL_STENCIL_INDEX. |
| 815 | fStencilFormats.push_back() = gS8; |
| 816 | fStencilFormats.push_back() = gS16; |
| 817 | if (supportsPackedDS) { |
| 818 | fStencilFormats.push_back() = gD24S8; |
| 819 | } |
| 820 | fStencilFormats.push_back() = gS4; |
| 821 | if (supportsPackedDS) { |
| 822 | fStencilFormats.push_back() = gDS; |
| 823 | } |
| 824 | } else { |
| 825 | // ES2 has STENCIL_INDEX8 without extensions but requires extensions |
| 826 | // for other formats. |
| 827 | // ES doesn't support using the unsized format. |
| 828 | |
| 829 | fStencilFormats.push_back() = gS8; |
| 830 | //fStencilFormats.push_back() = gS16; |
commit-bot@chromium.org | 04c500f | 2013-09-06 15:28:01 +0000 | [diff] [blame] | 831 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 832 | ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 833 | fStencilFormats.push_back() = gD24S8; |
| 834 | } |
| 835 | if (ctxInfo.hasExtension("GL_OES_stencil4")) { |
| 836 | fStencilFormats.push_back() = gS4; |
| 837 | } |
| 838 | } |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 839 | SkASSERT(0 == fStencilVerifiedColorConfigs.count()); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 840 | fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); |
| 841 | } |
| 842 | |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 843 | static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 844 | switch (p) { |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 845 | case kLow_GrSLPrecision: |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 846 | return GR_GL_LOW_FLOAT; |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 847 | case kMedium_GrSLPrecision: |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 848 | return GR_GL_MEDIUM_FLOAT; |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 849 | case kHigh_GrSLPrecision: |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 850 | return GR_GL_HIGH_FLOAT; |
| 851 | } |
| 852 | SkFAIL("Unknown precision."); |
| 853 | return -1; |
| 854 | } |
| 855 | |
| 856 | static GrGLenum shader_type_to_gl_shader(GrShaderType type) { |
| 857 | switch (type) { |
| 858 | case kVertex_GrShaderType: |
| 859 | return GR_GL_VERTEX_SHADER; |
| 860 | case kGeometry_GrShaderType: |
| 861 | return GR_GL_GEOMETRY_SHADER; |
| 862 | case kFragment_GrShaderType: |
| 863 | return GR_GL_FRAGMENT_SHADER; |
| 864 | } |
| 865 | SkFAIL("Unknown shader type."); |
| 866 | return -1; |
| 867 | } |
| 868 | |
| 869 | void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* intf) { |
| 870 | if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(4,1) || |
| 871 | ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) { |
| 872 | for (int s = 0; s < kGrShaderTypeCount; ++s) { |
bsalomon | 06194c5 | 2014-12-09 11:16:12 -0800 | [diff] [blame] | 873 | if (kGeometry_GrShaderType != s) { |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 874 | GrShaderType shaderType = static_cast<GrShaderType>(s); |
| 875 | GrGLenum glShader = shader_type_to_gl_shader(shaderType); |
| 876 | PrecisionInfo* first = NULL; |
| 877 | fShaderPrecisionVaries = false; |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 878 | for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
| 879 | GrSLPrecision precision = static_cast<GrSLPrecision>(p); |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 880 | GrGLenum glPrecision = precision_to_gl_float_type(precision); |
| 881 | GrGLint range[2]; |
| 882 | GrGLint bits; |
| 883 | GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits); |
| 884 | if (bits) { |
| 885 | fFloatPrecisions[s][p].fLogRangeLow = range[0]; |
| 886 | fFloatPrecisions[s][p].fLogRangeHigh = range[1]; |
| 887 | fFloatPrecisions[s][p].fBits = bits; |
| 888 | if (!first) { |
| 889 | first = &fFloatPrecisions[s][p]; |
| 890 | } else if (!fShaderPrecisionVaries) { |
| 891 | fShaderPrecisionVaries = (*first != fFloatPrecisions[s][p]); |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | } |
| 896 | } |
| 897 | } else { |
| 898 | // We're on a desktop GL that doesn't have precision info. Assume they're all 32bit float. |
| 899 | fShaderPrecisionVaries = false; |
| 900 | for (int s = 0; s < kGrShaderTypeCount; ++s) { |
bsalomon | 06194c5 | 2014-12-09 11:16:12 -0800 | [diff] [blame] | 901 | if (kGeometry_GrShaderType != s) { |
bsalomon | c0bd648 | 2014-12-09 10:04:14 -0800 | [diff] [blame] | 902 | for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 903 | fFloatPrecisions[s][p].fLogRangeLow = 127; |
| 904 | fFloatPrecisions[s][p].fLogRangeHigh = 127; |
| 905 | fFloatPrecisions[s][p].fBits = 23; |
| 906 | } |
| 907 | } |
| 908 | } |
| 909 | } |
bsalomon | 06194c5 | 2014-12-09 11:16:12 -0800 | [diff] [blame] | 910 | // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader type. Assume they're |
| 911 | // the same as the vertex shader. Only fragment shaders were ever allowed to omit support for |
| 912 | // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that |
| 913 | // are recommended against. |
| 914 | if (fGeometryShaderSupport) { |
| 915 | for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
| 916 | fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVertex_GrShaderType][p]; |
| 917 | } |
| 918 | } |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 922 | void GrGLCaps::markColorConfigAndStencilFormatAsVerified( |
| 923 | GrPixelConfig config, |
| 924 | const GrGLStencilBuffer::Format& format) { |
| 925 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 926 | return; |
| 927 | #endif |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 928 | SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
| 929 | SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count()); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 930 | int count = fStencilFormats.count(); |
| 931 | // we expect a really small number of possible formats so linear search |
| 932 | // should be OK |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 933 | SkASSERT(count < 16); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 934 | for (int i = 0; i < count; ++i) { |
| 935 | if (format.fInternalFormat == |
| 936 | fStencilFormats[i].fInternalFormat) { |
| 937 | fStencilVerifiedColorConfigs[i].markVerified(config); |
| 938 | return; |
| 939 | } |
| 940 | } |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 941 | SkFAIL("Why are we seeing a stencil format that " |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 942 | "GrGLCaps doesn't know about."); |
| 943 | } |
| 944 | |
| 945 | bool GrGLCaps::isColorConfigAndStencilFormatVerified( |
| 946 | GrPixelConfig config, |
| 947 | const GrGLStencilBuffer::Format& format) const { |
| 948 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 949 | return false; |
| 950 | #endif |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 951 | SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 952 | int count = fStencilFormats.count(); |
| 953 | // we expect a really small number of possible formats so linear search |
| 954 | // should be OK |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 955 | SkASSERT(count < 16); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 956 | for (int i = 0; i < count; ++i) { |
| 957 | if (format.fInternalFormat == |
| 958 | fStencilFormats[i].fInternalFormat) { |
| 959 | return fStencilVerifiedColorConfigs[i].isVerified(config); |
| 960 | } |
| 961 | } |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 962 | SkFAIL("Why are we seeing a stencil format that " |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 963 | "GLCaps doesn't know about."); |
| 964 | return false; |
| 965 | } |
| 966 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 967 | SkString GrGLCaps::dump() const { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 968 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 969 | SkString r = INHERITED::dump(); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 970 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 971 | r.appendf("--- GL-Specific ---\n"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 972 | for (int i = 0; i < fStencilFormats.count(); ++i) { |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 973 | 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] | 974 | i, |
| 975 | fStencilFormats[i].fStencilBits, |
| 976 | fStencilFormats[i].fTotalBits); |
| 977 | } |
| 978 | |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 979 | static const char* kMSFBOExtStr[] = { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 980 | "None", |
| 981 | "ARB", |
| 982 | "EXT", |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 983 | "ES 3.0", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 984 | "Apple", |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 985 | "IMG MS To Texture", |
| 986 | "EXT MS To Texture", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 987 | }; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 988 | GR_STATIC_ASSERT(0 == kNone_MSFBOType); |
| 989 | GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType); |
| 990 | GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType); |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 991 | GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType); |
| 992 | GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType); |
| 993 | GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType); |
| 994 | GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType); |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 995 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1); |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 996 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 997 | static const char* kInvalidateFBTypeStr[] = { |
| 998 | "None", |
| 999 | "Discard", |
| 1000 | "Invalidate", |
| 1001 | }; |
| 1002 | GR_STATIC_ASSERT(0 == kNone_InvalidateFBType); |
| 1003 | GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType); |
| 1004 | GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType); |
| 1005 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1); |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 1006 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 1007 | static const char* kMapBufferTypeStr[] = { |
| 1008 | "None", |
| 1009 | "MapBuffer", |
| 1010 | "MapBufferRange", |
| 1011 | "Chromium", |
| 1012 | }; |
| 1013 | GR_STATIC_ASSERT(0 == kNone_MapBufferType); |
| 1014 | GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType); |
| 1015 | GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType); |
| 1016 | GR_STATIC_ASSERT(3 == kChromium_MapBufferType); |
| 1017 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1); |
| 1018 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1019 | r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1020 | r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 1021 | r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO")); |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 1022 | r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]); |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 1023 | r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1024 | r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
| 1025 | r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 1026 | if (!fIsCoreProfile) { |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1027 | r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords); |
commit-bot@chromium.org | 3628ad9 | 2013-08-30 19:43:47 +0000 | [diff] [blame] | 1028 | } |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1029 | r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
| 1030 | 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] | 1031 | r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO")); |
| 1032 | r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO")); |
| 1033 | r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO")); |
| 1034 | r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")); |
| 1035 | r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO")); |
| 1036 | r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 1037 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1038 | r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")); |
| 1039 | r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO")); |
| 1040 | r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
| 1041 | r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
| 1042 | r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
| 1043 | r.appendf("Fragment coord conventions support: %s\n", |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 1044 | (fFragCoordsConventionSupport ? "YES": "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1045 | r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); |
| 1046 | r.appendf("Use non-VBO for dynamic data: %s\n", |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 1047 | (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 1048 | 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] | 1049 | 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] | 1050 | return r; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 1051 | } |