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