OLD | NEW |
---|---|
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 // On some devices this may have a perf hit. Also multiple render t argets are disabled | 304 // On some devices this may have a perf hit. Also multiple render t argets are disabled |
305 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM)); | 305 GL_CALL(Enable(GR_GL_FETCH_PER_SAMPLE_ARM)); |
306 } | 306 } |
307 fHWWriteToColor = kUnknown_TriState; | 307 fHWWriteToColor = kUnknown_TriState; |
308 // we only ever use lines in hairline mode | 308 // we only ever use lines in hairline mode |
309 GL_CALL(LineWidth(1)); | 309 GL_CALL(LineWidth(1)); |
310 } | 310 } |
311 | 311 |
312 if (resetBits & kMSAAEnable_GrGLBackendState) { | 312 if (resetBits & kMSAAEnable_GrGLBackendState) { |
313 fMSAAEnabled = kUnknown_TriState; | 313 fMSAAEnabled = kUnknown_TriState; |
314 fCoverageModulationEnabled = kUnknown_TriState; | |
314 } | 315 } |
315 | 316 |
316 fHWActiveTextureUnitIdx = -1; // invalid | 317 fHWActiveTextureUnitIdx = -1; // invalid |
317 | 318 |
318 if (resetBits & kTextureBinding_GrGLBackendState) { | 319 if (resetBits & kTextureBinding_GrGLBackendState) { |
319 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { | 320 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { |
320 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; | 321 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; |
321 } | 322 } |
322 } | 323 } |
323 | 324 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 } | 441 } |
441 | 442 |
442 return texture; | 443 return texture; |
443 } | 444 } |
444 | 445 |
445 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) { | 446 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) { |
446 GrGLRenderTarget::IDDesc idDesc; | 447 GrGLRenderTarget::IDDesc idDesc; |
447 GrGLuint fboID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); | 448 GrGLuint fboID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); |
448 idDesc.fRenderFBO.reset(SkNEW_ARGS(GrGLFBO, (fboID))); | 449 idDesc.fRenderFBO.reset(SkNEW_ARGS(GrGLFBO, (fboID))); |
449 idDesc.fMSColorRenderbufferID = 0; | 450 idDesc.fMSColorRenderbufferID = 0; |
451 idDesc.fSampleConfig = wrapDesc.fSampleConfig; | |
450 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; | 452 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
451 | 453 |
452 GrSurfaceDesc desc; | 454 GrSurfaceDesc desc; |
453 desc.fConfig = wrapDesc.fConfig; | 455 desc.fConfig = wrapDesc.fConfig; |
454 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 456 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
455 desc.fWidth = wrapDesc.fWidth; | 457 desc.fWidth = wrapDesc.fWidth; |
456 desc.fHeight = wrapDesc.fHeight; | 458 desc.fHeight = wrapDesc.fHeight; |
457 desc.fSampleCnt = wrapDesc.fSampleCnt; | 459 desc.fSampleCnt = wrapDesc.fSampleCnt; |
458 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 460 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
459 | 461 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
787 | 789 |
788 static bool renderbuffer_storage_msaa(GrGLContext& ctx, | 790 static bool renderbuffer_storage_msaa(GrGLContext& ctx, |
789 int sampleCount, | 791 int sampleCount, |
790 GrGLenum format, | 792 GrGLenum format, |
791 int width, int height) { | 793 int width, int height) { |
792 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); | 794 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); |
793 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); | 795 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); |
794 switch (ctx.caps()->msFBOType()) { | 796 switch (ctx.caps()->msFBOType()) { |
795 case GrGLCaps::kDesktop_ARB_MSFBOType: | 797 case GrGLCaps::kDesktop_ARB_MSFBOType: |
796 case GrGLCaps::kDesktop_EXT_MSFBOType: | 798 case GrGLCaps::kDesktop_EXT_MSFBOType: |
799 case GrGLCaps::kStencil_MSFBOType: | |
797 case GrGLCaps::kES_3_0_MSFBOType: | 800 case GrGLCaps::kES_3_0_MSFBOType: |
798 GL_ALLOC_CALL(ctx.interface(), | 801 GL_ALLOC_CALL(ctx.interface(), |
799 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, | 802 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
800 sampleCount, | 803 sampleCount, |
801 format, | 804 format, |
802 width, height)); | 805 width, height)); |
803 break; | 806 break; |
804 case GrGLCaps::kES_Apple_MSFBOType: | 807 case GrGLCaps::kES_Apple_MSFBOType: |
805 GL_ALLOC_CALL(ctx.interface(), | 808 GL_ALLOC_CALL(ctx.interface(), |
806 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, | 809 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, |
(...skipping 14 matching lines...) Expand all Loading... | |
821 break; | 824 break; |
822 } | 825 } |
823 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; | 826 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; |
824 } | 827 } |
825 | 828 |
826 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID, | 829 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID, |
827 GrGLRenderTarget::IDDesc* idDesc) { | 830 GrGLRenderTarget::IDDesc* idDesc) { |
828 idDesc->fMSColorRenderbufferID = 0; | 831 idDesc->fMSColorRenderbufferID = 0; |
829 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : | 832 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
830 GrGpuResource::kUncached_LifeCycle; | 833 GrGpuResource::kUncached_LifeCycle; |
834 idDesc->fSampleConfig = GrGLCaps::kStencil_MSFBOType == | |
835 this->glCaps().msFBOType() ? kStencil_GrSampleConfig : | |
836 kUnified_GrSampleConfig ; | |
831 | 837 |
832 GrGLenum status; | 838 GrGLenum status; |
833 | 839 |
834 GrGLenum msColorFormat = 0; // suppress warning | 840 GrGLenum msColorFormat = 0; // suppress warning |
835 GrGLenum fboTarget = 0; // suppress warning | 841 GrGLenum fboTarget = 0; // suppress warning |
836 | 842 |
837 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { | 843 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { |
838 goto FAILED; | 844 goto FAILED; |
839 } | 845 } |
840 | 846 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1140 } | 1146 } |
1141 } | 1147 } |
1142 | 1148 |
1143 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) { | 1149 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) { |
1144 // All internally created RTs are also textures. We don't create | 1150 // All internally created RTs are also textures. We don't create |
1145 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . | 1151 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . |
1146 SkASSERT(rt->asTexture()); | 1152 SkASSERT(rt->asTexture()); |
1147 SkASSERT(width >= rt->width()); | 1153 SkASSERT(width >= rt->width()); |
1148 SkASSERT(height >= rt->height()); | 1154 SkASSERT(height >= rt->height()); |
1149 | 1155 |
1150 int samples = rt->numSamples(); | 1156 int samples = rt->numSamples(kStencil_GrSampleConfig); |
1151 GrGLStencilBuffer::IDDesc sbDesc; | 1157 GrGLStencilBuffer::IDDesc sbDesc; |
1152 | 1158 |
1153 int stencilFmtCnt = this->glCaps().stencilFormats().count(); | 1159 int stencilFmtCnt = this->glCaps().stencilFormats().count(); |
1154 for (int i = 0; i < stencilFmtCnt; ++i) { | 1160 for (int i = 0; i < stencilFmtCnt; ++i) { |
1155 if (!sbDesc.fRenderbufferID) { | 1161 if (!sbDesc.fRenderbufferID) { |
1156 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); | 1162 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); |
1157 } | 1163 } |
1158 if (!sbDesc.fRenderbufferID) { | 1164 if (!sbDesc.fRenderbufferID) { |
1159 return false; | 1165 return false; |
1160 } | 1166 } |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2088 stencilSettings, | 2094 stencilSettings, |
2089 GR_GL_FRONT_AND_BACK, | 2095 GR_GL_FRONT_AND_BACK, |
2090 GrStencilSettings::kFront_Face); | 2096 GrStencilSettings::kFront_Face); |
2091 } | 2097 } |
2092 } | 2098 } |
2093 fHWStencilSettings = stencilSettings; | 2099 fHWStencilSettings = stencilSettings; |
2094 } | 2100 } |
2095 } | 2101 } |
2096 | 2102 |
2097 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2103 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
2098 SkASSERT(!useHWAA || rt->isMultisampled()); | 2104 SkASSERT(!useHWAA || rt->isMultisampled(kStencil_GrSampleConfig)); |
2099 | 2105 |
2100 if (kGL_GrGLStandard == this->glStandard()) { | 2106 if (kGL_GrGLStandard == this->glStandard() || |
2107 this->glCaps().fbMixedSamplesSupport()) { | |
2101 if (useHWAA) { | 2108 if (useHWAA) { |
2102 if (kYes_TriState != fMSAAEnabled) { | 2109 if (kYes_TriState != fMSAAEnabled) { |
2103 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2110 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
2104 fMSAAEnabled = kYes_TriState; | 2111 fMSAAEnabled = kYes_TriState; |
2105 } | 2112 } |
2106 } else { | 2113 } else { |
2107 if (kNo_TriState != fMSAAEnabled) { | 2114 if (kNo_TriState != fMSAAEnabled) { |
2108 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2115 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
2109 fMSAAEnabled = kNo_TriState; | 2116 fMSAAEnabled = kNo_TriState; |
2110 } | 2117 } |
2111 } | 2118 } |
2112 } | 2119 } |
2120 if (this->glCaps().fbMixedSamplesSupport()) { | |
2121 if (useHWAA && kStencil_GrSampleConfig == rt->sampleConfig()) { | |
2122 if (kYes_TriState != fCoverageModulationEnabled) { | |
2123 GL_CALL(CoverageModulation(GR_GL_RGBA)); | |
Chris Dalton
2015/03/17 00:39:35
I verified with Brian that Skia always writes prem
| |
2124 fCoverageModulationEnabled = kYes_TriState; | |
2125 } | |
2126 } else { | |
2127 if (kNo_TriState != fCoverageModulationEnabled) { | |
2128 GL_CALL(CoverageModulation(GR_GL_NONE)); | |
2129 fCoverageModulationEnabled = kNo_TriState; | |
2130 } | |
2131 } | |
2132 } | |
2113 } | 2133 } |
2114 | 2134 |
2115 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { | 2135 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { |
2116 // Any optimization to disable blending should have already been applied and | 2136 // Any optimization to disable blending should have already been applied and |
2117 // tweaked the coeffs to (1, 0). | 2137 // tweaked the coeffs to (1, 0). |
2118 | 2138 |
2119 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; | 2139 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; |
2120 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; | 2140 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; |
2121 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo eff; | 2141 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo eff; |
2122 if (blendOff) { | 2142 if (blendOff) { |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2813 this->setVertexArrayID(gpu, 0); | 2833 this->setVertexArrayID(gpu, 0); |
2814 } | 2834 } |
2815 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2835 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2816 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2836 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2817 fDefaultVertexArrayAttribState.resize(attrCount); | 2837 fDefaultVertexArrayAttribState.resize(attrCount); |
2818 } | 2838 } |
2819 attribState = &fDefaultVertexArrayAttribState; | 2839 attribState = &fDefaultVertexArrayAttribState; |
2820 } | 2840 } |
2821 return attribState; | 2841 return attribState; |
2822 } | 2842 } |
OLD | NEW |