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