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

Side by Side Diff: content/common/gpu/client/command_buffer_metrics.cc

Issue 1095893002: gpu: Fix some context lost marking glitches+leaks and add UMA stats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: kbr's comment Created 5 years, 7 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/common/gpu/client/command_buffer_metrics.h"
6
7 #include "base/metrics/histogram.h"
8
9 namespace content {
10
11 namespace {
12
13 enum CommandBufferContextLostReason {
14 // Don't add new values here.
15 CONTEXT_INIT_FAILED,
16 CONTEXT_LOST_GPU_CHANNEL_ERROR,
17 CONTEXT_PARSE_ERROR_INVALID_SIZE,
18 CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS,
19 CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND,
20 CONTEXT_PARSE_ERROR_INVALID_ARGS,
21 CONTEXT_PARSE_ERROR_GENERIC_ERROR,
22 CONTEXT_LOST_GUILTY,
23 CONTEXT_LOST_INNOCENT,
24 CONTEXT_LOST_UNKNOWN,
25 CONTEXT_LOST_OUT_OF_MEMORY,
26 CONTEXT_LOST_MAKECURRENT_FAILED,
27 // Add new values here and update _MAX_ENUM.
28 CONTEXT_LOST_REASON_MAX_ENUM = CONTEXT_LOST_MAKECURRENT_FAILED
29 };
30
31 CommandBufferContextLostReason GetContextLostReason(
32 gpu::error::Error error,
33 gpu::error::ContextLostReason reason) {
34 if (error == gpu::error::kLostContext) {
35 switch (reason) {
36 case gpu::error::kGuilty:
37 return CONTEXT_LOST_GUILTY;
38 case gpu::error::kInnocent:
39 return CONTEXT_LOST_INNOCENT;
40 case gpu::error::kUnknown:
41 return CONTEXT_LOST_UNKNOWN;
42 case gpu::error::kOutOfMemory:
43 return CONTEXT_LOST_OUT_OF_MEMORY;
44 case gpu::error::kMakeCurrentFailed:
45 return CONTEXT_LOST_MAKECURRENT_FAILED;
46 case gpu::error::kGpuChannelLost:
47 return CONTEXT_LOST_GPU_CHANNEL_ERROR;
48 }
49 }
50 switch (error) {
51 case gpu::error::kInvalidSize:
52 return CONTEXT_PARSE_ERROR_INVALID_SIZE;
53 case gpu::error::kOutOfBounds:
54 return CONTEXT_PARSE_ERROR_OUT_OF_BOUNDS;
55 case gpu::error::kUnknownCommand:
56 return CONTEXT_PARSE_ERROR_UNKNOWN_COMMAND;
57 case gpu::error::kInvalidArguments:
58 return CONTEXT_PARSE_ERROR_INVALID_ARGS;
59 case gpu::error::kGenericError:
60 return CONTEXT_PARSE_ERROR_GENERIC_ERROR;
61 case gpu::error::kDeferCommandUntilLater:
62 case gpu::error::kNoError:
63 case gpu::error::kLostContext:
64 NOTREACHED();
65 return CONTEXT_LOST_UNKNOWN;
66 }
67 NOTREACHED();
68 return CONTEXT_LOST_UNKNOWN;
69 }
70
71 void RecordContextLost(CommandBufferContextType type,
72 CommandBufferContextLostReason reason) {
73 switch (type) {
74 case BROWSER_COMPOSITOR_ONSCREEN_CONTEXT:
75 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.BrowserCompositor", reason,
76 CONTEXT_LOST_REASON_MAX_ENUM);
77 break;
78 case BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT:
79 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.BrowserMainThread", reason,
80 CONTEXT_LOST_REASON_MAX_ENUM);
81 break;
82 case RENDER_COMPOSITOR_CONTEXT:
83 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.RenderCompositor", reason,
84 CONTEXT_LOST_REASON_MAX_ENUM);
85 break;
86 case RENDER_WORKER_CONTEXT:
87 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.RenderWorker", reason,
88 CONTEXT_LOST_REASON_MAX_ENUM);
89 break;
90 case RENDERER_MAINTHREAD_CONTEXT:
91 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.RenderMainThread", reason,
92 CONTEXT_LOST_REASON_MAX_ENUM);
93 break;
94 case GPU_VIDEO_ACCELERATOR_CONTEXT:
95 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.VideoAccelerator", reason,
96 CONTEXT_LOST_REASON_MAX_ENUM);
97 break;
98 case OFFSCREEN_VIDEO_CAPTURE_CONTEXT:
99 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.VideoCapture", reason,
100 CONTEXT_LOST_REASON_MAX_ENUM);
101 break;
102 case OFFSCREEN_CONTEXT_FOR_WEBGL:
103 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.WebGL", reason,
104 CONTEXT_LOST_REASON_MAX_ENUM);
105 break;
106 case CONTEXT_TYPE_UNKNOWN:
107 UMA_HISTOGRAM_ENUMERATION("GPU.ContextLost.Unknown", reason,
108 CONTEXT_LOST_REASON_MAX_ENUM);
109 break;
110 }
111 }
112
113 } // anonymous namespace
114
115 std::string CommandBufferContextTypeToString(CommandBufferContextType type) {
116 switch (type) {
117 case OFFSCREEN_CONTEXT_FOR_TESTING:
118 return "Context-For-Testing";
119 case BROWSER_COMPOSITOR_ONSCREEN_CONTEXT:
120 return "Compositor";
121 case BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT:
122 return "Offscreen-MainThread";
123 case RENDER_COMPOSITOR_CONTEXT:
124 return "RenderCompositor";
125 case RENDER_WORKER_CONTEXT:
126 return "RenderWorker";
127 case RENDERER_MAINTHREAD_CONTEXT:
128 return "Offscreen-MainThread";
129 case GPU_VIDEO_ACCELERATOR_CONTEXT:
130 return "GPU-VideoAccelerator-Offscreen";
131 case OFFSCREEN_VIDEO_CAPTURE_CONTEXT:
132 return "Offscreen-CaptureThread";
133 case OFFSCREEN_CONTEXT_FOR_WEBGL:
134 return "Offscreen-For-WebGL";
135 default:
136 NOTREACHED();
137 return "unknown";
138 }
139 }
140
141 void UmaRecordContextInitFailed(CommandBufferContextType type) {
142 RecordContextLost(type, CONTEXT_INIT_FAILED);
143 }
144
145 void UmaRecordContextLost(CommandBufferContextType type,
146 gpu::error::Error error,
147 gpu::error::ContextLostReason reason) {
148 CommandBufferContextLostReason converted_reason =
149 GetContextLostReason(error, reason);
150 RecordContextLost(type, converted_reason);
151 }
152
153 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/command_buffer_metrics.h ('k') | content/common/gpu/client/command_buffer_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698