Move verified color attachment flag to FormatInfo.

Bug: skia:6718
Change-Id: I7d44177bab44d8d72ded7442e1a17c5f451882a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228058
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2019-07-17 10:40:13 -04:00 committed by Skia Commit-Bot
parent f2c2ba99f6
commit 9bb268be63
2 changed files with 21 additions and 21 deletions

View File

@ -244,20 +244,18 @@ public:
void setStencilFormatIndexForFormat(GrGLFormat, int index);
/**
* Call to note that a color config has been verified as a valid color
* attachment. This may save future calls to glCheckFramebufferStatus
* using isConfigVerifiedColorAttachment().
* Call to note that a GrGLFormat has been verified as a valid color attachment. This may save
* future calls to glCheckFramebufferStatus using isFormatVerifiedColorAttachment().
*/
void markConfigAsValidColorAttachment(GrPixelConfig config) {
fConfigTable[config].fVerifiedColorAttachment = true;
void markFormatAsValidColorAttachment(GrGLFormat format) {
this->getFormatInfo(format).fVerifiedColorAttachment = true;
}
/**
* Call to check whether a config has been verified as a valid color
* attachment.
* Call to check whether a format has been verified as a valid color attachment.
*/
bool isConfigVerifiedColorAttachment(GrPixelConfig config) const {
return fConfigTable[config].fVerifiedColorAttachment;
bool isFormatVerifiedColorAttachment(GrGLFormat format) const {
return this->getFormatInfo(format).fVerifiedColorAttachment;
}
/**
@ -613,10 +611,6 @@ private:
// color channels this indicates how each channel should be interpreted. May contain
// 0s and 1s.
GrSwizzle fRGBAReadSwizzle = GrSwizzle("rgba");
// verification of color attachment validity is done while flushing. Although only ever
// used in the (sole) rendering thread it can cause races if it is glommed into fFlags.
bool fVerifiedColorAttachment = false;
};
ConfigInfo fConfigTable[kGrPixelConfigCnt];
@ -692,6 +686,10 @@ private:
SkTDArray<int> fColorSampleCounts;
// verification of color attachment validity is done while flushing. Although only ever
// used in the (sole) rendering thread it can cause races if it is glommed into fFlags.
bool fVerifiedColorAttachment = false;
SkSTArray<1, ColorTypeInfo> fColorTypeInfos;
};

View File

@ -1348,6 +1348,11 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
GrGLenum colorRenderbufferFormat = 0; // suppress warning
GrGLFormat format = GrGLFormatFromGLEnum(texInfo.fFormat);
if (format == GrGLFormat::kUnknown) {
goto FAILED;
}
if (desc.fSampleCnt > 1 && GrGLCaps::kNone_MSFBOType == this->glCaps().msFBOType()) {
goto FAILED;
}
@ -1368,10 +1373,7 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
!idDesc->fMSColorRenderbufferID) {
goto FAILED;
}
GrGLFormat glFormat =
GrGLFormatFromGLEnum(this->glCaps().configSizedInternalFormat(desc.fConfig));
colorRenderbufferFormat =
this->glCaps().getRenderbufferInternalFormat(glFormat);
colorRenderbufferFormat = this->glCaps().getRenderbufferInternalFormat(format);
} else {
idDesc->fRTFBOID = idDesc->fTexFBOID;
}
@ -1392,12 +1394,12 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
GR_GL_COLOR_ATTACHMENT0,
GR_GL_RENDERBUFFER,
idDesc->fMSColorRenderbufferID));
if (!this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) {
if (!this->glCaps().isFormatVerifiedColorAttachment(format)) {
GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
goto FAILED;
}
fGLContext->caps()->markConfigAsValidColorAttachment(desc.fConfig);
fGLContext->caps()->markFormatAsValidColorAttachment(format);
}
}
this->bindFramebuffer(GR_GL_FRAMEBUFFER, idDesc->fTexFBOID);
@ -1413,12 +1415,12 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
texInfo.fTarget,
texInfo.fID, 0));
}
if (!this->glCaps().isConfigVerifiedColorAttachment(desc.fConfig)) {
if (!this->glCaps().isFormatVerifiedColorAttachment(format)) {
GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
goto FAILED;
}
fGLContext->caps()->markConfigAsValidColorAttachment(desc.fConfig);
fGLContext->caps()->markFormatAsValidColorAttachment(format);
}
return true;