aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLCaps.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-11-03 13:42:00 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-03 18:06:37 +0000
commit71d9d84d6cd38b9dc8711849952bb9e668ab33a2 (patch)
tree35f68bcf7d8ac337555a0479882e19a7fc8bec15 /src/gpu/gl/GrGLCaps.cpp
parent89eda8a5e3f9023a4ee4648627101d7b4e60b4c8 (diff)
Use temporary FBO for GrGLGpu::onReadPixels.
Allow configs to be supported as FBO attachments for copies/readbacks without being "renderable" elsewhere in Ganesh. The motivation for this is to add support for int textures as srcs but not as dsts (at least initially) but to still be able to read them back. This means we don't pay for a unneeded GPU copy when reading back a GrSurface that is a GrTexture and not a GrRenderTarget. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4345 Change-Id: I824a73c6b8c1b9634206d76ccf0848d5f9b64441 Reviewed-on: https://skia-review.googlesource.com/4345 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/gl/GrGLCaps.cpp')
-rw-r--r--src/gpu/gl/GrGLCaps.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 220da0faf3..0af5c57a3e 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -852,19 +852,19 @@ bool GrGLCaps::hasPathRenderingSupport(const GrGLContextInfo& ctxInfo, const GrG
return true;
}
-bool GrGLCaps::readPixelsSupported(GrPixelConfig rtConfig,
+bool GrGLCaps::readPixelsSupported(GrPixelConfig surfaceConfig,
GrPixelConfig readConfig,
std::function<void (GrGLenum, GrGLint*)> getIntegerv,
std::function<bool ()> bindRenderTarget) const {
- // If it's not possible to even have a render target of rtConfig then read pixels is
+ // If it's not possible to even have a color attachment of surfaceConfig then read pixels is
// not supported regardless of readConfig.
- if (!this->isConfigRenderable(rtConfig, false)) {
+ if (!this->canConfigBeFBOColorAttachment(surfaceConfig)) {
return false;
}
GrGLenum readFormat;
GrGLenum readType;
- if (!this->getReadPixelsFormat(rtConfig, readConfig, &readFormat, &readType)) {
+ if (!this->getReadPixelsFormat(surfaceConfig, readConfig, &readFormat, &readType)) {
return false;
}
@@ -890,20 +890,20 @@ bool GrGLCaps::readPixelsSupported(GrPixelConfig rtConfig,
// See Section 16.1.2 in the ES 3.2 specification.
- if (kNormalizedFixedPoint_FormatType == fConfigTable[rtConfig].fFormatType) {
+ if (kNormalizedFixedPoint_FormatType == fConfigTable[surfaceConfig].fFormatType) {
if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) {
return true;
}
} else {
- SkASSERT(kFloat_FormatType == fConfigTable[rtConfig].fFormatType);
+ SkASSERT(kFloat_FormatType == fConfigTable[surfaceConfig].fFormatType);
if (GR_GL_RGBA == readFormat && GR_GL_FLOAT == readType) {
return true;
}
}
- if (0 == fConfigTable[rtConfig].fSecondReadPixelsFormat.fFormat) {
+ if (0 == fConfigTable[surfaceConfig].fSecondReadPixelsFormat.fFormat) {
ReadPixelsFormat* rpFormat =
- const_cast<ReadPixelsFormat*>(&fConfigTable[rtConfig].fSecondReadPixelsFormat);
+ const_cast<ReadPixelsFormat*>(&fConfigTable[surfaceConfig].fSecondReadPixelsFormat);
GrGLint format = 0, type = 0;
if (!bindRenderTarget()) {
return false;
@@ -914,8 +914,8 @@ bool GrGLCaps::readPixelsSupported(GrPixelConfig rtConfig,
rpFormat->fType = type;
}
- return fConfigTable[rtConfig].fSecondReadPixelsFormat.fFormat == readFormat &&
- fConfigTable[rtConfig].fSecondReadPixelsFormat.fType == readType;
+ return fConfigTable[surfaceConfig].fSecondReadPixelsFormat.fFormat == readFormat &&
+ fConfigTable[surfaceConfig].fSecondReadPixelsFormat.fType == readType;
}
void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
@@ -1400,11 +1400,12 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ES 3.2
Adds R16F, RG16F, RGBA16F, R32F, RG32F, RGBA32F, R11F_G11F_B10F.
*/
- uint32_t allRenderFlags = ConfigInfo::kRenderable_Flag;
+ uint32_t nonMSAARenderFlags = ConfigInfo::kRenderable_Flag |
+ ConfigInfo::kFBOColorAttachment_Flag;
+ uint32_t allRenderFlags = nonMSAARenderFlags;
if (kNone_MSFBOType != fMSFBOType) {
allRenderFlags |= ConfigInfo::kRenderableWithMSAA_Flag;
}
-
GrGLStandard standard = ctxInfo.standard();
GrGLVersion version = ctxInfo.version();
@@ -1487,7 +1488,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
}
} else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag |
- ConfigInfo::kRenderable_Flag;
+ nonMSAARenderFlags;
if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888") &&
(this->usesMSAARenderBuffers() || this->fMSFBOType == kMixedSamples_MSFBOType)) {
fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |=
@@ -1652,8 +1653,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
bool hasFPTextures = false;
bool hasHalfFPTextures = false;
// for now we don't support floating point MSAA on ES
- uint32_t fpRenderFlags = (kGL_GrGLStandard == standard) ?
- allRenderFlags : (uint32_t)ConfigInfo::kRenderable_Flag;
+ uint32_t fpRenderFlags = (kGL_GrGLStandard == standard) ? allRenderFlags : nonMSAARenderFlags;
if (kGL_GrGLStandard == standard) {
if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_texture_float")) {
@@ -1946,6 +1946,10 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
// Make sure we initialized everything.
ConfigInfo defaultEntry;
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
+ // Make sure we didn't set renderable and not blittable or renderable with msaa and not
+ // renderable.
+ SkASSERT(!((ConfigInfo::kRenderable_Flag) && !(ConfigInfo::kFBOColorAttachment_Flag)));
+ SkASSERT(!((ConfigInfo::kRenderableWithMSAA_Flag) && !(ConfigInfo::kRenderable_Flag)));
SkASSERT(defaultEntry.fFormats.fBaseInternalFormat !=
fConfigTable[i].fFormats.fBaseInternalFormat);
SkASSERT(defaultEntry.fFormats.fSizedInternalFormat !=