Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: include/private/SkGpuTimer.h

Issue 2388433003: skpbench: add option for gpu timing (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/gpu/TestContext.h » ('j') | tools/gpu/gl/GLTestContext.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkGpuTimer_DEFINED
9 #define SkGpuTimer_DEFINED
10
11 #include "SkTypes.h"
12 #include "SkExchange.h"
13 #include <chrono>
14
15 using SkPlatformGpuTimerQuery = intptr_t;
bsalomon 2016/09/30 18:37:16 What do you think about putting this in sk_gpu_tes
csmartdalton 2016/10/03 16:52:24 Done.
16 constexpr static SkPlatformGpuTimerQuery SK_InvalidGpuTimerQuery = 0;
17
18 /**
19 * Platform-independent interface for timing operations on the GPU.
20 */
21 class SkGpuTimer {
22 public:
23 SkGpuTimer(bool disjointSupport)
24 : fDisjointSupport(disjointSupport)
25 , fActiveTimer(SK_InvalidGpuTimerQuery) {
26 }
27 virtual ~SkGpuTimer() { SkASSERT(!fActiveTimer); }
28
29 /**
30 * Returns whether this timer can detect disjoint GPU operations while timin g. If false, a query
31 * has less confidence when it completes with QueryStatus::kAccurate.
32 */
33 bool disjointSupport() const { return fDisjointSupport; }
34
35 /**
36 * Inserts a "start timing" command in the GPU command stream.
37 */
38 void queueStart() {
39 SkASSERT(!fActiveTimer);
40 fActiveTimer = this->onQueueTimerStart();
41 }
42
43 /**
44 * Inserts a "stop timing" command in the GPU command stream.
45 *
46 * @return a query object that can retrieve the time elapsed once the timer has completed.
47 */
48 SkPlatformGpuTimerQuery SK_WARN_UNUSED_RESULT queueStop() {
49 SkASSERT(fActiveTimer);
50 this->onQueueTimerStop(fActiveTimer);
51 return skstd::exchange(fActiveTimer, SK_InvalidGpuTimerQuery);
52 }
53
54 enum class QueryStatus {
55 kInvalid, //<! the timer query is invalid.
56 kPending, //<! the timer is still running on the GPU.
57 kDisjoint, //<! the query is complete, but dubious due to disjoint GPU o perations.
58 kAccurate //<! the query is complete and reliable.
59 };
60
61 virtual QueryStatus checkQueryStatus(SkPlatformGpuTimerQuery) = 0;
62 virtual std::chrono::nanoseconds getTimeElapsed(SkPlatformGpuTimerQuery) = 0 ;
63 virtual void deleteQuery(SkPlatformGpuTimerQuery) = 0;
64
65 private:
66 virtual SkPlatformGpuTimerQuery onQueueTimerStart() const = 0;
67 virtual void onQueueTimerStop(SkPlatformGpuTimerQuery) const = 0;
68
69 bool const fDisjointSupport;
70 SkPlatformGpuTimerQuery fActiveTimer;
71 };
72
73 #endif
OLDNEW
« no previous file with comments | « no previous file | tools/gpu/TestContext.h » ('j') | tools/gpu/gl/GLTestContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698