Chromium Code Reviews| 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 fCoverageModulationEnabled = kUnknown_TriState; | |
|
Chris Dalton
2015/06/09 17:39:51
At this point we can just call:
glCoverageModula
| |
| 376 } | 377 } |
| 377 | 378 |
| 378 fHWActiveTextureUnitIdx = -1; // invalid | 379 fHWActiveTextureUnitIdx = -1; // invalid |
| 379 | 380 |
| 380 if (resetBits & kTextureBinding_GrGLBackendState) { | 381 if (resetBits & kTextureBinding_GrGLBackendState) { |
| 381 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { | 382 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { |
| 382 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; | 383 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; |
| 383 } | 384 } |
| 384 } | 385 } |
| 385 | 386 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 } | 498 } |
| 498 | 499 |
| 499 return texture; | 500 return texture; |
| 500 } | 501 } |
| 501 | 502 |
| 502 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) { | 503 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc) { |
| 503 GrGLRenderTarget::IDDesc idDesc; | 504 GrGLRenderTarget::IDDesc idDesc; |
| 504 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); | 505 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); |
| 505 idDesc.fMSColorRenderbufferID = 0; | 506 idDesc.fMSColorRenderbufferID = 0; |
| 506 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; | 507 idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID; |
| 508 idDesc.fSampleConfig = (wrapDesc.fFlags & kStencilMSAAOnly_GrBackendRenderTa rgetFlags) ? | |
|
Chris Dalton
2015/06/09 17:39:51
Here we ought to ignore the multisample stencil bu
| |
| 509 GrRenderTarget::kStencil_SampleConfig : | |
| 510 GrRenderTarget::kUnified_SampleConfig; | |
| 507 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; | 511 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
| 508 | 512 |
| 509 GrSurfaceDesc desc; | 513 GrSurfaceDesc desc; |
| 510 desc.fConfig = wrapDesc.fConfig; | 514 desc.fConfig = wrapDesc.fConfig; |
| 511 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 515 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
| 512 desc.fWidth = wrapDesc.fWidth; | 516 desc.fWidth = wrapDesc.fWidth; |
| 513 desc.fHeight = wrapDesc.fHeight; | 517 desc.fHeight = wrapDesc.fHeight; |
| 514 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); | 518 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); |
| 515 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 519 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
| 516 | 520 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 | 848 |
| 845 static bool renderbuffer_storage_msaa(const GrGLContext& ctx, | 849 static bool renderbuffer_storage_msaa(const GrGLContext& ctx, |
| 846 int sampleCount, | 850 int sampleCount, |
| 847 GrGLenum format, | 851 GrGLenum format, |
| 848 int width, int height) { | 852 int width, int height) { |
| 849 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); | 853 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); |
| 850 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); | 854 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); |
| 851 switch (ctx.caps()->msFBOType()) { | 855 switch (ctx.caps()->msFBOType()) { |
| 852 case GrGLCaps::kDesktop_ARB_MSFBOType: | 856 case GrGLCaps::kDesktop_ARB_MSFBOType: |
| 853 case GrGLCaps::kDesktop_EXT_MSFBOType: | 857 case GrGLCaps::kDesktop_EXT_MSFBOType: |
| 858 case GrGLCaps::kMixedSamples_MSFBOType: | |
| 854 case GrGLCaps::kES_3_0_MSFBOType: | 859 case GrGLCaps::kES_3_0_MSFBOType: |
| 855 GL_ALLOC_CALL(ctx.interface(), | 860 GL_ALLOC_CALL(ctx.interface(), |
| 856 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, | 861 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
| 857 sampleCount, | 862 sampleCount, |
| 858 format, | 863 format, |
| 859 width, height)); | 864 width, height)); |
| 860 break; | 865 break; |
| 861 case GrGLCaps::kES_Apple_MSFBOType: | 866 case GrGLCaps::kES_Apple_MSFBOType: |
| 862 GL_ALLOC_CALL(ctx.interface(), | 867 GL_ALLOC_CALL(ctx.interface(), |
| 863 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, | 868 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 881 } | 886 } |
| 882 | 887 |
| 883 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, | 888 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, |
| 884 GrGpuResource::LifeCycle lifeCycle, | 889 GrGpuResource::LifeCycle lifeCycle, |
| 885 GrGLuint texID, | 890 GrGLuint texID, |
| 886 GrGLRenderTarget::IDDesc* idDesc) { | 891 GrGLRenderTarget::IDDesc* idDesc) { |
| 887 idDesc->fMSColorRenderbufferID = 0; | 892 idDesc->fMSColorRenderbufferID = 0; |
| 888 idDesc->fRTFBOID = 0; | 893 idDesc->fRTFBOID = 0; |
| 889 idDesc->fTexFBOID = 0; | 894 idDesc->fTexFBOID = 0; |
| 890 idDesc->fLifeCycle = lifeCycle; | 895 idDesc->fLifeCycle = lifeCycle; |
| 896 idDesc->fSampleConfig = GrGLCaps::kMixedSamples_MSFBOType == | |
| 897 this->glCaps().msFBOType() ? GrRenderTarget::kStenci l_SampleConfig : | |
| 898 GrRenderTarget::kUnifie d_SampleConfig; | |
| 891 | 899 |
| 892 GrGLenum status; | 900 GrGLenum status; |
| 893 | 901 |
| 894 GrGLenum msColorFormat = 0; // suppress warning | 902 GrGLenum msColorFormat = 0; // suppress warning |
| 895 | 903 |
| 896 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { | 904 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { |
| 897 goto FAILED; | 905 goto FAILED; |
| 898 } | 906 } |
| 899 | 907 |
| 900 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); | 908 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1163 } | 1171 } |
| 1164 } | 1172 } |
| 1165 | 1173 |
| 1166 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { | 1174 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { |
| 1167 // All internally created RTs are also textures. We don't create | 1175 // 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) . | 1176 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . |
| 1169 SkASSERT(rt->asTexture()); | 1177 SkASSERT(rt->asTexture()); |
| 1170 SkASSERT(width >= rt->width()); | 1178 SkASSERT(width >= rt->width()); |
| 1171 SkASSERT(height >= rt->height()); | 1179 SkASSERT(height >= rt->height()); |
| 1172 | 1180 |
| 1173 int samples = rt->numSamples(); | 1181 int samples = rt->numStencilSamples(); |
| 1174 GrGLStencilAttachment::IDDesc sbDesc; | 1182 GrGLStencilAttachment::IDDesc sbDesc; |
| 1175 | 1183 |
| 1176 int stencilFmtCnt = this->glCaps().stencilFormats().count(); | 1184 int stencilFmtCnt = this->glCaps().stencilFormats().count(); |
| 1177 for (int i = 0; i < stencilFmtCnt; ++i) { | 1185 for (int i = 0; i < stencilFmtCnt; ++i) { |
| 1178 if (!sbDesc.fRenderbufferID) { | 1186 if (!sbDesc.fRenderbufferID) { |
| 1179 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); | 1187 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); |
| 1180 } | 1188 } |
| 1181 if (!sbDesc.fRenderbufferID) { | 1189 if (!sbDesc.fRenderbufferID) { |
| 1182 return false; | 1190 return false; |
| 1183 } | 1191 } |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2083 stencilSettings, | 2091 stencilSettings, |
| 2084 GR_GL_FRONT_AND_BACK, | 2092 GR_GL_FRONT_AND_BACK, |
| 2085 GrStencilSettings::kFront_Face); | 2093 GrStencilSettings::kFront_Face); |
| 2086 } | 2094 } |
| 2087 } | 2095 } |
| 2088 fHWStencilSettings = stencilSettings; | 2096 fHWStencilSettings = stencilSettings; |
| 2089 } | 2097 } |
| 2090 } | 2098 } |
| 2091 | 2099 |
| 2092 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2100 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
| 2093 SkASSERT(!useHWAA || rt->isMultisampled()); | 2101 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
| 2094 | 2102 |
| 2095 if (this->glCaps().multisampleDisableSupport()) { | 2103 if (this->glCaps().multisampleDisableSupport() || |
| 2104 this->glCaps().shaderCaps()->mixedSamplesSupport()) { | |
|
Chris Dalton
2015/06/09 17:39:52
I would recommend rolling this into the multisampl
| |
| 2096 if (useHWAA) { | 2105 if (useHWAA) { |
| 2097 if (kYes_TriState != fMSAAEnabled) { | 2106 if (kYes_TriState != fMSAAEnabled) { |
| 2098 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2107 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
| 2099 fMSAAEnabled = kYes_TriState; | 2108 fMSAAEnabled = kYes_TriState; |
| 2100 } | 2109 } |
| 2101 } else { | 2110 } else { |
| 2102 if (kNo_TriState != fMSAAEnabled) { | 2111 if (kNo_TriState != fMSAAEnabled) { |
| 2103 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2112 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
| 2104 fMSAAEnabled = kNo_TriState; | 2113 fMSAAEnabled = kNo_TriState; |
| 2105 } | 2114 } |
| 2106 } | 2115 } |
| 2107 } | 2116 } |
| 2117 if (this->glCaps().shaderCaps()->mixedSamplesSupport()) { | |
| 2118 if (useHWAA && GrRenderTarget::kStencil_SampleConfig == rt->sampleConfig ()) { | |
| 2119 if (kYes_TriState != fCoverageModulationEnabled) { | |
| 2120 GL_CALL(CoverageModulation(GR_GL_RGBA)); | |
| 2121 fCoverageModulationEnabled = kYes_TriState; | |
| 2122 } | |
| 2123 } else { | |
| 2124 if (kNo_TriState != fCoverageModulationEnabled) { | |
| 2125 GL_CALL(CoverageModulation(GR_GL_NONE)); | |
| 2126 fCoverageModulationEnabled = kNo_TriState; | |
| 2127 } | |
| 2128 } | |
| 2129 } | |
| 2108 } | 2130 } |
| 2109 | 2131 |
| 2110 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { | 2132 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { |
| 2111 // Any optimization to disable blending should have already been applied and | 2133 // Any optimization to disable blending should have already been applied and |
| 2112 // tweaked the equation to "add" or "subtract", and the coeffs to (1, 0). | 2134 // tweaked the equation to "add" or "subtract", and the coeffs to (1, 0). |
| 2113 | 2135 |
| 2114 GrBlendEquation equation = blendInfo.fEquation; | 2136 GrBlendEquation equation = blendInfo.fEquation; |
| 2115 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; | 2137 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; |
| 2116 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; | 2138 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; |
| 2117 bool blendOff = (kAdd_GrBlendEquation == equation || kSubtract_GrBlendEquati on == equation) && | 2139 bool blendOff = (kAdd_GrBlendEquation == equation || kSubtract_GrBlendEquati on == equation) && |
| (...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3067 this->setVertexArrayID(gpu, 0); | 3089 this->setVertexArrayID(gpu, 0); |
| 3068 } | 3090 } |
| 3069 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3091 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3070 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3092 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3071 fDefaultVertexArrayAttribState.resize(attrCount); | 3093 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3072 } | 3094 } |
| 3073 attribState = &fDefaultVertexArrayAttribState; | 3095 attribState = &fDefaultVertexArrayAttribState; |
| 3074 } | 3096 } |
| 3075 return attribState; | 3097 return attribState; |
| 3076 } | 3098 } |
| OLD | NEW |