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 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.fSampleConfig; | |
438 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; | 440 idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle; |
439 | 441 |
440 GrSurfaceDesc desc; | 442 GrSurfaceDesc desc; |
441 desc.fConfig = wrapDesc.fConfig; | 443 desc.fConfig = wrapDesc.fConfig; |
442 desc.fFlags = kCheckAllocation_GrSurfaceFlag; | 444 desc.fFlags = kCheckAllocation_GrSurfaceFlag; |
443 desc.fWidth = wrapDesc.fWidth; | 445 desc.fWidth = wrapDesc.fWidth; |
444 desc.fHeight = wrapDesc.fHeight; | 446 desc.fHeight = wrapDesc.fHeight; |
445 desc.fSampleCnt = wrapDesc.fSampleCnt; | 447 desc.fSampleCnt = wrapDesc.fSampleCnt; |
446 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); | 448 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); |
447 | 449 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 | 777 |
776 static bool renderbuffer_storage_msaa(GrGLContext& ctx, | 778 static bool renderbuffer_storage_msaa(GrGLContext& ctx, |
777 int sampleCount, | 779 int sampleCount, |
778 GrGLenum format, | 780 GrGLenum format, |
779 int width, int height) { | 781 int width, int height) { |
780 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); | 782 CLEAR_ERROR_BEFORE_ALLOC(ctx.interface()); |
781 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); | 783 SkASSERT(GrGLCaps::kNone_MSFBOType != ctx.caps()->msFBOType()); |
782 switch (ctx.caps()->msFBOType()) { | 784 switch (ctx.caps()->msFBOType()) { |
783 case GrGLCaps::kDesktop_ARB_MSFBOType: | 785 case GrGLCaps::kDesktop_ARB_MSFBOType: |
784 case GrGLCaps::kDesktop_EXT_MSFBOType: | 786 case GrGLCaps::kDesktop_EXT_MSFBOType: |
787 case GrGLCaps::kStencil_MSFBOType: | |
785 case GrGLCaps::kES_3_0_MSFBOType: | 788 case GrGLCaps::kES_3_0_MSFBOType: |
786 GL_ALLOC_CALL(ctx.interface(), | 789 GL_ALLOC_CALL(ctx.interface(), |
787 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, | 790 RenderbufferStorageMultisample(GR_GL_RENDERBUFFER, |
788 sampleCount, | 791 sampleCount, |
789 format, | 792 format, |
790 width, height)); | 793 width, height)); |
791 break; | 794 break; |
792 case GrGLCaps::kES_Apple_MSFBOType: | 795 case GrGLCaps::kES_Apple_MSFBOType: |
793 GL_ALLOC_CALL(ctx.interface(), | 796 GL_ALLOC_CALL(ctx.interface(), |
794 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, | 797 RenderbufferStorageMultisampleES2APPLE(GR_GL_RENDERB UFFER, |
(...skipping 16 matching lines...) Expand all Loading... | |
811 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; | 814 return (GR_GL_NO_ERROR == CHECK_ALLOC_ERROR(ctx.interface()));; |
812 } | 815 } |
813 | 816 |
814 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID, | 817 bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted , GrGLuint texID, |
815 GrGLRenderTarget::IDDesc* idDesc) { | 818 GrGLRenderTarget::IDDesc* idDesc) { |
816 idDesc->fMSColorRenderbufferID = 0; | 819 idDesc->fMSColorRenderbufferID = 0; |
817 idDesc->fRTFBOID = 0; | 820 idDesc->fRTFBOID = 0; |
818 idDesc->fTexFBOID = 0; | 821 idDesc->fTexFBOID = 0; |
819 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : | 822 idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle : |
820 GrGpuResource::kUncached_LifeCycle; | 823 GrGpuResource::kUncached_LifeCycle; |
824 idDesc->fSampleConfig = GrGLCaps::kStencil_MSFBOType == | |
825 this->glCaps().msFBOType() ? kStencil_GrSampleConfig : | |
826 kUnified_GrSampleConfig ; | |
821 | 827 |
822 GrGLenum status; | 828 GrGLenum status; |
823 | 829 |
824 GrGLenum msColorFormat = 0; // suppress warning | 830 GrGLenum msColorFormat = 0; // suppress warning |
825 | 831 |
826 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { | 832 if (desc.fSampleCnt > 0 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBO Type()) { |
827 goto FAILED; | 833 goto FAILED; |
828 } | 834 } |
829 | 835 |
830 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); | 836 GL_CALL(GenFramebuffers(1, &idDesc->fTexFBOID)); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
923 // SkDEBUGFAIL("null texture"); | 929 // SkDEBUGFAIL("null texture"); |
924 return NULL; | 930 return NULL; |
925 } | 931 } |
926 | 932 |
927 #if 0 && defined(SK_DEBUG) | 933 #if 0 && defined(SK_DEBUG) |
928 static size_t as_size_t(int x) { | 934 static size_t as_size_t(int x) { |
929 return x; | 935 return x; |
930 } | 936 } |
931 #endif | 937 #endif |
932 | 938 |
933 GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& origDesc, bool budgeted , | 939 GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& origDesc, bool budgeted , |
bsalomon
2015/04/01 13:15:36
Do there need to be any changes in here? Does the
Chris Dalton
2015/04/01 20:34:17
No changes are needed, everything just works out.
| |
934 const void* srcData, size_t rowBytes) { | 940 const void* srcData, size_t rowBytes) { |
935 | 941 |
936 GrSurfaceDesc desc = origDesc; | 942 GrSurfaceDesc desc = origDesc; |
937 | 943 |
938 // Attempt to catch un- or wrongly initialized sample counts; | 944 // Attempt to catch un- or wrongly initialized sample counts; |
939 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); | 945 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); |
940 // We fail if the MSAA was requested and is not available. | 946 // We fail if the MSAA was requested and is not available. |
941 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) { | 947 if (GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType() && desc.fSampleC nt) { |
942 //SkDebugf("MSAA RT requested but not supported on this platform."); | 948 //SkDebugf("MSAA RT requested but not supported on this platform."); |
943 return return_null_texture(); | 949 return return_null_texture(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 } | 1138 } |
1133 } | 1139 } |
1134 | 1140 |
1135 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) { | 1141 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) { |
1136 // All internally created RTs are also textures. We don't create | 1142 // 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) . | 1143 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . |
1138 SkASSERT(rt->asTexture()); | 1144 SkASSERT(rt->asTexture()); |
1139 SkASSERT(width >= rt->width()); | 1145 SkASSERT(width >= rt->width()); |
1140 SkASSERT(height >= rt->height()); | 1146 SkASSERT(height >= rt->height()); |
1141 | 1147 |
1142 int samples = rt->numSamples(); | 1148 int samples = rt->numSamples(GrRenderTarget::kStencilBuffer_PipelineStage); |
1143 GrGLStencilBuffer::IDDesc sbDesc; | 1149 GrGLStencilBuffer::IDDesc sbDesc; |
1144 | 1150 |
1145 int stencilFmtCnt = this->glCaps().stencilFormats().count(); | 1151 int stencilFmtCnt = this->glCaps().stencilFormats().count(); |
1146 for (int i = 0; i < stencilFmtCnt; ++i) { | 1152 for (int i = 0; i < stencilFmtCnt; ++i) { |
1147 if (!sbDesc.fRenderbufferID) { | 1153 if (!sbDesc.fRenderbufferID) { |
1148 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); | 1154 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); |
1149 } | 1155 } |
1150 if (!sbDesc.fRenderbufferID) { | 1156 if (!sbDesc.fRenderbufferID) { |
1151 return false; | 1157 return false; |
1152 } | 1158 } |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2069 stencilSettings, | 2075 stencilSettings, |
2070 GR_GL_FRONT_AND_BACK, | 2076 GR_GL_FRONT_AND_BACK, |
2071 GrStencilSettings::kFront_Face); | 2077 GrStencilSettings::kFront_Face); |
2072 } | 2078 } |
2073 } | 2079 } |
2074 fHWStencilSettings = stencilSettings; | 2080 fHWStencilSettings = stencilSettings; |
2075 } | 2081 } |
2076 } | 2082 } |
2077 | 2083 |
2078 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { | 2084 void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) { |
2079 SkASSERT(!useHWAA || rt->isMultisampled()); | 2085 SkASSERT(!useHWAA || rt->isMultisampled(GrRenderTarget::kAnywhere_PipelineSt age)); |
2080 | 2086 |
2081 if (kGL_GrGLStandard == this->glStandard()) { | 2087 if (kGL_GrGLStandard == this->glStandard() || |
2088 this->glCaps().fbMixedSamplesSupport()) { | |
2082 if (useHWAA) { | 2089 if (useHWAA) { |
2083 if (kYes_TriState != fMSAAEnabled) { | 2090 if (kYes_TriState != fMSAAEnabled) { |
2084 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 2091 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
2085 fMSAAEnabled = kYes_TriState; | 2092 fMSAAEnabled = kYes_TriState; |
2086 } | 2093 } |
2087 } else { | 2094 } else { |
2088 if (kNo_TriState != fMSAAEnabled) { | 2095 if (kNo_TriState != fMSAAEnabled) { |
2089 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 2096 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
2090 fMSAAEnabled = kNo_TriState; | 2097 fMSAAEnabled = kNo_TriState; |
2091 } | 2098 } |
2092 } | 2099 } |
2093 } | 2100 } |
2101 if (this->glCaps().fbMixedSamplesSupport()) { | |
2102 if (useHWAA && kStencil_GrSampleConfig == rt->sampleConfig()) { | |
2103 if (kYes_TriState != fCoverageModulationEnabled) { | |
2104 GL_CALL(CoverageModulation(GR_GL_RGBA)); | |
2105 fCoverageModulationEnabled = kYes_TriState; | |
bsalomon
2015/03/31 16:37:33
For cases where we couldn't tweak alpha for covera
Chris Dalton
2015/03/31 19:47:30
Yes that's right. useHWAA always ends up false whe
| |
2106 } | |
2107 } else { | |
2108 if (kNo_TriState != fCoverageModulationEnabled) { | |
2109 GL_CALL(CoverageModulation(GR_GL_NONE)); | |
2110 fCoverageModulationEnabled = kNo_TriState; | |
2111 } | |
2112 } | |
2113 } | |
2094 } | 2114 } |
2095 | 2115 |
2096 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { | 2116 void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) { |
2097 // Any optimization to disable blending should have already been applied and | 2117 // Any optimization to disable blending should have already been applied and |
2098 // tweaked the coeffs to (1, 0). | 2118 // tweaked the coeffs to (1, 0). |
2099 | 2119 |
2100 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; | 2120 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; |
2101 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; | 2121 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; |
2102 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo eff; | 2122 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo eff; |
2103 if (blendOff) { | 2123 if (blendOff) { |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2796 this->setVertexArrayID(gpu, 0); | 2816 this->setVertexArrayID(gpu, 0); |
2797 } | 2817 } |
2798 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2818 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2799 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2819 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2800 fDefaultVertexArrayAttribState.resize(attrCount); | 2820 fDefaultVertexArrayAttribState.resize(attrCount); |
2801 } | 2821 } |
2802 attribState = &fDefaultVertexArrayAttribState; | 2822 attribState = &fDefaultVertexArrayAttribState; |
2803 } | 2823 } |
2804 return attribState; | 2824 return attribState; |
2805 } | 2825 } |
OLD | NEW |