OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
10 #include "GrGLContext.h" | 10 #include "GrGLContext.h" |
11 #include "SkTSearch.h" | 11 #include "SkTSearch.h" |
12 | 12 |
13 GrGLCaps::GrGLCaps() { | 13 GrGLCaps::GrGLCaps() { |
14 this->reset(); | 14 this->reset(); |
15 } | 15 } |
16 | 16 |
17 void GrGLCaps::reset() { | 17 void GrGLCaps::reset() { |
| 18 INHERITED::reset(); |
| 19 |
18 fVerifiedColorConfigs.reset(); | 20 fVerifiedColorConfigs.reset(); |
19 fStencilFormats.reset(); | 21 fStencilFormats.reset(); |
20 fStencilVerifiedColorConfigs.reset(); | 22 fStencilVerifiedColorConfigs.reset(); |
21 fMSFBOType = kNone_MSFBOType; | 23 fMSFBOType = kNone_MSFBOType; |
22 fCoverageAAType = kNone_CoverageAAType; | 24 fCoverageAAType = kNone_CoverageAAType; |
23 fMaxFragmentUniformVectors = 0; | 25 fMaxFragmentUniformVectors = 0; |
24 fMaxVertexAttributes = 0; | 26 fMaxVertexAttributes = 0; |
25 fRGBA8RenderbufferSupport = false; | 27 fRGBA8RenderbufferSupport = false; |
26 fBGRAFormatSupport = false; | 28 fBGRAFormatSupport = false; |
27 fBGRAIsInternalFormat = false; | 29 fBGRAIsInternalFormat = false; |
(...skipping 11 matching lines...) Expand all Loading... |
39 fVertexArrayObjectSupport = false; | 41 fVertexArrayObjectSupport = false; |
40 fUseNonVBOVertexAndIndexDynamicData = false; | 42 fUseNonVBOVertexAndIndexDynamicData = false; |
41 fIsCoreProfile = false; | 43 fIsCoreProfile = false; |
42 } | 44 } |
43 | 45 |
44 GrGLCaps::GrGLCaps(const GrGLCaps& caps) { | 46 GrGLCaps::GrGLCaps(const GrGLCaps& caps) { |
45 *this = caps; | 47 *this = caps; |
46 } | 48 } |
47 | 49 |
48 GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) { | 50 GrGLCaps& GrGLCaps::operator = (const GrGLCaps& caps) { |
| 51 INHERITED::operator=(caps); |
49 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; | 52 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; |
50 fStencilFormats = caps.fStencilFormats; | 53 fStencilFormats = caps.fStencilFormats; |
51 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; | 54 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; |
52 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; | 55 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; |
53 fMaxVertexAttributes = caps.fMaxVertexAttributes; | 56 fMaxVertexAttributes = caps.fMaxVertexAttributes; |
54 fMSFBOType = caps.fMSFBOType; | 57 fMSFBOType = caps.fMSFBOType; |
55 fCoverageAAType = caps.fCoverageAAType; | 58 fCoverageAAType = caps.fCoverageAAType; |
56 fMSAACoverageModes = caps.fMSAACoverageModes; | 59 fMSAACoverageModes = caps.fMSAACoverageModes; |
57 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; | 60 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; |
58 fBGRAFormatSupport = caps.fBGRAFormatSupport; | 61 fBGRAFormatSupport = caps.fBGRAFormatSupport; |
(...skipping 19 matching lines...) Expand all Loading... |
78 void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { | 81 void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
79 | 82 |
80 this->reset(); | 83 this->reset(); |
81 if (!ctxInfo.isInitialized()) { | 84 if (!ctxInfo.isInitialized()) { |
82 return; | 85 return; |
83 } | 86 } |
84 | 87 |
85 GrGLBinding binding = ctxInfo.binding(); | 88 GrGLBinding binding = ctxInfo.binding(); |
86 GrGLVersion version = ctxInfo.version(); | 89 GrGLVersion version = ctxInfo.version(); |
87 | 90 |
| 91 /************************************************************************** |
| 92 * Caps specific to GrGLCaps |
| 93 **************************************************************************/ |
| 94 |
88 if (kES2_GrGLBinding == binding) { | 95 if (kES2_GrGLBinding == binding) { |
89 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, | 96 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, |
90 &fMaxFragmentUniformVectors); | 97 &fMaxFragmentUniformVectors); |
91 } else { | 98 } else { |
92 GrAssert(kDesktop_GrGLBinding == binding); | 99 GrAssert(kDesktop_GrGLBinding == binding); |
93 GrGLint max; | 100 GrGLint max; |
94 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); | 101 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); |
95 fMaxFragmentUniformVectors = max / 4; | 102 fMaxFragmentUniformVectors = max / 4; |
96 } | 103 } |
97 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); | 104 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 194 |
188 if (kDesktop_GrGLBinding == binding) { | 195 if (kDesktop_GrGLBinding == binding) { |
189 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || | 196 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
190 ctxInfo.hasExtension("GL_ARB_vertex_array_ob
ject"); | 197 ctxInfo.hasExtension("GL_ARB_vertex_array_ob
ject"); |
191 } else { | 198 } else { |
192 fVertexArrayObjectSupport = ctxInfo.hasExtension("GL_OES_vertex_array_ob
ject"); | 199 fVertexArrayObjectSupport = ctxInfo.hasExtension("GL_OES_vertex_array_ob
ject"); |
193 } | 200 } |
194 | 201 |
195 this->initFSAASupport(ctxInfo, gli); | 202 this->initFSAASupport(ctxInfo, gli); |
196 this->initStencilFormats(ctxInfo); | 203 this->initStencilFormats(ctxInfo); |
| 204 |
| 205 /************************************************************************** |
| 206 * GrDrawTarget::Caps fields |
| 207 **************************************************************************/ |
| 208 GrGLint maxTextureUnits; |
| 209 // check FS and fixed-function texture unit limits |
| 210 // we only use textures in the fragment stage currently. |
| 211 // checks are > to make sure we have a spare unit. |
| 212 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); |
| 213 GrAssert(maxTextureUnits > GrDrawState::kNumStages); |
| 214 |
| 215 GrGLint numFormats; |
| 216 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats); |
| 217 SkAutoSTMalloc<10, GrGLint> formats(numFormats); |
| 218 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); |
| 219 for (int i = 0; i < numFormats; ++i) { |
| 220 if (formats[i] == GR_GL_PALETTE8_RGBA8) { |
| 221 f8BitPaletteSupport = true; |
| 222 break; |
| 223 } |
| 224 } |
| 225 |
| 226 if (kDesktop_GrGLBinding == binding) { |
| 227 // we could also look for GL_ATI_separate_stencil extension or |
| 228 // GL_EXT_stencil_two_side but they use different function signatures |
| 229 // than GL2.0+ (and than each other). |
| 230 fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0)); |
| 231 // supported on GL 1.4 and higher or by extension |
| 232 fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) || |
| 233 ctxInfo.hasExtension("GL_EXT_stencil_wrap"); |
| 234 } else { |
| 235 // ES 2 has two sided stencil and stencil wrap |
| 236 fTwoSidedStencilSupport = true; |
| 237 fStencilWrapOpsSupport = true; |
| 238 } |
| 239 |
| 240 if (kDesktop_GrGLBinding == binding) { |
| 241 fBufferLockSupport = true; // we require VBO support and the desktop VBO
extension includes |
| 242 // glMapBuffer. |
| 243 } else { |
| 244 fBufferLockSupport = ctxInfo.hasExtension("GL_OES_mapbuffer"); |
| 245 } |
| 246 |
| 247 if (kDesktop_GrGLBinding == binding) { |
| 248 if (ctxInfo.version() >= GR_GL_VER(2,0) || |
| 249 ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")) { |
| 250 fNPOTTextureTileSupport = true; |
| 251 } else { |
| 252 fNPOTTextureTileSupport = false; |
| 253 } |
| 254 } else { |
| 255 // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip
filters only |
| 256 fNPOTTextureTileSupport = ctxInfo.hasExtension("GL_OES_texture_npot"); |
| 257 } |
| 258 |
| 259 fHWAALineSupport = (kDesktop_GrGLBinding == binding); |
| 260 |
| 261 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_SIZE, &fMaxTextureSize); |
| 262 GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize); |
| 263 // Our render targets are always created with textures as the color |
| 264 // attachment, hence this min: |
| 265 fMaxRenderTargetSize = GrMin(fMaxTextureSize, fMaxRenderTargetSize); |
| 266 |
| 267 fPathStencilingSupport = GR_GL_USE_NV_PATH_RENDERING && |
| 268 ctxInfo.hasExtension("GL_NV_path_rendering"); |
| 269 |
| 270 // Enable supported shader-related caps |
| 271 if (kDesktop_GrGLBinding == binding) { |
| 272 fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) || |
| 273 ctxInfo.hasExtension("GL_ARB_blend_func_ext
ended"); |
| 274 fShaderDerivativeSupport = true; |
| 275 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS |
| 276 fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3,2) && |
| 277 ctxInfo.glslGeneration() >= k150_GrGLSLGenerati
on; |
| 278 } else { |
| 279 fShaderDerivativeSupport = ctxInfo.hasExtension("GL_OES_standard_derivat
ives"); |
| 280 } |
| 281 |
| 282 if (GrGLCaps::kImaginationES_MSFBOType == fMSFBOType) { |
| 283 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount); |
| 284 } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) { |
| 285 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount); |
| 286 } |
197 } | 287 } |
198 | 288 |
199 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, | 289 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
200 GrGLenum format, | 290 GrGLenum format, |
201 GrGLenum type) const { | 291 GrGLenum type) const { |
202 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { | 292 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { |
203 // ES 2 guarantees this format is supported | 293 // ES 2 guarantees this format is supported |
204 return true; | 294 return true; |
205 } | 295 } |
206 | 296 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 fStencilFormats[i].fInternalFormat) { | 494 fStencilFormats[i].fInternalFormat) { |
405 return fStencilVerifiedColorConfigs[i].isVerified(config); | 495 return fStencilVerifiedColorConfigs[i].isVerified(config); |
406 } | 496 } |
407 } | 497 } |
408 GrCrash("Why are we seeing a stencil format that " | 498 GrCrash("Why are we seeing a stencil format that " |
409 "GLCaps doesn't know about."); | 499 "GLCaps doesn't know about."); |
410 return false; | 500 return false; |
411 } | 501 } |
412 | 502 |
413 void GrGLCaps::print() const { | 503 void GrGLCaps::print() const { |
| 504 |
| 505 INHERITED::print(); |
| 506 |
| 507 GrPrintf("--- GL-Specific ---\n"); |
414 for (int i = 0; i < fStencilFormats.count(); ++i) { | 508 for (int i = 0; i < fStencilFormats.count(); ++i) { |
415 GrPrintf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n", | 509 GrPrintf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n", |
416 i, | 510 i, |
417 fStencilFormats[i].fStencilBits, | 511 fStencilFormats[i].fStencilBits, |
418 fStencilFormats[i].fTotalBits); | 512 fStencilFormats[i].fTotalBits); |
419 } | 513 } |
420 | 514 |
421 GR_STATIC_ASSERT(0 == kNone_MSFBOType); | 515 GR_STATIC_ASSERT(0 == kNone_MSFBOType); |
422 GR_STATIC_ASSERT(1 == kDesktopARB_MSFBOType); | 516 GR_STATIC_ASSERT(1 == kDesktopARB_MSFBOType); |
423 GR_STATIC_ASSERT(2 == kDesktopEXT_MSFBOType); | 517 GR_STATIC_ASSERT(2 == kDesktopEXT_MSFBOType); |
424 GR_STATIC_ASSERT(3 == kAppleES_MSFBOType); | 518 GR_STATIC_ASSERT(3 == kAppleES_MSFBOType); |
425 GR_STATIC_ASSERT(4 == kImaginationES_MSFBOType); | 519 GR_STATIC_ASSERT(4 == kImaginationES_MSFBOType); |
426 static const char* gMSFBOExtStr[] = { | 520 static const char* gMSFBOExtStr[] = { |
427 "None", | 521 "None", |
428 "ARB", | 522 "ARB", |
429 "EXT", | 523 "EXT", |
430 "Apple", | 524 "Apple", |
431 "IMG", | 525 "IMG", |
432 }; | 526 }; |
433 GrPrintf("MSAA Type: %s\n", gMSFBOExtStr[fMSFBOType]); | 527 GrPrintf("MSAA Type: %s\n", gMSFBOExtStr[fMSFBOType]); |
434 GrPrintf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); | 528 GrPrintf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
435 GrPrintf("Support RGBA8 Render Buffer: %s\n", | 529 GrPrintf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
436 (fRGBA8RenderbufferSupport ? "YES": "NO")); | 530 GrPrintf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "
YES": "NO")); |
437 GrPrintf("BGRA is an internal format: %s\n", | 531 GrPrintf("BGRA support: %s\n", (fBGRAFormatSupport ? "YES": "NO")); |
438 (fBGRAIsInternalFormat ? "YES": "NO")); | 532 GrPrintf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES":
"NO")); |
439 GrPrintf("Support texture swizzle: %s\n", | 533 GrPrintf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "
NO")); |
440 (fTextureSwizzleSupport ? "YES": "NO")); | 534 GrPrintf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES"
: "NO")); |
441 GrPrintf("Unpack Row length support: %s\n", | 535 GrPrintf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO"))
; |
442 (fUnpackRowLengthSupport ? "YES": "NO")); | 536 GrPrintf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "N
O")); |
443 GrPrintf("Unpack Flip Y support: %s\n", | 537 GrPrintf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
444 (fUnpackFlipYSupport ? "YES": "NO")); | 538 |
445 GrPrintf("Pack Row length support: %s\n", | 539 GrPrintf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")
); |
446 (fPackRowLengthSupport ? "YES": "NO")); | 540 GrPrintf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO")
); |
447 GrPrintf("Pack Flip Y support: %s\n", | 541 GrPrintf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
448 (fPackFlipYSupport ? "YES": "NO")); | 542 GrPrintf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
449 GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 543 GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
450 GrPrintf("Fragment coord conventions support: %s\n", (fFragCoordsConventionS
upport ? "YES": "NO")); | 544 GrPrintf("Fragment coord conventions support: %s\n", |
| 545 (fFragCoordsConventionSupport ? "YES": "NO")); |
| 546 GrPrintf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "
YES": "NO")); |
| 547 GrPrintf("Use non-VBO for dynamic data: %s\n", |
| 548 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
| 549 GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
451 } | 550 } |
OLD | NEW |