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

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: GrRenderTarget::BufferBits, BackendRTDesc::fFlags and hasMixedSamplesModulation Created 5 years, 8 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
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 "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // On some devices this may have a perf hit. Also multiple render t argets are disabled 294 // On some devices this may have a perf hit. Also multiple render t argets are disabled
295 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM)); 295 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM));
296 } 296 }
297 fHWWriteToColor = kUnknown_TriState; 297 fHWWriteToColor = kUnknown_TriState;
298 // we only ever use lines in hairline mode 298 // we only ever use lines in hairline mode
299 GL_CALL(LineWidth(1)); 299 GL_CALL(LineWidth(1));
300 } 300 }
301 301
302 if (resetBits & kMSAAEnable_GrGLBackendState) { 302 if (resetBits & kMSAAEnable_GrGLBackendState) {
303 fMSAAEnabled = kUnknown_TriState; 303 fMSAAEnabled = kUnknown_TriState;
304 fCoverageModulationEnabled = kUnknown_TriState;
304 } 305 }
305 306
306 fHWActiveTextureUnitIdx = -1; // invalid 307 fHWActiveTextureUnitIdx = -1; // invalid
307 308
308 if (resetBits & kTextureBinding_GrGLBackendState) { 309 if (resetBits & kTextureBinding_GrGLBackendState) {
309 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { 310 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) {
310 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; 311 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID;
311 } 312 }
312 } 313 }
313 314
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 429 }
429 430
430 return texture; 431 return texture;
431 } 432 }
432 433
433 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) { 434 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) {
434 GrGLRenderTarget::IDDesc idDesc; 435 GrGLRenderTarget::IDDesc idDesc;
435 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); 436 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle);
436 idDesc.fMSColorRenderbufferID = 0; 437 idDesc.fMSColorRenderbufferID = 0;
437 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; 438 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
439 idDesc.fSampleConfig = (wrapDesc.fFlags & kStencilMSAAOnly_GrBackendRenderTa rgetFlags) ?
440 GrRenderTarget::kStencil_SampleConfig : GrRenderTarge t::kUnified_SampleConfig;
Chris Dalton 2015/04/07 23:48:23 Looks like we broke 100 columns...
vbuzinov 2015/04/08 12:05:30 Done.
438 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; 441 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle;
439 442
440 GrSurfaceDesc desc; 443 GrSurfaceDesc desc;
441 desc.fConfig = wrapDesc.fConfig; 444 desc.fConfig = wrapDesc.fConfig;
442 desc.fFlags = kCheckAllocation_GrSurfaceFlag; 445 desc.fFlags = kCheckAllocation_GrSurfaceFlag;
443 desc.fWidth = wrapDesc.fWidth; 446 desc.fWidth = wrapDesc.fWidth;
444 desc.fHeight = wrapDesc.fHeight; 447 desc.fHeight = wrapDesc.fHeight;
445 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); 448 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() );
446 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); 449 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true);
447 450
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 778
776 static bool renderbuffer_storage_msaa(GrGLContext& ctx, 779 static bool renderbuffer_storage_msaa(GrGLContext& ctx,
777 int sampleCount, 780 int sampleCount,
778 GrGLenum format, 781 GrGLenum format,
779 int width, int height) { 782 int width, int height) {
780 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); 783 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface());
781 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); 784 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType());
782 switch (ctx.caps()->msFBOType()) { 785 switch (ctx.caps()->msFBOType()) {
783 case GrGLCaps::kDesktop_ARB_MSFBOType: 786 case GrGLCaps::kDesktop_ARB_MSFBOType:
784 case GrGLCaps::kDesktop_EXT_MSFBOType: 787 case GrGLCaps::kDesktop_EXT_MSFBOType:
788 case GrGLCaps::kMixedSamples_MSFBOType:
785 case GrGLCaps::kES_3_0_MSFBOType: 789 case GrGLCaps::kES_3_0_MSFBOType:
786 GL_ALLOC_CALL(ctx.interface(), 790 GL_ALLOC_CALL(ctx.interface(),
787 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, 791 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
788 sampleCount, 792 sampleCount,
789 format, 793 format,
790 width, height)); 794 width, height));
791 break; 795 break;
792 case GrGLCaps::kES_Apple_MSFBOType: 796 case GrGLCaps::kES_Apple_MSFBOType:
793 GL_ALLOC_CALL(ctx.interface(), 797 GL_ALLOC_CALL(ctx.interface(),
794 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, 798 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER,
(...skipping 16 matching lines...) Expand all
811 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); 815 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));
812 } 816 }
813 817
814 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID, 818 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID,
815 GrGLRenderTarget::IDDesc* idDesc) { 819 GrGLRenderTarget::IDDesc* idDesc) {
816 idDesc->fMSColorRenderbufferID = 0; 820 idDesc->fMSColorRenderbufferID = 0;
817 idDesc->fRTFBOID = 0; 821 idDesc->fRTFBOID = 0;
818 idDesc->fTexFBOID = 0; 822 idDesc->fTexFBOID = 0;
819 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : 823 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle :
820 GrGpuResource::kUncached_LifeCycle; 824 GrGpuResource::kUncached_LifeCycle;
825 idDesc->fSampleConfig = GrGLCaps::kMixedSamples_MSFBOType ==
826 this->glCaps().msFBOType() ? GrRenderTarget::kStenci l_SampleConfig :
827 GrRenderTarget::kUnifie d_SampleConfig;
821 828
822 GrGLenum status; 829 GrGLenum status;
823 830
824 GrGLenum msColorFormat = 0; // suppress warning 831 GrGLenum msColorFormat = 0; // suppress warning
825 832
826 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { 833 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) {
827 goto FAILED; 834 goto FAILED;
828 } 835 }
829 836
830 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); 837 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 } 1139 }
1133 } 1140 }
1134 1141
1135 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) { 1142 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) {
1136 // All internally created RTs are also textures. We don't create 1143 // All internally created RTs are also textures. We don't create
1137 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . 1144 // SBs for a client's standalone RT (that is a RT that isn't also a texture) .
1138 SkASSERT(rt->asTexture()); 1145 SkASSERT(rt->asTexture());
1139 SkASSERT(width >= rt->width()); 1146 SkASSERT(width >= rt->width());
1140 SkASSERT(height >= rt->height()); 1147 SkASSERT(height >= rt->height());
1141 1148
1142 int samples = rt->numSamples(); 1149 int samples = rt->numSamples(GrRenderTarget::BufferBits::kStencil_BufferBit) ;
1143 GrGLStencilBuffer::IDDesc sbDesc; 1150 GrGLStencilBuffer::IDDesc sbDesc;
1144 1151
1145 int stencilFmtCnt = this->glCaps().stencilFormats().count(); 1152 int stencilFmtCnt = this->glCaps().stencilFormats().count();
1146 for (int i = 0; i < stencilFmtCnt; ++i) { 1153 for (int i = 0; i < stencilFmtCnt; ++i) {
1147 if (!sbDesc.fRenderbufferID) { 1154 if (!sbDesc.fRenderbufferID) {
1148 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); 1155 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID));
1149 } 1156 }
1150 if (!sbDesc.fRenderbufferID) { 1157 if (!sbDesc.fRenderbufferID) {
1151 return false; 1158 return false;
1152 } 1159 }
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 stencilSettings, 2096 stencilSettings,
2090 GR_GL_FRONT_AND_BACK, 2097 GR_GL_FRONT_AND_BACK,
2091 GrStencilSettings::kFront_Face); 2098 GrStencilSettings::kFront_Face);
2092 } 2099 }
2093 } 2100 }
2094 fHWStencilSettings = stencilSettings; 2101 fHWStencilSettings = stencilSettings;
2095 } 2102 }
2096 } 2103 }
2097 2104
2098 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { 2105 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) {
2099 SkASSERT(!useHWAA || rt->isMultisampled()); 2106 SkASSERT(!useHWAA || rt->isMultisampled(GrRenderTarget::BufferBits::kAny_Buf ferBits));
2100 2107
2101 if (kGL_GrGLStandard == this->glStandard()) { 2108 if (kGL_GrGLStandard == this->glStandard() ||
2109 this->glCaps().fbMixedSamplesSupport()) {
2102 if (useHWAA) { 2110 if (useHWAA) {
2103 if (kYes_TriState != fMSAAEnabled) { 2111 if (kYes_TriState != fMSAAEnabled) {
2104 GL_CALL(Enable(GR_GL_MULTISAMPLE)); 2112 GL_CALL(Enable(GR_GL_MULTISAMPLE));
Mark Kilgard 2015/04/08 03:20:09 warning: enabling/disabling GL_MULTISAMPLE is not
vbuzinov 2015/04/08 12:05:30 Doesn't look like there was an explicit check for
2105 fMSAAEnabled = kYes_TriState; 2113 fMSAAEnabled = kYes_TriState;
2106 } 2114 }
2107 } else { 2115 } else {
2108 if (kNo_TriState != fMSAAEnabled) { 2116 if (kNo_TriState != fMSAAEnabled) {
2109 GL_CALL(Disable(GR_GL_MULTISAMPLE)); 2117 GL_CALL(Disable(GR_GL_MULTISAMPLE));
2110 fMSAAEnabled = kNo_TriState; 2118 fMSAAEnabled = kNo_TriState;
2111 } 2119 }
2112 } 2120 }
2113 } 2121 }
2122 if (this->glCaps().fbMixedSamplesSupport()) {
2123 if (useHWAA && GrRenderTarget::kStencil_SampleConfig == rt->sampleConfig ()) {
2124 if (kYes_TriState != fCoverageModulationEnabled) {
Mark Kilgard 2015/04/08 03:20:09 ...technically this mode isn't an enable though Sk
2125 GL_CALL(CoverageModulation(GR_GL_RGBA));
2126 fCoverageModulationEnabled = kYes_TriState;
2127 }
2128 } else {
2129 if (kNo_TriState != fCoverageModulationEnabled) {
2130 GL_CALL(CoverageModulation(GR_GL_NONE));
2131 fCoverageModulationEnabled = kNo_TriState;
2132 }
2133 }
2134 }
2114 } 2135 }
2115 2136
2116 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { 2137 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) {
2117 // Any optimization to disable blending should have already been applied and 2138 // Any optimization to disable blending should have already been applied and
2118 // tweaked the coeffs to (1, 0). 2139 // tweaked the coeffs to (1, 0).
2119 2140
2120 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; 2141 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
2121 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; 2142 GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
2122 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo eff; 2143 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo eff;
2123 if (blendOff) { 2144 if (blendOff) {
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2816 this->setVertexArrayID(gpu, 0); 2837 this->setVertexArrayID(gpu, 0);
2817 } 2838 }
2818 int attrCount = gpu->glCaps().maxVertexAttributes(); 2839 int attrCount = gpu->glCaps().maxVertexAttributes();
2819 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2840 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2820 fDefaultVertexArrayAttribState.resize(attrCount); 2841 fDefaultVertexArrayAttribState.resize(attrCount);
2821 } 2842 }
2822 attribState = &fDefaultVertexArrayAttribState; 2843 attribState = &fDefaultVertexArrayAttribState;
2823 } 2844 }
2824 return attribState; 2845 return attribState;
2825 } 2846 }
OLDNEW
« src/gpu/gl/GrGLGpu.h ('K') | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLRenderTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698