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" |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 10 | #include "GrGLContext.h" |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 11 | #include "SkTSearch.h" |
bsalomon@google.com | 20f7f17 | 2013-05-17 19:05:03 +0000 | [diff] [blame] | 12 | #include "SkTSort.h" |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 13 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 14 | SK_DEFINE_INST_COUNT(GrGLCaps) |
| 15 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 16 | GrGLCaps::GrGLCaps() { |
| 17 | this->reset(); |
| 18 | } |
| 19 | |
| 20 | void GrGLCaps::reset() { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 21 | INHERITED::reset(); |
| 22 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 23 | fVerifiedColorConfigs.reset(); |
| 24 | fStencilFormats.reset(); |
| 25 | fStencilVerifiedColorConfigs.reset(); |
| 26 | fMSFBOType = kNone_MSFBOType; |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 27 | fCoverageAAType = kNone_CoverageAAType; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 28 | fFBFetchType = kNone_FBFetchType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 29 | fMaxFragmentUniformVectors = 0; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 30 | fMaxVertexAttributes = 0; |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 31 | fMaxFragmentTextureUnits = 0; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame^] | 32 | fMaxFixedFunctionTextureCoords = 0; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 33 | fRGBA8RenderbufferSupport = false; |
| 34 | fBGRAFormatSupport = false; |
| 35 | fBGRAIsInternalFormat = false; |
| 36 | fTextureSwizzleSupport = false; |
| 37 | fUnpackRowLengthSupport = false; |
| 38 | fUnpackFlipYSupport = false; |
| 39 | fPackRowLengthSupport = false; |
| 40 | fPackFlipYSupport = false; |
| 41 | fTextureUsageSupport = false; |
| 42 | fTexStorageSupport = false; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 43 | fTextureRedSupport = false; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 44 | fImagingSupport = false; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 45 | fTwoFormatLimit = false; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 46 | fFragCoordsConventionSupport = false; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 47 | fVertexArrayObjectSupport = false; |
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 | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 50 | fDiscardFBSupport = false; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 51 | } |
| 52 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 53 | GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 54 | *this = caps; |
| 55 | } |
| 56 | |
| 57 | GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 58 | INHERITED::operator=(caps); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 59 | fVerifiedColorConfigs = caps.fVerifiedColorConfigs; |
| 60 | fStencilFormats = caps.fStencilFormats; |
| 61 | fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; |
| 62 | fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 63 | fMaxVertexAttributes = caps.fMaxVertexAttributes; |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 64 | fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame^] | 65 | fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 66 | fMSFBOType = caps.fMSFBOType; |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 67 | fCoverageAAType = caps.fCoverageAAType; |
| 68 | fMSAACoverageModes = caps.fMSAACoverageModes; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 69 | fFBFetchType = caps.fFBFetchType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 70 | fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; |
| 71 | fBGRAFormatSupport = caps.fBGRAFormatSupport; |
| 72 | fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat; |
| 73 | fTextureSwizzleSupport = caps.fTextureSwizzleSupport; |
| 74 | fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport; |
| 75 | fUnpackFlipYSupport = caps.fUnpackFlipYSupport; |
| 76 | fPackRowLengthSupport = caps.fPackRowLengthSupport; |
| 77 | fPackFlipYSupport = caps.fPackFlipYSupport; |
| 78 | fTextureUsageSupport = caps.fTextureUsageSupport; |
| 79 | fTexStorageSupport = caps.fTexStorageSupport; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 80 | fTextureRedSupport = caps.fTextureRedSupport; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 81 | fImagingSupport = caps.fImagingSupport; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 82 | fTwoFormatLimit = caps.fTwoFormatLimit; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 83 | fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 84 | fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 85 | fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData; |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 86 | fIsCoreProfile = caps.fIsCoreProfile; |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 87 | fDiscardFBSupport = caps.fDiscardFBSupport; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 88 | |
| 89 | return *this; |
| 90 | } |
| 91 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 92 | void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 93 | |
| 94 | this->reset(); |
| 95 | if (!ctxInfo.isInitialized()) { |
| 96 | return; |
| 97 | } |
| 98 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 99 | GrGLBinding binding = ctxInfo.binding(); |
| 100 | GrGLVersion version = ctxInfo.version(); |
| 101 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 102 | /************************************************************************** |
| 103 | * Caps specific to GrGLCaps |
| 104 | **************************************************************************/ |
| 105 | |
bsalomon@google.com | 791816a | 2013-08-15 18:54:39 +0000 | [diff] [blame] | 106 | if (kES_GrGLBinding == binding) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 107 | GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, |
| 108 | &fMaxFragmentUniformVectors); |
| 109 | } else { |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 110 | SkASSERT(kDesktop_GrGLBinding == binding); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 111 | GrGLint max; |
| 112 | GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); |
| 113 | fMaxFragmentUniformVectors = max / 4; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame^] | 114 | if (version >= GR_GL_VER(3, 2)) { |
| 115 | GrGLint profileMask; |
| 116 | GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); |
| 117 | fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); |
| 118 | } |
| 119 | if (!fIsCoreProfile) { |
| 120 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_COORDS, &fMaxFixedFunctionTextureCoords); |
| 121 | // Sanity check |
| 122 | SkASSERT(fMaxFixedFunctionTextureCoords > 0 && fMaxFixedFunctionTextureCoords < 128); |
| 123 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 124 | } |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 125 | GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 126 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 127 | |
| 128 | if (kDesktop_GrGLBinding == binding) { |
| 129 | fRGBA8RenderbufferSupport = true; |
| 130 | } else { |
commit-bot@chromium.org | c5dffe4 | 2013-08-20 15:25:21 +0000 | [diff] [blame] | 131 | fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) || |
| 132 | ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 133 | ctxInfo.hasExtension("GL_ARM_rgba8"); |
| 134 | } |
| 135 | |
| 136 | if (kDesktop_GrGLBinding == binding) { |
| 137 | fBGRAFormatSupport = version >= GR_GL_VER(1,2) || |
| 138 | ctxInfo.hasExtension("GL_EXT_bgra"); |
| 139 | } else { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 140 | if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { |
| 141 | fBGRAFormatSupport = true; |
| 142 | } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { |
| 143 | fBGRAFormatSupport = true; |
| 144 | fBGRAIsInternalFormat = true; |
| 145 | } |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 146 | SkASSERT(fBGRAFormatSupport || |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 147 | kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | if (kDesktop_GrGLBinding == binding) { |
| 151 | fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || |
| 152 | ctxInfo.hasExtension("GL_ARB_texture_swizzle"); |
| 153 | } else { |
commit-bot@chromium.org | 6364b5e | 2013-08-20 20:22:52 +0000 | [diff] [blame] | 154 | fTextureSwizzleSupport = version >= GR_GL_VER(3,0); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | if (kDesktop_GrGLBinding == binding) { |
| 158 | fUnpackRowLengthSupport = true; |
| 159 | fUnpackFlipYSupport = false; |
| 160 | fPackRowLengthSupport = true; |
| 161 | fPackFlipYSupport = false; |
| 162 | } else { |
commit-bot@chromium.org | dc3134c | 2013-08-16 16:12:23 +0000 | [diff] [blame] | 163 | fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || |
| 164 | ctxInfo.hasExtension("GL_EXT_unpack_subimage"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 165 | fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); |
commit-bot@chromium.org | dc3134c | 2013-08-16 16:12:23 +0000 | [diff] [blame] | 166 | fPackRowLengthSupport = version >= GR_GL_VER(3,0) || |
| 167 | ctxInfo.hasExtension("GL_NV_pack_subimage"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 168 | fPackFlipYSupport = |
| 169 | ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order"); |
| 170 | } |
| 171 | |
bsalomon@google.com | 791816a | 2013-08-15 18:54:39 +0000 | [diff] [blame] | 172 | fTextureUsageSupport = (kES_GrGLBinding == binding) && |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 173 | ctxInfo.hasExtension("GL_ANGLE_texture_usage"); |
| 174 | |
commit-bot@chromium.org | 7a434a2 | 2013-08-21 14:01:56 +0000 | [diff] [blame] | 175 | if (kDesktop_GrGLBinding == binding) { |
| 176 | // The EXT version can apply to either GL or GLES. |
| 177 | fTexStorageSupport = version >= GR_GL_VER(4,2) || |
| 178 | ctxInfo.hasExtension("GL_ARB_texture_storage") || |
| 179 | ctxInfo.hasExtension("GL_EXT_texture_storage"); |
| 180 | } else { |
| 181 | // Qualcomm Adreno drivers appear to have issues with texture storage. |
| 182 | fTexStorageSupport = (version >= GR_GL_VER(3,0) && |
| 183 | kQualcomm_GrGLVendor != ctxInfo.vendor()) || |
| 184 | ctxInfo.hasExtension("GL_EXT_texture_storage"); |
| 185 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 186 | |
commit-bot@chromium.org | 459104c | 2013-06-14 14:42:56 +0000 | [diff] [blame] | 187 | // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support it if |
| 188 | // it doesn't have ARB_texture_rg extension. |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 189 | if (kDesktop_GrGLBinding == binding) { |
commit-bot@chromium.org | 459104c | 2013-06-14 14:42:56 +0000 | [diff] [blame] | 190 | if (ctxInfo.isMesa()) { |
| 191 | fTextureRedSupport = ctxInfo.hasExtension("GL_ARB_texture_rg"); |
| 192 | } else { |
| 193 | fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 194 | ctxInfo.hasExtension("GL_ARB_texture_rg"); |
| 195 | } |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 196 | } else { |
commit-bot@chromium.org | c5dffe4 | 2013-08-20 15:25:21 +0000 | [diff] [blame] | 197 | fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 198 | ctxInfo.hasExtension("GL_EXT_texture_rg"); |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 199 | } |
| 200 | |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 201 | fImagingSupport = kDesktop_GrGLBinding == binding && |
| 202 | ctxInfo.hasExtension("GL_ARB_imaging"); |
| 203 | |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 204 | // ES 2 only guarantees RGBA/uchar + one other format/type combo for |
| 205 | // ReadPixels. The other format has to checked at run-time since it |
| 206 | // can change based on which render target is bound |
bsalomon@google.com | 791816a | 2013-08-15 18:54:39 +0000 | [diff] [blame] | 207 | fTwoFormatLimit = kES_GrGLBinding == binding; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 208 | |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 209 | // Known issue on at least some Intel platforms: |
| 210 | // http://code.google.com/p/skia/issues/detail?id=946 |
| 211 | if (kIntel_GrGLVendor != ctxInfo.vendor()) { |
| 212 | fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration || |
| 213 | ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions"); |
| 214 | } |
| 215 | |
bsalomon@google.com | 3012ded | 2013-02-22 16:44:04 +0000 | [diff] [blame] | 216 | // SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with |
| 217 | // frequently changing VBOs. We've measured a performance increase using non-VBO vertex |
| 218 | // data for dynamic content on these GPUs. Perhaps we should read the renderer string and |
| 219 | // limit this decision to specific GPU families rather than basing it on the vendor alone. |
| 220 | if (!GR_GL_MUST_USE_VBO && |
| 221 | (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor())) { |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 222 | fUseNonVBOVertexAndIndexDynamicData = true; |
| 223 | } |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 224 | |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 225 | fDiscardFBSupport = ctxInfo.hasExtension("GL_EXT_discard_framebuffer"); |
| 226 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 227 | if (kDesktop_GrGLBinding == binding) { |
| 228 | fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
| 229 | ctxInfo.hasExtension("GL_ARB_vertex_array_object"); |
| 230 | } else { |
commit-bot@chromium.org | 2276c01 | 2013-08-16 15:53:33 +0000 | [diff] [blame] | 231 | fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
| 232 | ctxInfo.hasExtension("GL_OES_vertex_array_object"); |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 233 | } |
| 234 | |
bsalomon@google.com | 791816a | 2013-08-15 18:54:39 +0000 | [diff] [blame] | 235 | if (kES_GrGLBinding == binding) { |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 236 | if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) { |
| 237 | fFBFetchType = kEXT_FBFetchType; |
| 238 | } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) { |
| 239 | fFBFetchType = kNV_FBFetchType; |
| 240 | } |
| 241 | } |
| 242 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 243 | this->initFSAASupport(ctxInfo, gli); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 244 | this->initStencilFormats(ctxInfo); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 245 | |
| 246 | /************************************************************************** |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 247 | * GrDrawTargetCaps fields |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 248 | **************************************************************************/ |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 249 | GrGLint numFormats; |
| 250 | GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats); |
bungeman@google.com | 7103344 | 2013-05-01 14:21:20 +0000 | [diff] [blame] | 251 | if (numFormats) { |
| 252 | SkAutoSTMalloc<10, GrGLint> formats(numFormats); |
| 253 | GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); |
| 254 | for (int i = 0; i < numFormats; ++i) { |
| 255 | if (formats[i] == GR_GL_PALETTE8_RGBA8) { |
| 256 | f8BitPaletteSupport = true; |
| 257 | break; |
| 258 | } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | |
| 262 | if (kDesktop_GrGLBinding == binding) { |
| 263 | // we could also look for GL_ATI_separate_stencil extension or |
| 264 | // GL_EXT_stencil_two_side but they use different function signatures |
| 265 | // than GL2.0+ (and than each other). |
| 266 | fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0)); |
| 267 | // supported on GL 1.4 and higher or by extension |
| 268 | fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) || |
| 269 | ctxInfo.hasExtension("GL_EXT_stencil_wrap"); |
| 270 | } else { |
| 271 | // ES 2 has two sided stencil and stencil wrap |
| 272 | fTwoSidedStencilSupport = true; |
| 273 | fStencilWrapOpsSupport = true; |
| 274 | } |
| 275 | |
| 276 | if (kDesktop_GrGLBinding == binding) { |
| 277 | fBufferLockSupport = true; // we require VBO support and the desktop VBO extension includes |
| 278 | // glMapBuffer. |
| 279 | } else { |
| 280 | fBufferLockSupport = ctxInfo.hasExtension("GL_OES_mapbuffer"); |
| 281 | } |
| 282 | |
| 283 | if (kDesktop_GrGLBinding == binding) { |
| 284 | if (ctxInfo.version() >= GR_GL_VER(2,0) || |
| 285 | ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")) { |
| 286 | fNPOTTextureTileSupport = true; |
| 287 | } else { |
| 288 | fNPOTTextureTileSupport = false; |
| 289 | } |
| 290 | } else { |
| 291 | // 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] | 292 | // ES3 has no limitations. |
| 293 | fNPOTTextureTileSupport = ctxInfo.version() >= GR_GL_VER(3,0) || |
| 294 | ctxInfo.hasExtension("GL_OES_texture_npot"); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | fHWAALineSupport = (kDesktop_GrGLBinding == binding); |
| 298 | |
| 299 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_SIZE, &fMaxTextureSize); |
| 300 | GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize); |
| 301 | // Our render targets are always created with textures as the color |
| 302 | // attachment, hence this min: |
| 303 | fMaxRenderTargetSize = GrMin(fMaxTextureSize, fMaxRenderTargetSize); |
| 304 | |
| 305 | fPathStencilingSupport = GR_GL_USE_NV_PATH_RENDERING && |
| 306 | ctxInfo.hasExtension("GL_NV_path_rendering"); |
| 307 | |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 308 | fDstReadInShaderSupport = kNone_FBFetchType != fFBFetchType; |
| 309 | |
robertphillips@google.com | e4eaea2 | 2013-07-19 16:51:46 +0000 | [diff] [blame] | 310 | #if 0 |
| 311 | // This has to be temporarily disabled. On Android it causes the texture |
| 312 | // usage to become front loaded and the OS kills the process. It can |
| 313 | // be re-enabled once the more dynamic (ref-driven) cache clearing |
| 314 | // system is in place. |
commit-bot@chromium.org | b835652 | 2013-07-18 22:26:39 +0000 | [diff] [blame] | 315 | fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor(); |
robertphillips@google.com | e4eaea2 | 2013-07-19 16:51:46 +0000 | [diff] [blame] | 316 | #else |
| 317 | fReuseScratchTextures = true; |
| 318 | #endif |
commit-bot@chromium.org | b835652 | 2013-07-18 22:26:39 +0000 | [diff] [blame] | 319 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 320 | // Enable supported shader-related caps |
| 321 | if (kDesktop_GrGLBinding == binding) { |
| 322 | fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) || |
| 323 | ctxInfo.hasExtension("GL_ARB_blend_func_extended"); |
| 324 | fShaderDerivativeSupport = true; |
| 325 | // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS |
| 326 | fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3,2) && |
| 327 | ctxInfo.glslGeneration() >= k150_GrGLSLGeneration; |
| 328 | } else { |
| 329 | fShaderDerivativeSupport = ctxInfo.hasExtension("GL_OES_standard_derivatives"); |
| 330 | } |
| 331 | |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 332 | if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 333 | GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount); |
| 334 | } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) { |
| 335 | GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount); |
| 336 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 337 | } |
| 338 | |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 339 | bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 340 | GrGLenum format, |
| 341 | GrGLenum type) const { |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 342 | if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { |
| 343 | // ES 2 guarantees this format is supported |
robertphillips@google.com | eca2dfb | 2012-06-27 20:13:49 +0000 | [diff] [blame] | 344 | return true; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | if (!fTwoFormatLimit) { |
| 348 | // not limited by ES 2's constraints |
| 349 | return true; |
| 350 | } |
| 351 | |
bsalomon@google.com | 548a433 | 2012-07-11 19:45:22 +0000 | [diff] [blame] | 352 | GrGLint otherFormat = GR_GL_RGBA; |
| 353 | GrGLint otherType = GR_GL_UNSIGNED_BYTE; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 354 | |
| 355 | // The other supported format/type combo supported for ReadPixels |
| 356 | // can change based on which render target is bound |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 357 | GR_GL_GetIntegerv(intf, |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 358 | GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, |
| 359 | &otherFormat); |
| 360 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 361 | GR_GL_GetIntegerv(intf, |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 362 | GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, |
| 363 | &otherType); |
| 364 | |
bsalomon@google.com | 548a433 | 2012-07-11 19:45:22 +0000 | [diff] [blame] | 365 | return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 366 | } |
| 367 | |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 368 | namespace { |
bsalomon@google.com | 20f7f17 | 2013-05-17 19:05:03 +0000 | [diff] [blame] | 369 | bool cov_mode_less(const GrGLCaps::MSAACoverageMode& left, |
| 370 | const GrGLCaps::MSAACoverageMode& right) { |
| 371 | if (left.fCoverageSampleCnt < right.fCoverageSampleCnt) { |
| 372 | return true; |
| 373 | } else if (right.fCoverageSampleCnt < left.fCoverageSampleCnt) { |
| 374 | return false; |
| 375 | } else if (left.fColorSampleCnt < right.fColorSampleCnt) { |
| 376 | return true; |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 377 | } |
bsalomon@google.com | 20f7f17 | 2013-05-17 19:05:03 +0000 | [diff] [blame] | 378 | return false; |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 382 | void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 383 | |
| 384 | fMSFBOType = kNone_MSFBOType; |
| 385 | if (kDesktop_GrGLBinding != ctxInfo.binding()) { |
| 386 | if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { |
| 387 | // chrome's extension is equivalent to the EXT msaa |
| 388 | // and fbo_blit extensions. |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 389 | fMSFBOType = kDesktop_EXT_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 390 | } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 391 | fMSFBOType = kES_Apple_MSFBOType; |
| 392 | } else if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { |
| 393 | fMSFBOType = kES_EXT_MsToTexture_MSFBOType; |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 394 | } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 395 | fMSFBOType = kES_IMG_MsToTexture_MSFBOType; |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 396 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 397 | } else { |
| 398 | if ((ctxInfo.version() >= GR_GL_VER(3,0)) || |
| 399 | ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 400 | fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 401 | } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") && |
| 402 | ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 403 | fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 404 | } |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 405 | // TODO: We could populate fMSAACoverageModes using GetInternalformativ |
| 406 | // on GL 4.2+. It's format-specific, though. See also |
| 407 | // http://code.google.com/p/skia/issues/detail?id=470 about using actual |
| 408 | // rather than requested sample counts in cache key. |
| 409 | if (ctxInfo.hasExtension("GL_NV_framebuffer_multisample_coverage")) { |
| 410 | fCoverageAAType = kNVDesktop_CoverageAAType; |
| 411 | GrGLint count; |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 412 | GR_GL_GetIntegerv(gli, |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 413 | GR_GL_MAX_MULTISAMPLE_COVERAGE_MODES, |
| 414 | &count); |
| 415 | fMSAACoverageModes.setCount(count); |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 416 | GR_GL_GetIntegerv(gli, |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 417 | GR_GL_MULTISAMPLE_COVERAGE_MODES, |
| 418 | (int*)&fMSAACoverageModes[0]); |
| 419 | // The NV driver seems to return the modes already sorted but the |
| 420 | // spec doesn't require this. So we sort. |
bsalomon@google.com | 20f7f17 | 2013-05-17 19:05:03 +0000 | [diff] [blame] | 421 | typedef SkTLessFunctionToFunctorAdaptor<MSAACoverageMode, cov_mode_less> SortFunctor; |
| 422 | SortFunctor sortFunctor; |
| 423 | SkTQSort<MSAACoverageMode, SortFunctor>(fMSAACoverageModes.begin(), |
| 424 | fMSAACoverageModes.end() - 1, |
| 425 | sortFunctor); |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
bsalomon@google.com | 8a70eef | 2013-03-19 13:58:55 +0000 | [diff] [blame] | 430 | const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampleCount) const { |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 431 | static const MSAACoverageMode kNoneMode = {0, 0}; |
| 432 | if (0 == fMSAACoverageModes.count()) { |
| 433 | return kNoneMode; |
| 434 | } else { |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 435 | SkASSERT(kNone_CoverageAAType != fCoverageAAType); |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 436 | int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt; |
| 437 | desiredSampleCount = GrMin(desiredSampleCount, max); |
| 438 | MSAACoverageMode desiredMode = {desiredSampleCount, 0}; |
bsalomon@google.com | 20f7f17 | 2013-05-17 19:05:03 +0000 | [diff] [blame] | 439 | int idx = SkTSearch<const MSAACoverageMode, cov_mode_less>(&fMSAACoverageModes[0], |
| 440 | fMSAACoverageModes.count(), |
| 441 | desiredMode, |
| 442 | sizeof(MSAACoverageMode)); |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 443 | if (idx < 0) { |
| 444 | idx = ~idx; |
| 445 | } |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 446 | SkASSERT(idx >= 0 && idx < fMSAACoverageModes.count()); |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 447 | return fMSAACoverageModes[idx]; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 448 | } |
| 449 | } |
| 450 | |
| 451 | namespace { |
| 452 | const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; |
| 453 | } |
| 454 | |
| 455 | void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) { |
| 456 | |
| 457 | // Build up list of legal stencil formats (though perhaps not supported on |
| 458 | // the particular gpu/driver) from most preferred to least. |
| 459 | |
| 460 | // these consts are in order of most preferred to least preferred |
| 461 | // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8 |
| 462 | |
| 463 | static const StencilFormat |
| 464 | // internal Format stencil bits total bits packed? |
| 465 | gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false}, |
| 466 | gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false}, |
| 467 | gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true }, |
| 468 | gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false}, |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 469 | // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false}, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 470 | gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true }; |
| 471 | |
| 472 | if (kDesktop_GrGLBinding == ctxInfo.binding()) { |
| 473 | bool supportsPackedDS = |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 474 | ctxInfo.version() >= GR_GL_VER(3,0) || |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 475 | ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") || |
| 476 | ctxInfo.hasExtension("GL_ARB_framebuffer_object"); |
| 477 | |
| 478 | // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we |
| 479 | // require FBO support we can expect these are legal formats and don't |
| 480 | // check. These also all support the unsized GL_STENCIL_INDEX. |
| 481 | fStencilFormats.push_back() = gS8; |
| 482 | fStencilFormats.push_back() = gS16; |
| 483 | if (supportsPackedDS) { |
| 484 | fStencilFormats.push_back() = gD24S8; |
| 485 | } |
| 486 | fStencilFormats.push_back() = gS4; |
| 487 | if (supportsPackedDS) { |
| 488 | fStencilFormats.push_back() = gDS; |
| 489 | } |
| 490 | } else { |
| 491 | // ES2 has STENCIL_INDEX8 without extensions but requires extensions |
| 492 | // for other formats. |
| 493 | // ES doesn't support using the unsized format. |
| 494 | |
| 495 | fStencilFormats.push_back() = gS8; |
| 496 | //fStencilFormats.push_back() = gS16; |
| 497 | if (ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) { |
| 498 | fStencilFormats.push_back() = gD24S8; |
| 499 | } |
| 500 | if (ctxInfo.hasExtension("GL_OES_stencil4")) { |
| 501 | fStencilFormats.push_back() = gS4; |
| 502 | } |
| 503 | } |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 504 | SkASSERT(0 == fStencilVerifiedColorConfigs.count()); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 505 | fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); |
| 506 | } |
| 507 | |
| 508 | void GrGLCaps::markColorConfigAndStencilFormatAsVerified( |
| 509 | GrPixelConfig config, |
| 510 | const GrGLStencilBuffer::Format& format) { |
| 511 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 512 | return; |
| 513 | #endif |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 514 | SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
| 515 | SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count()); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 516 | int count = fStencilFormats.count(); |
| 517 | // we expect a really small number of possible formats so linear search |
| 518 | // should be OK |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 519 | SkASSERT(count < 16); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 520 | for (int i = 0; i < count; ++i) { |
| 521 | if (format.fInternalFormat == |
| 522 | fStencilFormats[i].fInternalFormat) { |
| 523 | fStencilVerifiedColorConfigs[i].markVerified(config); |
| 524 | return; |
| 525 | } |
| 526 | } |
| 527 | GrCrash("Why are we seeing a stencil format that " |
| 528 | "GrGLCaps doesn't know about."); |
| 529 | } |
| 530 | |
| 531 | bool GrGLCaps::isColorConfigAndStencilFormatVerified( |
| 532 | GrPixelConfig config, |
| 533 | const GrGLStencilBuffer::Format& format) const { |
| 534 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 535 | return false; |
| 536 | #endif |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 537 | SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 538 | int count = fStencilFormats.count(); |
| 539 | // we expect a really small number of possible formats so linear search |
| 540 | // should be OK |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 541 | SkASSERT(count < 16); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 542 | for (int i = 0; i < count; ++i) { |
| 543 | if (format.fInternalFormat == |
| 544 | fStencilFormats[i].fInternalFormat) { |
| 545 | return fStencilVerifiedColorConfigs[i].isVerified(config); |
| 546 | } |
| 547 | } |
| 548 | GrCrash("Why are we seeing a stencil format that " |
| 549 | "GLCaps doesn't know about."); |
| 550 | return false; |
| 551 | } |
| 552 | |
| 553 | void GrGLCaps::print() const { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 554 | |
| 555 | INHERITED::print(); |
| 556 | |
| 557 | GrPrintf("--- GL-Specific ---\n"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 558 | for (int i = 0; i < fStencilFormats.count(); ++i) { |
| 559 | GrPrintf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n", |
| 560 | i, |
| 561 | fStencilFormats[i].fStencilBits, |
| 562 | fStencilFormats[i].fTotalBits); |
| 563 | } |
| 564 | |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 565 | static const char* kMSFBOExtStr[] = { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 566 | "None", |
| 567 | "ARB", |
| 568 | "EXT", |
| 569 | "Apple", |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 570 | "IMG MS To Texture", |
| 571 | "EXT MS To Texture", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 572 | }; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 573 | GR_STATIC_ASSERT(0 == kNone_MSFBOType); |
| 574 | GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType); |
| 575 | GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType); |
| 576 | GR_STATIC_ASSERT(3 == kES_Apple_MSFBOType); |
| 577 | GR_STATIC_ASSERT(4 == kES_IMG_MsToTexture_MSFBOType); |
| 578 | GR_STATIC_ASSERT(5 == kES_EXT_MsToTexture_MSFBOType); |
| 579 | GR_STATIC_ASSERT(GR_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1); |
| 580 | |
| 581 | static const char* kFBFetchTypeStr[] = { |
| 582 | "None", |
| 583 | "EXT", |
| 584 | "NV", |
| 585 | }; |
| 586 | GR_STATIC_ASSERT(0 == kNone_FBFetchType); |
| 587 | GR_STATIC_ASSERT(1 == kEXT_FBFetchType); |
| 588 | GR_STATIC_ASSERT(2 == kNV_FBFetchType); |
| 589 | GR_STATIC_ASSERT(GR_ARRAY_COUNT(kFBFetchTypeStr) == kLast_FBFetchType + 1); |
| 590 | |
| 591 | |
| 592 | GrPrintf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); |
| 593 | GrPrintf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 594 | GrPrintf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 595 | GrPrintf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
| 596 | GrPrintf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); |
| 597 | GrPrintf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); |
| 598 | GrPrintf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO")); |
| 599 | GrPrintf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO")); |
| 600 | GrPrintf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO")); |
| 601 | GrPrintf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")); |
| 602 | GrPrintf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO")); |
| 603 | GrPrintf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
| 604 | |
| 605 | GrPrintf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")); |
| 606 | GrPrintf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO")); |
| 607 | GrPrintf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
| 608 | GrPrintf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 609 | GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 610 | GrPrintf("Fragment coord conventions support: %s\n", |
| 611 | (fFragCoordsConventionSupport ? "YES": "NO")); |
| 612 | GrPrintf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); |
| 613 | GrPrintf("Use non-VBO for dynamic data: %s\n", |
| 614 | (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
| 615 | GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 616 | GrPrintf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "NO")); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 617 | } |