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