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 GL_CALL(CoverageModulation(GR_GL_RGBA)); | |
|
Chris Dalton
2015/06/10 19:52:39
We need to wrap this in a check for mixedSamplesSu
| |
| 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_GrBackendRenderT argetFlags) && | |
| 509 this->caps()->shaderCaps()->mixedSamplesSupport()) ? | |
| 510 GrRenderTarget::kStencil_SampleConfig : | |
| 511 GrRenderTarget::kUnified_SampleConfig; | |
|
Chris Dalton
2015/06/10 19:52:39
If we block the mixed samples due to it not being
Chris Dalton
2015/06/10 20:55:56
Looks like we're taking out kStencilMSAAOnly_GrBac
| |
| 512 | |
| 507 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; | 513 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
| 508 | 514 |
| 509 GrSurfaceDesc desc; | 515 GrSurfaceDesc desc; |
| 510 desc.fConfig = wrapDesc.fConfig; | 516 desc.fConfig = wrapDesc.fConfig; |
| 511 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 517 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
| 512 desc.fWidth = wrapDesc.fWidth; | 518 desc.fWidth = wrapDesc.fWidth; |
| 513 desc.fHeight = wrapDesc.fHeight; | 519 desc.fHeight = wrapDesc.fHeight; |
| 514 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); | 520 desc.fSampleCnt = SkTMin(wrapDesc.fSampleCnt, this->caps()->maxSampleCount() ); |
| 515 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 521 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
| 516 | 522 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 | 850 |
| 845 static bool renderbuffer_storage_msaa(const GrGLContext& ctx, | 851 static bool renderbuffer_storage_msaa(const GrGLContext& ctx, |
| 846 int sampleCount, | 852 int sampleCount, |
| 847 GrGLenum format, | 853 GrGLenum format, |
| 848 int width, int height) { | 854 int width, int height) { |
| 849 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); | 855 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); |
| 850 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); | 856 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); |
| 851 switch (ctx.caps()->msFBOType()) { | 857 switch (ctx.caps()->msFBOType()) { |
| 852 case GrGLCaps::kDesktop_ARB_MSFBOType: | 858 case GrGLCaps::kDesktop_ARB_MSFBOType: |
| 853 case GrGLCaps::kDesktop_EXT_MSFBOType: | 859 case GrGLCaps::kDesktop_EXT_MSFBOType: |
| 860 case GrGLCaps::kMixedSamples_MSFBOType: | |
| 854 case GrGLCaps::kES_3_0_MSFBOType: | 861 case GrGLCaps::kES_3_0_MSFBOType: |
| 855 GL_ALLOC_CALL(ctx.interface(), | 862 GL_ALLOC_CALL(ctx.interface(), |
| 856 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, | 863 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
| 857 sampleCount, | 864 sampleCount, |
| 858 format, | 865 format, |
| 859 width, height)); | 866 width, height)); |
| 860 break; | 867 break; |
| 861 case GrGLCaps::kES_Apple_MSFBOType: | 868 case GrGLCaps::kES_Apple_MSFBOType: |
| 862 GL_ALLOC_CALL(ctx.interface(), | 869 GL_ALLOC_CALL(ctx.interface(), |
| 863 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, | 870 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 881 } | 888 } |
| 882 | 889 |
| 883 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, | 890 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, |
| 884 GrGpuResource::LifeCycle lifeCycle, | 891 GrGpuResource::LifeCycle lifeCycle, |
| 885 GrGLuint texID, | 892 GrGLuint texID, |
| 886 GrGLRenderTarget::IDDesc* idDesc) { | 893 GrGLRenderTarget::IDDesc* idDesc) { |
| 887 idDesc->fMSColorRenderbufferID = 0; | 894 idDesc->fMSColorRenderbufferID = 0; |
| 888 idDesc->fRTFBOID = 0; | 895 idDesc->fRTFBOID = 0; |
| 889 idDesc->fTexFBOID = 0; | 896 idDesc->fTexFBOID = 0; |
| 890 idDesc->fLifeCycle = lifeCycle; | 897 idDesc->fLifeCycle = lifeCycle; |
| 898 idDesc->fSampleConfig = GrGLCaps::kMixedSamples_MSFBOType == | |
| 899 this->glCaps().msFBOType() ? GrRenderTarget::kStenci l_SampleConfig : | |
| 900 GrRenderTarget::kUnifie d_SampleConfig; | |
| 891 | 901 |
| 892 GrGLenum status; | 902 GrGLenum status; |
| 893 | 903 |
| 894 GrGLenum msColorFormat = 0; // suppress warning | 904 GrGLenum msColorFormat = 0; // suppress warning |
| 895 | 905 |
| 896 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { | 906 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { |
| 897 goto FAILED; | 907 goto FAILED; |
| 898 } | 908 } |
| 899 | 909 |
| 900 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); | 910 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1163 } | 1173 } |
| 1164 } | 1174 } |
| 1165 | 1175 |
| 1166 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { | 1176 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { |
| 1167 // All internally created RTs are also textures. We don't create | 1177 // 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) . | 1178 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . |
| 1169 SkASSERT(rt->asTexture()); | 1179 SkASSERT(rt->asTexture()); |
| 1170 SkASSERT(width >= rt->width()); | 1180 SkASSERT(width >= rt->width()); |
| 1171 SkASSERT(height >= rt->height()); | 1181 SkASSERT(height >= rt->height()); |
| 1172 | 1182 |
| 1173 int samples = rt->numSamples(); | 1183 int samples = rt->numStencilSamples(); |
| 1174 GrGLStencilAttachment::IDDesc sbDesc; | 1184 GrGLStencilAttachment::IDDesc sbDesc; |
| 1175 | 1185 |
| 1176 int stencilFmtCnt = this->glCaps().stencilFormats().count(); | 1186 int stencilFmtCnt = this->glCaps().stencilFormats().count(); |
| 1177 for (int i = 0; i < stencilFmtCnt; ++i) { | 1187 for (int i = 0; i < stencilFmtCnt; ++i) { |
| 1178 if (!sbDesc.fRenderbufferID) { | 1188 if (!sbDesc.fRenderbufferID) { |
| 1179 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); | 1189 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); |
| 1180 } | 1190 } |
| 1181 if (!sbDesc.fRenderbufferID) { | 1191 if (!sbDesc.fRenderbufferID) { |
| 1182 return false; | 1192 return false; |
| 1183 } | 1193 } |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1599 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); | 1609 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); |
| 1600 if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) { | 1610 if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) { |
| 1601 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 1611 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 1602 fStats.incRenderTargetBinds(); | 1612 fStats.incRenderTargetBinds(); |
| 1603 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); | 1613 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); |
| 1604 } | 1614 } |
| 1605 switch (this->glCaps().invalidateFBType()) { | 1615 switch (this->glCaps().invalidateFBType()) { |
| 1606 case GrGLCaps::kNone_InvalidateFBType: | 1616 case GrGLCaps::kNone_InvalidateFBType: |
| 1607 SkFAIL("Should never get here."); | 1617 SkFAIL("Should never get here."); |
| 1608 break; | 1618 break; |
| 1609 case GrGLCaps::kInvalidate_InvalidateFBType: | 1619 case GrGLCaps::kInvalidate_InvalidateFBType: |
|
Chris Dalton
2015/06/11 00:02:29
Don't forget the workaround.
if (renderTarget->
| |
| 1610 if (0 == glRT->renderFBOID()) { | 1620 if (0 == glRT->renderFBOID()) { |
| 1611 // When rendering to the default framebuffer the legal values f or attachments | 1621 // When rendering to the default framebuffer the legal values f or attachments |
| 1612 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari ous FBO attachment | 1622 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari ous FBO attachment |
| 1613 // types. | 1623 // types. |
| 1614 static const GrGLenum attachments[] = { GR_GL_COLOR }; | 1624 static const GrGLenum attachments[] = { GR_GL_COLOR }; |
| 1615 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), | 1625 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), |
| 1616 attachments)); | 1626 attachments)); |
| 1617 } else { | 1627 } else { |
| 1618 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 }; | 1628 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 }; |
| 1619 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), | 1629 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2083 stencilSettings, | 2093 stencilSettings, |
| 2084 GR_GL_FRONT_AND_BACK, | 2094 GR_GL_FRONT_AND_BACK, |
| 2085 GrStencilSettings::kFront_Face); | 2095 GrStencilSettings::kFront_Face); |
| 2086 } | 2096 } |
| 2087 } | 2097 } |
| 2088 fHWStencilSettings = stencilSettings; | 2098 fHWStencilSettings = stencilSettings; |
| 2089 } | 2099 } |
| 2090 } | 2100 } |
| 2091 | 2101 |
| 2092 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2102 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
| 2093 SkASSERT(!useHWAA || rt->isMultisampled()); | 2103 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
| 2094 | 2104 |
| 2095 if (this->glCaps().multisampleDisableSupport()) { | 2105 if (this->glCaps().multisampleDisableSupport()) { |
| 2096 if (useHWAA) { | 2106 if (useHWAA) { |
| 2097 if (kYes_TriState != fMSAAEnabled) { | 2107 if (kYes_TriState != fMSAAEnabled) { |
| 2098 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2108 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
| 2099 fMSAAEnabled = kYes_TriState; | 2109 fMSAAEnabled = kYes_TriState; |
| 2100 } | 2110 } |
| 2101 } else { | 2111 } else { |
| 2102 if (kNo_TriState != fMSAAEnabled) { | 2112 if (kNo_TriState != fMSAAEnabled) { |
| 2103 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2113 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3067 this->setVertexArrayID(gpu, 0); | 3077 this->setVertexArrayID(gpu, 0); |
| 3068 } | 3078 } |
| 3069 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3079 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3070 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3080 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3071 fDefaultVertexArrayAttribState.resize(attrCount); | 3081 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3072 } | 3082 } |
| 3073 attribState = &fDefaultVertexArrayAttribState; | 3083 attribState = &fDefaultVertexArrayAttribState; |
| 3074 } | 3084 } |
| 3075 return attribState; | 3085 return attribState; |
| 3076 } | 3086 } |
| OLD | NEW |