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 30 matching lines...) Expand all Loading... |
41 fTexStorageSupport = false; | 41 fTexStorageSupport = false; |
42 fTextureRedSupport = false; | 42 fTextureRedSupport = false; |
43 fImagingSupport = false; | 43 fImagingSupport = false; |
44 fTwoFormatLimit = false; | 44 fTwoFormatLimit = false; |
45 fFragCoordsConventionSupport = false; | 45 fFragCoordsConventionSupport = false; |
46 fVertexArrayObjectSupport = false; | 46 fVertexArrayObjectSupport = false; |
47 fUseNonVBOVertexAndIndexDynamicData = false; | 47 fUseNonVBOVertexAndIndexDynamicData = false; |
48 fIsCoreProfile = false; | 48 fIsCoreProfile = false; |
49 fFullClearIsFree = false; | 49 fFullClearIsFree = false; |
50 fDropsTileOnZeroDivide = false; | 50 fDropsTileOnZeroDivide = false; |
51 | |
52 fReadPixelsSupportedCache.reset(); | |
53 } | 51 } |
54 | 52 |
55 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { | 53 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { |
56 *this = caps; | 54 *this = caps; |
57 } | 55 } |
58 | 56 |
59 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { | 57 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { |
60 INHERITED::operator=(caps); | 58 INHERITED::operator=(caps); |
61 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; | 59 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; |
62 fStencilFormats = caps.fStencilFormats; | 60 fStencilFormats = caps.fStencilFormats; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 // glCompressedTexImage2D is available on all OpenGL ES devices... | 497 // glCompressedTexImage2D is available on all OpenGL ES devices... |
500 // however, it is only available on standard OpenGL after version 1.3 | 498 // however, it is only available on standard OpenGL after version 1.3 |
501 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VE
R(1, 3)); | 499 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VE
R(1, 3)); |
502 | 500 |
503 // Check for ETC1 | 501 // Check for ETC1 |
504 bool hasETC1 = false; | 502 bool hasETC1 = false; |
505 | 503 |
506 // First check version for support | 504 // First check version for support |
507 if (kGL_GrGLStandard == standard) { | 505 if (kGL_GrGLStandard == standard) { |
508 hasETC1 = hasCompressTex2D && | 506 hasETC1 = hasCompressTex2D && |
509 (version >= GR_GL_VER(4, 3) || | 507 (version >= GR_GL_VER(4, 3) || |
510 ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); | 508 ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); |
511 } else { | 509 } else { |
512 hasETC1 = hasCompressTex2D && | 510 hasETC1 = hasCompressTex2D && |
513 (version >= GR_GL_VER(3, 0) || | 511 (version >= GR_GL_VER(3, 0) || |
514 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || | 512 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || |
515 // ETC2 is a superset of ETC1, so we can just check for that, too. | 513 // ETC2 is a superset of ETC1, so we can just check for that, too. |
516 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && | 514 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && |
517 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); | 515 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); |
518 } | 516 } |
519 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; | 517 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 553 |
556 // Check for R11_EAC | 554 // Check for R11_EAC |
557 if (kGL_GrGLStandard == standard) { | 555 if (kGL_GrGLStandard == standard) { |
558 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = | 556 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = |
559 version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa
tibility"); | 557 version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa
tibility"); |
560 } else { | 558 } else { |
561 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3,
0); | 559 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3,
0); |
562 } | 560 } |
563 } | 561 } |
564 | 562 |
565 bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf, | 563 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
566 GrGLenum format, | 564 GrGLenum format, |
567 GrGLenum type) const { | 565 GrGLenum type) const { |
568 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { | 566 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { |
569 // ES 2 guarantees this format is supported | 567 // ES 2 guarantees this format is supported |
570 return true; | 568 return true; |
571 } | 569 } |
572 | 570 |
573 if (!fTwoFormatLimit) { | 571 if (!fTwoFormatLimit) { |
574 // not limited by ES 2's constraints | 572 // not limited by ES 2's constraints |
575 return true; | 573 return true; |
576 } | 574 } |
577 | 575 |
578 GrGLint otherFormat = GR_GL_RGBA; | 576 GrGLint otherFormat = GR_GL_RGBA; |
579 GrGLint otherType = GR_GL_UNSIGNED_BYTE; | 577 GrGLint otherType = GR_GL_UNSIGNED_BYTE; |
580 | 578 |
581 // The other supported format/type combo supported for ReadPixels | 579 // The other supported format/type combo supported for ReadPixels |
582 // can change based on which render target is bound | 580 // can change based on which render target is bound |
583 GR_GL_GetIntegerv(intf, | 581 GR_GL_GetIntegerv(intf, |
584 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, | 582 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, |
585 &otherFormat); | 583 &otherFormat); |
586 | 584 |
587 GR_GL_GetIntegerv(intf, | 585 GR_GL_GetIntegerv(intf, |
588 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, | 586 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, |
589 &otherType); | 587 &otherType); |
590 | 588 |
591 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; | 589 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; |
592 } | 590 } |
593 | 591 |
594 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, | |
595 GrGLenum format, | |
596 GrGLenum type, | |
597 GrGLenum currFboFormat) const { | |
598 | |
599 ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat}; | |
600 | |
601 ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key
); | |
602 | |
603 if (NULL == cachedValue) { | |
604 bool value = doReadPixelsSupported(intf, format, type); | |
605 ReadPixelsSupportedFormats newValue(key, value); | |
606 fReadPixelsSupportedCache.add(newValue); | |
607 | |
608 return newValue.value(); | |
609 } | |
610 | |
611 return cachedValue->value(); | |
612 } | |
613 | |
614 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { | 592 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { |
615 | 593 |
616 fMSFBOType = kNone_MSFBOType; | 594 fMSFBOType = kNone_MSFBOType; |
617 if (kGL_GrGLStandard != ctxInfo.standard()) { | 595 if (kGL_GrGLStandard != ctxInfo.standard()) { |
618 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed | 596 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed |
619 // ES3 driver bugs on at least one device with a tiled GPU (N10). | 597 // ES3 driver bugs on at least one device with a tiled GPU (N10). |
620 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { | 598 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { |
621 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; | 599 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; |
622 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")
) { | 600 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")
) { |
623 fMSFBOType = kES_IMG_MsToTexture_MSFBOType; | 601 fMSFBOType = kES_IMG_MsToTexture_MSFBOType; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 810 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
833 r.appendf("Fragment coord conventions support: %s\n", | 811 r.appendf("Fragment coord conventions support: %s\n", |
834 (fFragCoordsConventionSupport ? "YES": "NO")); | 812 (fFragCoordsConventionSupport ? "YES": "NO")); |
835 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 813 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
836 r.appendf("Use non-VBO for dynamic data: %s\n", | 814 r.appendf("Use non-VBO for dynamic data: %s\n", |
837 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 815 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
838 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); | 816 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); |
839 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); | 817 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); |
840 return r; | 818 return r; |
841 } | 819 } |
OLD | NEW |