Skip to content

Commit

Permalink
[graphite] Add fRequireOrderedRecordings ContextOption.
Browse files Browse the repository at this point in the history
This is essentially a rename of fDisableCachedGlyphUploads to reflect
what it actually does.  fDisableCachedGlyphUploads will be removed once
clients have been changed over to the new name.

Also includes a fix to clear the RasterPathAtlas as well, if
fRequiredOrderedRecordings isn't true.

Change-Id: Ie2877f36925347dbffc9c596e684372a3e7b95aa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/929358
Reviewed-by: Robert Phillips <[email protected]>
Reviewed-by: Greg Daniel <[email protected]>
Commit-Queue: Jim Van Verth <[email protected]>
  • Loading branch information
jvanverth authored and SkCQ committed Dec 12, 2024
1 parent b6d30e8 commit 8a888c4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bench/nanobench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ struct GraphiteTarget : public Target {
}
bool init(SkImageInfo info, Benchmark* bench) override {
skiatest::graphite::TestOptions testOptions = gTestOptions;
testOptions.fContextOptions.fDisableCachedGlyphUploads = true;
testOptions.fContextOptions.fRequireOrderedRecordings = true;
bench->modifyGraphiteContextOptions(&testOptions.fContextOptions);

this->factory = std::make_unique<ContextFactory>(testOptions);
Expand Down
18 changes: 15 additions & 3 deletions include/gpu/graphite/ContextOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,22 @@ struct SK_API ContextOptions {
bool fSupportBilerpFromGlyphAtlas = false;

/**
* Disable caching of glyph uploads at the start of each Recording. These can add additional
* overhead and are only necessary if Recordings are replayed or played out of order.
* For the moment, if Recordings are replayed in the order they are recorded, then
* Graphite can make certain assumptions that allow for better performance. Otherwise
* we have to flush some caches at the start of each Recording to ensure that they can
* be played back properly.
*
* Deprecated, now only used to set requireOrderedRecordings Caps.
* To support prior usage, the requireOrderedRecordings() Caps will be set to true if
* fRequiredOrderedRecordings || fDisableCachedGlyphUploads.
*/
bool fRequireOrderedRecordings = false;

/**
* Deprecated. Disable caching of glyph uploads at the start of each Recording. These can add
* additional overhead and are only necessary if Recordings are replayed or played out of order.
*
* To support prior usage, the requireOrderedRecordings() Caps will be set to true if
* fRequiredOrderedRecordings || fDisableCachedGlyphUploads.
*/
bool fDisableCachedGlyphUploads = false;

Expand Down
6 changes: 6 additions & 0 deletions relnotes/requireorderedrecordings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Graphite has a new `ContextOptions::fRequiredOrderedRecordings` flag that enables certain optimizations when the
client knows that recordings are played back in order. Otherwise Graphite will need to clear some caches at the
start of each recording to ensure proper playback, which can significantly affect performance.

This replaces the old `ContextOptions::fDisableCachedGlyphUploads` flag which was deprecated but still being used by some
clients to get the same behavior.
2 changes: 1 addition & 1 deletion src/gpu/graphite/Caps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void Caps::finishInitialization(const ContextOptions& options) {
fMaxPathAtlasTextureSize = options.fMaxPathAtlasTextureSize;
fAllowMultipleAtlasTextures = options.fAllowMultipleAtlasTextures;
fSupportBilerpFromGlyphAtlas = options.fSupportBilerpFromGlyphAtlas;
if (options.fDisableCachedGlyphUploads) {
if (options.fRequireOrderedRecordings || options.fDisableCachedGlyphUploads) {
fRequireOrderedRecordings = true;
}
fSetBackendLabels = options.fSetBackendLabels;
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/graphite/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ std::unique_ptr<Recording> Recorder::snap() {
fProxyReadCounts = std::make_unique<ProxyReadCountMap>();
fTextureDataCache = std::make_unique<TextureDataCache>();
if (!this->priv().caps()->requireOrderedRecordings()) {
fAtlasProvider->textAtlasManager()->evictAtlases();
fAtlasProvider->invalidateAtlases();
}

return recording;
Expand Down
2 changes: 1 addition & 1 deletion tools/window/GraphiteNativeMetalWindowContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
SkASSERT(fDisplayParams->graphiteTestOptions());
skwindow::GraphiteTestOptions opts = *fDisplayParams->graphiteTestOptions();

opts.fTestOptions.fContextOptions.fDisableCachedGlyphUploads = true;
opts.fTestOptions.fContextOptions.fRequireOrderedRecordings = true;
// Needed to make synchronous readPixels work:
opts.fPriv.fStoreContextRefInRecorder = true;
fDisplayParams =
Expand Down

0 comments on commit 8a888c4

Please sign in to comment.