[graphite] Restructure how we handle AtlasProvider uploads.
* Moves all the uploads into one call that Device uses
* Moves RasterPathAtlas::reset() to be internal
* Moves TokenTracker update to Device::flushPendingWork
Bug: b/291735945
Change-Id: I47787c0b691b82a2d2bcaca6a802d0434c67c9f5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/765757
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/AtlasTypes.h b/src/gpu/AtlasTypes.h
index 4b44de0..46cf8b9 100644
--- a/src/gpu/AtlasTypes.h
+++ b/src/gpu/AtlasTypes.h
@@ -22,7 +22,7 @@
class GrOpFlushState;
class TestingUploadTarget;
-namespace skgpu::graphite { class TextAtlasManager; }
+namespace skgpu::graphite { class Device; }
/**
* This file includes internal types that are used by all of our gpu backends for atlases.
@@ -211,7 +211,7 @@
// Only these classes get to increment the token counters
friend class ::GrOpFlushState;
friend class ::TestingUploadTarget;
- friend class skgpu::graphite::TextAtlasManager;
+ friend class skgpu::graphite::Device;
// Issues the next token for a draw.
AtlasToken issueDrawToken() { return ++fCurrentDrawToken; }
diff --git a/src/gpu/graphite/AtlasProvider.cpp b/src/gpu/graphite/AtlasProvider.cpp
index 2c72aa3..e622254 100644
--- a/src/gpu/graphite/AtlasProvider.cpp
+++ b/src/gpu/graphite/AtlasProvider.cpp
@@ -8,6 +8,8 @@
#include "src/gpu/graphite/AtlasProvider.h"
#include "include/gpu/graphite/Recorder.h"
+#include "src/gpu/graphite/DrawContext.h"
+#include "src/gpu/graphite/Log.h"
#include "src/gpu/graphite/PathAtlas.h"
#include "src/gpu/graphite/RasterPathAtlas.h"
#include "src/gpu/graphite/RecorderPriv.h"
@@ -85,4 +87,14 @@
fTexturePool.clear();
}
+void AtlasProvider::recordUploads(DrawContext* dc, Recorder* recorder) {
+ if (!dc->recordTextUploads(fTextAtlasManager.get())) {
+ SKGPU_LOG_E("TextAtlasManager uploads have failed -- may see invalid results.");
+ }
+
+ if (fRasterPathAtlas) {
+ fRasterPathAtlas->recordUploads(dc, recorder);
+ }
+}
+
} // namespace skgpu::graphite
diff --git a/src/gpu/graphite/AtlasProvider.h b/src/gpu/graphite/AtlasProvider.h
index bb96759..2da95f6 100644
--- a/src/gpu/graphite/AtlasProvider.h
+++ b/src/gpu/graphite/AtlasProvider.h
@@ -19,6 +19,7 @@
namespace skgpu::graphite {
class ComputePathAtlas;
+class DrawContext;
class PathAtlas;
class RasterPathAtlas;
class Recorder;
@@ -67,6 +68,9 @@
void clearTexturePool();
+ // Push any pending uploads to atlases onto the draw context
+ void recordUploads(DrawContext*, Recorder*);
+
private:
std::unique_ptr<TextAtlasManager> fTextAtlasManager;
diff --git a/src/gpu/graphite/Device.cpp b/src/gpu/graphite/Device.cpp
index 2d20fb1..395aed5 100644
--- a/src/gpu/graphite/Device.cpp
+++ b/src/gpu/graphite/Device.cpp
@@ -1303,16 +1303,15 @@
// TODO: we may need to further split this function up since device->device drawList and
// DrawPass stealing will need to share some of the same logic w/o becoming a Task.
- // push any pending uploads from the atlasmanager
- auto textAtlasManager = fRecorder->priv().atlasProvider()->textAtlasManager();
- if (!fDC->recordTextUploads(textAtlasManager)) {
- SKGPU_LOG_E("TextAtlasManager uploads have failed -- may see invalid results.");
- }
+ // Push any pending uploads from the atlasProvider
+ fRecorder->priv().atlasProvider()->recordUploads(fDC.get(), fRecorder);
auto uploadTask = fDC->snapUploadTask(fRecorder);
if (uploadTask) {
fRecorder->priv().add(std::move(uploadTask));
}
+ // Issue next upload flush token
+ fRecorder->priv().tokenTracker()->issueFlushToken();
fClip.recordDeferredClipDraws();
diff --git a/src/gpu/graphite/DrawContext.cpp b/src/gpu/graphite/DrawContext.cpp
index 99bc195..c82af9c 100644
--- a/src/gpu/graphite/DrawContext.cpp
+++ b/src/gpu/graphite/DrawContext.cpp
@@ -261,12 +261,6 @@
}
sk_sp<Task> DrawContext::snapUploadTask(Recorder* recorder) {
- RasterPathAtlas* rasterPathAtlas = recorder->priv().atlasProvider()->getRasterPathAtlas();
- if (rasterPathAtlas) {
- rasterPathAtlas->recordUploads(this, recorder);
- rasterPathAtlas->reset();
- }
-
if (!fPendingUploads || fPendingUploads->size() == 0) {
return nullptr;
}
diff --git a/src/gpu/graphite/RasterPathAtlas.cpp b/src/gpu/graphite/RasterPathAtlas.cpp
index 4d79d15..c522d50 100644
--- a/src/gpu/graphite/RasterPathAtlas.cpp
+++ b/src/gpu/graphite/RasterPathAtlas.cpp
@@ -63,6 +63,8 @@
}
pageIter.next();
}
+
+ this->reset();
}
bool RasterPathAtlas::Page::initializeTextureIfNeeded(Recorder* recorder, uint16_t identifier) {
diff --git a/src/gpu/graphite/RasterPathAtlas.h b/src/gpu/graphite/RasterPathAtlas.h
index 45c71f0..8bb5321 100644
--- a/src/gpu/graphite/RasterPathAtlas.h
+++ b/src/gpu/graphite/RasterPathAtlas.h
@@ -31,14 +31,6 @@
~RasterPathAtlas() override {}
void recordUploads(DrawContext*, Recorder*);
- // Clear all scheduled atlas draws and free up atlas allocations, if necessary. After this call
- // the atlas can be considered cleared and available for new shape insertions. However this
- // method does not have any bearing on the contents of any atlas textures themselves, which may
- // be in use by GPU commands that are in-flight or yet to be submitted.
- // TODO: can probably remove this once caching is working, or only use it for the LRU page
- // when out of space
- void reset();
-
protected:
const TextureProxy* onAddShape(Recorder* recorder,
const Shape&,
@@ -82,6 +74,11 @@
};
void makeMRU(Page*);
+ // Free up atlas allocations, if necessary. After this call the atlas can be considered
+ // available for new shape insertions. However this method does not have any bearing on the
+ // contents of any atlas textures themselves, which may be in use by GPU commands that are
+ // in-flight or yet to be submitted.
+ void reset();
// Moving from one cached page to two gives improved results on some of our more complex SKPs.
// Any higher uses more memory seemly without much of an overall perf gain. More investigation
diff --git a/src/gpu/graphite/text/TextAtlasManager.cpp b/src/gpu/graphite/text/TextAtlasManager.cpp
index ca6a0e5..7717c69 100644
--- a/src/gpu/graphite/text/TextAtlasManager.cpp
+++ b/src/gpu/graphite/text/TextAtlasManager.cpp
@@ -247,7 +247,6 @@
}
}
- fRecorder->priv().tokenTracker()->issueFlushToken();
return true;
}