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 | |
377 // In mixed samples mode coverage modulation allows the coverage to be c onverted to | |
378 // "opacity", which can then be blended into the color buffer to accompl ish antialiasing. | |
379 // Enable coverage modulation suitable for premultiplied alpha colors. | |
Chris Dalton
2015/06/11 23:34:38
// This state has no effect when not rendering to
| |
380 if (this->glCaps().shaderCaps()->mixedSamplesSupport()) { | |
381 GL_CALL(CoverageModulation(GR_GL_RGBA)); | |
382 } | |
376 } | 383 } |
377 | 384 |
378 fHWActiveTextureUnitIdx = -1; // invalid | 385 fHWActiveTextureUnitIdx = -1; // invalid |
379 | 386 |
380 if (resetBits & kTextureBinding_GrGLBackendState) { | 387 if (resetBits & kTextureBinding_GrGLBackendState) { |
381 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { | 388 for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) { |
382 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; | 389 fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID; |
383 } | 390 } |
384 } | 391 } |
385 | 392 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
844 | 851 |
845 static bool renderbuffer_storage_msaa(const GrGLContext& ctx, | 852 static bool renderbuffer_storage_msaa(const GrGLContext& ctx, |
846 int sampleCount, | 853 int sampleCount, |
847 GrGLenum format, | 854 GrGLenum format, |
848 int width, int height) { | 855 int width, int height) { |
849 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); | 856 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); |
850 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); | 857 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); |
851 switch (ctx.caps()->msFBOType()) { | 858 switch (ctx.caps()->msFBOType()) { |
852 case GrGLCaps::kDesktop_ARB_MSFBOType: | 859 case GrGLCaps::kDesktop_ARB_MSFBOType: |
853 case GrGLCaps::kDesktop_EXT_MSFBOType: | 860 case GrGLCaps::kDesktop_EXT_MSFBOType: |
861 case GrGLCaps::kMixedSamples_MSFBOType: | |
854 case GrGLCaps::kES_3_0_MSFBOType: | 862 case GrGLCaps::kES_3_0_MSFBOType: |
855 GL_ALLOC_CALL(ctx.interface(), | 863 GL_ALLOC_CALL(ctx.interface(), |
856 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, | 864 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
857 sampleCount, | 865 sampleCount, |
858 format, | 866 format, |
859 width, height)); | 867 width, height)); |
860 break; | 868 break; |
861 case GrGLCaps::kES_Apple_MSFBOType: | 869 case GrGLCaps::kES_Apple_MSFBOType: |
862 GL_ALLOC_CALL(ctx.interface(), | 870 GL_ALLOC_CALL(ctx.interface(), |
863 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, | 871 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, |
(...skipping 17 matching lines...) Expand all Loading... | |
881 } | 889 } |
882 | 890 |
883 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, | 891 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, |
884 GrGpuResource::LifeCycle lifeCycle, | 892 GrGpuResource::LifeCycle lifeCycle, |
885 GrGLuint texID, | 893 GrGLuint texID, |
886 GrGLRenderTarget::IDDesc* idDesc) { | 894 GrGLRenderTarget::IDDesc* idDesc) { |
887 idDesc->fMSColorRenderbufferID = 0; | 895 idDesc->fMSColorRenderbufferID = 0; |
888 idDesc->fRTFBOID = 0; | 896 idDesc->fRTFBOID = 0; |
889 idDesc->fTexFBOID = 0; | 897 idDesc->fTexFBOID = 0; |
890 idDesc->fLifeCycle = lifeCycle; | 898 idDesc->fLifeCycle = lifeCycle; |
899 idDesc->fSampleConfig = (GrGLCaps::kMixedSamples_MSFBOType == this->glCaps() .msFBOType() && | |
900 desc.fSampleCnt > 0) ? GrRenderTarget::kStencil_Samp leConfig : | |
901 GrRenderTarget::kUnified_Samp leConfig; | |
891 | 902 |
892 GrGLenum status; | 903 GrGLenum status; |
893 | 904 |
894 GrGLenum msColorFormat = 0; // suppress warning | 905 GrGLenum msColorFormat = 0; // suppress warning |
895 | 906 |
896 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { | 907 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { |
897 goto FAILED; | 908 goto FAILED; |
898 } | 909 } |
899 | 910 |
900 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); | 911 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1163 } | 1174 } |
1164 } | 1175 } |
1165 | 1176 |
1166 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { | 1177 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { |
1167 // All internally created RTs are also textures. We don't create | 1178 // 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) . | 1179 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . |
1169 SkASSERT(rt->asTexture()); | 1180 SkASSERT(rt->asTexture()); |
1170 SkASSERT(width >= rt->width()); | 1181 SkASSERT(width >= rt->width()); |
1171 SkASSERT(height >= rt->height()); | 1182 SkASSERT(height >= rt->height()); |
1172 | 1183 |
1173 int samples = rt->numSamples(); | 1184 int samples = rt->numStencilSamples(); |
1174 GrGLStencilAttachment::IDDesc sbDesc; | 1185 GrGLStencilAttachment::IDDesc sbDesc; |
1175 | 1186 |
1176 int stencilFmtCnt = this->glCaps().stencilFormats().count(); | 1187 int stencilFmtCnt = this->glCaps().stencilFormats().count(); |
1177 for (int i = 0; i < stencilFmtCnt; ++i) { | 1188 for (int i = 0; i < stencilFmtCnt; ++i) { |
1178 if (!sbDesc.fRenderbufferID) { | 1189 if (!sbDesc.fRenderbufferID) { |
1179 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); | 1190 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); |
1180 } | 1191 } |
1181 if (!sbDesc.fRenderbufferID) { | 1192 if (!sbDesc.fRenderbufferID) { |
1182 return false; | 1193 return false; |
1183 } | 1194 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1600 if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) { | 1611 if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) { |
1601 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 1612 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
1602 fStats.incRenderTargetBinds(); | 1613 fStats.incRenderTargetBinds(); |
1603 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); | 1614 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); |
1604 } | 1615 } |
1605 switch (this->glCaps().invalidateFBType()) { | 1616 switch (this->glCaps().invalidateFBType()) { |
1606 case GrGLCaps::kNone_InvalidateFBType: | 1617 case GrGLCaps::kNone_InvalidateFBType: |
1607 SkFAIL("Should never get here."); | 1618 SkFAIL("Should never get here."); |
1608 break; | 1619 break; |
1609 case GrGLCaps::kInvalidate_InvalidateFBType: | 1620 case GrGLCaps::kInvalidate_InvalidateFBType: |
1621 if (kNVIDIA_GrGLDriver == this->glContext().driver() && | |
1622 this->glCaps().shaderCaps()->mixedSamplesSupport()) { | |
vbuzinov
2015/06/11 12:30:57
The nature of glInvalidateFramebuffer bug seems to
bsalomon
2015/06/11 13:33:14
Can we just disable support for framebuffer invali
| |
1623 // Workaround NVIDIA bug related to glInvalidateFramebuffer and mixed samples. | |
1624 break; | |
1625 } | |
1610 if (0 == glRT->renderFBOID()) { | 1626 if (0 == glRT->renderFBOID()) { |
1611 // When rendering to the default framebuffer the legal values f or attachments | 1627 // 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 | 1628 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari ous FBO attachment |
1613 // types. | 1629 // types. |
1614 static const GrGLenum attachments[] = { GR_GL_COLOR }; | 1630 static const GrGLenum attachments[] = { GR_GL_COLOR }; |
1615 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), | 1631 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), |
1616 attachments)); | 1632 attachments)); |
1617 } else { | 1633 } else { |
1618 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 }; | 1634 static const GrGLenum attachments[] = { GR_GL_COLOR_ATTACHMENT0 }; |
1619 GL_CALL(InvalidateFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT( attachments), | 1635 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, | 2099 stencilSettings, |
2084 GR_GL_FRONT_AND_BACK, | 2100 GR_GL_FRONT_AND_BACK, |
2085 GrStencilSettings::kFront_Face); | 2101 GrStencilSettings::kFront_Face); |
2086 } | 2102 } |
2087 } | 2103 } |
2088 fHWStencilSettings = stencilSettings; | 2104 fHWStencilSettings = stencilSettings; |
2089 } | 2105 } |
2090 } | 2106 } |
2091 | 2107 |
2092 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2108 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
2093 SkASSERT(!useHWAA || rt->isMultisampled()); | 2109 SkASSERT(!useHWAA || rt->isStencilBufferMultisampled()); |
2094 | 2110 |
2095 if (this->glCaps().multisampleDisableSupport()) { | 2111 if (this->glCaps().multisampleDisableSupport()) { |
2096 if (useHWAA) { | 2112 if (useHWAA) { |
2097 if (kYes_TriState != fMSAAEnabled) { | 2113 if (kYes_TriState != fMSAAEnabled) { |
2098 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2114 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
2099 fMSAAEnabled = kYes_TriState; | 2115 fMSAAEnabled = kYes_TriState; |
2100 } | 2116 } |
2101 } else { | 2117 } else { |
2102 if (kNo_TriState != fMSAAEnabled) { | 2118 if (kNo_TriState != fMSAAEnabled) { |
2103 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2119 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3067 this->setVertexArrayID(gpu, 0); | 3083 this->setVertexArrayID(gpu, 0); |
3068 } | 3084 } |
3069 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3085 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3070 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3086 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3071 fDefaultVertexArrayAttribState.resize(attrCount); | 3087 fDefaultVertexArrayAttribState.resize(attrCount); |
3072 } | 3088 } |
3073 attribState = &fDefaultVertexArrayAttribState; | 3089 attribState = &fDefaultVertexArrayAttribState; |
3074 } | 3090 } |
3075 return attribState; | 3091 return attribState; |
3076 } | 3092 } |
OLD | NEW |