Rename glrt->textureFBOID() -> singleSampleFBOID()

Bug: skia:11396
Change-Id: I02fdb4acd368a54e585891ef3c38f6b0c79a5d17
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/392718
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2021-04-05 16:48:24 -06:00 committed by Skia Commit-Bot
parent 47b087eb81
commit b21bfc8de5
5 changed files with 36 additions and 34 deletions

View File

@ -4160,7 +4160,8 @@ GrCaps::SurfaceReadPixelsSupport GrGLCaps::surfaceSupportsReadPixels(
} else if (auto rt = static_cast<const GrGLRenderTarget*>(surface->asRenderTarget())) {
// glReadPixels does not allow reading back from a MSAA framebuffer. If the underlying
// GrSurface doesn't have a second FBO to resolve to then we must make a copy.
if (rt->numSamples() > 1 && rt->textureFBOID() == GrGLRenderTarget::kUnresolvableFBOID) {
if (rt->numSamples() > 1 &&
rt->singleSampleFBOID() == GrGLRenderTarget::kUnresolvableFBOID) {
return SurfaceReadPixelsSupport::kCopyToTexture2D;
}
}

View File

@ -790,7 +790,7 @@ sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
GrGLRenderTarget::IDs rtIDs;
rtIDs.fRTFBOID = info.fFBOID;
rtIDs.fMSColorRenderbufferID = 0;
rtIDs.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
rtIDs.fSingleSampleFBOID = GrGLRenderTarget::kUnresolvableFBOID;
rtIDs.fRTFBOOwnership = GrBackendObjectOwnership::kBorrowed;
int sampleCount = this->glCaps().getRenderTargetSampleCount(backendRT.sampleCnt(), format);
@ -1171,7 +1171,7 @@ bool GrGLGpu::createRenderTargetObjects(const GrGLTexture::Desc& desc,
rtIDs->fMSColorRenderbufferID = 0;
rtIDs->fRTFBOID = 0;
rtIDs->fRTFBOOwnership = GrBackendObjectOwnership::kOwned;
rtIDs->fTexFBOID = 0;
rtIDs->fSingleSampleFBOID = 0;
GrGLenum colorRenderbufferFormat = 0; // suppress warning
@ -1183,8 +1183,8 @@ bool GrGLGpu::createRenderTargetObjects(const GrGLTexture::Desc& desc,
goto FAILED;
}
GL_CALL(GenFramebuffers(1, &rtIDs->fTexFBOID));
if (!rtIDs->fTexFBOID) {
GL_CALL(GenFramebuffers(1, &rtIDs->fSingleSampleFBOID));
if (!rtIDs->fSingleSampleFBOID) {
goto FAILED;
}
@ -1193,7 +1193,7 @@ bool GrGLGpu::createRenderTargetObjects(const GrGLTexture::Desc& desc,
// extension the texture is multisampled when rendered to and then auto-resolves it when it is
// rendered from.
if (sampleCount <= 1) {
rtIDs->fRTFBOID = rtIDs->fTexFBOID;
rtIDs->fRTFBOID = rtIDs->fSingleSampleFBOID;
} else {
GL_CALL(GenFramebuffers(1, &rtIDs->fRTFBOID));
if (!rtIDs->fRTFBOID) {
@ -1225,7 +1225,7 @@ bool GrGLGpu::createRenderTargetObjects(const GrGLTexture::Desc& desc,
} else if (sampleCount > 1) {
// multisampled_render_to_texture
SkASSERT(this->glCaps().usesImplicitMSAAResolve()); // Otherwise fMSColorRenderbufferID!=0.
SkASSERT(rtIDs->fRTFBOID != rtIDs->fTexFBOID);
SkASSERT(rtIDs->fRTFBOID != rtIDs->fSingleSampleFBOID);
this->bindFramebuffer(GR_GL_FRAMEBUFFER, rtIDs->fRTFBOID);
GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
@ -1235,7 +1235,7 @@ bool GrGLGpu::createRenderTargetObjects(const GrGLTexture::Desc& desc,
sampleCount));
}
this->bindFramebuffer(GR_GL_FRAMEBUFFER, rtIDs->fTexFBOID);
this->bindFramebuffer(GR_GL_FRAMEBUFFER, rtIDs->fSingleSampleFBOID);
GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
desc.fTarget,
@ -1248,11 +1248,11 @@ FAILED:
if (rtIDs->fMSColorRenderbufferID) {
GL_CALL(DeleteRenderbuffers(1, &rtIDs->fMSColorRenderbufferID));
}
if (rtIDs->fRTFBOID != rtIDs->fTexFBOID) {
if (rtIDs->fRTFBOID != rtIDs->fSingleSampleFBOID) {
this->deleteFramebuffer(rtIDs->fRTFBOID);
}
if (rtIDs->fTexFBOID) {
this->deleteFramebuffer(rtIDs->fTexFBOID);
if (rtIDs->fSingleSampleFBOID) {
this->deleteFramebuffer(rtIDs->fSingleSampleFBOID);
}
return false;
}
@ -2113,11 +2113,11 @@ bool GrGLGpu::readOrTransferPixelsFrom(GrSurface* surface, int left, int top, in
if (renderTarget) {
if (renderTarget->numSamples() > 1) {
// Bind the texture FBO since we can't read pixels from an MSAA framebuffer.
if (renderTarget->textureFBOID() == GrGLRenderTarget::kUnresolvableFBOID) {
if (renderTarget->singleSampleFBOID() == GrGLRenderTarget::kUnresolvableFBOID) {
return false;
}
// we don't track the state of the READ FBO ID.
this->bindFramebuffer(GR_GL_READ_FRAMEBUFFER, renderTarget->textureFBOID());
this->bindFramebuffer(GR_GL_READ_FRAMEBUFFER, renderTarget->singleSampleFBOID());
} else {
this->flushRenderTargetNoColorWrites(renderTarget);
}
@ -2316,9 +2316,9 @@ void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target, const SkIRect& resol
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target);
SkASSERT(rt->requiresManualMSAAResolve());
SkASSERT(rt->textureFBOID() != 0 && rt->renderFBOID() != 0);
SkASSERT(rt->singleSampleFBOID() != 0 && rt->renderFBOID() != 0);
this->bindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID());
this->bindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID());
this->bindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->singleSampleFBOID());
// make sure we go through flushRenderTarget() since we've modified
// the bound DRAW FBO ID.
@ -3538,7 +3538,7 @@ void GrGLGpu::xferBarrier(GrRenderTarget* rt, GrXferBarrierType type) {
switch (type) {
case kTexture_GrXferBarrierType: {
GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt);
SkASSERT(glrt->textureFBOID() != 0 && glrt->renderFBOID() != 0);
SkASSERT(glrt->singleSampleFBOID() != 0 && glrt->renderFBOID() != 0);
if (glrt->requiresManualMSAAResolve()) {
// The render target uses separate storage so no need for glTextureBarrier.
// FIXME: The render target will resolve automatically when its texture is bound,

View File

@ -52,7 +52,7 @@ inline void GrGLRenderTarget::setFlags(const GrGLCaps& glCaps, const IDs& idDesc
void GrGLRenderTarget::init(GrGLFormat format, const IDs& idDesc) {
fRTFBOID = idDesc.fRTFBOID;
fTexFBOID = idDesc.fTexFBOID;
fSingleSampleFBOID = idDesc.fSingleSampleFBOID;
fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
fRTFBOOwnership = idDesc.fRTFBOOwnership;
fRTFormat = format;
@ -180,10 +180,10 @@ bool GrGLRenderTarget::completeStencilAttachment() {
void GrGLRenderTarget::onRelease() {
if (GrBackendObjectOwnership::kBorrowed != fRTFBOOwnership) {
GrGLGpu* gpu = this->getGLGpu();
if (fTexFBOID) {
gpu->deleteFramebuffer(fTexFBOID);
if (fSingleSampleFBOID) {
gpu->deleteFramebuffer(fSingleSampleFBOID);
}
if (fRTFBOID && fRTFBOID != fTexFBOID) {
if (fRTFBOID && fRTFBOID != fSingleSampleFBOID) {
gpu->deleteFramebuffer(fRTFBOID);
}
if (fMSColorRenderbufferID) {
@ -191,14 +191,14 @@ void GrGLRenderTarget::onRelease() {
}
}
fRTFBOID = 0;
fTexFBOID = 0;
fSingleSampleFBOID = 0;
fMSColorRenderbufferID = 0;
INHERITED::onRelease();
}
void GrGLRenderTarget::onAbandon() {
fRTFBOID = 0;
fTexFBOID = 0;
fSingleSampleFBOID = 0;
fMSColorRenderbufferID = 0;
INHERITED::onAbandon();
}
@ -254,21 +254,22 @@ void GrGLRenderTarget::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump)
}
int GrGLRenderTarget::msaaSamples() const {
if (fTexFBOID == kUnresolvableFBOID || fTexFBOID != fRTFBOID) {
// If the render target's FBO is external (fTexFBOID == kUnresolvableFBOID), or if we own
// the render target's FBO (fTexFBOID == fRTFBOID) then we use the provided sample count.
if (fSingleSampleFBOID == kUnresolvableFBOID || fSingleSampleFBOID != fRTFBOID) {
// If the render target's FBO is external (fSingleSampleFBOID == kUnresolvableFBOID), or if
// we own the render target's FBO (fSingleSampleFBOID == fRTFBOID) then we use the provided
// sample count.
return this->numSamples();
}
// When fTexFBOID == fRTFBOID, we either are not using MSAA, or MSAA is auto resolving, so use
// 0 for the sample count.
// When fSingleSampleFBOID == fRTFBOID, we either are not using MSAA, or MSAA is auto resolving,
// so use 0 for the sample count.
return 0;
}
int GrGLRenderTarget::totalSamples() const {
int total_samples = this->msaaSamples();
if (fTexFBOID != kUnresolvableFBOID) {
if (fSingleSampleFBOID != kUnresolvableFBOID) {
// If we own the resolve buffer then that is one more sample per pixel.
total_samples += 1;
}

View File

@ -21,14 +21,14 @@ class GrGLRenderTarget : public GrRenderTarget {
public:
bool alwaysClearStencil() const override { return 0 == fRTFBOID; }
// set fTexFBOID to this value to indicate that it is multisampled but
// set fSingleSampleFBOID to this value to indicate that it is multisampled but
// Gr doesn't know how to resolve it.
enum { kUnresolvableFBOID = 0 };
struct IDs {
GrGLuint fRTFBOID;
GrBackendObjectOwnership fRTFBOOwnership;
GrGLuint fTexFBOID;
GrGLuint fSingleSampleFBOID;
GrGLuint fMSColorRenderbufferID;
};
@ -44,7 +44,7 @@ public:
// FBO ID used to render into
GrGLuint renderFBOID() const { return fRTFBOID; }
// FBO ID that has texture ID attached.
GrGLuint textureFBOID() const { return fTexFBOID; }
GrGLuint singleSampleFBOID() const { return fSingleSampleFBOID; }
GrBackendRenderTarget getBackendRenderTarget() const override;
@ -90,7 +90,7 @@ private:
int totalSamples() const;
GrGLuint fRTFBOID;
GrGLuint fTexFBOID;
GrGLuint fSingleSampleFBOID;
GrGLuint fMSColorRenderbufferID;
GrGLFormat fRTFormat;

View File

@ -131,7 +131,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_ownedGLRenderTarget, rep
GrGLRenderTarget::IDs rtIDs;
rtIDs.fRTFBOID = 20;
rtIDs.fRTFBOOwnership = GrBackendObjectOwnership::kOwned;
rtIDs.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
rtIDs.fSingleSampleFBOID = GrGLRenderTarget::kUnresolvableFBOID;
rtIDs.fMSColorRenderbufferID = 22;
sk_sp<GrGLRenderTarget> rt =
@ -149,7 +149,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLRenderTarget, r
GrGLRenderTarget::IDs rtIDs;
rtIDs.fRTFBOID = 20;
rtIDs.fRTFBOOwnership = GrBackendObjectOwnership::kBorrowed;
rtIDs.fTexFBOID = GrGLRenderTarget::kUnresolvableFBOID;
rtIDs.fSingleSampleFBOID = GrGLRenderTarget::kUnresolvableFBOID;
rtIDs.fMSColorRenderbufferID = 22;
sk_sp<GrGLRenderTarget> rt =