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