OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 // Multiply-included message file, hence no include guard here, but see below | |
6 // for a much smaller-than-usual include guard section. | |
7 | |
8 #include "build/build_config.h" | |
9 #include "content/common/content_export.h" | |
10 #include "content/common/content_param_traits.h" | |
11 #include "content/common/gpu/establish_channel_params.h" | |
12 #include "content/common/gpu/gpu_memory_uma_stats.h" | |
13 #include "content/common/gpu/gpu_process_launch_causes.h" | |
14 #include "gpu/command_buffer/common/sync_token.h" | |
15 #include "gpu/command_buffer/common/value_state.h" | |
16 #include "gpu/command_buffer/service/gpu_preferences.h" | |
17 #include "gpu/config/gpu_info.h" | |
18 #include "gpu/ipc/common/memory_stats.h" | |
19 #include "gpu/ipc/common/surface_handle.h" | |
20 #include "ipc/ipc_channel_handle.h" | |
21 #include "ipc/ipc_message_macros.h" | |
22 #include "ipc/ipc_message_start.h" | |
23 #include "ui/gfx/gpu_memory_buffer.h" | |
24 #include "ui/gfx/ipc/gfx_param_traits.h" | |
25 #include "url/gurl.h" | |
26 #include "url/ipc/url_param_traits.h" | |
27 | |
28 #if defined(OS_MACOSX) | |
29 #include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h" | |
30 #include "content/common/gpu/buffer_presented_params_mac.h" | |
31 #include "ui/base/cocoa/remote_layer_api.h" | |
32 #include "ui/gfx/mac/io_surface.h" | |
33 #endif | |
34 | |
35 #undef IPC_MESSAGE_EXPORT | |
36 #define IPC_MESSAGE_EXPORT CONTENT_EXPORT | |
37 | |
38 #define IPC_MESSAGE_START GpuMsgStart | |
39 | |
40 IPC_ENUM_TRAITS_MAX_VALUE(content::CauseForGpuLaunch, | |
41 content::CAUSE_FOR_GPU_LAUNCH_MAX_ENUM - 1) | |
42 | |
43 IPC_STRUCT_TRAITS_BEGIN(content::GPUMemoryUmaStats) | |
44 IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_current) | |
45 IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_max) | |
46 IPC_STRUCT_TRAITS_END() | |
47 | |
48 IPC_STRUCT_TRAITS_BEGIN(gpu::VideoMemoryUsageStats) | |
49 IPC_STRUCT_TRAITS_MEMBER(process_map) | |
50 IPC_STRUCT_TRAITS_MEMBER(bytes_allocated) | |
51 IPC_STRUCT_TRAITS_MEMBER(bytes_allocated_historical_max) | |
52 IPC_STRUCT_TRAITS_END() | |
53 | |
54 IPC_STRUCT_TRAITS_BEGIN(gpu::VideoMemoryUsageStats::ProcessStats) | |
55 IPC_STRUCT_TRAITS_MEMBER(video_memory) | |
56 IPC_STRUCT_TRAITS_MEMBER(has_duplicates) | |
57 IPC_STRUCT_TRAITS_END() | |
58 | |
59 IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBuffer_Params) | |
60 IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id) | |
61 IPC_STRUCT_MEMBER(gfx::Size, size) | |
62 IPC_STRUCT_MEMBER(gfx::BufferFormat, format) | |
63 IPC_STRUCT_MEMBER(gfx::BufferUsage, usage) | |
64 IPC_STRUCT_MEMBER(int32_t, client_id) | |
65 IPC_STRUCT_MEMBER(gpu::SurfaceHandle, surface_handle) | |
66 IPC_STRUCT_END() | |
67 | |
68 IPC_STRUCT_BEGIN(GpuMsg_CreateGpuMemoryBufferFromHandle_Params) | |
69 IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferHandle, handle) | |
70 IPC_STRUCT_MEMBER(gfx::GpuMemoryBufferId, id) | |
71 IPC_STRUCT_MEMBER(gfx::Size, size) | |
72 IPC_STRUCT_MEMBER(gfx::BufferFormat, format) | |
73 IPC_STRUCT_MEMBER(int32_t, client_id) | |
74 IPC_STRUCT_END() | |
75 | |
76 IPC_STRUCT_TRAITS_BEGIN(content::EstablishChannelParams) | |
77 IPC_STRUCT_TRAITS_MEMBER(client_id) | |
78 IPC_STRUCT_TRAITS_MEMBER(client_tracing_id) | |
79 IPC_STRUCT_TRAITS_MEMBER(preempts) | |
80 IPC_STRUCT_TRAITS_MEMBER(allow_view_command_buffers) | |
81 IPC_STRUCT_TRAITS_MEMBER(allow_real_time_streams) | |
82 IPC_STRUCT_TRAITS_END() | |
83 | |
84 #if defined(OS_MACOSX) | |
85 IPC_STRUCT_TRAITS_BEGIN(content::AcceleratedSurfaceBuffersSwappedParams) | |
86 IPC_STRUCT_TRAITS_MEMBER(surface_id) | |
87 // Only one of ca_context_id or io_surface may be non-0. | |
88 IPC_STRUCT_TRAITS_MEMBER(ca_context_id) | |
89 IPC_STRUCT_TRAITS_MEMBER(io_surface) | |
90 IPC_STRUCT_TRAITS_MEMBER(size) | |
91 IPC_STRUCT_TRAITS_MEMBER(scale_factor) | |
92 IPC_STRUCT_TRAITS_MEMBER(latency_info) | |
93 IPC_STRUCT_TRAITS_END() | |
94 | |
95 IPC_STRUCT_TRAITS_BEGIN(content::BufferPresentedParams) | |
96 // The vsync parameters, to synchronize presentation with the display. | |
97 IPC_STRUCT_TRAITS_MEMBER(surface_id) | |
98 IPC_STRUCT_TRAITS_MEMBER(vsync_timebase) | |
99 IPC_STRUCT_TRAITS_MEMBER(vsync_interval) | |
100 IPC_STRUCT_TRAITS_END() | |
101 #endif | |
102 | |
103 IPC_STRUCT_TRAITS_BEGIN(gpu::GpuPreferences) | |
104 IPC_STRUCT_TRAITS_MEMBER(single_process) | |
105 IPC_STRUCT_TRAITS_MEMBER(in_process_gpu) | |
106 IPC_STRUCT_TRAITS_MEMBER(ui_prioritize_in_gpu_process) | |
107 IPC_STRUCT_TRAITS_MEMBER(disable_accelerated_video_decode) | |
108 #if defined(OS_CHROMEOS) | |
109 IPC_STRUCT_TRAITS_MEMBER(disable_vaapi_accelerated_video_encode) | |
110 #endif | |
111 #if defined(ENABLE_WEBRTC) | |
112 IPC_STRUCT_TRAITS_MEMBER(disable_web_rtc_hw_encoding) | |
113 #endif | |
114 #if defined(OS_WIN) | |
115 IPC_STRUCT_TRAITS_MEMBER(enable_accelerated_vpx_decode) | |
116 #endif | |
117 IPC_STRUCT_TRAITS_MEMBER(compile_shader_always_succeeds) | |
118 IPC_STRUCT_TRAITS_MEMBER(disable_gl_error_limit) | |
119 IPC_STRUCT_TRAITS_MEMBER(disable_glsl_translator) | |
120 IPC_STRUCT_TRAITS_MEMBER(disable_gpu_driver_bug_workarounds) | |
121 IPC_STRUCT_TRAITS_MEMBER(disable_shader_name_hashing) | |
122 IPC_STRUCT_TRAITS_MEMBER(enable_gpu_command_logging) | |
123 IPC_STRUCT_TRAITS_MEMBER(enable_gpu_debugging) | |
124 IPC_STRUCT_TRAITS_MEMBER(enable_gpu_service_logging_gpu) | |
125 IPC_STRUCT_TRAITS_MEMBER(disable_gpu_program_cache) | |
126 IPC_STRUCT_TRAITS_MEMBER(enforce_gl_minimums) | |
127 IPC_STRUCT_TRAITS_MEMBER(force_gpu_mem_available) | |
128 IPC_STRUCT_TRAITS_MEMBER(gpu_program_cache_size) | |
129 IPC_STRUCT_TRAITS_MEMBER(disable_gpu_shader_disk_cache) | |
130 IPC_STRUCT_TRAITS_MEMBER(enable_share_group_async_texture_upload) | |
131 IPC_STRUCT_TRAITS_MEMBER(enable_subscribe_uniform_extension) | |
132 IPC_STRUCT_TRAITS_MEMBER(enable_threaded_texture_mailboxes) | |
133 IPC_STRUCT_TRAITS_MEMBER(gl_shader_interm_output) | |
134 IPC_STRUCT_TRAITS_MEMBER(emulate_shader_precision) | |
135 IPC_STRUCT_TRAITS_MEMBER(enable_gpu_service_logging) | |
136 IPC_STRUCT_TRAITS_MEMBER(enable_gpu_service_tracing) | |
137 IPC_STRUCT_TRAITS_MEMBER(enable_unsafe_es3_apis) | |
138 IPC_STRUCT_TRAITS_END() | |
139 | |
140 //------------------------------------------------------------------------------ | |
141 // GPU Messages | |
142 // These are messages from the browser to the GPU process. | |
143 | |
144 // Tells the GPU process to initialize itself. The browser explicitly | |
145 // requests this be done so that we are guaranteed that the channel is set | |
146 // up between the browser and GPU process before doing any work that might | |
147 // potentially crash the GPU process. Detection of the child process | |
148 // exiting abruptly is predicated on having the IPC channel set up. | |
149 IPC_MESSAGE_CONTROL1(GpuMsg_Initialize, | |
150 gpu::GpuPreferences /* gpu_prefernces */) | |
151 | |
152 // Tells the GPU process to shutdown itself. | |
153 IPC_MESSAGE_CONTROL0(GpuMsg_Finalize) | |
154 | |
155 // Tells the GPU process to create a new channel for communication with a | |
156 // given client. The channel name is returned in a | |
157 // GpuHostMsg_ChannelEstablished message. The client ID is passed so | |
158 // that the GPU process reuses an existing channel to that process if it exists. | |
159 // This ID is a unique opaque identifier generated by the browser process. | |
160 // The client_tracing_id is a unique ID used for the purposes of tracing. | |
161 IPC_MESSAGE_CONTROL1(GpuMsg_EstablishChannel, | |
162 content::EstablishChannelParams /* params */) | |
163 | |
164 // Tells the GPU process to close the channel identified by |client_id|. | |
165 // If no channel can be identified, do nothing. | |
166 IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel, | |
167 int32_t /* client_id */) | |
168 | |
169 // Tells the GPU process to create a new gpu memory buffer. | |
170 IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBuffer, | |
171 GpuMsg_CreateGpuMemoryBuffer_Params) | |
172 | |
173 // Tells the GPU process to create a new gpu memory buffer from an existing | |
174 // handle. | |
175 IPC_MESSAGE_CONTROL1(GpuMsg_CreateGpuMemoryBufferFromHandle, | |
176 GpuMsg_CreateGpuMemoryBufferFromHandle_Params) | |
177 | |
178 // Tells the GPU process to destroy buffer. | |
179 IPC_MESSAGE_CONTROL3(GpuMsg_DestroyGpuMemoryBuffer, | |
180 gfx::GpuMemoryBufferId, /* id */ | |
181 int32_t, /* client_id */ | |
182 gpu::SyncToken /* sync_token */) | |
183 | |
184 // Tells the GPU process to create a context for collecting graphics card | |
185 // information. | |
186 IPC_MESSAGE_CONTROL0(GpuMsg_CollectGraphicsInfo) | |
187 | |
188 // Tells the GPU process to report video_memory information for the task manager | |
189 IPC_MESSAGE_CONTROL0(GpuMsg_GetVideoMemoryUsageStats) | |
190 | |
191 #if defined(OS_MACOSX) | |
192 // Tells the GPU process that the browser process has handled the swap | |
193 // buffers or post sub-buffer request. | |
194 IPC_MESSAGE_CONTROL1(AcceleratedSurfaceMsg_BufferPresented, | |
195 content::BufferPresentedParams) | |
196 #endif | |
197 | |
198 #if defined(OS_ANDROID) | |
199 // Tells the GPU process to wake up the GPU because we're about to draw. | |
200 IPC_MESSAGE_CONTROL0(GpuMsg_WakeUpGpu) | |
201 #endif | |
202 | |
203 // Tells the GPU process to remove all contexts. | |
204 IPC_MESSAGE_CONTROL0(GpuMsg_Clean) | |
205 | |
206 // Tells the GPU process to crash. | |
207 IPC_MESSAGE_CONTROL0(GpuMsg_Crash) | |
208 | |
209 // Tells the GPU process to hang. | |
210 IPC_MESSAGE_CONTROL0(GpuMsg_Hang) | |
211 | |
212 // Tells the GPU process to disable the watchdog thread. | |
213 IPC_MESSAGE_CONTROL0(GpuMsg_DisableWatchdog) | |
214 | |
215 // Tells the GPU process that the browser has seen a GPU switch. | |
216 IPC_MESSAGE_CONTROL0(GpuMsg_GpuSwitched) | |
217 | |
218 // Sends an input event to the gpu service. | |
219 IPC_MESSAGE_CONTROL3(GpuMsg_UpdateValueState, | |
220 int, /* client_id */ | |
221 unsigned int, /* target */ | |
222 gpu::ValueState /* valuestate */) | |
223 | |
224 //------------------------------------------------------------------------------ | |
225 // GPU Host Messages | |
226 // These are messages to the browser. | |
227 | |
228 // A renderer sends this when it wants to create a connection to the GPU | |
229 // process. The browser will create the GPU process if necessary, and will | |
230 // return a handle to the channel via a GpuChannelEstablished message. | |
231 IPC_SYNC_MESSAGE_CONTROL1_3(GpuHostMsg_EstablishGpuChannel, | |
232 content::CauseForGpuLaunch, | |
233 int /* client id */, | |
234 IPC::ChannelHandle /* handle to channel */, | |
235 gpu::GPUInfo /* stats about GPU process*/) | |
236 | |
237 // A renderer sends this when it wants to know whether a gpu process exists. | |
238 IPC_SYNC_MESSAGE_CONTROL0_1(GpuHostMsg_HasGpuProcess, bool /* result */) | |
239 | |
240 // Response from GPU to a GputMsg_Initialize message. | |
241 IPC_MESSAGE_CONTROL2(GpuHostMsg_Initialized, | |
242 bool /* result */, | |
243 ::gpu::GPUInfo /* gpu_info */) | |
244 | |
245 // Response from GPU to a GpuHostMsg_EstablishChannel message. | |
246 IPC_MESSAGE_CONTROL1(GpuHostMsg_ChannelEstablished, | |
247 IPC::ChannelHandle /* channel_handle */) | |
248 | |
249 // Message from GPU to notify to destroy the channel. | |
250 IPC_MESSAGE_CONTROL1(GpuHostMsg_DestroyChannel, int32_t /* client_id */) | |
251 | |
252 // Message to cache the given shader information. | |
253 IPC_MESSAGE_CONTROL3(GpuHostMsg_CacheShader, | |
254 int32_t /* client_id */, | |
255 std::string /* key */, | |
256 std::string /* shader */) | |
257 | |
258 // Message to the GPU that a shader was loaded from disk. | |
259 IPC_MESSAGE_CONTROL1(GpuMsg_LoadedShader, std::string /* encoded shader */) | |
260 | |
261 // Response from GPU to a GpuMsg_CreateGpuMemoryBuffer message. | |
262 IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryBufferCreated, | |
263 gfx::GpuMemoryBufferHandle /* handle */) | |
264 | |
265 // Response from GPU to a GpuMsg_CollectGraphicsInfo. | |
266 IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected, | |
267 gpu::GPUInfo /* GPU logging stats */) | |
268 | |
269 // Response from GPU to a GpuMsg_GetVideoMemory. | |
270 IPC_MESSAGE_CONTROL1(GpuHostMsg_VideoMemoryUsageStats, | |
271 gpu::VideoMemoryUsageStats /* GPU memory stats */) | |
272 | |
273 #if defined(OS_MACOSX) | |
274 // Tells the browser that an accelerated surface has swapped. | |
275 IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | |
276 content::AcceleratedSurfaceBuffersSwappedParams) | |
277 #endif | |
278 | |
279 #if defined(OS_WIN) | |
280 IPC_MESSAGE_CONTROL2(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, | |
281 gpu::SurfaceHandle /* parent_window */, | |
282 gpu::SurfaceHandle /* child_window */) | |
283 #endif | |
284 | |
285 IPC_MESSAGE_CONTROL1(GpuHostMsg_DidCreateOffscreenContext, GURL /* url */) | |
286 | |
287 IPC_MESSAGE_CONTROL3(GpuHostMsg_DidLoseContext, | |
288 bool /* offscreen */, | |
289 gpu::error::ContextLostReason /* reason */, | |
290 GURL /* url */) | |
291 | |
292 IPC_MESSAGE_CONTROL1(GpuHostMsg_DidDestroyOffscreenContext, GURL /* url */) | |
293 | |
294 // Tells the browser about GPU memory usage statistics for UMA logging. | |
295 IPC_MESSAGE_CONTROL1(GpuHostMsg_GpuMemoryUmaStats, | |
296 content::GPUMemoryUmaStats /* GPU memory UMA stats */) | |
297 | |
298 // Tells the browser that a context has subscribed to a new target and | |
299 // the browser should start sending the corresponding information | |
300 IPC_MESSAGE_CONTROL2(GpuHostMsg_AddSubscription, | |
301 int32_t /* client_id */, | |
302 unsigned int /* target */) | |
303 | |
304 // Tells the browser that no contexts are subscribed to the target anymore | |
305 // so the browser should stop sending the corresponding information | |
306 IPC_MESSAGE_CONTROL2(GpuHostMsg_RemoveSubscription, | |
307 int32_t /* client_id */, | |
308 unsigned int /* target */) | |
309 | |
310 // Message from GPU to add a GPU log message to the about:gpu page. | |
311 IPC_MESSAGE_CONTROL3(GpuHostMsg_OnLogMessage, | |
312 int /*severity*/, | |
313 std::string /* header */, | |
314 std::string /* message */) | |
OLD | NEW |