Add flag to force gpu trace markers to be used and printed out for debugging.

BUG=skia:

Review URL: https://codereview.chromium.org/976413002
This commit is contained in:
egdaniel 2015-03-05 12:19:17 -08:00 committed by Commit bot
parent a0865b4620
commit bdad9c34d8
4 changed files with 32 additions and 1 deletions

View File

@ -232,4 +232,12 @@ typedef unsigned __int64 uint64_t;
#define GR_ALWAYS_ALLOCATE_ON_HEAP 0
#endif
/**
* GR_FORCE_GPU_TRACE_DEBUGGING will force gpu tracing/debug markers to be turned on. The trace
* markers will be printed out instead of making the backend calls to push and pop them.
*/
#if !defined(GR_FORCE_GPU_TRACE_DEBUGGING)
#define GR_FORCE_GPU_TRACE_DEBUGGING 0
#endif
#endif

View File

@ -80,7 +80,11 @@ public:
bool pathRenderingSupport() const { return fPathRenderingSupport; }
bool dstReadInShaderSupport() const { return fDstReadInShaderSupport; }
bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; }
#if GR_FORCE_GPU_TRACE_DEBUGGING
bool gpuTracingSupport() const { return true; }
#else
bool gpuTracingSupport() const { return fGpuTracingSupport; }
#endif
bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; }
bool oversizedStencilSupport() const { return fOversizedStencilSupport; }

View File

@ -85,6 +85,11 @@ private:
INTERNAL_TRACE_EVENT_ADD_SCOPED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"),name, \
"id", name_counter, ##__VA_ARGS__);
#if GR_FORCE_GPU_TRACE_DEBUGGING
#define GR_CREATE_GPU_TRACE_MARKER(name, name_counter, target) \
GrGpuTraceMarkerGenerator SK_MACRO_APPEND_LINE(TMG)(target); \
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter);
#else
#define GR_CREATE_GPU_TRACE_MARKER(name, name_counter, target) \
GrGpuTraceMarkerGenerator SK_MACRO_APPEND_LINE(TMG)(target); \
bool SK_MACRO_APPEND_LINE(gpuTracingEnabled); \
@ -93,7 +98,7 @@ private:
if (SK_MACRO_APPEND_LINE(gpuTracingEnabled)) { \
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter); \
}
#endif
#define GR_CREATE_TRACE_MARKER_CONTEXT(name, context) \
INTERNAL_GR_CREATE_TRACE_MARKER_SCOPED_C(name, context)
@ -114,6 +119,11 @@ private:
INTERNAL_TRACE_EVENT_ADD_SCOPED(TRACE_DISABLED_BY_DEFAULT("skia.gpu"),name, \
"id", name_counter, ##__VA_ARGS__);
#if GR_FORCE_GPU_TRACE_DEBUGGING
#define GR_CREATE_GPU_TRACE_MARKER_C(name, name_counter, context) \
GrGpuTraceMarkerGeneratorContext SK_MACRO_APPEND_LINE(TMG)(context); \
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter);
#else
#define GR_CREATE_GPU_TRACE_MARKER_C(name, name_counter, context) \
GrGpuTraceMarkerGeneratorContext SK_MACRO_APPEND_LINE(TMG)(context); \
bool SK_MACRO_APPEND_LINE(gpuTracingEnabled); \
@ -122,5 +132,6 @@ private:
if (SK_MACRO_APPEND_LINE(gpuTracingEnabled)) { \
SK_MACRO_APPEND_LINE(TMG).initialize(name, &name_counter); \
}
#endif
#endif

View File

@ -2778,13 +2778,21 @@ void GrGLGpu::didAddGpuTraceMarker() {
if (this->caps()->gpuTracingSupport()) {
const GrTraceMarkerSet& markerArray = this->getActiveTraceMarkers();
SkString markerString = markerArray.toStringLast();
#if GR_FORCE_GPU_TRACE_DEBUGGING
SkDebugf("%s\n", markerString.c_str());
#else
GL_CALL(PushGroupMarker(0, markerString.c_str()));
#endif
}
}
void GrGLGpu::didRemoveGpuTraceMarker() {
if (this->caps()->gpuTracingSupport()) {
#if GR_FORCE_GPU_TRACE_DEBUGGING
SkDebugf("Pop trace marker.\n");
#else
GL_CALL(PopGroupMarker());
#endif
}
}