Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 215ff33

Browse files
csmartdalton86Skia Commit-Bot
authored andcommitted
Don't attempt mixed samples on "borrowed" render targets
Bug: skia:9231 Change-Id: I55809299c34bb835c2d3437b31dab318572a948d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225165 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
1 parent e783ba4 commit 215ff33

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/gpu/GrRenderTargetProxy.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ bool GrRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) {
7777
return true;
7878
}
7979

80+
bool GrRenderTargetProxy::canChangeStencilAttachment() const {
81+
if (!fTarget) {
82+
// If we aren't instantiated, then we definitely are an internal render target. Ganesh is
83+
// free to change stencil attachments on internal render targets.
84+
return true;
85+
}
86+
return fTarget->asRenderTarget()->canAttemptStencilAttachment();
87+
}
88+
8089
sk_sp<GrSurface> GrRenderTargetProxy::createSurface(GrResourceProvider* resourceProvider) const {
8190
static constexpr GrSurfaceDescFlags kDescFlags = kRenderTarget_GrSurfaceFlag;
8291

src/gpu/GrRenderTargetProxy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class GrRenderTargetProxy : virtual public GrSurfaceProxy {
2929
bool instantiate(GrResourceProvider*) override;
3030

3131
bool canUseMixedSamples(const GrCaps& caps) const {
32-
// TODO: Is this a wrapped external RT? Is GrBackendObjectOwnership available?
3332
return caps.mixedSamplesSupport() && !this->glRTFBOIDIs0() &&
34-
caps.internalMultisampleCount(this->config()) > 0;
33+
caps.internalMultisampleCount(this->config()) > 0 &&
34+
this->canChangeStencilAttachment();
3535
}
3636

3737
/*
@@ -112,7 +112,7 @@ class GrRenderTargetProxy : virtual public GrSurfaceProxy {
112112
bool glRTFBOIDIs0() const {
113113
return fSurfaceFlags & GrInternalSurfaceFlags::kGLRTFBOIDIs0;
114114
}
115-
115+
bool canChangeStencilAttachment() const;
116116

117117
size_t onUninstantiatedGpuMemorySize() const override;
118118
SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;)

src/gpu/GrResourceProvider.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,11 @@ bool GrResourceProvider::attachStencilAttachment(GrRenderTarget* rt, int minSten
418418
}
419419
rt->renderTargetPriv().attachStencilAttachment(std::move(stencil));
420420
}
421-
return SkToBool(rt->renderTargetPriv().getStencilAttachment());
421+
422+
if (GrStencilAttachment* stencil = rt->renderTargetPriv().getStencilAttachment()) {
423+
return stencil->numSamples() >= minStencilSampleCount;
424+
}
425+
return false;
422426
}
423427

424428
sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendTextureAsRenderTarget(

0 commit comments

Comments
 (0)