Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH

Previously we blocked all PBO->texture transfers.

Bug: angleproject:5542

Change-Id: I1decfbc9293c03da125716c73e6d635e2ab9cb1d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406997
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Brian Salomon 2021-06-04 10:59:23 -04:00 committed by Skia Commit-Bot
parent 9500c8b1f9
commit 7788b3a62f
9 changed files with 28 additions and 12 deletions

View File

@ -315,9 +315,9 @@ struct SK_API GrContextOptions {
bool fRandomGLOOM = false;
/**
* Force off support for write pixels row bytes in caps.
* Force off support for write/transfer pixels row bytes in caps.
*/
bool fDisallowWritePixelRowBytes = false;
bool fDisallowWriteAndTransferPixelRowBytes = false;
/**
* Include or exclude specific GPU path renderers.

View File

@ -52,6 +52,7 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fTransferFromBufferToTextureSupport = false;
fTransferFromSurfaceToBufferSupport = false;
fWritePixelsRowBytesSupport = false;
fTransferPixelsToRowBytesSupport = false;
fReadPixelsRowBytesSupport = false;
fShouldCollapseSrcOverToSrcWhenAble = false;
fMustSyncGpuDuringAbandon = true;
@ -134,8 +135,9 @@ void GrCaps::applyOptionsOverrides(const GrContextOptions& options) {
if (options.fClearAllTextures) {
fShouldInitializeTextures = true;
}
if (options.fDisallowWritePixelRowBytes) {
if (options.fDisallowWriteAndTransferPixelRowBytes) {
fWritePixelsRowBytesSupport = false;
fTransferPixelsToRowBytesSupport = false;
}
#endif
if (options.fSuppressMipmapSupport) {
@ -232,6 +234,7 @@ void GrCaps::dumpJSON(SkJSONWriter* writer) const {
writer->appendBool("Supports transfers from textures to buffers",
fTransferFromSurfaceToBufferSupport);
writer->appendBool("Write pixels row bytes support", fWritePixelsRowBytesSupport);
writer->appendBool("Transfer pixels to row bytes support", fTransferPixelsToRowBytesSupport);
writer->appendBool("Read pixels row bytes support", fReadPixelsRowBytesSupport);
writer->appendBool("Disable msaa clip mask atlas on current driver [workaround]",
fDriverDisableMSAAClipAtlas);

View File

@ -314,10 +314,16 @@ public:
GrColorType dstColorType) const;
/**
* Do GrGpu::writePixels() and GrGpu::transferPixelsTo() support a src buffer where the row
* bytes is not equal to bpp * w?
* Does GrGpu::writePixels() support a src buffer where the row bytes is not equal to bpp * w?
*/
bool writePixelsRowBytesSupport() const { return fWritePixelsRowBytesSupport; }
/**
* Does GrGpu::transferPixelsTo() support a src buffer where the row bytes is not equal to
* bpp * w?
*/
bool transferPixelsToRowBytesSupport() const { return fTransferPixelsToRowBytesSupport; }
/**
* Does GrGpu::readPixels() support a dst buffer where the row bytes is not equal to bpp * w?
*/
@ -537,6 +543,7 @@ protected:
bool fTransferFromBufferToTextureSupport : 1;
bool fTransferFromSurfaceToBufferSupport : 1;
bool fWritePixelsRowBytesSupport : 1;
bool fTransferPixelsToRowBytesSupport : 1;
bool fReadPixelsRowBytesSupport : 1;
bool fShouldCollapseSrcOverToSrcWhenAble : 1;
bool fMustSyncGpuDuringAbandon : 1;

View File

@ -44,6 +44,7 @@ GrD3DCaps::GrD3DCaps(const GrContextOptions& contextOptions, IDXGIAdapter1* adap
// We always copy in/out of a transfer buffer so it's trivial to support row bytes.
fReadPixelsRowBytesSupport = true;
fWritePixelsRowBytesSupport = true;
fTransferPixelsToRowBytesSupport = true;
fTransferFromBufferToTextureSupport = true;
fTransferFromSurfaceToBufferSupport = true;

View File

@ -129,6 +129,8 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
fWritePixelsRowBytesSupport = version >= GR_GL_VER(2, 0);
fReadPixelsRowBytesSupport = version >= GR_GL_VER(2, 0);
}
fTransferPixelsToRowBytesSupport = fWritePixelsRowBytesSupport;
if (fDriverBugWorkarounds.pack_parameters_workaround_with_pack_buffer) {
// In some cases drivers handle copying the last row incorrectly
// when using GL_PACK_ROW_LENGTH. Chromium handles this by iterating
@ -3518,10 +3520,11 @@ void GrGLCaps::applyDriverCorrectnessWorkarounds(const GrGLContextInfo& ctxInfo,
fTransferBufferType = TransferBufferType::kNone;
}
// The TransferPixelsToTexture test fails on ANGLE D3D.
// The TransferPixelsToTexture test fails on ANGLE D3D9 and D3D11 if this is enabled.
// https://anglebug.com/5542
if (ctxInfo.angleBackend() == GrGLANGLEBackend::kD3D9 ||
ctxInfo.angleBackend() == GrGLANGLEBackend::kD3D11) {
fTransferFromBufferToTextureSupport = false;
fTransferPixelsToRowBytesSupport = false;
}
// Using MIPs on this GPU seems to be a source of trouble.

View File

@ -593,7 +593,8 @@ void GrGLGpu::onResetContext(uint32_t resetBits) {
// we assume these values
if (resetBits & kPixelStore_GrGLBackendState) {
if (this->caps()->writePixelsRowBytesSupport()) {
if (this->caps()->writePixelsRowBytesSupport() ||
this->caps()->transferPixelsToRowBytesSupport()) {
GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, 0));
}
if (this->glCaps().readPixelsRowBytesSupport()) {
@ -892,7 +893,7 @@ bool GrGLGpu::onTransferPixelsTo(GrTexture* texture,
bool restoreGLRowLength = false;
if (trimRowBytes != rowBytes) {
// we should have checked for this support already
SkASSERT(this->glCaps().writePixelsRowBytesSupport());
SkASSERT(this->glCaps().transferPixelsToRowBytesSupport());
GL_CALL(PixelStorei(GR_GL_UNPACK_ROW_LENGTH, rowBytes / bpp));
restoreGLRowLength = true;
}

View File

@ -275,6 +275,7 @@ void GrMtlCaps::initGrCaps(id<MTLDevice> device) {
// We always copy in/out of a transfer buffer so it's trivial to support row bytes.
fReadPixelsRowBytesSupport = true;
fWritePixelsRowBytesSupport = true;
fTransferPixelsToRowBytesSupport = true;
// RenderTarget and Texture size
if (this->isMac()) {

View File

@ -740,7 +740,7 @@ DEF_GPUTEST(ColorTypeBackendAllocationTest, reporter, options) {
if (info.directContext()->priv().caps()->writePixelsRowBytesSupport() &&
info.directContext()->backend() == GrBackendApi::kOpenGL) {
GrContextOptions overrideOptions = options;
overrideOptions.fDisallowWritePixelRowBytes = true;
overrideOptions.fDisallowWriteAndTransferPixelRowBytes = true;
sk_gpu_test::GrContextFactory overrideFactory(overrideOptions);
info = overrideFactory.getContextInfo(type);
color_type_backend_allocation_test(info, reporter);

View File

@ -123,7 +123,7 @@ void basic_transfer_to_test(skiatest::Reporter* reporter,
GrGpu* gpu = dContext->priv().getGpu();
static constexpr SkISize kTexDims = {16, 16};
int srcBufferWidth = caps->writePixelsRowBytesSupport() ? 20 : 16;
int srcBufferWidth = caps->transferPixelsToRowBytesSupport() ? 20 : 16;
const int kBufferHeight = 16;
sk_sp<GrTexture> tex =
@ -217,7 +217,7 @@ void basic_transfer_to_test(skiatest::Reporter* reporter,
// transfer partial data
// We're relying on this cap to write partial texture data
if (!caps->writePixelsRowBytesSupport()) {
if (!caps->transferPixelsToRowBytesSupport()) {
return;
}
// We keep a 1 to 1 correspondence between pixels in the buffer and the entire texture. We