Enable transfer from texture to buffer on ANGLE.

This is necessary to support the async readback API on Windows Chrome.

Transfer from buffer to texture is still disabled as the unit test
still fails.

Bug: chromium:1040643

Change-Id: I0e16437c066fadfdd8dbbbcaf376c6901a538063
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263528
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Brian Salomon 2020-01-10 13:04:45 -05:00 committed by Skia Commit-Bot
parent ba80f359af
commit fb28c6fb7f
8 changed files with 33 additions and 22 deletions

View File

@ -45,7 +45,8 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fAvoidLargeIndexBufferDraws = false;
fPerformStencilClearsAsDraws = false;
fAllowCoverageCounting = false;
fTransferBufferSupport = false;
fTransferFromBufferToTextureSupport = false;
fTransferFromSurfaceToBufferSupport = false;
fWritePixelsRowBytesSupport = false;
fReadPixelsRowBytesSupport = false;
fDriverBlacklistCCPR = false;
@ -212,7 +213,10 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const {
writer->appendBool("Avoid Large IndexBuffer Draws", fAvoidLargeIndexBufferDraws);
writer->appendBool("Use draws for stencil clip clears", fPerformStencilClearsAsDraws);
writer->appendBool("Allow coverage counting shortcuts", fAllowCoverageCounting);
writer->appendBool("Supports transfer buffers", fTransferBufferSupport);
writer->appendBool("Supports transfers from buffers to textures",
fTransferFromBufferToTextureSupport);
writer->appendBool("Supports transfers from textures to buffers",
fTransferFromSurfaceToBufferSupport);
writer->appendBool("Write pixels row bytes support", fWritePixelsRowBytesSupport);
writer->appendBool("Read pixels row bytes support", fReadPixelsRowBytesSupport);
writer->appendBool("Blacklist CCPR on current driver [workaround]", fDriverBlacklistCCPR);

View File

@ -290,8 +290,8 @@ public:
*/
bool readPixelsRowBytesSupport() const { return fReadPixelsRowBytesSupport; }
/** Are transfer buffers (to textures and from surfaces) supported? */
bool transferBufferSupport() const { return fTransferBufferSupport; }
bool transferFromSurfaceToBufferSupport() const { return fTransferFromSurfaceToBufferSupport; }
bool transferFromBufferToTextureSupport() const { return fTransferFromBufferToTextureSupport; }
bool suppressPrints() const { return fSuppressPrints; }
@ -511,7 +511,8 @@ protected:
bool fAvoidLargeIndexBufferDraws : 1;
bool fPerformStencilClearsAsDraws : 1;
bool fAllowCoverageCounting : 1;
bool fTransferBufferSupport : 1;
bool fTransferFromBufferToTextureSupport : 1;
bool fTransferFromSurfaceToBufferSupport : 1;
bool fWritePixelsRowBytesSupport : 1;
bool fReadPixelsRowBytesSupport : 1;

View File

@ -694,7 +694,7 @@ GrSurfaceContext::PixelTransferResult GrSurfaceContext::transferPixels(GrColorTy
return {};
}
if (!this->caps()->transferBufferSupport() ||
if (!this->caps()->transferFromSurfaceToBufferSupport() ||
!supportedRead.fOffsetAlignmentForTransferBuffer) {
return {};
}

View File

@ -493,7 +493,8 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
if (GR_IS_GR_GL(standard)) {
if (version >= GR_GL_VER(2, 1) || ctxInfo.hasExtension("GL_ARB_pixel_buffer_object") ||
ctxInfo.hasExtension("GL_EXT_pixel_buffer_object")) {
fTransferBufferSupport = true;
fTransferFromBufferToTextureSupport = true;
fTransferFromSurfaceToBufferSupport = true;
fTransferBufferType = kPBO_TransferBufferType;
}
} else if (GR_IS_GR_GL_ES(standard)) {
@ -501,11 +502,13 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
(ctxInfo.hasExtension("GL_NV_pixel_buffer_object") &&
// GL_EXT_unpack_subimage needed to support subtexture rectangles
ctxInfo.hasExtension("GL_EXT_unpack_subimage"))) {
fTransferBufferSupport = true;
fTransferFromBufferToTextureSupport = true;
fTransferFromSurfaceToBufferSupport = true;
fTransferBufferType = kPBO_TransferBufferType;
// TODO: get transfer buffers working in Chrome
// } else if (ctxInfo.hasExtension("GL_CHROMIUM_pixel_transfer_buffer_object")) {
// fTransferBufferSupport = true;
// fTransferFromBufferToTextureSupport = false;
// fTransferFromSurfaceToBufferSupport = false;
// fTransferBufferType = kChromium_TransferBufferType;
}
} // no WebGL support
@ -3328,14 +3331,14 @@ void GrGLCaps::applyDriverCorrectnessWorkarounds(const GrGLContextInfo& ctxInfo,
ctxInfo.driverVersion() > GR_GL_DRIVER_VER(127, 0, 0)) {
fMapBufferType = kNone_MapBufferType;
fMapBufferFlags = kNone_MapFlags;
fTransferBufferSupport = false;
fTransferFromBufferToTextureSupport = false;
fTransferFromSurfaceToBufferSupport = false;
fTransferBufferType = kNone_TransferBufferType;
}
// TODO: re-enable for ANGLE
// The TransferPixelsToTexture test fails on ANGLE.
if (kANGLE_GrGLDriver == ctxInfo.driver()) {
fTransferBufferSupport = false;
fTransferBufferType = kNone_TransferBufferType;
fTransferFromBufferToTextureSupport = false;
}
// Using MIPs on this GPU seems to be a source of trouble.

View File

@ -268,7 +268,8 @@ void GrMtlCaps::initGrCaps(const id<MTLDevice> device) {
fReuseScratchTextures = true; // Assuming this okay
fTransferBufferSupport = true;
fTransferFromBufferToTextureSupport = true;
fTransferFromSurfaceToBufferSupport = true;
fTextureBarrierSupport = false; // Need to figure out if we can do this

View File

@ -51,7 +51,8 @@ GrVkCaps::GrVkCaps(const GrContextOptions& contextOptions, const GrVkInterface*
fReadPixelsRowBytesSupport = true;
fWritePixelsRowBytesSupport = true;
fTransferBufferSupport = true;
fTransferFromBufferToTextureSupport = true;
fTransferFromSurfaceToBufferSupport = true;
fMaxRenderTargetSize = 4096; // minimum required by spec
fMaxTextureSize = 4096; // minimum required by spec
@ -403,7 +404,7 @@ void GrVkCaps::applyDriverCorrectnessWorkarounds(const VkPhysicalDevicePropertie
if (kQualcomm_VkVendor == properties.vendorID) {
fMustDoCopiesFromOrigin = true;
// Transfer doesn't support this workaround.
fTransferBufferSupport = false;
fTransferFromSurfaceToBufferSupport = false;
}
#if defined(SK_BUILD_FOR_WIN)

View File

@ -1035,8 +1035,9 @@ DEF_GPUTEST(AsyncReadPixelsContextShutdown, reporter, options) {
if (!context) {
continue;
}
// This test is only meaningful for contexts that support transfer buffers.
if (!context->priv().caps()->transferBufferSupport()) {
// This test is only meaningful for contexts that support transfer buffers for
// reads.
if (!context->priv().caps()->transferFromSurfaceToBufferSupport()) {
continue;
}
auto surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, ii, 1, nullptr);

View File

@ -417,8 +417,8 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C
#endif
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TransferPixelsToTest, reporter, ctxInfo) {
if (!ctxInfo.grContext()->priv().caps()->transferBufferSupport()) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TransferPixelsToTextureTest, reporter, ctxInfo) {
if (!ctxInfo.grContext()->priv().caps()->transferFromBufferToTextureSupport()) {
return;
}
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
@ -448,8 +448,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TransferPixelsToTest, reporter, ctxInfo) {
}
// TODO(bsalomon): Metal
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TransferPixelsFromTest, reporter, ctxInfo) {
if (!ctxInfo.grContext()->priv().caps()->transferBufferSupport()) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(TransferPixelsFromTextureTest, reporter, ctxInfo) {
if (!ctxInfo.grContext()->priv().caps()->transferFromSurfaceToBufferSupport()) {
return;
}
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {