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

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

Issue 1001503002: Implement support for mixed sampled render targets (Closed) Base URL: https://skia.googlesource.com/skia.git@mix1
Patch Set: Fix build error related to isMultisamped renaming Created 5 years, 6 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.cpp ('k') | src/gpu/gl/GrGLRenderTarget.h » ('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 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 "GrGLStencilAttachment.h" 10 #include "GrGLStencilAttachment.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // On some devices this may have a perf hit. Also multiple render t argets are disabled 366 // On some devices this may have a perf hit. Also multiple render t argets are disabled
367 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM)); 367 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM));
368 } 368 }
369 fHWWriteToColor = kUnknown_TriState; 369 fHWWriteToColor = kUnknown_TriState;
370 // we only ever use lines in hairline mode 370 // we only ever use lines in hairline mode
371 GL_CALL(LineWidth(1)); 371 GL_CALL(LineWidth(1));
372 } 372 }
373 373
374 if (resetBits & kMSAAEnable_GrGLBackendState) { 374 if (resetBits & kMSAAEnable_GrGLBackendState) {
375 fMSAAEnabled = kUnknown_TriState; 375 fMSAAEnabled = kUnknown_TriState;
376
377 // In mixed samples mode coverage modulation allows the coverage to be c onverted to
378 // "opacity", which can then be blended into the color buffer to accompl ish antialiasing.
379 // Enable coverage modulation suitable for premultiplied alpha colors.
380 // This state has no effect when not rendering to a mixed sampled target .
381 if (this->glCaps().shaderCaps()->mixedSamplesSupport()) {
382 GL_CALL(CoverageModulation(GR_GL_RGBA));
383 }
376 } 384 }
377 385
378 fHWActiveTextureUnitIdx = -1; // invalid 386 fHWActiveTextureUnitIdx = -1; // invalid
379 387
380 if (resetBits & kTextureBinding_GrGLBackendState) { 388 if (resetBits & kTextureBinding_GrGLBackendState) {
381 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { 389 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) {
382 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; 390 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID;
383 } 391 }
384 } 392 }
385 393
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 852
845 static bool renderbuffer_storage_msaa(const GrGLContext& ctx, 853 static bool renderbuffer_storage_msaa(const GrGLContext& ctx,
846 int sampleCount, 854 int sampleCount,
847 GrGLenum format, 855 GrGLenum format,
848 int width, int height) { 856 int width, int height) {
849 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); 857 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
850 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); 858 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType());
851 switch (ctx.caps()->msFBOType()) { 859 switch (ctx.caps()->msFBOType()) {
852 case GrGLCaps::kDesktop_ARB_MSFBOType: 860 case GrGLCaps::kDesktop_ARB_MSFBOType:
853 case GrGLCaps::kDesktop_EXT_MSFBOType: 861 case GrGLCaps::kDesktop_EXT_MSFBOType:
862 case GrGLCaps::kMixedSamples_MSFBOType:
854 case GrGLCaps::kES_3_0_MSFBOType: 863 case GrGLCaps::kES_3_0_MSFBOType:
855 GL_ALLOC_CALL(ctx.interface(), 864 GL_ALLOC_CALL(ctx.interface(),
856 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, 865 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
857 sampleCount, 866 sampleCount,
858 format, 867 format,
859 width, height)); 868 width, height));
860 break; 869 break;
861 case GrGLCaps::kES_Apple_MSFBOType: 870 case GrGLCaps::kES_Apple_MSFBOType:
862 GL_ALLOC_CALL(ctx.interface(), 871 GL_ALLOC_CALL(ctx.interface(),
863 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, 872 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER,
(...skipping 17 matching lines...) Expand all
881 } 890 }
882 891
883 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, 892 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
884 GrGpuResource::LifeCycle lifeCycle, 893 GrGpuResource::LifeCycle lifeCycle,
885 GrGLuint texID, 894 GrGLuint texID,
886 GrGLRenderTarget::IDDesc* idDesc) { 895 GrGLRenderTarget::IDDesc* idDesc) {
887 idDesc->fMSColorRenderbufferID = 0; 896 idDesc->fMSColorRenderbufferID = 0;
888 idDesc->fRTFBOID = 0; 897 idDesc->fRTFBOID = 0;
889 idDesc->fTexFBOID = 0; 898 idDesc->fTexFBOID = 0;
890 idDesc->fLifeCycle = lifeCycle; 899 idDesc->fLifeCycle = lifeCycle;
900 idDesc->fSampleConfig = (GrGLCaps::kMixedSamples_MSFBOType == this->glCaps() .msFBOType() &&
901 desc.fSampleCnt > 0) ? GrRenderTarget::kStencil_Samp leConfig :
902 GrRenderTarget::kUnified_Samp leConfig;
891 903
892 GrGLenum status; 904 GrGLenum status;
893 905
894 GrGLenum msColorFormat = 0; // suppress warning 906 GrGLenum msColorFormat = 0; // suppress warning
895 907
896 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { 908 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) {
897 goto FAILED; 909 goto FAILED;
898 } 910 }
899 911
900 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); 912 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID));
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 } 1175 }
1164 } 1176 }
1165 1177
1166 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { 1178 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) {
1167 // All internally created RTs are also textures. We don't create 1179 // All internally created RTs are also textures. We don't create
1168 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . 1180 // SBs for a client's standalone RT (that is a RT that isn't also a texture) .
1169 SkASSERT(rt->asTexture()); 1181 SkASSERT(rt->asTexture());
1170 SkASSERT(width >= rt->width()); 1182 SkASSERT(width >= rt->width());
1171 SkASSERT(height >= rt->height()); 1183 SkASSERT(height >= rt->height());
1172 1184
1173 int samples = rt->numSamples(); 1185 int samples = rt->numStencilSamples();
1174 GrGLStencilAttachment::IDDesc sbDesc; 1186 GrGLStencilAttachment::IDDesc sbDesc;
1175 1187
1176 int stencilFmtCnt = this->glCaps().stencilFormats().count(); 1188 int stencilFmtCnt = this->glCaps().stencilFormats().count();
1177 for (int i = 0; i < stencilFmtCnt; ++i) { 1189 for (int i = 0; i < stencilFmtCnt; ++i) {
1178 if (!sbDesc.fRenderbufferID) { 1190 if (!sbDesc.fRenderbufferID) {
1179 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); 1191 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID));
1180 } 1192 }
1181 if (!sbDesc.fRenderbufferID) { 1193 if (!sbDesc.fRenderbufferID) {
1182 return false; 1194 return false;
1183 } 1195 }
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 stencilSettings, 2095 stencilSettings,
2084 GR_GL_FRONT_AND_BACK, 2096 GR_GL_FRONT_AND_BACK,
2085 GrStencilSettings::kFront_Face); 2097 GrStencilSettings::kFront_Face);
2086 } 2098 }
2087 } 2099 }
2088 fHWStencilSettings = stencilSettings; 2100 fHWStencilSettings = stencilSettings;
2089 } 2101 }
2090 } 2102 }
2091 2103
2092 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { 2104 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) {
2093 SkASSERT(!useHWAA || rt->isMultisampled()); 2105 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled());
2094 2106
2095 if (this->glCaps().multisampleDisableSupport()) { 2107 if (this->glCaps().multisampleDisableSupport()) {
2096 if (useHWAA) { 2108 if (useHWAA) {
2097 if (kYes_TriState != fMSAAEnabled) { 2109 if (kYes_TriState != fMSAAEnabled) {
2098 GL_CALL(Enable(GR_GL_MULTISAMPLE)); 2110 GL_CALL(Enable(GR_GL_MULTISAMPLE));
2099 fMSAAEnabled = kYes_TriState; 2111 fMSAAEnabled = kYes_TriState;
2100 } 2112 }
2101 } else { 2113 } else {
2102 if (kNo_TriState != fMSAAEnabled) { 2114 if (kNo_TriState != fMSAAEnabled) {
2103 GL_CALL(Disable(GR_GL_MULTISAMPLE)); 2115 GL_CALL(Disable(GR_GL_MULTISAMPLE));
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
3067 this->setVertexArrayID(gpu, 0); 3079 this->setVertexArrayID(gpu, 0);
3068 } 3080 }
3069 int attrCount = gpu->glCaps().maxVertexAttributes(); 3081 int attrCount = gpu->glCaps().maxVertexAttributes();
3070 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3082 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3071 fDefaultVertexArrayAttribState.resize(attrCount); 3083 fDefaultVertexArrayAttribState.resize(attrCount);
3072 } 3084 }
3073 attribState = &fDefaultVertexArrayAttribState; 3085 attribState = &fDefaultVertexArrayAttribState;
3074 } 3086 }
3075 return attribState; 3087 return attribState;
3076 } 3088 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGLRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698