skia2/tools/DDLTileHelper.h

148 lines
5.7 KiB
C
Raw Normal View History

/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef DDLTileHelper_DEFINED
#define DDLTileHelper_DEFINED
#include "include/core/SkDeferredDisplayList.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurfaceCharacterization.h"
Reland "Support sharing promise images between DDLs" This reverts commit 38b9a4bc3e3c11e0f17545d15e714a74c10211e3. Reason for revert: Fixed ASAN, TSAN, and other bugs via other CLs. Original change's description: > Revert "Support sharing promise images between DDLs" > > This reverts commit 07e11d48cb02ba9a3845e653c1772c25021e65a3. > > Reason for revert: Broke DDL3_ASAN and DDL3_TSAN > > Original change's description: > > Support sharing promise images between DDLs > > > > - Migrate our code to SkImage::MakePromiseTexture > > - Have DDLTileHelper share one SKP and one set of promise images across all tiles. > > - Disallow on-the-fly allocation of mips for promise textures. > > > > Bug: skia:10286 > > Change-Id: Ie35976958454fc520f3c9d860e6285441260c9f7 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291938 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > TBR=robertphillips@google.com,adlai@google.com > > Change-Id: I939b14875d1a20e4a92eab94680adcfe9596ad81 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10286 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375738 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> Bug: skia:10286 Change-Id: Ibfd7dfcd72f10a4e29a87fa8c610f2dfd018e0db Cq-Include-Trybots: luci.skia.skia.primary:Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-DDL3_ASAN,Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-DDL3_TSAN Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375739 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Adlai Holler <adlai@google.com>
2021-03-03 23:12:56 +00:00
#include "src/core/SkSpan.h"
class DDLPromiseImageHelper;
class PromiseImageCallbackContext;
class SkCanvas;
class SkData;
class SkDeferredDisplayListRecorder;
class SkPicture;
class SkSurface;
class SkSurfaceCharacterization;
class SkTaskGroup;
class DDLTileHelper {
public:
// The TileData class encapsulates the information and behavior of a single tile when
// rendering with DDLs.
class TileData {
public:
TileData();
~TileData();
bool initialized() const { return fID != -1; }
void init(int id,
GrDirectContext*,
const SkSurfaceCharacterization& dstChar,
const SkIRect& clip,
const SkIRect& paddingOutsets);
// Create the DDL for this tile (i.e., fill in 'fDisplayList').
Reland "Support sharing promise images between DDLs" This reverts commit 38b9a4bc3e3c11e0f17545d15e714a74c10211e3. Reason for revert: Fixed ASAN, TSAN, and other bugs via other CLs. Original change's description: > Revert "Support sharing promise images between DDLs" > > This reverts commit 07e11d48cb02ba9a3845e653c1772c25021e65a3. > > Reason for revert: Broke DDL3_ASAN and DDL3_TSAN > > Original change's description: > > Support sharing promise images between DDLs > > > > - Migrate our code to SkImage::MakePromiseTexture > > - Have DDLTileHelper share one SKP and one set of promise images across all tiles. > > - Disallow on-the-fly allocation of mips for promise textures. > > > > Bug: skia:10286 > > Change-Id: Ie35976958454fc520f3c9d860e6285441260c9f7 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291938 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > TBR=robertphillips@google.com,adlai@google.com > > Change-Id: I939b14875d1a20e4a92eab94680adcfe9596ad81 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10286 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375738 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> Bug: skia:10286 Change-Id: Ibfd7dfcd72f10a4e29a87fa8c610f2dfd018e0db Cq-Include-Trybots: luci.skia.skia.primary:Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-DDL3_ASAN,Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-DDL3_TSAN Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375739 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Adlai Holler <adlai@google.com>
2021-03-03 23:12:56 +00:00
void createDDL(const SkPicture*);
void dropDDL() { fDisplayList.reset(); }
// Precompile all the programs required to draw this tile's DDL
void precompile(GrDirectContext*);
Reland "Update skpbench's DDL timing" This reverts commit f35dfabe405159819df2223d54d98d3597a512ce. Reason for revert: Relanding - usage of the flag has been removed from the bots in: https://skia-review.googlesource.com/c/skia/+/275688 (Remove bot to record DDL creation time) Original change's description: > Revert "Update skpbench's DDL timing" > > This reverts commit 6f0124ad687bcd9c2b23b4ab71849555d3d32881. > > Reason for revert: need to remove flag on bots first > > Original change's description: > > Update skpbench's DDL timing > > > > Chrome is seeing some extra overhead when using DDLs for rasterization. This CL updates skpbench to try to replicate their usage of DDLs (or, at least, better illustrate the overhead of using DDLs). > > > > Bug: skia:9455 > > Change-Id: I2abc7cf2d597c97d1d7a47425064c621a7ef0eb3 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275496 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Robert Phillips <robertphillips@google.com> > > TBR=egdaniel@google.com,robertphillips@google.com > > Change-Id: I87b8c78355b81f5f6c90b74f59f176f3cdbdfdaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:9455 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275681 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,robertphillips@google.com Change-Id: I18446e385edb7827fae89541a03545194fe84f6a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:9455 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275691 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-03-06 20:26:28 +00:00
// Just draw the re-inflated per-tile SKP directly into this tile w/o going through a DDL
// first. This is used for determining the overhead of using DDLs (i.e., it replaces
// a 'createDDL' and 'draw' pair.
Reland "Support sharing promise images between DDLs" This reverts commit 38b9a4bc3e3c11e0f17545d15e714a74c10211e3. Reason for revert: Fixed ASAN, TSAN, and other bugs via other CLs. Original change's description: > Revert "Support sharing promise images between DDLs" > > This reverts commit 07e11d48cb02ba9a3845e653c1772c25021e65a3. > > Reason for revert: Broke DDL3_ASAN and DDL3_TSAN > > Original change's description: > > Support sharing promise images between DDLs > > > > - Migrate our code to SkImage::MakePromiseTexture > > - Have DDLTileHelper share one SKP and one set of promise images across all tiles. > > - Disallow on-the-fly allocation of mips for promise textures. > > > > Bug: skia:10286 > > Change-Id: Ie35976958454fc520f3c9d860e6285441260c9f7 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291938 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > TBR=robertphillips@google.com,adlai@google.com > > Change-Id: I939b14875d1a20e4a92eab94680adcfe9596ad81 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10286 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375738 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> Bug: skia:10286 Change-Id: Ibfd7dfcd72f10a4e29a87fa8c610f2dfd018e0db Cq-Include-Trybots: luci.skia.skia.primary:Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-DDL3_ASAN,Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-DDL3_TSAN Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375739 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Adlai Holler <adlai@google.com>
2021-03-03 23:12:56 +00:00
void drawSKPDirectly(GrDirectContext*, const SkPicture*);
Reland "Update skpbench's DDL timing" This reverts commit f35dfabe405159819df2223d54d98d3597a512ce. Reason for revert: Relanding - usage of the flag has been removed from the bots in: https://skia-review.googlesource.com/c/skia/+/275688 (Remove bot to record DDL creation time) Original change's description: > Revert "Update skpbench's DDL timing" > > This reverts commit 6f0124ad687bcd9c2b23b4ab71849555d3d32881. > > Reason for revert: need to remove flag on bots first > > Original change's description: > > Update skpbench's DDL timing > > > > Chrome is seeing some extra overhead when using DDLs for rasterization. This CL updates skpbench to try to replicate their usage of DDLs (or, at least, better illustrate the overhead of using DDLs). > > > > Bug: skia:9455 > > Change-Id: I2abc7cf2d597c97d1d7a47425064c621a7ef0eb3 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275496 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Robert Phillips <robertphillips@google.com> > > TBR=egdaniel@google.com,robertphillips@google.com > > Change-Id: I87b8c78355b81f5f6c90b74f59f176f3cdbdfdaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:9455 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275681 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,robertphillips@google.com Change-Id: I18446e385edb7827fae89541a03545194fe84f6a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:9455 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275691 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-03-06 20:26:28 +00:00
// Replay the recorded DDL into the tile surface - filling in 'fBackendTexture'.
void draw(GrDirectContext*);
void reset();
int id() const { return fID; }
SkIRect clipRect() const { return fClip; }
SkISize paddedRectSize() const {
return { fClip.width() + fPaddingOutsets.fLeft + fPaddingOutsets.fRight,
fClip.height() + fPaddingOutsets.fTop + fPaddingOutsets.fBottom };
}
SkIVector padOffset() const { return { fPaddingOutsets.fLeft, fPaddingOutsets.fTop }; }
SkDeferredDisplayList* ddl() { return fDisplayList.get(); }
Reland "Support sharing promise images between DDLs" This reverts commit 38b9a4bc3e3c11e0f17545d15e714a74c10211e3. Reason for revert: Fixed ASAN, TSAN, and other bugs via other CLs. Original change's description: > Revert "Support sharing promise images between DDLs" > > This reverts commit 07e11d48cb02ba9a3845e653c1772c25021e65a3. > > Reason for revert: Broke DDL3_ASAN and DDL3_TSAN > > Original change's description: > > Support sharing promise images between DDLs > > > > - Migrate our code to SkImage::MakePromiseTexture > > - Have DDLTileHelper share one SKP and one set of promise images across all tiles. > > - Disallow on-the-fly allocation of mips for promise textures. > > > > Bug: skia:10286 > > Change-Id: Ie35976958454fc520f3c9d860e6285441260c9f7 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291938 > > Commit-Queue: Adlai Holler <adlai@google.com> > > Reviewed-by: Robert Phillips <robertphillips@google.com> > > TBR=robertphillips@google.com,adlai@google.com > > Change-Id: I939b14875d1a20e4a92eab94680adcfe9596ad81 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10286 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375738 > Reviewed-by: Adlai Holler <adlai@google.com> > Commit-Queue: Adlai Holler <adlai@google.com> Bug: skia:10286 Change-Id: Ibfd7dfcd72f10a4e29a87fa8c610f2dfd018e0db Cq-Include-Trybots: luci.skia.skia.primary:Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Debug-All-DDL3_ASAN,Test-Ubuntu18-Clang-Golo-GPU-QuadroP400-x86_64-Release-All-DDL3_TSAN Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375739 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Adlai Holler <adlai@google.com>
2021-03-03 23:12:56 +00:00
sk_sp<SkImage> makePromiseImageForDst(sk_sp<GrContextThreadSafeProxy>);
void dropCallbackContext() { fCallbackContext.reset(); }
static void CreateBackendTexture(GrDirectContext*, TileData*);
static void DeleteBackendTexture(GrDirectContext*, TileData*);
private:
sk_sp<SkSurface> makeWrappedTileDest(GrRecordingContext* context);
sk_sp<PromiseImageCallbackContext> refCallbackContext() { return fCallbackContext; }
int fID = -1;
SkIRect fClip; // in the device space of the final SkSurface
SkIRect fPaddingOutsets; // random padding for the output surface
SkSurfaceCharacterization fPlaybackChar; // characterization for the tile's dst surface
// The callback context holds (via its SkPromiseImageTexture) the backend texture
// that is both wrapped in 'fTileSurface' and backs this tile's promise image
// (i.e., the one returned by 'makePromiseImage').
sk_sp<PromiseImageCallbackContext> fCallbackContext;
// 'fTileSurface' wraps the backend texture in 'fCallbackContext' and must exist until
// after 'fDisplayList' has been flushed (bc it owns the proxy the DDL's destination
// trampoline points at).
// TODO: fix the ref-order so we don't need 'fTileSurface' here
sk_sp<SkSurface> fTileSurface;
sk_sp<SkDeferredDisplayList> fDisplayList;
};
DDLTileHelper(GrDirectContext*,
const SkSurfaceCharacterization& dstChar,
const SkIRect& viewport,
int numXDivisions, int numYDivisions,
bool addRandomPaddingToDst);
void kickOffThreadedWork(SkTaskGroup* recordingTaskGroup,
SkTaskGroup* gpuTaskGroup,
GrDirectContext*,
SkPicture*);
void createDDLsInParallel(SkPicture*);
// Create the DDL that will compose all the tile images into a final result.
void createComposeDDL();
const sk_sp<SkDeferredDisplayList>& composeDDL() const { return fComposeDDL; }
Reland "Update skpbench's DDL timing" This reverts commit f35dfabe405159819df2223d54d98d3597a512ce. Reason for revert: Relanding - usage of the flag has been removed from the bots in: https://skia-review.googlesource.com/c/skia/+/275688 (Remove bot to record DDL creation time) Original change's description: > Revert "Update skpbench's DDL timing" > > This reverts commit 6f0124ad687bcd9c2b23b4ab71849555d3d32881. > > Reason for revert: need to remove flag on bots first > > Original change's description: > > Update skpbench's DDL timing > > > > Chrome is seeing some extra overhead when using DDLs for rasterization. This CL updates skpbench to try to replicate their usage of DDLs (or, at least, better illustrate the overhead of using DDLs). > > > > Bug: skia:9455 > > Change-Id: I2abc7cf2d597c97d1d7a47425064c621a7ef0eb3 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275496 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Robert Phillips <robertphillips@google.com> > > TBR=egdaniel@google.com,robertphillips@google.com > > Change-Id: I87b8c78355b81f5f6c90b74f59f176f3cdbdfdaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:9455 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275681 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,robertphillips@google.com Change-Id: I18446e385edb7827fae89541a03545194fe84f6a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:9455 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275691 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-03-06 20:26:28 +00:00
// For each tile, create its DDL and then draw it - all on a single thread. This is to allow
// comparison w/ just drawing the SKP directly (i.e., drawAllTilesDirectly). The
// DDL creations and draws are interleaved to prevent starvation of the GPU.
// Note: this is somewhat of a misuse/pessimistic-use of DDLs since they are supposed to
// be created on a separate thread.
void interleaveDDLCreationAndDraw(GrDirectContext*, SkPicture*);
Reland "Update skpbench's DDL timing" This reverts commit f35dfabe405159819df2223d54d98d3597a512ce. Reason for revert: Relanding - usage of the flag has been removed from the bots in: https://skia-review.googlesource.com/c/skia/+/275688 (Remove bot to record DDL creation time) Original change's description: > Revert "Update skpbench's DDL timing" > > This reverts commit 6f0124ad687bcd9c2b23b4ab71849555d3d32881. > > Reason for revert: need to remove flag on bots first > > Original change's description: > > Update skpbench's DDL timing > > > > Chrome is seeing some extra overhead when using DDLs for rasterization. This CL updates skpbench to try to replicate their usage of DDLs (or, at least, better illustrate the overhead of using DDLs). > > > > Bug: skia:9455 > > Change-Id: I2abc7cf2d597c97d1d7a47425064c621a7ef0eb3 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275496 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Robert Phillips <robertphillips@google.com> > > TBR=egdaniel@google.com,robertphillips@google.com > > Change-Id: I87b8c78355b81f5f6c90b74f59f176f3cdbdfdaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:9455 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275681 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,robertphillips@google.com Change-Id: I18446e385edb7827fae89541a03545194fe84f6a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:9455 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275691 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-03-06 20:26:28 +00:00
// This draws all the per-tile SKPs directly into all of the tiles w/o converting them to
// DDLs first - all on a single thread.
void drawAllTilesDirectly(GrDirectContext*, SkPicture*);
Reland "Update skpbench's DDL timing" This reverts commit f35dfabe405159819df2223d54d98d3597a512ce. Reason for revert: Relanding - usage of the flag has been removed from the bots in: https://skia-review.googlesource.com/c/skia/+/275688 (Remove bot to record DDL creation time) Original change's description: > Revert "Update skpbench's DDL timing" > > This reverts commit 6f0124ad687bcd9c2b23b4ab71849555d3d32881. > > Reason for revert: need to remove flag on bots first > > Original change's description: > > Update skpbench's DDL timing > > > > Chrome is seeing some extra overhead when using DDLs for rasterization. This CL updates skpbench to try to replicate their usage of DDLs (or, at least, better illustrate the overhead of using DDLs). > > > > Bug: skia:9455 > > Change-Id: I2abc7cf2d597c97d1d7a47425064c621a7ef0eb3 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275496 > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > Commit-Queue: Robert Phillips <robertphillips@google.com> > > TBR=egdaniel@google.com,robertphillips@google.com > > Change-Id: I87b8c78355b81f5f6c90b74f59f176f3cdbdfdaa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:9455 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275681 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,robertphillips@google.com Change-Id: I18446e385edb7827fae89541a03545194fe84f6a No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:9455 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275691 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
2020-03-06 20:26:28 +00:00
void dropCallbackContexts();
void resetAllTiles();
int numTiles() const { return fNumXDivisions * fNumYDivisions; }
void createBackendTextures(SkTaskGroup*, GrDirectContext*);
void deleteBackendTextures(SkTaskGroup*, GrDirectContext*);
private:
int fNumXDivisions; // number of tiles horizontally
int fNumYDivisions; // number of tiles vertically
SkAutoTArray<TileData> fTiles; // 'fNumXDivisions' x 'fNumYDivisions'
sk_sp<SkDeferredDisplayList> fComposeDDL;
const SkSurfaceCharacterization fDstCharacterization;
};
#endif