Reland "Add ability to specify different GP textures for each mesh in a draw."
This reverts commit deeb655912b90d9b19d692f4b6ebe55ff4ce90cb.
Reason for revert: Fix landed for incorrect chaining logic: https://skia-review.googlesource.com/148380
Original change's description:
> Revert "Add ability to specify different GP textures for each mesh in a draw."
>
> This reverts commit d1b8a166db27ffb8e550c4e853afbd67025948bf.
>
> Reason for revert: breaks android apps, by drawing overlapping content out of painters order.
>
> Original change's description:
> > Add ability to specify different GP textures for each mesh in a draw.
> >
> > Uses GrPipeline::DynamicStateArrays to allow per-mesh GP textures when
> > drawing an array of GrMeshes.
> >
> > Uses this along with op-chaining to make drawing multiple TextureOps
> > with different textures faster.
> >
> > Change-Id: Iec4da1b72a13d0e0c94c8a8568fe4221c539dfcf
> > Reviewed-on: https://skia-review.googlesource.com/145960
> > Commit-Queue: Brian Salomon <bsalomon@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,brianosman@google.com
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Change-Id: I5c686b85adb378ba7faf34576efce74aebd348f7
> Reviewed-on: https://skia-review.googlesource.com/147260
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I90173d4072c64b9ec4c87989e63e4ed283bd4829
Reviewed-on: https://skia-review.googlesource.com/148681
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrOpFlushState.cpp b/src/gpu/GrOpFlushState.cpp
index 6385c9f..a1d9229 100644
--- a/src/gpu/GrOpFlushState.cpp
+++ b/src/gpu/GrOpFlushState.cpp
@@ -102,19 +102,28 @@
void GrOpFlushState::draw(sk_sp<const GrGeometryProcessor> gp, const GrPipeline* pipeline,
const GrPipeline::FixedDynamicState* fixedDynamicState,
+ const GrPipeline::DynamicStateArrays* dynamicStateArrays,
const GrMesh meshes[], int meshCnt) {
SkASSERT(fOpArgs);
SkASSERT(fOpArgs->fOp);
bool firstDraw = fDraws.begin() == fDraws.end();
auto& draw = fDraws.append(&fArena);
GrDeferredUploadToken token = fTokenTracker->issueDrawToken();
- for (int i = 0; i < gp->numTextureSamplers(); ++i) {
- fixedDynamicState->fPrimitiveProcessorTextures[i]->addPendingRead();
+ if (fixedDynamicState && fixedDynamicState->fPrimitiveProcessorTextures) {
+ for (int i = 0; i < gp->numTextureSamplers(); ++i) {
+ fixedDynamicState->fPrimitiveProcessorTextures[i]->addPendingRead();
+ }
+ }
+ if (dynamicStateArrays && dynamicStateArrays->fPrimitiveProcessorTextures) {
+ int n = gp->numTextureSamplers() * meshCnt;
+ for (int i = 0; i < n; ++i) {
+ dynamicStateArrays->fPrimitiveProcessorTextures[i]->addPendingRead();
+ }
}
draw.fGeometryProcessor = std::move(gp);
draw.fPipeline = pipeline;
draw.fFixedDynamicState = fixedDynamicState;
- draw.fDynamicStateArrays = nullptr;
+ draw.fDynamicStateArrays = dynamicStateArrays;
draw.fMeshes = meshes;
draw.fMeshCnt = meshCnt;
draw.fOpID = fOpArgs->fOp->uniqueID();
@@ -165,3 +174,20 @@
GrAtlasManager* GrOpFlushState::atlasManager() const {
return fGpu->getContext()->contextPriv().getAtlasManager();
}
+
+//////////////////////////////////////////////////////////////////////////////
+
+GrOpFlushState::Draw::~Draw() {
+ if (fFixedDynamicState && fFixedDynamicState->fPrimitiveProcessorTextures) {
+ for (int i = 0; i < fGeometryProcessor->numTextureSamplers(); ++i) {
+ fFixedDynamicState->fPrimitiveProcessorTextures[i]->completedRead();
+ }
+ }
+ if (fDynamicStateArrays && fDynamicStateArrays->fPrimitiveProcessorTextures) {
+ int n = fGeometryProcessor->numTextureSamplers() * fMeshCnt;
+ const auto* textures = fDynamicStateArrays->fPrimitiveProcessorTextures;
+ for (int i = 0; i < n; ++i) {
+ textures[i]->completedRead();
+ }
+ }
+}