Improve gpu tracing when applying markers directly to gpu target

- Change the debug marker strings sent by the GrGpuGL target to only grab the last object
  added to the set of active markers. This improves the readability when we end up with a
  large stack of trace markers. Any trace markers the come from the IODB will continue to
  be squashed into a single debug marker

- Added some more useful, high level markers

BUG=skia:
R=bsalomon@google.com

Author: egdaniel@google.com

Review URL: https://codereview.chromium.org/378933002
This commit is contained in:
egdaniel 2014-07-09 10:41:26 -07:00 committed by Commit bot
parent 1c577cd3ee
commit d78a168ec2
6 changed files with 36 additions and 7 deletions

View File

@ -657,6 +657,7 @@ void GrContext::clear(const SkIRect* rect,
GrRenderTarget* target) {
AutoRestoreEffects are;
AutoCheckFlush acf(this);
GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this);
this->prepareToDraw(NULL, BUFFERED_DRAW, &are, &acf)->clear(rect, color,
canIgnoreRect, target);
}
@ -671,6 +672,7 @@ void GrContext::drawPaint(const GrPaint& origPaint) {
SkMatrix inverse;
SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
AutoMatrix am;
GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::drawPaint", this);
// We attempt to map r by the inverse matrix and draw that. mapRect will
// map the four corners and bound them with a new rect. This will not
@ -808,7 +810,6 @@ void GrContext::drawRect(const GrPaint& paint,
GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW, &are, &acf);
GR_CREATE_TRACE_MARKER("GrContext::drawRect", target);
SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getStrokeRec().getWidth();
SkMatrix combinedMatrix = target->drawState()->getViewMatrix();
if (NULL != matrix) {

View File

@ -595,8 +595,9 @@ void GrInOrderDrawBuffer::flush() {
fDstGpu->saveActiveTraceMarkers();
for (int c = 0; c < numCmds; ++c) {
GrGpuTraceMarker newMarker("", -1);
SkString traceString;
if (cmd_has_trace_marker(fCmds[c])) {
SkString traceString = fGpuCmdMarkers[currCmdMarker].toString();
traceString = fGpuCmdMarkers[currCmdMarker].toString();
newMarker.fMarker = traceString.c_str();
fDstGpu->addGpuTraceMarker(&newMarker);
++currCmdMarker;

View File

@ -39,6 +39,21 @@ int GrTraceMarkerSet::count() const {
return this->fMarkerArray.count();
}
SkString GrTraceMarkerSet::toStringLast() const {
const int numMarkers = this->fMarkerArray.count();
SkString marker_string;
if (numMarkers > 0) {
GrGpuTraceMarker& lastMarker = this->fMarkerArray[numMarkers - 1];
marker_string.append(lastMarker.fMarker);
if (lastMarker.fID != -1) {
marker_string.append("(");
marker_string.appendS32(lastMarker.fID);
marker_string.append(")");
}
}
return marker_string;
}
SkString GrTraceMarkerSet::toString() const {
SkTQSort<GrGpuTraceMarker>(this->fMarkerArray.begin(), this->fMarkerArray.end() - 1);
SkString marker_string;
@ -57,12 +72,14 @@ SkString GrTraceMarkerSet::toString() const {
GrGpuTraceMarker& currMarker = this->fMarkerArray[i];
const char* currCmd = currMarker.fMarker;
if (currCmd != prevMarkerName) {
if (counter != 0) {
if (prevMarkerID != -1) {
marker_string.append(") ");
}
marker_string.append(currCmd);
marker_string.append("(");
marker_string.appendS32(currMarker.fID);
if (currMarker.fID != -1) {
marker_string.append("(");
marker_string.appendS32(currMarker.fID);
}
prevMarkerName = currCmd;
} else if (currMarker.fID != prevMarkerID) {
marker_string.append(", ");
@ -71,7 +88,7 @@ SkString GrTraceMarkerSet::toString() const {
prevMarkerID = currMarker.fID;
++counter;
}
if (counter > 0) {
if (counter > 0 && prevMarkerID != -1) {
marker_string.append(")");
}
return marker_string;

View File

@ -55,6 +55,8 @@ public:
*/
SkString toString() const;
SkString toStringLast() const;
class Iter;
Iter begin() const;

View File

@ -344,6 +344,7 @@ SK_COMPILE_ASSERT(SkShader::kLast_BitmapType == 6, shader_type_mismatch);
///////////////////////////////////////////////////////////////////////////////
void SkGpuDevice::clear(SkColor color) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::clear", fContext);
SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
fContext->clear(&rect, SkColor2GrColor(color), true, fRenderTarget);
fNeedClear = false;
@ -351,6 +352,7 @@ void SkGpuDevice::clear(SkColor color) {
void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
CHECK_SHOULD_DRAW(draw, false);
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPaint", fContext);
GrPaint grPaint;
SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
@ -471,6 +473,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect,
void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect,
const SkPaint& paint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawRRect", fContext);
CHECK_FOR_ANNOTATION(paint);
CHECK_SHOULD_DRAW(draw, false);
@ -559,6 +562,7 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval,
const SkPaint& paint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawOval", fContext);
CHECK_FOR_ANNOTATION(paint);
CHECK_SHOULD_DRAW(draw, false);
@ -724,6 +728,7 @@ void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
bool pathIsMutable) {
CHECK_FOR_ANNOTATION(paint);
CHECK_SHOULD_DRAW(draw, false);
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPath", fContext);
GrPaint grPaint;
SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
@ -1500,6 +1505,7 @@ void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap,
void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
int x, int y, const SkPaint& paint) {
// clear of the source device must occur before CHECK_SHOULD_DRAW
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawDevice", fContext);
SkGpuDevice* dev = static_cast<SkGpuDevice*>(device);
if (dev->fNeedClear) {
// TODO: could check here whether we really need to draw at all
@ -1605,6 +1611,7 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
const SkPaint& paint) {
CHECK_SHOULD_DRAW(draw, false);
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawVertices", fContext);
// If both textures and vertex-colors are NULL, strokes hairlines with the paint's color.
if ((NULL == texs || NULL == paint.getShader()) && NULL == colors) {
texs = NULL;
@ -1678,6 +1685,7 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint) {
CHECK_SHOULD_DRAW(draw, false);
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawText", fContext);
if (fMainTextContext->canDraw(paint)) {
GrPaint grPaint;

View File

@ -2982,7 +2982,7 @@ bool GrGpuGL::onCanCopySurface(GrSurface* dst,
void GrGpuGL::didAddGpuTraceMarker() {
if (this->caps()->gpuTracingSupport()) {
const GrTraceMarkerSet& markerArray = this->getActiveTraceMarkers();
SkString markerString = markerArray.toString();
SkString markerString = markerArray.toStringLast();
GL_CALL(PushGroupMarker(0, markerString.c_str()));
}
}