Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1001503002: Implement support for mixed sampled render targets (Closed) Base URL: https://skia.googlesource.com/skia.git@mix1
Patch Set: Handle numSamples cases in SkGpuDevice Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGLGpu.cpp
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 954ecc4f61c3401ba89f753e5323f27e996e217f..e0a2cb7d7ba85a32712bebb69b1d16e98e5af597 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -301,6 +301,7 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
if (resetBits & kMSAAEnable_GrGLBackendState) {
fMSAAEnabled = kUnknown_TriState;
+ fCoverageModulationEnabled = kUnknown_TriState;
}
fHWActiveTextureUnitIdx = -1; // invalid
@@ -435,6 +436,9 @@ GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe
idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle);
idDesc.fMSColorRenderbufferID = 0;
idDesc.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
+ idDesc.fSampleConfig = (wrapDesc.fFlags & kStencilMSAAOnly_GrBackendRenderTargetFlags) ?
+ GrRenderTarget::kStencil_SampleConfig :
+ GrRenderTarget::kUnified_SampleConfig;
idDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle;
GrSurfaceDesc desc;
@@ -782,6 +786,7 @@ static bool renderbuffer_storage_msaa(GrGLContext& ctx,
switch (ctx.caps()->msFBOType()) {
case GrGLCaps::kDesktop_ARB_MSFBOType:
case GrGLCaps::kDesktop_EXT_MSFBOType:
+ case GrGLCaps::kMixedSamples_MSFBOType:
case GrGLCaps::kES_3_0_MSFBOType:
GL_ALLOC_CALL(ctx.interface(),
RenderbufferStorageMultisample(GR_GL_RENDERBUFFER,
@@ -818,6 +823,9 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc, bool budgeted
idDesc->fTexFBOID = 0;
idDesc->fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle :
GrGpuResource::kUncached_LifeCycle;
+ idDesc->fSampleConfig = GrGLCaps::kMixedSamples_MSFBOType ==
+ this->glCaps().msFBOType() ? GrRenderTarget::kStencil_SampleConfig :
+ GrRenderTarget::kUnified_SampleConfig;
GrGLenum status;
@@ -1139,7 +1147,7 @@ bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid
SkASSERT(width >= rt->width());
SkASSERT(height >= rt->height());
- int samples = rt->numSamples();
+ int samples = rt->numSamples(GrRenderTarget::kStencil_BufferBit);
GrGLStencilAttachment::IDDesc sbDesc;
int stencilFmtCnt = this->glCaps().stencilFormats().count();
@@ -2096,9 +2104,10 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) {
}
void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) {
- SkASSERT(!useHWAA || rt->isMultisampled());
+ SkASSERT(!useHWAA || rt->isMultisampled(GrRenderTarget::kAny_BufferBits));
- if (kGL_GrGLStandard == this->glStandard()) {
+ if (kGL_GrGLStandard == this->glStandard() ||
+ this->glCaps().fbMixedSamplesSupport()) {
if (useHWAA) {
if (kYes_TriState != fMSAAEnabled) {
GL_CALL(Enable(GR_GL_MULTISAMPLE));
@@ -2111,6 +2120,19 @@ void GrGLGpu::flushHWAAState(GrRenderTarget* rt, bool useHWAA) {
}
}
}
+ if (this->glCaps().fbMixedSamplesSupport()) {
+ if (useHWAA && GrRenderTarget::kStencil_SampleConfig == rt->sampleConfig()) {
+ if (kYes_TriState != fCoverageModulationEnabled) {
+ GL_CALL(CoverageModulation(GR_GL_RGBA));
+ fCoverageModulationEnabled = kYes_TriState;
+ }
+ } else {
+ if (kNo_TriState != fCoverageModulationEnabled) {
+ GL_CALL(CoverageModulation(GR_GL_NONE));
+ fCoverageModulationEnabled = kNo_TriState;
+ }
+ }
+ }
}
void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) {

Powered by Google App Engine
This is Rietveld 408576698