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