diff options
author | keyar@chromium.org <keyar@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-20 15:03:41 +0000 |
---|---|---|
committer | keyar@chromium.org <keyar@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-20 15:03:41 +0000 |
commit | fe6391a624f98b1c70581ac86d5733afe11872d3 (patch) | |
tree | b6855a4d8292bcc0ec3384d2a8eecd7de3a55017 | |
parent | 81058469d5570082a685cd8b0e67027535a65acd (diff) |
Have GPU based approach workingish.
Benchmarks do not work and it is always on.
git-svn-id: http://skia.googlecode.com/svn/trunk@5175 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | tools/PictureBenchmark.cpp | 44 | ||||
-rw-r--r-- | tools/PictureBenchmark.h | 56 | ||||
-rw-r--r-- | tools/PictureRenderer.h | 10 | ||||
-rw-r--r-- | tools/bench_pictures_main.cpp | 1 |
4 files changed, 83 insertions, 28 deletions
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp index a9449a1da0..379a79b0d2 100644 --- a/tools/PictureBenchmark.cpp +++ b/tools/PictureBenchmark.cpp @@ -21,22 +21,26 @@ void PipePictureBenchmark::run(SkPicture* pict) { return; } - renderer.init(pict); + fRenderer.init(pict); // We throw this away to remove first time effects (such as paging in this // program) - renderer.render(); + fRenderer.render(); BenchTimer timer = BenchTimer(NULL); timer.start(); for (int i = 0; i < fRepeats; ++i) { - renderer.render(); + fRenderer.render(); } timer.end(); - renderer.end(); + fRenderer.end(); - SkDebugf("pipe: msecs = %6.2f\n", timer.fWall / fRepeats); + SkDebugf("pipe: msecs = %6.2f", timer.fWall / fRepeats); + if (fRenderer.isUsingGpuDevice()) { + SkDebugf(" gmsecs = %6.2f", timer.fGpu / fRepeats); + } + SkDebugf("\n"); } void RecordPictureBenchmark::run(SkPicture* pict) { @@ -71,22 +75,26 @@ void SimplePictureBenchmark::run(SkPicture* pict) { return; } - renderer.init(pict); + fRenderer.init(pict); // We throw this away to remove first time effects (such as paging in this // program) - renderer.render(); + fRenderer.render(); BenchTimer timer = BenchTimer(NULL); timer.start(); for (int i = 0; i < fRepeats; ++i) { - renderer.render(); + fRenderer.render(); } timer.end(); - renderer.end(); + fRenderer.end(); - printf("simple: msecs = %6.2f\n", timer.fWall / fRepeats); + SkDebugf("simple: msecs = %6.2f", timer.fWall / fRepeats); + if (fRenderer.isUsingGpuDevice()) { + SkDebugf(" gmsecs = %6.2f", timer.fGpu / fRepeats); + } + SkDebugf("\n"); } void TiledPictureBenchmark::run(SkPicture* pict) { @@ -95,23 +103,27 @@ void TiledPictureBenchmark::run(SkPicture* pict) { return; } - renderer.init(pict); + fRenderer.init(pict); // We throw this away to remove first time effects (such as paging in this // program) - renderer.drawTiles(); + fRenderer.drawTiles(); BenchTimer timer = BenchTimer(NULL); timer.start(); for (int i = 0; i < fRepeats; ++i) { - renderer.drawTiles(); + fRenderer.drawTiles(); } timer.end(); - renderer.end(); + fRenderer.end(); - SkDebugf("%i_tiles_%ix%i: msecs = %6.2f\n", renderer.numTiles(), renderer.getTileWidth(), - renderer.getTileHeight(), timer.fWall / fRepeats); + SkDebugf("%i_tiles_%ix%i: msecs = %6.2f", fRenderer.numTiles(), fRenderer.getTileWidth(), + fRenderer.getTileHeight(), timer.fWall / fRepeats); + if (fRenderer.isUsingGpuDevice()) { + SkDebugf(" gmsecs = %6.2f", timer.fGpu / fRepeats); + } + SkDebugf("\n"); } void UnflattenPictureBenchmark::run(SkPicture* pict) { diff --git a/tools/PictureBenchmark.h b/tools/PictureBenchmark.h index 53ab5c2443..309f570743 100644 --- a/tools/PictureBenchmark.h +++ b/tools/PictureBenchmark.h @@ -28,19 +28,45 @@ public: return fRepeats; } + void setUseBitmapDevice() { + sk_tools::PictureRenderer* renderer = getRenderer(); + + if (renderer != NULL) { + renderer->setUseBitmapDevice(); + } + } + +#if SK_SUPPORT_GPU + void setUseGpuDevice() { + sk_tools::PictureRenderer* renderer = getRenderer(); + + if (renderer != NULL) { + renderer->setUseGpuDevice(); + } + } +#endif + protected: int fRepeats; private: typedef SkRefCnt INHERITED; + + virtual sk_tools::PictureRenderer* getRenderer() { + return NULL; + } }; class PipePictureBenchmark : public PictureBenchmark { public: virtual void run(SkPicture* pict) SK_OVERRIDE; private: - PipePictureRenderer renderer; + PipePictureRenderer fRenderer; typedef PictureBenchmark INHERITED; + + virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE { + return &fRenderer; + } }; class RecordPictureBenchmark : public PictureBenchmark { @@ -54,8 +80,12 @@ class SimplePictureBenchmark : public PictureBenchmark { public: virtual void run(SkPicture* pict) SK_OVERRIDE; private: - SimplePictureRenderer renderer; + SimplePictureRenderer fRenderer; typedef PictureBenchmark INHERITED; + + virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE { + return &fRenderer; + } }; class TiledPictureBenchmark : public PictureBenchmark { @@ -63,40 +93,44 @@ public: virtual void run(SkPicture* pict) SK_OVERRIDE; void setTileWidth(int width) { - renderer.setTileWidth(width); + fRenderer.setTileWidth(width); } int getTileWidth() const { - return renderer.getTileWidth(); + return fRenderer.getTileWidth(); } void setTileHeight(int height) { - renderer.setTileHeight(height); + fRenderer.setTileHeight(height); } int getTileHeight() const { - return renderer.getTileHeight(); + return fRenderer.getTileHeight(); } void setTileWidthPercentage(double percentage) { - renderer.setTileWidthPercentage(percentage); + fRenderer.setTileWidthPercentage(percentage); } double getTileWidthPercentage() const { - return renderer.getTileWidthPercentage(); + return fRenderer.getTileWidthPercentage(); } void setTileHeightPercentage(double percentage) { - renderer.setTileHeightPercentage(percentage); + fRenderer.setTileHeightPercentage(percentage); } double getTileHeightPercentage() const { - return renderer.getTileHeightPercentage(); + return fRenderer.getTileHeightPercentage(); } private: - TiledPictureRenderer renderer; + TiledPictureRenderer fRenderer; typedef PictureBenchmark INHERITED; + + virtual sk_tools::PictureRenderer* getRenderer() SK_OVERRIDE{ + return &fRenderer; + } }; class UnflattenPictureBenchmark : public PictureBenchmark { diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index 8f6a8fdfc5..5f8e7917a1 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -34,13 +34,21 @@ public: } void setUseBitmapDevice() { - fDeviceType=kBitmap_DeviceType; + fDeviceType = kBitmap_DeviceType; + } + + bool isUsingBitmapDevice() { + return fDeviceType == kBitmap_DeviceType; } #if SK_SUPPORT_GPU void setUseGpuDevice() { fDeviceType = kGPU_DeviceType; } + + bool isUsingGpuDevice() { + return fDeviceType == kGPU_DeviceType; + } #endif PictureRenderer() diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index ae9e850b1a..0521005eb2 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -187,6 +187,7 @@ static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* } benchmark->setRepeats(repeats); + benchmark->setUseGpuDevice(); } static void process_input(const SkString& input, sk_tools::PictureBenchmark& benchmark) { |