Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Side by Side Diff: src/gpu/gl/GrGLCaps.cpp

Issue 364193004: Reopened: Caching the result of readPixelsSupported (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 fTwoFormatLimit = false; 43 fTwoFormatLimit = false;
44 fFragCoordsConventionSupport = false; 44 fFragCoordsConventionSupport = false;
45 fVertexArrayObjectSupport = false; 45 fVertexArrayObjectSupport = false;
46 fUseNonVBOVertexAndIndexDynamicData = false; 46 fUseNonVBOVertexAndIndexDynamicData = false;
47 fIsCoreProfile = false; 47 fIsCoreProfile = false;
48 fFullClearIsFree = false; 48 fFullClearIsFree = false;
49 fDropsTileOnZeroDivide = false; 49 fDropsTileOnZeroDivide = false;
50 fFBFetchSupport = false; 50 fFBFetchSupport = false;
51 fFBFetchColorName = NULL; 51 fFBFetchColorName = NULL;
52 fFBFetchExtensionString = NULL; 52 fFBFetchExtensionString = NULL;
53
54 fReadPixelsSupportedCache.reset();
53 } 55 }
54 56
55 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { 57 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
56 *this = caps; 58 *this = caps;
57 } 59 }
58 60
59 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { 61 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
60 INHERITED::operator=(caps); 62 INHERITED::operator=(caps);
61 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; 63 fVerifiedColorConfigs = caps.fVerifiedColorConfigs;
62 fStencilFormats = caps.fStencilFormats; 64 fStencilFormats = caps.fStencilFormats;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 fLATCAlias = alias; 577 fLATCAlias = alias;
576 578
577 // Check for R11_EAC ... We don't support R11_EAC on desktop, as most 579 // Check for R11_EAC ... We don't support R11_EAC on desktop, as most
578 // cards default to decompressing the textures in the driver, and is 580 // cards default to decompressing the textures in the driver, and is
579 // generally slower. 581 // generally slower.
580 if (kGL_GrGLStandard != standard) { 582 if (kGL_GrGLStandard != standard) {
581 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0); 583 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
582 } 584 }
583 585
584 // Check for ASTC 586 // Check for ASTC
585 fConfigTextureSupport[kASTC_12x12_GrPixelConfig] = 587 fConfigTextureSupport[kASTC_12x12_GrPixelConfig] =
586 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || 588 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
587 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || 589 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
588 ctxInfo.hasExtension("GL_OES_texture_compression_astc"); 590 ctxInfo.hasExtension("GL_OES_texture_compression_astc");
589 591
590 // Check for floating point texture support 592 // Check for floating point texture support
591 // NOTE: We disallow floating point textures on ES devices if linear 593 // NOTE: We disallow floating point textures on ES devices if linear
592 // filtering modes are not supported. This is for simplicity, but a more 594 // filtering modes are not supported. This is for simplicity, but a more
593 // granular approach is possible. Coincidentally, floating point textures b ecame part of 595 // granular approach is possible. Coincidentally, floating point textures b ecame part of
594 // the standard in ES3.1 / OGL 3.1, hence the shorthand 596 // the standard in ES3.1 / OGL 3.1, hence the shorthand
595 bool hasFPTextures = version >= GR_GL_VER(3, 1); 597 bool hasFPTextures = version >= GR_GL_VER(3, 1);
596 if (!hasFPTextures) { 598 if (!hasFPTextures) {
597 hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || 599 hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
598 (ctxInfo.hasExtension("OES_texture_float_linear") && 600 (ctxInfo.hasExtension("OES_texture_float_linear") &&
599 ctxInfo.hasExtension("GL_OES_texture_float")); 601 ctxInfo.hasExtension("GL_OES_texture_float"));
600 } 602 }
601 fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures; 603 fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
602 } 604 }
603 605
604 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, 606 bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf,
605 GrGLenum format, 607 GrGLenum format,
606 GrGLenum type) const { 608 GrGLenum type) const {
607 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { 609 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) {
608 // ES 2 guarantees this format is supported 610 // ES 2 guarantees this format is supported
609 return true; 611 return true;
610 } 612 }
611 613
612 if (!fTwoFormatLimit) { 614 if (!fTwoFormatLimit) {
613 // not limited by ES 2's constraints 615 // not limited by ES 2's constraints
614 return true; 616 return true;
615 } 617 }
616 618
617 GrGLint otherFormat = GR_GL_RGBA; 619 GrGLint otherFormat = GR_GL_RGBA;
618 GrGLint otherType = GR_GL_UNSIGNED_BYTE; 620 GrGLint otherType = GR_GL_UNSIGNED_BYTE;
619 621
620 // The other supported format/type combo supported for ReadPixels 622 // The other supported format/type combo supported for ReadPixels
621 // can change based on which render target is bound 623 // can change based on which render target is bound
622 GR_GL_GetIntegerv(intf, 624 GR_GL_GetIntegerv(intf,
623 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, 625 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT,
624 &otherFormat); 626 &otherFormat);
625 627
626 GR_GL_GetIntegerv(intf, 628 GR_GL_GetIntegerv(intf,
627 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, 629 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE,
628 &otherType); 630 &otherType);
629 631
630 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; 632 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type;
631 } 633 }
632 634
635 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
636 GrGLenum format,
637 GrGLenum type,
638 GrGLenum currFboFormat) const {
639
640 ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat};
641
642 ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key );
643
644 if (NULL == cachedValue) {
645 bool value = doReadPixelsSupported(intf, format, type);
646 ReadPixelsSupportedFormats newValue(key, value);
647 fReadPixelsSupportedCache.add(newValue);
648
649 return newValue.value();
650 }
651
652 return cachedValue->value();
653 }
654
633 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli) { 655 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli) {
634 656
635 fMSFBOType = kNone_MSFBOType; 657 fMSFBOType = kNone_MSFBOType;
636 if (kGL_GrGLStandard != ctxInfo.standard()) { 658 if (kGL_GrGLStandard != ctxInfo.standard()) {
637 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed 659 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed
638 // ES3 driver bugs on at least one device with a tiled GPU (N10). 660 // ES3 driver bugs on at least one device with a tiled GPU (N10).
639 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { 661 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) {
640 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; 662 fMSFBOType = kES_EXT_MsToTexture_MSFBOType;
641 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture") ) { 663 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture") ) {
642 fMSFBOType = kES_IMG_MsToTexture_MSFBOType; 664 fMSFBOType = kES_IMG_MsToTexture_MSFBOType;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); 863 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
842 r.appendf("Fragment coord conventions support: %s\n", 864 r.appendf("Fragment coord conventions support: %s\n",
843 (fFragCoordsConventionSupport ? "YES": "NO")); 865 (fFragCoordsConventionSupport ? "YES": "NO"));
844 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); 866 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
845 r.appendf("Use non-VBO for dynamic data: %s\n", 867 r.appendf("Use non-VBO for dynamic data: %s\n",
846 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); 868 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
847 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO ")); 869 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO "));
848 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO")); 870 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
849 return r; 871 return r;
850 } 872 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698