OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
8 #include "base/test/test_message_loop.h" | 8 #include "base/test/test_message_loop.h" |
9 #include "gpu/ipc/common/gpu_messages.h" | 9 #include "gpu/ipc/common/gpu_messages.h" |
10 #include "gpu/ipc/service/gpu_channel.h" | 10 #include "gpu/ipc/service/gpu_channel.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 GpuChannel* channel = | 207 GpuChannel* channel = |
208 CreateChannel(kClientId, allow_view_command_buffers, false); | 208 CreateChannel(kClientId, allow_view_command_buffers, false); |
209 ASSERT_TRUE(channel); | 209 ASSERT_TRUE(channel); |
210 | 210 |
211 SurfaceHandle surface_handle = kFakeSurfaceHandle; | 211 SurfaceHandle surface_handle = kFakeSurfaceHandle; |
212 DCHECK_NE(surface_handle, kNullSurfaceHandle); | 212 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
213 | 213 |
214 int32_t kRouteId = 1; | 214 int32_t kRouteId = 1; |
215 GPUCreateCommandBufferConfig init_params; | 215 GPUCreateCommandBufferConfig init_params; |
216 init_params.surface_handle = surface_handle; | 216 init_params.surface_handle = surface_handle; |
217 init_params.size = gfx::Size(); | |
218 init_params.share_group_id = MSG_ROUTING_NONE; | 217 init_params.share_group_id = MSG_ROUTING_NONE; |
219 init_params.stream_id = 0; | 218 init_params.stream_id = 0; |
220 init_params.stream_priority = GpuStreamPriority::NORMAL; | 219 init_params.stream_priority = GpuStreamPriority::NORMAL; |
221 init_params.attribs = gles2::ContextCreationAttribHelper(); | 220 init_params.attribs = gles2::ContextCreationAttribHelper(); |
222 init_params.active_url = GURL(); | 221 init_params.active_url = GURL(); |
223 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
224 bool result = false; | 222 bool result = false; |
225 gpu::Capabilities capabilities; | 223 gpu::Capabilities capabilities; |
226 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 224 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
227 init_params, kRouteId, GetSharedHandle(), &result, | 225 init_params, kRouteId, GetSharedHandle(), &result, |
228 &capabilities)); | 226 &capabilities)); |
229 EXPECT_TRUE(result); | 227 EXPECT_TRUE(result); |
230 | 228 |
231 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); | 229 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); |
232 ASSERT_TRUE(stub); | 230 ASSERT_TRUE(stub); |
233 } | 231 } |
234 | 232 |
235 TEST_F(GpuChannelTest, CreateViewCommandBufferDisallowed) { | 233 TEST_F(GpuChannelTest, CreateViewCommandBufferDisallowed) { |
236 int32_t kClientId = 1; | 234 int32_t kClientId = 1; |
237 bool allow_view_command_buffers = false; | 235 bool allow_view_command_buffers = false; |
238 GpuChannel* channel = | 236 GpuChannel* channel = |
239 CreateChannel(kClientId, allow_view_command_buffers, false); | 237 CreateChannel(kClientId, allow_view_command_buffers, false); |
240 ASSERT_TRUE(channel); | 238 ASSERT_TRUE(channel); |
241 | 239 |
242 SurfaceHandle surface_handle = kFakeSurfaceHandle; | 240 SurfaceHandle surface_handle = kFakeSurfaceHandle; |
243 DCHECK_NE(surface_handle, kNullSurfaceHandle); | 241 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
244 | 242 |
245 int32_t kRouteId = 1; | 243 int32_t kRouteId = 1; |
246 GPUCreateCommandBufferConfig init_params; | 244 GPUCreateCommandBufferConfig init_params; |
247 init_params.surface_handle = surface_handle; | 245 init_params.surface_handle = surface_handle; |
248 init_params.size = gfx::Size(); | |
249 init_params.share_group_id = MSG_ROUTING_NONE; | 246 init_params.share_group_id = MSG_ROUTING_NONE; |
250 init_params.stream_id = 0; | 247 init_params.stream_id = 0; |
251 init_params.stream_priority = GpuStreamPriority::NORMAL; | 248 init_params.stream_priority = GpuStreamPriority::NORMAL; |
252 init_params.attribs = gles2::ContextCreationAttribHelper(); | 249 init_params.attribs = gles2::ContextCreationAttribHelper(); |
253 init_params.active_url = GURL(); | 250 init_params.active_url = GURL(); |
254 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
255 bool result = false; | 251 bool result = false; |
256 gpu::Capabilities capabilities; | 252 gpu::Capabilities capabilities; |
257 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 253 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
258 init_params, kRouteId, GetSharedHandle(), &result, | 254 init_params, kRouteId, GetSharedHandle(), &result, |
259 &capabilities)); | 255 &capabilities)); |
260 EXPECT_FALSE(result); | 256 EXPECT_FALSE(result); |
261 | 257 |
262 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); | 258 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); |
263 EXPECT_FALSE(stub); | 259 EXPECT_FALSE(stub); |
264 } | 260 } |
265 | 261 |
266 TEST_F(GpuChannelTest, CreateOffscreenCommandBuffer) { | 262 TEST_F(GpuChannelTest, CreateOffscreenCommandBuffer) { |
267 int32_t kClientId = 1; | 263 int32_t kClientId = 1; |
268 GpuChannel* channel = CreateChannel(kClientId, true, false); | 264 GpuChannel* channel = CreateChannel(kClientId, true, false); |
269 ASSERT_TRUE(channel); | 265 ASSERT_TRUE(channel); |
270 | 266 |
271 int32_t kRouteId = 1; | 267 int32_t kRouteId = 1; |
272 GPUCreateCommandBufferConfig init_params; | 268 GPUCreateCommandBufferConfig init_params; |
273 init_params.surface_handle = kNullSurfaceHandle; | 269 init_params.surface_handle = kNullSurfaceHandle; |
274 init_params.size = gfx::Size(1, 1); | |
275 init_params.share_group_id = MSG_ROUTING_NONE; | 270 init_params.share_group_id = MSG_ROUTING_NONE; |
276 init_params.stream_id = 0; | 271 init_params.stream_id = 0; |
277 init_params.stream_priority = GpuStreamPriority::NORMAL; | 272 init_params.stream_priority = GpuStreamPriority::NORMAL; |
278 init_params.attribs = gles2::ContextCreationAttribHelper(); | 273 init_params.attribs = gles2::ContextCreationAttribHelper(); |
279 init_params.active_url = GURL(); | 274 init_params.active_url = GURL(); |
280 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
281 bool result = false; | 275 bool result = false; |
282 gpu::Capabilities capabilities; | 276 gpu::Capabilities capabilities; |
283 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 277 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
284 init_params, kRouteId, GetSharedHandle(), &result, | 278 init_params, kRouteId, GetSharedHandle(), &result, |
285 &capabilities)); | 279 &capabilities)); |
286 EXPECT_TRUE(result); | 280 EXPECT_TRUE(result); |
287 | 281 |
288 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); | 282 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); |
289 EXPECT_TRUE(stub); | 283 EXPECT_TRUE(stub); |
290 } | 284 } |
291 | 285 |
292 TEST_F(GpuChannelTest, IncompatibleStreamIds) { | 286 TEST_F(GpuChannelTest, IncompatibleStreamIds) { |
293 int32_t kClientId = 1; | 287 int32_t kClientId = 1; |
294 GpuChannel* channel = CreateChannel(kClientId, true, false); | 288 GpuChannel* channel = CreateChannel(kClientId, true, false); |
295 ASSERT_TRUE(channel); | 289 ASSERT_TRUE(channel); |
296 | 290 |
297 // Create first context. | 291 // Create first context. |
298 int32_t kRouteId1 = 1; | 292 int32_t kRouteId1 = 1; |
299 int32_t kStreamId1 = 1; | 293 int32_t kStreamId1 = 1; |
300 GPUCreateCommandBufferConfig init_params; | 294 GPUCreateCommandBufferConfig init_params; |
301 init_params.surface_handle = kNullSurfaceHandle; | 295 init_params.surface_handle = kNullSurfaceHandle; |
302 init_params.size = gfx::Size(1, 1); | |
303 init_params.share_group_id = MSG_ROUTING_NONE; | 296 init_params.share_group_id = MSG_ROUTING_NONE; |
304 init_params.stream_id = kStreamId1; | 297 init_params.stream_id = kStreamId1; |
305 init_params.stream_priority = GpuStreamPriority::NORMAL; | 298 init_params.stream_priority = GpuStreamPriority::NORMAL; |
306 init_params.attribs = gles2::ContextCreationAttribHelper(); | 299 init_params.attribs = gles2::ContextCreationAttribHelper(); |
307 init_params.active_url = GURL(); | 300 init_params.active_url = GURL(); |
308 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
309 bool result = false; | 301 bool result = false; |
310 gpu::Capabilities capabilities; | 302 gpu::Capabilities capabilities; |
311 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 303 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
312 init_params, kRouteId1, GetSharedHandle(), &result, | 304 init_params, kRouteId1, GetSharedHandle(), &result, |
313 &capabilities)); | 305 &capabilities)); |
314 EXPECT_TRUE(result); | 306 EXPECT_TRUE(result); |
315 | 307 |
316 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1); | 308 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1); |
317 EXPECT_TRUE(stub); | 309 EXPECT_TRUE(stub); |
318 | 310 |
319 // Create second context in same share group but different stream. | 311 // Create second context in same share group but different stream. |
320 int32_t kRouteId2 = 2; | 312 int32_t kRouteId2 = 2; |
321 int32_t kStreamId2 = 2; | 313 int32_t kStreamId2 = 2; |
322 | 314 |
323 init_params.share_group_id = kRouteId1; | 315 init_params.share_group_id = kRouteId1; |
324 init_params.stream_id = kStreamId2; | 316 init_params.stream_id = kStreamId2; |
325 init_params.stream_priority = GpuStreamPriority::NORMAL; | 317 init_params.stream_priority = GpuStreamPriority::NORMAL; |
326 init_params.attribs = gles2::ContextCreationAttribHelper(); | 318 init_params.attribs = gles2::ContextCreationAttribHelper(); |
327 init_params.active_url = GURL(); | 319 init_params.active_url = GURL(); |
328 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
329 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 320 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
330 init_params, kRouteId2, GetSharedHandle(), &result, | 321 init_params, kRouteId2, GetSharedHandle(), &result, |
331 &capabilities)); | 322 &capabilities)); |
332 EXPECT_FALSE(result); | 323 EXPECT_FALSE(result); |
333 | 324 |
334 stub = channel->LookupCommandBuffer(kRouteId2); | 325 stub = channel->LookupCommandBuffer(kRouteId2); |
335 EXPECT_FALSE(stub); | 326 EXPECT_FALSE(stub); |
336 } | 327 } |
337 | 328 |
338 TEST_F(GpuChannelTest, StreamLifetime) { | 329 TEST_F(GpuChannelTest, StreamLifetime) { |
339 int32_t kClientId = 1; | 330 int32_t kClientId = 1; |
340 GpuChannel* channel = CreateChannel(kClientId, true, false); | 331 GpuChannel* channel = CreateChannel(kClientId, true, false); |
341 ASSERT_TRUE(channel); | 332 ASSERT_TRUE(channel); |
342 | 333 |
343 // Create first context. | 334 // Create first context. |
344 int32_t kRouteId1 = 1; | 335 int32_t kRouteId1 = 1; |
345 int32_t kStreamId1 = 1; | 336 int32_t kStreamId1 = 1; |
346 GpuStreamPriority kStreamPriority1 = GpuStreamPriority::NORMAL; | 337 GpuStreamPriority kStreamPriority1 = GpuStreamPriority::NORMAL; |
347 GPUCreateCommandBufferConfig init_params; | 338 GPUCreateCommandBufferConfig init_params; |
348 init_params.surface_handle = kNullSurfaceHandle; | 339 init_params.surface_handle = kNullSurfaceHandle; |
349 init_params.size = gfx::Size(1, 1); | |
350 init_params.share_group_id = MSG_ROUTING_NONE; | 340 init_params.share_group_id = MSG_ROUTING_NONE; |
351 init_params.stream_id = kStreamId1; | 341 init_params.stream_id = kStreamId1; |
352 init_params.stream_priority = kStreamPriority1; | 342 init_params.stream_priority = kStreamPriority1; |
353 init_params.attribs = gles2::ContextCreationAttribHelper(); | 343 init_params.attribs = gles2::ContextCreationAttribHelper(); |
354 init_params.active_url = GURL(); | 344 init_params.active_url = GURL(); |
355 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
356 bool result = false; | 345 bool result = false; |
357 gpu::Capabilities capabilities; | 346 gpu::Capabilities capabilities; |
358 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 347 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
359 init_params, kRouteId1, GetSharedHandle(), &result, | 348 init_params, kRouteId1, GetSharedHandle(), &result, |
360 &capabilities)); | 349 &capabilities)); |
361 EXPECT_TRUE(result); | 350 EXPECT_TRUE(result); |
362 | 351 |
363 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1); | 352 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId1); |
364 EXPECT_TRUE(stub); | 353 EXPECT_TRUE(stub); |
365 | 354 |
366 HandleMessage(channel, new GpuChannelMsg_DestroyCommandBuffer(kRouteId1)); | 355 HandleMessage(channel, new GpuChannelMsg_DestroyCommandBuffer(kRouteId1)); |
367 stub = channel->LookupCommandBuffer(kRouteId1); | 356 stub = channel->LookupCommandBuffer(kRouteId1); |
368 EXPECT_FALSE(stub); | 357 EXPECT_FALSE(stub); |
369 | 358 |
370 // Create second context in same share group but different stream. | 359 // Create second context in same share group but different stream. |
371 int32_t kRouteId2 = 2; | 360 int32_t kRouteId2 = 2; |
372 int32_t kStreamId2 = 2; | 361 int32_t kStreamId2 = 2; |
373 GpuStreamPriority kStreamPriority2 = GpuStreamPriority::LOW; | 362 GpuStreamPriority kStreamPriority2 = GpuStreamPriority::LOW; |
374 | 363 |
375 init_params.share_group_id = MSG_ROUTING_NONE; | 364 init_params.share_group_id = MSG_ROUTING_NONE; |
376 init_params.stream_id = kStreamId2; | 365 init_params.stream_id = kStreamId2; |
377 init_params.stream_priority = kStreamPriority2; | 366 init_params.stream_priority = kStreamPriority2; |
378 init_params.attribs = gles2::ContextCreationAttribHelper(); | 367 init_params.attribs = gles2::ContextCreationAttribHelper(); |
379 init_params.active_url = GURL(); | 368 init_params.active_url = GURL(); |
380 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
381 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 369 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
382 init_params, kRouteId2, GetSharedHandle(), &result, | 370 init_params, kRouteId2, GetSharedHandle(), &result, |
383 &capabilities)); | 371 &capabilities)); |
384 EXPECT_TRUE(result); | 372 EXPECT_TRUE(result); |
385 | 373 |
386 stub = channel->LookupCommandBuffer(kRouteId2); | 374 stub = channel->LookupCommandBuffer(kRouteId2); |
387 EXPECT_TRUE(stub); | 375 EXPECT_TRUE(stub); |
388 } | 376 } |
389 | 377 |
390 TEST_F(GpuChannelTest, RealTimeStreamsDisallowed) { | 378 TEST_F(GpuChannelTest, RealTimeStreamsDisallowed) { |
391 int32_t kClientId = 1; | 379 int32_t kClientId = 1; |
392 bool allow_real_time_streams = false; | 380 bool allow_real_time_streams = false; |
393 GpuChannel* channel = CreateChannel(kClientId, true, allow_real_time_streams); | 381 GpuChannel* channel = CreateChannel(kClientId, true, allow_real_time_streams); |
394 ASSERT_TRUE(channel); | 382 ASSERT_TRUE(channel); |
395 | 383 |
396 // Create first context. | 384 // Create first context. |
397 int32_t kRouteId = 1; | 385 int32_t kRouteId = 1; |
398 int32_t kStreamId = 1; | 386 int32_t kStreamId = 1; |
399 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME; | 387 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME; |
400 GPUCreateCommandBufferConfig init_params; | 388 GPUCreateCommandBufferConfig init_params; |
401 init_params.surface_handle = kNullSurfaceHandle; | 389 init_params.surface_handle = kNullSurfaceHandle; |
402 init_params.size = gfx::Size(1, 1); | |
403 init_params.share_group_id = MSG_ROUTING_NONE; | 390 init_params.share_group_id = MSG_ROUTING_NONE; |
404 init_params.stream_id = kStreamId; | 391 init_params.stream_id = kStreamId; |
405 init_params.stream_priority = kStreamPriority; | 392 init_params.stream_priority = kStreamPriority; |
406 init_params.attribs = gles2::ContextCreationAttribHelper(); | 393 init_params.attribs = gles2::ContextCreationAttribHelper(); |
407 init_params.active_url = GURL(); | 394 init_params.active_url = GURL(); |
408 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
409 bool result = false; | 395 bool result = false; |
410 gpu::Capabilities capabilities; | 396 gpu::Capabilities capabilities; |
411 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 397 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
412 init_params, kRouteId, GetSharedHandle(), &result, | 398 init_params, kRouteId, GetSharedHandle(), &result, |
413 &capabilities)); | 399 &capabilities)); |
414 EXPECT_FALSE(result); | 400 EXPECT_FALSE(result); |
415 | 401 |
416 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); | 402 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); |
417 EXPECT_FALSE(stub); | 403 EXPECT_FALSE(stub); |
418 } | 404 } |
419 | 405 |
420 TEST_F(GpuChannelTest, RealTimeStreamsAllowed) { | 406 TEST_F(GpuChannelTest, RealTimeStreamsAllowed) { |
421 int32_t kClientId = 1; | 407 int32_t kClientId = 1; |
422 bool allow_real_time_streams = true; | 408 bool allow_real_time_streams = true; |
423 GpuChannel* channel = CreateChannel(kClientId, true, allow_real_time_streams); | 409 GpuChannel* channel = CreateChannel(kClientId, true, allow_real_time_streams); |
424 ASSERT_TRUE(channel); | 410 ASSERT_TRUE(channel); |
425 | 411 |
426 // Create first context. | 412 // Create first context. |
427 int32_t kRouteId = 1; | 413 int32_t kRouteId = 1; |
428 int32_t kStreamId = 1; | 414 int32_t kStreamId = 1; |
429 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME; | 415 GpuStreamPriority kStreamPriority = GpuStreamPriority::REAL_TIME; |
430 GPUCreateCommandBufferConfig init_params; | 416 GPUCreateCommandBufferConfig init_params; |
431 init_params.surface_handle = kNullSurfaceHandle; | 417 init_params.surface_handle = kNullSurfaceHandle; |
432 init_params.size = gfx::Size(1, 1); | |
433 init_params.share_group_id = MSG_ROUTING_NONE; | 418 init_params.share_group_id = MSG_ROUTING_NONE; |
434 init_params.stream_id = kStreamId; | 419 init_params.stream_id = kStreamId; |
435 init_params.stream_priority = kStreamPriority; | 420 init_params.stream_priority = kStreamPriority; |
436 init_params.attribs = gles2::ContextCreationAttribHelper(); | 421 init_params.attribs = gles2::ContextCreationAttribHelper(); |
437 init_params.active_url = GURL(); | 422 init_params.active_url = GURL(); |
438 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
439 bool result = false; | 423 bool result = false; |
440 gpu::Capabilities capabilities; | 424 gpu::Capabilities capabilities; |
441 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 425 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
442 init_params, kRouteId, GetSharedHandle(), &result, | 426 init_params, kRouteId, GetSharedHandle(), &result, |
443 &capabilities)); | 427 &capabilities)); |
444 EXPECT_TRUE(result); | 428 EXPECT_TRUE(result); |
445 | 429 |
446 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); | 430 GpuCommandBufferStub* stub = channel->LookupCommandBuffer(kRouteId); |
447 EXPECT_TRUE(stub); | 431 EXPECT_TRUE(stub); |
448 } | 432 } |
449 | 433 |
450 TEST_F(GpuChannelTest, CreateFailsIfSharedContextIsLost) { | 434 TEST_F(GpuChannelTest, CreateFailsIfSharedContextIsLost) { |
451 int32_t kClientId = 1; | 435 int32_t kClientId = 1; |
452 GpuChannel* channel = CreateChannel(kClientId, false, false); | 436 GpuChannel* channel = CreateChannel(kClientId, false, false); |
453 ASSERT_TRUE(channel); | 437 ASSERT_TRUE(channel); |
454 | 438 |
455 // Create first context, we will share this one. | 439 // Create first context, we will share this one. |
456 int32_t kSharedRouteId = 1; | 440 int32_t kSharedRouteId = 1; |
457 { | 441 { |
458 SCOPED_TRACE("kSharedRouteId"); | 442 SCOPED_TRACE("kSharedRouteId"); |
459 GPUCreateCommandBufferConfig init_params; | 443 GPUCreateCommandBufferConfig init_params; |
460 init_params.surface_handle = kNullSurfaceHandle; | 444 init_params.surface_handle = kNullSurfaceHandle; |
461 init_params.size = gfx::Size(1, 1); | |
462 init_params.share_group_id = MSG_ROUTING_NONE; | 445 init_params.share_group_id = MSG_ROUTING_NONE; |
463 init_params.stream_id = 0; | 446 init_params.stream_id = 0; |
464 init_params.stream_priority = GpuStreamPriority::NORMAL; | 447 init_params.stream_priority = GpuStreamPriority::NORMAL; |
465 init_params.attribs = gles2::ContextCreationAttribHelper(); | 448 init_params.attribs = gles2::ContextCreationAttribHelper(); |
466 init_params.active_url = GURL(); | 449 init_params.active_url = GURL(); |
467 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
468 bool result = false; | 450 bool result = false; |
469 gpu::Capabilities capabilities; | 451 gpu::Capabilities capabilities; |
470 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 452 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
471 init_params, kSharedRouteId, GetSharedHandle(), | 453 init_params, kSharedRouteId, GetSharedHandle(), |
472 &result, &capabilities)); | 454 &result, &capabilities)); |
473 EXPECT_TRUE(result); | 455 EXPECT_TRUE(result); |
474 } | 456 } |
475 EXPECT_TRUE(channel->LookupCommandBuffer(kSharedRouteId)); | 457 EXPECT_TRUE(channel->LookupCommandBuffer(kSharedRouteId)); |
476 | 458 |
477 // This context shares with the first one, this should be possible. | 459 // This context shares with the first one, this should be possible. |
478 int32_t kFriendlyRouteId = 2; | 460 int32_t kFriendlyRouteId = 2; |
479 { | 461 { |
480 SCOPED_TRACE("kFriendlyRouteId"); | 462 SCOPED_TRACE("kFriendlyRouteId"); |
481 GPUCreateCommandBufferConfig init_params; | 463 GPUCreateCommandBufferConfig init_params; |
482 init_params.surface_handle = kNullSurfaceHandle; | 464 init_params.surface_handle = kNullSurfaceHandle; |
483 init_params.size = gfx::Size(1, 1); | |
484 init_params.share_group_id = kSharedRouteId; | 465 init_params.share_group_id = kSharedRouteId; |
485 init_params.stream_id = 0; | 466 init_params.stream_id = 0; |
486 init_params.stream_priority = GpuStreamPriority::NORMAL; | 467 init_params.stream_priority = GpuStreamPriority::NORMAL; |
487 init_params.attribs = gles2::ContextCreationAttribHelper(); | 468 init_params.attribs = gles2::ContextCreationAttribHelper(); |
488 init_params.active_url = GURL(); | 469 init_params.active_url = GURL(); |
489 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
490 bool result = false; | 470 bool result = false; |
491 gpu::Capabilities capabilities; | 471 gpu::Capabilities capabilities; |
492 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 472 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
493 init_params, kFriendlyRouteId, GetSharedHandle(), | 473 init_params, kFriendlyRouteId, GetSharedHandle(), |
494 &result, &capabilities)); | 474 &result, &capabilities)); |
495 EXPECT_TRUE(result); | 475 EXPECT_TRUE(result); |
496 } | 476 } |
497 EXPECT_TRUE(channel->LookupCommandBuffer(kFriendlyRouteId)); | 477 EXPECT_TRUE(channel->LookupCommandBuffer(kFriendlyRouteId)); |
498 | 478 |
499 // The shared context is lost. | 479 // The shared context is lost. |
500 channel->LookupCommandBuffer(kSharedRouteId)->MarkContextLost(); | 480 channel->LookupCommandBuffer(kSharedRouteId)->MarkContextLost(); |
501 | 481 |
502 // Meanwhile another context is being made pointing to the shared one. This | 482 // Meanwhile another context is being made pointing to the shared one. This |
503 // should fail. | 483 // should fail. |
504 int32_t kAnotherRouteId = 3; | 484 int32_t kAnotherRouteId = 3; |
505 { | 485 { |
506 SCOPED_TRACE("kAnotherRouteId"); | 486 SCOPED_TRACE("kAnotherRouteId"); |
507 GPUCreateCommandBufferConfig init_params; | 487 GPUCreateCommandBufferConfig init_params; |
508 init_params.surface_handle = kNullSurfaceHandle; | 488 init_params.surface_handle = kNullSurfaceHandle; |
509 init_params.size = gfx::Size(1, 1); | |
510 init_params.share_group_id = kSharedRouteId; | 489 init_params.share_group_id = kSharedRouteId; |
511 init_params.stream_id = 0; | 490 init_params.stream_id = 0; |
512 init_params.stream_priority = GpuStreamPriority::NORMAL; | 491 init_params.stream_priority = GpuStreamPriority::NORMAL; |
513 init_params.attribs = gles2::ContextCreationAttribHelper(); | 492 init_params.attribs = gles2::ContextCreationAttribHelper(); |
514 init_params.active_url = GURL(); | 493 init_params.active_url = GURL(); |
515 init_params.gpu_preference = gl::PreferIntegratedGpu; | |
516 bool result = false; | 494 bool result = false; |
517 gpu::Capabilities capabilities; | 495 gpu::Capabilities capabilities; |
518 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( | 496 HandleMessage(channel, new GpuChannelMsg_CreateCommandBuffer( |
519 init_params, kAnotherRouteId, GetSharedHandle(), | 497 init_params, kAnotherRouteId, GetSharedHandle(), |
520 &result, &capabilities)); | 498 &result, &capabilities)); |
521 EXPECT_FALSE(result); | 499 EXPECT_FALSE(result); |
522 } | 500 } |
523 EXPECT_FALSE(channel->LookupCommandBuffer(kAnotherRouteId)); | 501 EXPECT_FALSE(channel->LookupCommandBuffer(kAnotherRouteId)); |
524 | 502 |
525 // The lost context is still around though (to verify the failure happened due | 503 // The lost context is still around though (to verify the failure happened due |
526 // to the shared context being lost, not due to it being deleted). | 504 // to the shared context being lost, not due to it being deleted). |
527 EXPECT_TRUE(channel->LookupCommandBuffer(kSharedRouteId)); | 505 EXPECT_TRUE(channel->LookupCommandBuffer(kSharedRouteId)); |
528 | 506 |
529 // Destroy the command buffers we initialized before destoying GL. | 507 // Destroy the command buffers we initialized before destoying GL. |
530 HandleMessage(channel, | 508 HandleMessage(channel, |
531 new GpuChannelMsg_DestroyCommandBuffer(kFriendlyRouteId)); | 509 new GpuChannelMsg_DestroyCommandBuffer(kFriendlyRouteId)); |
532 HandleMessage(channel, | 510 HandleMessage(channel, |
533 new GpuChannelMsg_DestroyCommandBuffer(kSharedRouteId)); | 511 new GpuChannelMsg_DestroyCommandBuffer(kSharedRouteId)); |
534 } | 512 } |
535 | 513 |
536 } // namespace gpu | 514 } // namespace gpu |
OLD | NEW |