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 "GrGLStencilAttachment.h" | 10 #include "GrGLStencilAttachment.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 : |
| 441 GrRenderTarget::kUnified_SampleConfig; |
438 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; | 442 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
439 | 443 |
440 GrSurfaceDesc desc; | 444 GrSurfaceDesc desc; |
441 desc.fConfig = wrapDesc.fConfig; | 445 desc.fConfig = wrapDesc.fConfig; |
442 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 446 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
443 desc.fWidth = wrapDesc.fWidth; | 447 desc.fWidth = wrapDesc.fWidth; |
444 desc.fHeight = wrapDesc.fHeight; | 448 desc.fHeight = wrapDesc.fHeight; |
445 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()
); | 449 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount()
); |
446 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 450 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
447 | 451 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 | 779 |
776 static bool renderbuffer_storage_msaa(GrGLContext& ctx, | 780 static bool renderbuffer_storage_msaa(GrGLContext& ctx, |
777 int sampleCount, | 781 int sampleCount, |
778 GrGLenum format, | 782 GrGLenum format, |
779 int width, int height) { | 783 int width, int height) { |
780 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); | 784 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); |
781 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); | 785 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); |
782 switch (ctx.caps()->msFBOType()) { | 786 switch (ctx.caps()->msFBOType()) { |
783 case GrGLCaps::kDesktop_ARB_MSFBOType: | 787 case GrGLCaps::kDesktop_ARB_MSFBOType: |
784 case GrGLCaps::kDesktop_EXT_MSFBOType: | 788 case GrGLCaps::kDesktop_EXT_MSFBOType: |
| 789 case GrGLCaps::kMixedSamples_MSFBOType: |
785 case GrGLCaps::kES_3_0_MSFBOType: | 790 case GrGLCaps::kES_3_0_MSFBOType: |
786 GL_ALLOC_CALL(ctx.interface(), | 791 GL_ALLOC_CALL(ctx.interface(), |
787 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, | 792 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
788 sampleCount, | 793 sampleCount, |
789 format, | 794 format, |
790 width, height)); | 795 width, height)); |
791 break; | 796 break; |
792 case GrGLCaps::kES_Apple_MSFBOType: | 797 case GrGLCaps::kES_Apple_MSFBOType: |
793 GL_ALLOC_CALL(ctx.interface(), | 798 GL_ALLOC_CALL(ctx.interface(), |
794 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB
UFFER, | 799 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB
UFFER, |
(...skipping 16 matching lines...) Expand all Loading... |
811 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); | 816 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface())); |
812 } | 817 } |
813 | 818 |
814 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted
, GrGLuint texID, | 819 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted
, GrGLuint texID, |
815 GrGLRenderTarget::IDDesc* idDesc) { | 820 GrGLRenderTarget::IDDesc* idDesc) { |
816 idDesc->fMSColorRenderbufferID = 0; | 821 idDesc->fMSColorRenderbufferID = 0; |
817 idDesc->fRTFBOID = 0; | 822 idDesc->fRTFBOID = 0; |
818 idDesc->fTexFBOID = 0; | 823 idDesc->fTexFBOID = 0; |
819 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : | 824 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
820 GrGpuResource::kUncached_LifeCycle; | 825 GrGpuResource::kUncached_LifeCycle; |
| 826 idDesc->fSampleConfig = GrGLCaps::kMixedSamples_MSFBOType == |
| 827 this->glCaps().msFBOType() ? GrRenderTarget::kStenci
l_SampleConfig : |
| 828 GrRenderTarget::kUnifie
d_SampleConfig; |
821 | 829 |
822 GrGLenum status; | 830 GrGLenum status; |
823 | 831 |
824 GrGLenum msColorFormat = 0; // suppress warning | 832 GrGLenum msColorFormat = 0; // suppress warning |
825 | 833 |
826 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO
Type()) { | 834 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO
Type()) { |
827 goto FAILED; | 835 goto FAILED; |
828 } | 836 } |
829 | 837 |
830 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); | 838 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 } | 1140 } |
1133 } | 1141 } |
1134 | 1142 |
1135 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid
th, int height) { | 1143 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid
th, int height) { |
1136 // All internally created RTs are also textures. We don't create | 1144 // 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)
. | 1145 // SBs for a client's standalone RT (that is a RT that isn't also a texture)
. |
1138 SkASSERT(rt->asTexture()); | 1146 SkASSERT(rt->asTexture()); |
1139 SkASSERT(width >= rt->width()); | 1147 SkASSERT(width >= rt->width()); |
1140 SkASSERT(height >= rt->height()); | 1148 SkASSERT(height >= rt->height()); |
1141 | 1149 |
1142 int samples = rt->numSamples(); | 1150 int samples = rt->numSamples(GrRenderTarget::kStencil_BufferBit); |
1143 GrGLStencilAttachment::IDDesc sbDesc; | 1151 GrGLStencilAttachment::IDDesc sbDesc; |
1144 | 1152 |
1145 int stencilFmtCnt = this->glCaps().stencilFormats().count(); | 1153 int stencilFmtCnt = this->glCaps().stencilFormats().count(); |
1146 for (int i = 0; i < stencilFmtCnt; ++i) { | 1154 for (int i = 0; i < stencilFmtCnt; ++i) { |
1147 if (!sbDesc.fRenderbufferID) { | 1155 if (!sbDesc.fRenderbufferID) { |
1148 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); | 1156 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); |
1149 } | 1157 } |
1150 if (!sbDesc.fRenderbufferID) { | 1158 if (!sbDesc.fRenderbufferID) { |
1151 return false; | 1159 return false; |
1152 } | 1160 } |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 stencilSettings, | 2097 stencilSettings, |
2090 GR_GL_FRONT_AND_BACK, | 2098 GR_GL_FRONT_AND_BACK, |
2091 GrStencilSettings::kFront_Face); | 2099 GrStencilSettings::kFront_Face); |
2092 } | 2100 } |
2093 } | 2101 } |
2094 fHWStencilSettings = stencilSettings; | 2102 fHWStencilSettings = stencilSettings; |
2095 } | 2103 } |
2096 } | 2104 } |
2097 | 2105 |
2098 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2106 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
2099 SkASSERT(!useHWAA || rt->isMultisampled()); | 2107 SkASSERT(!useHWAA || rt->isMultisampled(GrRenderTarget::kAny_BufferBits)); |
2100 | 2108 |
2101 if (kGL_GrGLStandard == this->glStandard()) { | 2109 if (kGL_GrGLStandard == this->glStandard() || |
| 2110 this->glCaps().fbMixedSamplesSupport()) { |
2102 if (useHWAA) { | 2111 if (useHWAA) { |
2103 if (kYes_TriState != fMSAAEnabled) { | 2112 if (kYes_TriState != fMSAAEnabled) { |
2104 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2113 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
2105 fMSAAEnabled = kYes_TriState; | 2114 fMSAAEnabled = kYes_TriState; |
2106 } | 2115 } |
2107 } else { | 2116 } else { |
2108 if (kNo_TriState != fMSAAEnabled) { | 2117 if (kNo_TriState != fMSAAEnabled) { |
2109 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2118 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
2110 fMSAAEnabled = kNo_TriState; | 2119 fMSAAEnabled = kNo_TriState; |
2111 } | 2120 } |
2112 } | 2121 } |
2113 } | 2122 } |
| 2123 if (this->glCaps().fbMixedSamplesSupport()) { |
| 2124 if (useHWAA && GrRenderTarget::kStencil_SampleConfig == rt->sampleConfig
()) { |
| 2125 if (kYes_TriState != fCoverageModulationEnabled) { |
| 2126 GL_CALL(CoverageModulation(GR_GL_RGBA)); |
| 2127 fCoverageModulationEnabled = kYes_TriState; |
| 2128 } |
| 2129 } else { |
| 2130 if (kNo_TriState != fCoverageModulationEnabled) { |
| 2131 GL_CALL(CoverageModulation(GR_GL_NONE)); |
| 2132 fCoverageModulationEnabled = kNo_TriState; |
| 2133 } |
| 2134 } |
| 2135 } |
2114 } | 2136 } |
2115 | 2137 |
2116 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { | 2138 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { |
2117 // Any optimization to disable blending should have already been applied and | 2139 // Any optimization to disable blending should have already been applied and |
2118 // tweaked the coeffs to (1, 0). | 2140 // tweaked the coeffs to (1, 0). |
2119 | 2141 |
2120 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; | 2142 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; |
2121 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; | 2143 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; |
2122 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; | 2144 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; |
2123 if (blendOff) { | 2145 if (blendOff) { |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2816 this->setVertexArrayID(gpu, 0); | 2838 this->setVertexArrayID(gpu, 0); |
2817 } | 2839 } |
2818 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2840 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2819 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2841 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2820 fDefaultVertexArrayAttribState.resize(attrCount); | 2842 fDefaultVertexArrayAttribState.resize(attrCount); |
2821 } | 2843 } |
2822 attribState = &fDefaultVertexArrayAttribState; | 2844 attribState = &fDefaultVertexArrayAttribState; |
2823 } | 2845 } |
2824 return attribState; | 2846 return attribState; |
2825 } | 2847 } |
OLD | NEW |