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

Unified Diff: src/gpu/GrDrawTarget.h

Issue 184443003: Add Gpu Tracing to Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Partial version Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrDrawTarget.h
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 19ce16f64a68818512f0d32b7192c90a06dd6b4e..143562f63da89531b49f2379fe00c1da651815a6 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -22,10 +22,27 @@
class GrClipData;
class GrDrawTargetCaps;
+// class GrDrawTarget;
bsalomon 2014/03/17 17:50:38 ?
egdaniel 2014/03/17 19:49:12 Woops. Left over from some old test iteration. Rem
class GrPath;
class GrVertexBuffer;
class SkStrokeRec;
+class GpuTraceMarker {
+public:
+ GpuTraceMarker(const char* marker, int idCounter) : fMarker(marker), fID(idCounter) {}
+
+ bool operator<(const GpuTraceMarker& rhs) const {
+ return this->fMarker < rhs.fMarker || (this->fMarker == rhs.fMarker && this->fID < rhs.fID);
+ }
+
+ bool operator==(const GpuTraceMarker& rhs) const {
+ return (this->fID == rhs.fID && this->fMarker == rhs.fMarker);
+ }
+
+ const char* fMarker;
+ int fID;
+};
+
class GrDrawTarget : public SkRefCnt {
protected:
class DrawInfo;
@@ -423,18 +440,19 @@ public:
GrRenderTarget* renderTarget = NULL) = 0;
/**
- * instantGpuTraceEvent places a single "sign post" type marker into command stream. The
- * argument marker will be the name of the annotation that is added.
- */
- void instantGpuTraceEvent(const char* marker);
- /**
- * The following two functions are used for marking groups of commands. Use pushGpuTraceEvent
- * to set the beginning of a command set, and popGpuTraceEvent is be called at end of the
- * command set. The argument marker is the name for the annotation that is added. The push and
- * pops can be used hierarchically, but every push must have a match pop.
+ * Called at start and end of gpu trace marking
+ * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call these at the start
+ * and end of a code block respectively
*/
- void pushGpuTraceEvent(const char* marker);
- void popGpuTraceEvent();
+ void addGpuTraceMarker(GpuTraceMarker* marker);
+ void removeGpuTraceMarker(GpuTraceMarker* marker);
+
+ bool gpuTracingEnabled() const;
bsalomon 2014/03/17 17:50:38 I wonder if we really need enable/disable control
egdaniel 2014/03/17 19:49:12 This function is for controlling whether or not it
bsalomon 2014/03/19 13:28:44 sgtm
+
+ SkTDArray<GpuTraceMarker>* getActiveTraceMarkers() { return &fActiveTraceMarkers; }
bsalomon 2014/03/17 17:50:38 const &?
egdaniel 2014/03/17 19:49:12 in gl/GrGpuGl.cpp I call getActiveTraceMarkers(),
+
+ static SkString getTraceString(SkTDArray<GpuTraceMarker>* markerArray,
bsalomon 2014/03/17 17:50:38 Def. const & for markerArray. Also static function
egdaniel 2014/03/17 19:49:12 markerArray ends up getting sorted in the function
bsalomon 2014/03/19 13:28:44 Ok that makes sense. It'd be nice to hide this som
egdaniel 2014/03/19 14:27:03 So the function has already been moved to protecte
bsalomon 2014/03/19 14:43:43 It just seems to me like sorting-and-stringifying
egdaniel 2014/03/19 15:16:30 Okay so here is my proposal (GpuTM is our trace ma
bsalomon 2014/03/19 15:27:01 How about getActiveMarkersTraceString()?
egdaniel 2014/03/19 15:33:53 So internally I have a single array that stores th
bsalomon 2014/03/19 15:50:39 Got it. Do you think you get a lot of value out of
+ int startIdx, int numMarkers);
/**
* Copies a pixel rectangle from one surface to another. This call may finalize
@@ -868,9 +886,8 @@ private:
virtual void onDrawPath(const GrPath*, SkPath::FillType,
const GrDeviceCoordTexture* dstCopy) = 0;
- virtual void onInstantGpuTraceEvent(const char* marker) = 0;
- virtual void onPushGpuTraceEvent(const char* marker) = 0;
- virtual void onPopGpuTraceEvent() = 0;
+ virtual void onAddGpuTraceMarker() = 0;
bsalomon 2014/03/17 17:50:38 It's unclear from the header why we have all three
egdaniel 2014/03/17 19:49:12 So the basic structure here is: addGpuTraceMarker
bsalomon 2014/03/19 13:28:44 Ok so addTraceMarkerActiveSet is just a helper/imp
+ virtual void onRemoveGpuTraceMarker() = 0;
// helpers for reserving vertex and index space.
bool reserveVertexSpace(size_t vertexSize,
@@ -897,6 +914,12 @@ private:
// Check to see if this set of draw commands has been sent out
virtual bool isIssued(uint32_t drawID) { return true; }
+ // Add new marker to our current active set
+ void addTraceMarkerActiveSet(GpuTraceMarker* marker);
+
+ // Remove marker from our current active set
+ void removeTraceMarkerActiveSet(GpuTraceMarker* marker);
+
enum {
kPreallocGeoSrcStateStackCnt = 4,
};
@@ -906,10 +929,46 @@ private:
GrDrawState fDefaultDrawState;
// The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTarget.
GrContext* fContext;
- // To keep track that we always have at least as many debug marker pushes as pops
- int fPushGpuTraceCount;
+ // To keep track that we always have at least as many debug marker adds as removes
+ int fGpuTraceMarkerCount;
+ SkTDArray<GpuTraceMarker> fActiveTraceMarkers;
typedef SkRefCnt INHERITED;
};
+/**
+ * Marker generation class used for adding and removing markers around code blocks
+ */
+class TraceMarkerGenerator : public ::SkNoncopyable {
+public:
+ TraceMarkerGenerator(const char* marker_str, int* marker_counter, GrDrawTarget* target)
+ : fTarget(target), fTraceMarker(marker_str, *marker_counter) {
+ if (fTarget->gpuTracingEnabled()) {
+ sk_atomic_inc(marker_counter);
+ fTarget->addGpuTraceMarker(&fTraceMarker);
+ }
+ }
+ ~TraceMarkerGenerator() {
+ if (fTarget->gpuTracingEnabled()) {
+ fTarget->removeGpuTraceMarker(&fTraceMarker);
+ }
+ }
+private:
+ GrDrawTarget* fTarget;
+ GpuTraceMarker fTraceMarker;
+};
+
+////////// macros to place around the internal draw calls //////////////////
+// marker is of type const char* and target is of type GrDrawTarget*
+
+#define GR_CREATE_GPU_TRACE_MARKER(marker_str, target) \
+ static const char* static_str = marker_str; \
+ static int marker_counter = 0; \
+ TraceMarkerGenerator SK_MACRO_APPEND_LINE(TMG)(static_str, \
+ &marker_counter, \
+ target); \
+
+////////////////////////////////////////////////////////////////////////////
+
+
#endif

Powered by Google App Engine
This is Rietveld 408576698