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" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 GrGLVersion version = ctxInfo.version(); | 98 GrGLVersion version = ctxInfo.version(); |
99 | 99 |
100 /************************************************************************** | 100 /************************************************************************** |
101 * Caps specific to GrGLCaps | 101 * Caps specific to GrGLCaps |
102 **************************************************************************/ | 102 **************************************************************************/ |
103 | 103 |
104 if (kES_GrGLBinding == binding) { | 104 if (kES_GrGLBinding == binding) { |
105 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, | 105 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, |
106 &fMaxFragmentUniformVectors); | 106 &fMaxFragmentUniformVectors); |
107 } else { | 107 } else { |
108 GrAssert(kDesktop_GrGLBinding == binding); | 108 SkASSERT(kDesktop_GrGLBinding == binding); |
109 GrGLint max; | 109 GrGLint max; |
110 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); | 110 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); |
111 fMaxFragmentUniformVectors = max / 4; | 111 fMaxFragmentUniformVectors = max / 4; |
112 } | 112 } |
113 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); | 113 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); |
114 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUn
its); | 114 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUn
its); |
115 | 115 |
116 if (kDesktop_GrGLBinding == binding) { | 116 if (kDesktop_GrGLBinding == binding) { |
117 fRGBA8RenderbufferSupport = true; | 117 fRGBA8RenderbufferSupport = true; |
118 } else { | 118 } else { |
119 fRGBA8RenderbufferSupport = ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || | 119 fRGBA8RenderbufferSupport = ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || |
120 ctxInfo.hasExtension("GL_ARM_rgba8"); | 120 ctxInfo.hasExtension("GL_ARM_rgba8"); |
121 } | 121 } |
122 | 122 |
123 if (kDesktop_GrGLBinding == binding) { | 123 if (kDesktop_GrGLBinding == binding) { |
124 fBGRAFormatSupport = version >= GR_GL_VER(1,2) || | 124 fBGRAFormatSupport = version >= GR_GL_VER(1,2) || |
125 ctxInfo.hasExtension("GL_EXT_bgra"); | 125 ctxInfo.hasExtension("GL_EXT_bgra"); |
126 } else { | 126 } else { |
127 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { | 127 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { |
128 fBGRAFormatSupport = true; | 128 fBGRAFormatSupport = true; |
129 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { | 129 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { |
130 fBGRAFormatSupport = true; | 130 fBGRAFormatSupport = true; |
131 fBGRAIsInternalFormat = true; | 131 fBGRAIsInternalFormat = true; |
132 } | 132 } |
133 GrAssert(fBGRAFormatSupport || | 133 SkASSERT(fBGRAFormatSupport || |
134 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig); | 134 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig); |
135 } | 135 } |
136 | 136 |
137 if (kDesktop_GrGLBinding == binding) { | 137 if (kDesktop_GrGLBinding == binding) { |
138 fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || | 138 fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || |
139 ctxInfo.hasExtension("GL_ARB_texture_swizzle"); | 139 ctxInfo.hasExtension("GL_ARB_texture_swizzle"); |
140 } else { | 140 } else { |
141 fTextureSwizzleSupport = false; | 141 fTextureSwizzleSupport = false; |
142 } | 142 } |
143 | 143 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 sortFunctor); | 411 sortFunctor); |
412 } | 412 } |
413 } | 413 } |
414 } | 414 } |
415 | 415 |
416 const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampl
eCount) const { | 416 const GrGLCaps::MSAACoverageMode& GrGLCaps::getMSAACoverageMode(int desiredSampl
eCount) const { |
417 static const MSAACoverageMode kNoneMode = {0, 0}; | 417 static const MSAACoverageMode kNoneMode = {0, 0}; |
418 if (0 == fMSAACoverageModes.count()) { | 418 if (0 == fMSAACoverageModes.count()) { |
419 return kNoneMode; | 419 return kNoneMode; |
420 } else { | 420 } else { |
421 GrAssert(kNone_CoverageAAType != fCoverageAAType); | 421 SkASSERT(kNone_CoverageAAType != fCoverageAAType); |
422 int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt; | 422 int max = (fMSAACoverageModes.end() - 1)->fCoverageSampleCnt; |
423 desiredSampleCount = GrMin(desiredSampleCount, max); | 423 desiredSampleCount = GrMin(desiredSampleCount, max); |
424 MSAACoverageMode desiredMode = {desiredSampleCount, 0}; | 424 MSAACoverageMode desiredMode = {desiredSampleCount, 0}; |
425 int idx = SkTSearch<const MSAACoverageMode, cov_mode_less>(&fMSAACoverag
eModes[0], | 425 int idx = SkTSearch<const MSAACoverageMode, cov_mode_less>(&fMSAACoverag
eModes[0], |
426 fMSAACoverage
Modes.count(), | 426 fMSAACoverage
Modes.count(), |
427 desiredMode, | 427 desiredMode, |
428 sizeof(MSAACo
verageMode)); | 428 sizeof(MSAACo
verageMode)); |
429 if (idx < 0) { | 429 if (idx < 0) { |
430 idx = ~idx; | 430 idx = ~idx; |
431 } | 431 } |
432 GrAssert(idx >= 0 && idx < fMSAACoverageModes.count()); | 432 SkASSERT(idx >= 0 && idx < fMSAACoverageModes.count()); |
433 return fMSAACoverageModes[idx]; | 433 return fMSAACoverageModes[idx]; |
434 } | 434 } |
435 } | 435 } |
436 | 436 |
437 namespace { | 437 namespace { |
438 const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; | 438 const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; |
439 } | 439 } |
440 | 440 |
441 void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) { | 441 void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) { |
442 | 442 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 fStencilFormats.push_back() = gS8; | 481 fStencilFormats.push_back() = gS8; |
482 //fStencilFormats.push_back() = gS16; | 482 //fStencilFormats.push_back() = gS16; |
483 if (ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) { | 483 if (ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) { |
484 fStencilFormats.push_back() = gD24S8; | 484 fStencilFormats.push_back() = gD24S8; |
485 } | 485 } |
486 if (ctxInfo.hasExtension("GL_OES_stencil4")) { | 486 if (ctxInfo.hasExtension("GL_OES_stencil4")) { |
487 fStencilFormats.push_back() = gS4; | 487 fStencilFormats.push_back() = gS4; |
488 } | 488 } |
489 } | 489 } |
490 GrAssert(0 == fStencilVerifiedColorConfigs.count()); | 490 SkASSERT(0 == fStencilVerifiedColorConfigs.count()); |
491 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); | 491 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); |
492 } | 492 } |
493 | 493 |
494 void GrGLCaps::markColorConfigAndStencilFormatAsVerified( | 494 void GrGLCaps::markColorConfigAndStencilFormatAsVerified( |
495 GrPixelConfig config, | 495 GrPixelConfig config, |
496 const GrGLStencilBuffer::Format& format) { | 496 const GrGLStencilBuffer::Format& format) { |
497 #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT | 497 #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
498 return; | 498 return; |
499 #endif | 499 #endif |
500 GrAssert((unsigned)config < (unsigned)kGrPixelConfigCnt); | 500 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
501 GrAssert(fStencilFormats.count() == fStencilVerifiedColorConfigs.count()); | 501 SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count()); |
502 int count = fStencilFormats.count(); | 502 int count = fStencilFormats.count(); |
503 // we expect a really small number of possible formats so linear search | 503 // we expect a really small number of possible formats so linear search |
504 // should be OK | 504 // should be OK |
505 GrAssert(count < 16); | 505 SkASSERT(count < 16); |
506 for (int i = 0; i < count; ++i) { | 506 for (int i = 0; i < count; ++i) { |
507 if (format.fInternalFormat == | 507 if (format.fInternalFormat == |
508 fStencilFormats[i].fInternalFormat) { | 508 fStencilFormats[i].fInternalFormat) { |
509 fStencilVerifiedColorConfigs[i].markVerified(config); | 509 fStencilVerifiedColorConfigs[i].markVerified(config); |
510 return; | 510 return; |
511 } | 511 } |
512 } | 512 } |
513 GrCrash("Why are we seeing a stencil format that " | 513 GrCrash("Why are we seeing a stencil format that " |
514 "GrGLCaps doesn't know about."); | 514 "GrGLCaps doesn't know about."); |
515 } | 515 } |
516 | 516 |
517 bool GrGLCaps::isColorConfigAndStencilFormatVerified( | 517 bool GrGLCaps::isColorConfigAndStencilFormatVerified( |
518 GrPixelConfig config, | 518 GrPixelConfig config, |
519 const GrGLStencilBuffer::Format& format) const { | 519 const GrGLStencilBuffer::Format& format) const { |
520 #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT | 520 #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
521 return false; | 521 return false; |
522 #endif | 522 #endif |
523 GrAssert((unsigned)config < (unsigned)kGrPixelConfigCnt); | 523 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
524 int count = fStencilFormats.count(); | 524 int count = fStencilFormats.count(); |
525 // we expect a really small number of possible formats so linear search | 525 // we expect a really small number of possible formats so linear search |
526 // should be OK | 526 // should be OK |
527 GrAssert(count < 16); | 527 SkASSERT(count < 16); |
528 for (int i = 0; i < count; ++i) { | 528 for (int i = 0; i < count; ++i) { |
529 if (format.fInternalFormat == | 529 if (format.fInternalFormat == |
530 fStencilFormats[i].fInternalFormat) { | 530 fStencilFormats[i].fInternalFormat) { |
531 return fStencilVerifiedColorConfigs[i].isVerified(config); | 531 return fStencilVerifiedColorConfigs[i].isVerified(config); |
532 } | 532 } |
533 } | 533 } |
534 GrCrash("Why are we seeing a stencil format that " | 534 GrCrash("Why are we seeing a stencil format that " |
535 "GLCaps doesn't know about."); | 535 "GLCaps doesn't know about."); |
536 return false; | 536 return false; |
537 } | 537 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 GrPrintf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); | 594 GrPrintf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
595 GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 595 GrPrintf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
596 GrPrintf("Fragment coord conventions support: %s\n", | 596 GrPrintf("Fragment coord conventions support: %s\n", |
597 (fFragCoordsConventionSupport ? "YES": "NO")); | 597 (fFragCoordsConventionSupport ? "YES": "NO")); |
598 GrPrintf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "
YES": "NO")); | 598 GrPrintf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "
YES": "NO")); |
599 GrPrintf("Use non-VBO for dynamic data: %s\n", | 599 GrPrintf("Use non-VBO for dynamic data: %s\n", |
600 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 600 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
601 GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); | 601 GrPrintf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
602 GrPrintf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "
NO")); | 602 GrPrintf("Discard FrameBuffer support: %s\n", (fDiscardFBSupport ? "YES" : "
NO")); |
603 } | 603 } |
OLD | NEW |