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

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

Issue 1533903004: Remove GrGLGpu::configToGLFormats (Closed) Base URL: https://skia.googlesource.com/skia.git@rmc2glcalls
Patch Set: fix compile error 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 | « src/gpu/gl/GrGLGpu.h ('k') | 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 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 idDesc->fMSColorRenderbufferID = 0; 906 idDesc->fMSColorRenderbufferID = 0;
907 idDesc->fRTFBOID = 0; 907 idDesc->fRTFBOID = 0;
908 idDesc->fTexFBOID = 0; 908 idDesc->fTexFBOID = 0;
909 idDesc->fLifeCycle = lifeCycle; 909 idDesc->fLifeCycle = lifeCycle;
910 idDesc->fSampleConfig = (GrGLCaps::kMixedSamples_MSFBOType == this->glCaps() .msFBOType() && 910 idDesc->fSampleConfig = (GrGLCaps::kMixedSamples_MSFBOType == this->glCaps() .msFBOType() &&
911 desc.fSampleCnt > 0) ? GrRenderTarget::kStencil_Samp leConfig : 911 desc.fSampleCnt > 0) ? GrRenderTarget::kStencil_Samp leConfig :
912 GrRenderTarget::kUnified_Samp leConfig; 912 GrRenderTarget::kUnified_Samp leConfig;
913 913
914 GrGLenum status; 914 GrGLenum status;
915 915
916 GrGLenum msColorFormat = 0; // suppress warning 916 GrGLenum colorRenderbufferFormat = 0; // suppress warning
917 917
918 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { 918 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) {
919 goto FAILED; 919 goto FAILED;
920 } 920 }
921 921
922 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); 922 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID));
923 if (!idDesc->fTexFBOID) { 923 if (!idDesc->fTexFBOID) {
924 goto FAILED; 924 goto FAILED;
925 } 925 }
926 926
927
928 // If we are using multisampling we will create two FBOS. We render to one a nd then resolve to 927 // If we are using multisampling we will create two FBOS. We render to one a nd then resolve to
929 // the texture bound to the other. The exception is the IMG multisample exte nsion. With this 928 // the texture bound to the other. The exception is the IMG multisample exte nsion. With this
930 // extension the texture is multisampled when rendered to and then auto-reso lves it when it is 929 // extension the texture is multisampled when rendered to and then auto-reso lves it when it is
931 // rendered from. 930 // rendered from.
932 if (desc.fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) { 931 if (desc.fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) {
933 GL_CALL(GenFramebuffers(1, &idDesc->fRTFBOID)); 932 GL_CALL(GenFramebuffers(1, &idDesc->fRTFBOID));
934 GL_CALL(GenRenderbuffers(1, &idDesc->fMSColorRenderbufferID)); 933 GL_CALL(GenRenderbuffers(1, &idDesc->fMSColorRenderbufferID));
935 if (!idDesc->fRTFBOID || 934 if (!idDesc->fRTFBOID ||
936 !idDesc->fMSColorRenderbufferID || 935 !idDesc->fMSColorRenderbufferID) {
937 !this->configToGLFormats(desc.fConfig,
938 // ES2 and ES3 require sized internal forma ts for rb storage.
939 kGLES_GrGLStandard == this->glStandard(),
940 &msColorFormat,
941 nullptr,
942 nullptr)) {
943 goto FAILED; 936 goto FAILED;
944 } 937 }
938 // All ES versions (thus far) require sized internal formats for render buffers.
939 // TODO: Always use sized internal format?
940 // If this rule gets more complicated, add a field to ConfigEntry rather than logic here.
941 colorRenderbufferFormat = kGLES_GrGLStandard == this->glStandard() ?
942 fConfigTable[desc.fConfig].fSize dInternalFormat :
943 fConfigTable[desc.fConfig].fBase InternalFormat;
945 } else { 944 } else {
946 idDesc->fRTFBOID = idDesc->fTexFBOID; 945 idDesc->fRTFBOID = idDesc->fTexFBOID;
947 } 946 }
948 947
949 // below here we may bind the FBO 948 // below here we may bind the FBO
950 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 949 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
951 if (idDesc->fRTFBOID != idDesc->fTexFBOID) { 950 if (idDesc->fRTFBOID != idDesc->fTexFBOID) {
952 SkASSERT(desc.fSampleCnt > 0); 951 SkASSERT(desc.fSampleCnt > 0);
953 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, idDesc->fMSColorRenderbuffe rID)); 952 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, idDesc->fMSColorRenderbuffe rID));
954 if (!renderbuffer_storage_msaa(*fGLContext, 953 if (!renderbuffer_storage_msaa(*fGLContext,
955 desc.fSampleCnt, 954 desc.fSampleCnt,
956 msColorFormat, 955 colorRenderbufferFormat,
957 desc.fWidth, desc.fHeight)) { 956 desc.fWidth, desc.fHeight)) {
958 goto FAILED; 957 goto FAILED;
959 } 958 }
960 fStats.incRenderTargetBinds(); 959 fStats.incRenderTargetBinds();
961 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fRTFBOID)); 960 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fRTFBOID));
962 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 961 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
963 GR_GL_COLOR_ATTACHMENT0, 962 GR_GL_COLOR_ATTACHMENT0,
964 GR_GL_RENDERBUFFER, 963 GR_GL_RENDERBUFFER,
965 idDesc->fMSColorRenderbufferID)); 964 idDesc->fMSColorRenderbufferID));
966 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) || 965 if ((desc.fFlags & kCheckAllocation_GrSurfaceFlag) ||
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 ConfigEntry defaultEntry; 2747 ConfigEntry defaultEntry;
2749 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 2748 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
2750 SkASSERT(defaultEntry.fBaseInternalFormat != fConfigTable[i].fBaseIntern alFormat); 2749 SkASSERT(defaultEntry.fBaseInternalFormat != fConfigTable[i].fBaseIntern alFormat);
2751 SkASSERT(defaultEntry.fSizedInternalFormat != fConfigTable[i].fSizedInte rnalFormat); 2750 SkASSERT(defaultEntry.fSizedInternalFormat != fConfigTable[i].fSizedInte rnalFormat);
2752 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fExternalFormat ); 2751 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fExternalFormat );
2753 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fExternalType); 2752 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fExternalType);
2754 } 2753 }
2755 #endif 2754 #endif
2756 } 2755 }
2757 2756
2758 bool GrGLGpu::configToGLFormats(GrPixelConfig config,
2759 bool getSizedInternalFormat,
2760 GrGLenum* internalFormat,
2761 GrGLenum* externalFormat,
2762 GrGLenum* externalType) const {
2763 if(!this->glCaps().isConfigTexturable(config)) {
2764 return false;
2765 }
2766
2767 if (nullptr != internalFormat) {
2768 if (getSizedInternalFormat) {
2769 *internalFormat = fConfigTable[config].fSizedInternalFormat;
2770 } else {
2771 *internalFormat = fConfigTable[config].fBaseInternalFormat;
2772 }
2773 }
2774 if (nullptr != externalFormat) {
2775 *externalFormat = fConfigTable[config].fExternalFormat;
2776 }
2777 if (nullptr != externalType) {
2778 *externalType = fConfigTable[config].fExternalType;
2779 }
2780
2781 return true;
2782 }
2783
2784 void GrGLGpu::setTextureUnit(int unit) { 2757 void GrGLGpu::setTextureUnit(int unit) {
2785 SkASSERT(unit >= 0 && unit < fHWBoundTextureUniqueIDs.count()); 2758 SkASSERT(unit >= 0 && unit < fHWBoundTextureUniqueIDs.count());
2786 if (unit != fHWActiveTextureUnitIdx) { 2759 if (unit != fHWActiveTextureUnitIdx) {
2787 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); 2760 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit));
2788 fHWActiveTextureUnitIdx = unit; 2761 fHWActiveTextureUnitIdx = unit;
2789 } 2762 }
2790 } 2763 }
2791 2764
2792 void GrGLGpu::setScratchTextureUnit() { 2765 void GrGLGpu::setScratchTextureUnit() {
2793 // Bind the last texture unit since it is the least likely to be used by GrG LProgram. 2766 // Bind the last texture unit since it is the least likely to be used by GrG LProgram.
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
3576 this->setVertexArrayID(gpu, 0); 3549 this->setVertexArrayID(gpu, 0);
3577 } 3550 }
3578 int attrCount = gpu->glCaps().maxVertexAttributes(); 3551 int attrCount = gpu->glCaps().maxVertexAttributes();
3579 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3552 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3580 fDefaultVertexArrayAttribState.resize(attrCount); 3553 fDefaultVertexArrayAttribState.resize(attrCount);
3581 } 3554 }
3582 attribState = &fDefaultVertexArrayAttribState; 3555 attribState = &fDefaultVertexArrayAttribState;
3583 } 3556 }
3584 return attribState; 3557 return attribState;
3585 } 3558 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698