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

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

Issue 1531013005: Remove dead code for glTexStorage (Closed) Base URL: https://skia.googlesource.com/skia.git@readpixels
Patch Set: Created 5 years 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 | « no previous file | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) { 664 if (SkToBool(desc.fFlags & kCheckAllocation_GrSurfaceFlag)) {
665 return GR_GL_GET_ERROR(interface); 665 return GR_GL_GET_ERROR(interface);
666 } else { 666 } else {
667 return CHECK_ALLOC_ERROR(interface); 667 return CHECK_ALLOC_ERROR(interface);
668 } 668 }
669 } 669 }
670 670
671 /** 671 /**
672 * Determines if sized internal formats are available for the texture being crea ted. 672 * Determines if sized internal formats are available for the texture being crea ted.
673 * 673 *
674 * @param useTexStorage The result of a call to can_use_tex_storage().
675 * @param info Info about the GL context. 674 * @param info Info about the GL context.
676 * @param textureConfig The pixel configuration for the texture being created. 675 * @param textureConfig The pixel configuration for the texture being created.
677 */ 676 */
678 static bool use_sized_format_for_texture(bool useTexStorage, const GrGLContextIn fo& info, 677 static bool use_sized_format_for_texture(const GrGLContextInfo& info, GrPixelCon fig textureConfig) {
679 GrPixelConfig textureConfig) { 678 // ES2 requires an unsized format for glTexImage, unlike ES3 and desktop.
680 // glTexStorage requires sized internal formats on both desktop and ES. ES2 requires an unsized 679 bool useSizedFormat = false;
681 // format for glTexImage, unlike ES3 and desktop.
682 bool useSizedFormat = useTexStorage;
683 if (kGL_GrGLStandard == info.standard() || 680 if (kGL_GrGLStandard == info.standard() ||
684 (info.version() >= GR_GL_VER(3, 0) && 681 (info.version() >= GR_GL_VER(3, 0) &&
685 // ES3 only works with sized BGRA8 format if "GL_APPLE_texture_format_B GRA8888" enabled 682 // ES3 only works with sized BGRA8 format if "GL_APPLE_texture_format_B GRA8888" enabled
686 (kBGRA_8888_GrPixelConfig != textureConfig || !info.caps()->bgraIsInter nalFormat()))) { 683 (kBGRA_8888_GrPixelConfig != textureConfig || !info.caps()->bgraIsInter nalFormat()))) {
687 useSizedFormat = true; 684 useSizedFormat = true;
688 } 685 }
689 return useSizedFormat; 686 return useSizedFormat;
690 } 687 }
691 688
692 bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc, 689 bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc,
(...skipping 18 matching lines...) Expand all
711 size_t trimRowBytes = width * bpp; 708 size_t trimRowBytes = width * bpp;
712 709
713 // in case we need a temporary, trimmed copy of the src pixels 710 // in case we need a temporary, trimmed copy of the src pixels
714 #if defined(GOOGLE3) 711 #if defined(GOOGLE3)
715 // Stack frame size is limited in GOOGLE3. 712 // Stack frame size is limited in GOOGLE3.
716 SkAutoSMalloc<64 * 128> tempStorage; 713 SkAutoSMalloc<64 * 128> tempStorage;
717 #else 714 #else
718 SkAutoSMalloc<128 * 128> tempStorage; 715 SkAutoSMalloc<128 * 128> tempStorage;
719 #endif 716 #endif
720 717
721 // We currently lazily create MIPMAPs when the we see a draw with 718 bool useSizedFormat = use_sized_format_for_texture(this->ctxInfo(), desc.fCo nfig);
722 // GrTextureParams::kMipMap_FilterMode. Using texture storage requires that the
723 // MIP levels are all created when the texture is created. So for now we don 't use
724 // texture storage.
725 bool useTexStorage = false &&
726 isNewTexture &&
727 this->glCaps().texStorageSupport();
728
729 if (useTexStorage && kGL_GrGLStandard == this->glStandard()) {
730 // 565 is not a sized internal format on desktop GL. So on desktop with
731 // 565 we always use an unsized internal format to let the system pick
732 // the best sized format to convert the 565 data to. Since TexStorage
733 // only allows sized internal formats we will instead use TexImage2D.
734 useTexStorage = desc.fConfig != kRGB_565_GrPixelConfig;
735 }
736
737
738 bool useSizedFormat = use_sized_format_for_texture(useTexStorage, this->ctxI nfo(),
739 desc.fConfig);
740 719
741 // Internal format comes from the texture desc. 720 // Internal format comes from the texture desc.
742 GrGLenum internalFormat = useSizedFormat ? 721 GrGLenum internalFormat = useSizedFormat ?
743 fConfigTable[desc.fConfig].fSizedInternalFormat: 722 fConfigTable[desc.fConfig].fSizedInternalFormat:
744 fConfigTable[desc.fConfig].fBaseInternalFormat; 723 fConfigTable[desc.fConfig].fBaseInternalFormat;
745 724
746 // External format and type come from the upload data. 725 // External format and type come from the upload data.
747 GrGLenum externalFormat = fConfigTable[dataConfig].fExternalFormatForTexImag e; 726 GrGLenum externalFormat = fConfigTable[dataConfig].fExternalFormatForTexImag e;
748 GrGLenum externalType = fConfigTable[dataConfig].fExternalType; 727 GrGLenum externalType = fConfigTable[dataConfig].fExternalType;
749 728
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 // now point data to our copied version 771 // now point data to our copied version
793 data = tempStorage.get(); 772 data = tempStorage.get();
794 } 773 }
795 } 774 }
796 if (glFlipY) { 775 if (glFlipY) {
797 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_TRUE)); 776 GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_TRUE));
798 } 777 }
799 GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, config_alignment(dataConfig) )); 778 GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, config_alignment(dataConfig) ));
800 } 779 }
801 bool succeeded = true; 780 bool succeeded = true;
802 if (isNewTexture && 781 if (isNewTexture) {
803 0 == left && 0 == top && 782 if (data && !(0 == left && 0 == top && desc.fWidth == width && desc.fHei ght == height)) {
804 desc.fWidth == width && desc.fHeight == height) {
805 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
806 if (useTexStorage) {
807 // We never resize or change formats of textures.
808 GL_ALLOC_CALL(this->glInterface(),
809 TexStorage2D(target,
810 1, // levels
811 internalFormat,
812 desc.fWidth, desc.fHeight));
813 } else {
814 GL_ALLOC_CALL(this->glInterface(),
815 TexImage2D(target,
816 0, // level
817 internalFormat,
818 desc.fWidth, desc.fHeight,
819 0, // border
820 externalFormat, externalType,
821 data));
822 }
823 GrGLenum error = check_alloc_error(desc, this->glInterface());
824 if (error != GR_GL_NO_ERROR) {
825 succeeded = false; 783 succeeded = false;
826 } else { 784 } else {
827 // if we have data and we used TexStorage to create the texture, we 785 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
828 // now upload with TexSubImage. 786 GL_ALLOC_CALL(this->glInterface(), TexImage2D(target, 0, internalFor mat, desc.fWidth,
829 if (data && useTexStorage) { 787 desc.fHeight, 0, exte rnalFormat,
830 GL_CALL(TexSubImage2D(target, 788 externalType, data));
831 0, // level 789 GrGLenum error = check_alloc_error(desc, this->glInterface());
832 left, top, 790 if (error != GR_GL_NO_ERROR) {
833 width, height, 791 succeeded = false;
834 externalFormat, externalType,
835 data));
836 } 792 }
837 } 793 }
838 } else { 794 } else {
839 if (swFlipY || glFlipY) { 795 if (swFlipY || glFlipY) {
840 top = desc.fHeight - (top + height); 796 top = desc.fHeight - (top + height);
841 } 797 }
842 GL_CALL(TexSubImage2D(target, 798 GL_CALL(TexSubImage2D(target,
843 0, // level 799 0, // level
844 left, top, 800 left, top,
845 width, height, 801 width, height,
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1236 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1281 GR_GL_TEXTURE_WRAP_S, 1237 GR_GL_TEXTURE_WRAP_S,
1282 GR_GL_CLAMP_TO_EDGE)); 1238 GR_GL_CLAMP_TO_EDGE));
1283 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1239 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1284 GR_GL_TEXTURE_WRAP_T, 1240 GR_GL_TEXTURE_WRAP_T,
1285 GR_GL_CLAMP_TO_EDGE)); 1241 GR_GL_CLAMP_TO_EDGE));
1286 1242
1287 GrGLenum internalFormat = 0x0; // suppress warning 1243 GrGLenum internalFormat = 0x0; // suppress warning
1288 GrGLenum externalFormat = 0x0; // suppress warning 1244 GrGLenum externalFormat = 0x0; // suppress warning
1289 GrGLenum externalType = 0x0; // suppress warning 1245 GrGLenum externalType = 0x0; // suppress warning
1290 bool useSizedFormat = use_sized_format_for_texture(false, this->ctxInfo( ), config); 1246 bool useSizedFormat = use_sized_format_for_texture(this->ctxInfo(), conf ig);
1291 if (!this->configToGLFormats(config, useSizedFormat, &internalFormat, 1247 if (!this->configToGLFormats(config, useSizedFormat, &internalFormat,
1292 &externalFormat, &externalType)) { 1248 &externalFormat, &externalType)) {
1293 GL_CALL(DeleteTextures(1, &colorID)); 1249 GL_CALL(DeleteTextures(1, &colorID));
1294 return ConfigEntry::kUnsupported_StencilFormatIndex; 1250 return ConfigEntry::kUnsupported_StencilFormatIndex;
1295 } 1251 }
1296 1252
1297 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1253 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1298 GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D, 1254 GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D,
1299 0, internalFormat, 1255 0, internalFormat,
1300 kSize, 1256 kSize,
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3525 GL_CALL(BindTexture(info->fTarget, info->fID)); 3481 GL_CALL(BindTexture(info->fTarget, info->fID));
3526 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST )); 3482 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MAG_FILTER, GR_GL_NEAREST ));
3527 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST )); 3483 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_MIN_FILTER, GR_GL_NEAREST ));
3528 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_ED GE)); 3484 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_ED GE));
3529 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_ED GE)); 3485 GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_ED GE));
3530 3486
3531 GrGLenum internalFormat = 0x0; // suppress warning 3487 GrGLenum internalFormat = 0x0; // suppress warning
3532 GrGLenum externalFormat = 0x0; // suppress warning 3488 GrGLenum externalFormat = 0x0; // suppress warning
3533 GrGLenum externalType = 0x0; // suppress warning 3489 GrGLenum externalType = 0x0; // suppress warning
3534 3490
3535 bool useSizedFormat = use_sized_format_for_texture(false, this->ctxInfo(), c onfig); 3491 bool useSizedFormat = use_sized_format_for_texture(this->ctxInfo(), config);
3536 this->configToGLFormats(config, useSizedFormat, &internalFormat, &externalFo rmat, 3492 this->configToGLFormats(config, useSizedFormat, &internalFormat, &externalFo rmat,
3537 &externalType); 3493 &externalType);
3538 3494
3539 GL_CALL(TexImage2D(info->fTarget, 0, internalFormat, w, h, 0, externalFormat , 3495 GL_CALL(TexImage2D(info->fTarget, 0, internalFormat, w, h, 0, externalFormat ,
3540 externalType, pixels)); 3496 externalType, pixels));
3541 3497
3542 #ifdef SK_IGNORE_GL_TEXTURE_TARGET 3498 #ifdef SK_IGNORE_GL_TEXTURE_TARGET
3543 GrGLuint id = info->fID; 3499 GrGLuint id = info->fID;
3544 delete info; 3500 delete info;
3545 return id; 3501 return id;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
3633 this->setVertexArrayID(gpu, 0); 3589 this->setVertexArrayID(gpu, 0);
3634 } 3590 }
3635 int attrCount = gpu->glCaps().maxVertexAttributes(); 3591 int attrCount = gpu->glCaps().maxVertexAttributes();
3636 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3592 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3637 fDefaultVertexArrayAttribState.resize(attrCount); 3593 fDefaultVertexArrayAttribState.resize(attrCount);
3638 } 3594 }
3639 attribState = &fDefaultVertexArrayAttribState; 3595 attribState = &fDefaultVertexArrayAttribState;
3640 } 3596 }
3641 return attribState; 3597 return attribState;
3642 } 3598 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698