aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-02-27 16:46:11 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-28 03:14:25 +0000
commit3d86a19f420c2b406620b086c319732eb4135d33 (patch)
tree3270b5213f84f710c6e6d1d5d86422242d120586 /src
parente5b7ceeac865fb8a3bab82a73d65752c78682718 (diff)
Refactor GrCaps::renderTargetWritePixelsSupported to support for some GL workarounds
Make indirect path in writeSurfacePixels2 use a copy rather than a draw. Fix issue in GrVkGpu where render target dirty region is not updated after copy-as-draw Remove unnecessary resolve of MSAA RT in GrVkCopyManager. Splits WritePixelsNonTexture_Gpu test into MSAA and non-MSAA variants. MSAA variant blacklisted on Adreno because of: Bug: skia:7663 ~~~~~~AND~~~~~~~ Revert "Suppress CopySurface test on Nexus 7" This reverts commit b42b6169d52408a1712c2740655300465cd6ff1e. Bug: skia:7658 Change-Id: I8337d718efb41e266537744bbf5ff8b1545322a7 Reviewed-on: https://skia-review.googlesource.com/110700 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrContext.cpp14
-rw-r--r--src/gpu/gl/GrGLCaps.cpp23
-rw-r--r--src/gpu/gl/GrGLCaps.h7
-rw-r--r--src/gpu/gl/GrGLGpu.cpp1
-rw-r--r--src/gpu/mock/GrMockCaps.h4
-rw-r--r--src/gpu/mtl/GrMtlCaps.h4
-rw-r--r--src/gpu/vk/GrVkCaps.cpp9
-rw-r--r--src/gpu/vk/GrVkCaps.h4
-rw-r--r--src/gpu/vk/GrVkGpu.cpp2
9 files changed, 37 insertions, 31 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 5b3d6644d7..c61a6c189e 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1054,10 +1054,7 @@ bool GrContextPriv::writeSurfacePixels2(GrSurfaceContext* dst, int left, int top
return false;
}
- auto dstRTProxy = dstProxy->asRenderTargetProxy();
- if (dstRTProxy &&
- !fContext->caps()->renderTargetWritePixelsSupported(SkToBool(dstProxy->asTextureProxy()),
- dstRTProxy->numColorSamples())) {
+ if (!fContext->caps()->surfaceSupportsWritePixels(dstSurface)) {
GrSurfaceDesc desc;
desc.fConfig = dstProxy->config();
desc.fWidth = width;
@@ -1078,14 +1075,7 @@ bool GrContextPriv::writeSurfacePixels2(GrSurfaceContext* dst, int left, int top
srcColorSpace, buffer, rowBytes, pixelOpsFlags)) {
return false;
}
- GrPaint paint;
- paint.setAllowSRGBInputs(true);
- paint.addColorTextureProcessor(std::move(tempProxy), SkMatrix::I());
- paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- dst->asRenderTargetContext()->drawRect(GrNoClip(), std::move(paint), GrAA::kNo,
- SkMatrix::MakeTrans(left, top),
- SkRect::MakeIWH(width, height));
- return true;
+ return dst->copy(tempProxy.get(), SkIRect::MakeWH(width, height), {left, top});
}
// TODO: Make GrSurfaceContext know its alpha type and pass src buffer's alpha type.
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 3bdf5d0e60..c31cdc75bf 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -2391,9 +2391,6 @@ void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
SkASSERT(!fUseDrawInsteadOfAllRenderTargetWrites);
SkASSERT(!fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines);
}
- if (options.fUseDrawInsteadOfPartialRenderTargetWrite) {
- fUseDrawInsteadOfAllRenderTargetWrites = true;
- }
if (GrContextOptions::Enable::kNo == options.fUseDrawInsteadOfGLClear) {
fUseDrawToClearColor = false;
} else if (GrContextOptions::Enable::kYes == options.fUseDrawInsteadOfGLClear) {
@@ -2404,6 +2401,26 @@ void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
}
}
+bool GrGLCaps::surfaceSupportsWritePixels(const GrSurface* surface) const {
+ if (fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO) {
+ if (auto tex = static_cast<const GrGLTexture*>(surface->asTexture())) {
+ if (tex->hasBaseLevelBeenBoundToFBO()) {
+ return false;
+ }
+ }
+ }
+ if (auto rt = surface->asRenderTarget()) {
+ if (fUseDrawInsteadOfAllRenderTargetWrites) {
+ return false;
+ }
+ if (rt->numColorSamples() > 1 && this->usesMSAARenderBuffers()) {
+ return false;
+ }
+ return SkToBool(surface->asTexture());
+ }
+ return true;
+}
+
bool GrGLCaps::onIsMixedSamplesSupportedForRT(const GrBackendRenderTarget& backendRT) const {
const GrGLFramebufferInfo* fbInfo = backendRT.getGLFramebufferInfo();
SkASSERT(fbInfo);
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index f7b4f68b49..770ebca946 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -316,12 +316,7 @@ public:
/// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
- bool renderTargetWritePixelsSupported(bool isAlsoTexture, int sampleCnt) const override {
- if (sampleCnt > 1 && this->usesMSAARenderBuffers()) {
- return false;
- }
- return isAlsoTexture;
- }
+ bool surfaceSupportsWritePixels(const GrSurface* surface) const override;
/// Does ReadPixels support reading readConfig pixels from a FBO that is surfaceConfig?
bool readPixelsSupported(GrPixelConfig surfaceConfig,
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 76baafbd01..af7c4706d3 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3462,6 +3462,7 @@ bool GrGLGpu::onCopySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin,
return false;
}
// Don't prefer copying as a draw if the dst doesn't already have a FBO object.
+ // This implicitly handles this->glCaps().useDrawInsteadOfAllRenderTargetWrites().
bool preferCopy = SkToBool(dst->asRenderTarget());
if (preferCopy && src->asTexture()) {
if (this->copySurfaceAsDraw(dst, dstOrigin, src, srcOrigin, srcRect, dstPoint)) {
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index 3ef404f1dc..d8a2aad866 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -67,9 +67,7 @@ public:
return 0;
}
- bool renderTargetWritePixelsSupported(bool isAlsoTexture, int sampleCnt) const override {
- return true;
- }
+ bool surfaceSupportsWritePixels(const GrSurface* surface) const override { return true; }
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
bool* rectsMustMatch, bool* disallowSubrect) const override {
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
index 61eaffed64..1252fd8680 100644
--- a/src/gpu/mtl/GrMtlCaps.h
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -31,9 +31,7 @@ public:
int getRenderTargetSampleCount(int requestedCount, GrPixelConfig) const override;
int maxRenderTargetSampleCount(GrPixelConfig) const override;
- bool renderTargetWritePixelsSupported(bool isAlsoTexture, int sampleCnt) const override {
- return true;
- }
+ bool surfaceSupportsWritePixels(const GrSurface* surface) const override { return true; }
bool isConfigCopyable(GrPixelConfig config) const override {
return true;
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 602d07b27d..869d6e0e10 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -6,9 +6,9 @@
*/
#include "GrVkCaps.h"
-
#include "GrBackendSurface.h"
#include "GrRenderTargetProxy.h"
+#include "GrRenderTarget.h"
#include "GrShaderCaps.h"
#include "GrVkUtil.h"
#include "vk/GrVkBackendContext.h"
@@ -429,6 +429,13 @@ int GrVkCaps::maxRenderTargetSampleCount(GrPixelConfig config) const {
return table[table.count() - 1];
}
+bool GrVkCaps::surfaceSupportsWritePixels(const GrSurface* surface) const {
+ if (auto rt = surface->asRenderTarget()) {
+ return rt->numColorSamples() <= 1 && SkToBool(surface->asTexture());
+ }
+ return true;
+}
+
bool validate_image_info(VkFormat format, SkColorType ct, GrPixelConfig* config) {
*config = kUnknown_GrPixelConfig;
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h
index 55ed916807..14f37c94eb 100644
--- a/src/gpu/vk/GrVkCaps.h
+++ b/src/gpu/vk/GrVkCaps.h
@@ -40,9 +40,7 @@ public:
int getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const override;
int maxRenderTargetSampleCount(GrPixelConfig config) const override;
- bool renderTargetWritePixelsSupported(bool isAlsoTexture, int sampleCnt) const override {
- return sampleCnt <= 1 && isAlsoTexture;
- }
+ bool surfaceSupportsWritePixels(const GrSurface* surface) const override;
bool isConfigTexturableLinearly(GrPixelConfig config) const {
return SkToBool(ConfigInfo::kTextureable_Flag & fConfigTable[config].fLinearFlags);
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 95c86ef625..e4a980a97a 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1845,6 +1845,8 @@ bool GrVkGpu::onCopySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin,
}
if (fCopyManager.copySurfaceAsDraw(this, dst, dstOrigin, src, srcOrigin, srcRect, dstPoint)) {
+ auto dstRect = srcRect.makeOffset(dstPoint.fX, dstPoint.fY);
+ this->didWriteToSurface(dst, dstOrigin, &dstRect);
return true;
}