Use texture barriers to read directly from the RT
Updates GrXferProcessor to read directly from the RT texture when
texture barriers are supported and it needs to know the dst color.
Also adds the notion of an Xfer barrier and uses it to issue texture
barriers when the XP will read the RT.
BUG=skia:
Review URL: https://codereview.chromium.org/1040303002
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index e52e4f9..d868bcb 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -78,8 +78,20 @@
if (!pipelineBuilder.willXPNeedDstCopy(*this->caps(), colorPOI, coveragePOI)) {
return true;
}
- SkIRect copyRect;
+
GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
+
+ if (this->caps()->textureBarrierSupport()) {
+ if (GrTexture* rtTex = rt->asTexture()) {
+ // The render target is a texture, se we can read from it directly in the shader. The XP
+ // will be responsible to detect this situation and request a texture barrier.
+ dstCopy->setTexture(rtTex);
+ dstCopy->setOffset(0, 0);
+ return true;
+ }
+ }
+
+ SkIRect copyRect;
pipelineBuilder.clip().getConservativeBounds(rt, ©Rect);
if (drawBounds) {