OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 8205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8216 // Set a mock Async delegate | 8216 // Set a mock Async delegate |
8217 StrictMock<gpu::MockAsyncPixelTransferManager>* manager = | 8217 StrictMock<gpu::MockAsyncPixelTransferManager>* manager = |
8218 new StrictMock<gpu::MockAsyncPixelTransferManager>; | 8218 new StrictMock<gpu::MockAsyncPixelTransferManager>; |
8219 manager->Initialize(group().texture_manager()); | 8219 manager->Initialize(group().texture_manager()); |
8220 decoder_->SetAsyncPixelTransferManagerForTest(manager); | 8220 decoder_->SetAsyncPixelTransferManagerForTest(manager); |
8221 StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate = NULL; | 8221 StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate = NULL; |
8222 | 8222 |
8223 // Tex(Sub)Image2D upload commands. | 8223 // Tex(Sub)Image2D upload commands. |
8224 AsyncTexImage2DCHROMIUM teximage_cmd; | 8224 AsyncTexImage2DCHROMIUM teximage_cmd; |
8225 teximage_cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, | 8225 teximage_cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, |
8226 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); | 8226 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, |
| 8227 0, 0, 0); |
8227 AsyncTexSubImage2DCHROMIUM texsubimage_cmd; | 8228 AsyncTexSubImage2DCHROMIUM texsubimage_cmd; |
8228 texsubimage_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGBA, | 8229 texsubimage_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGBA, |
8229 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); | 8230 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, |
| 8231 0, 0, 0); |
8230 WaitAsyncTexImage2DCHROMIUM wait_cmd; | 8232 WaitAsyncTexImage2DCHROMIUM wait_cmd; |
8231 wait_cmd.Init(GL_TEXTURE_2D); | 8233 wait_cmd.Init(GL_TEXTURE_2D); |
| 8234 WaitAllAsyncTexImage2DCHROMIUM wait_all_cmd; |
| 8235 wait_all_cmd.Init(); |
8232 | 8236 |
8233 // No transfer state exists initially. | 8237 // No transfer state exists initially. |
8234 EXPECT_FALSE( | 8238 EXPECT_FALSE( |
8235 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | 8239 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( |
8236 texture_ref)); | 8240 texture_ref)); |
8237 | 8241 |
8238 base::Closure bind_callback; | 8242 base::Closure bind_callback; |
8239 | 8243 |
8240 // AsyncTexImage2D | 8244 // AsyncTexImage2D |
8241 { | 8245 { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8347 EXPECT_TRUE(texture->SafeToRenderFrom()); | 8351 EXPECT_TRUE(texture->SafeToRenderFrom()); |
8348 } | 8352 } |
8349 | 8353 |
8350 // Delete delegate on DeleteTexture. | 8354 // Delete delegate on DeleteTexture. |
8351 { | 8355 { |
8352 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); | 8356 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); |
8353 DoDeleteTexture(client_texture_id_, kServiceTextureId); | 8357 DoDeleteTexture(client_texture_id_, kServiceTextureId); |
8354 EXPECT_FALSE( | 8358 EXPECT_FALSE( |
8355 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | 8359 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( |
8356 texture_ref)); | 8360 texture_ref)); |
| 8361 texture = NULL; |
| 8362 texture_ref = NULL; |
8357 delegate = NULL; | 8363 delegate = NULL; |
8358 } | 8364 } |
8359 | 8365 |
8360 // WaitAsyncTexImage2D | 8366 // WaitAsyncTexImage2D |
8361 { | 8367 { |
8362 // Get a fresh texture since the existing texture cannot be respecified | 8368 // Get a fresh texture since the existing texture cannot be respecified |
8363 // asynchronously and AsyncTexSubImage2D does not involved binding. | 8369 // asynchronously and AsyncTexSubImage2D does not involve binding. |
8364 EXPECT_CALL(*gl_, GenTextures(1, _)) | 8370 EXPECT_CALL(*gl_, GenTextures(1, _)) |
8365 .WillOnce(SetArgumentPointee<1>(kServiceTextureId)); | 8371 .WillOnce(SetArgumentPointee<1>(kServiceTextureId)); |
8366 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 8372 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
8367 texture_ref = GetTexture(client_texture_id_); | 8373 texture_ref = GetTexture(client_texture_id_); |
8368 texture = texture_ref->texture(); | 8374 texture = texture_ref->texture(); |
8369 texture->SetImmutable(false); | 8375 texture->SetImmutable(false); |
8370 // Create transfer state since it doesn't exist. | 8376 // Create transfer state since it doesn't exist. |
8371 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | 8377 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) |
8372 .WillOnce(Return( | 8378 .WillOnce(Return( |
8373 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) | 8379 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) |
8374 .RetiresOnSaturation(); | 8380 .RetiresOnSaturation(); |
8375 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) | 8381 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) |
8376 .RetiresOnSaturation(); | 8382 .RetiresOnSaturation(); |
8377 // Start async transfer. | 8383 // Start async transfer. |
8378 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); | 8384 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); |
8379 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 8385 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
8380 EXPECT_EQ( | 8386 EXPECT_EQ( |
8381 delegate, | 8387 delegate, |
8382 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | 8388 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( |
8383 texture_ref)); | 8389 texture_ref)); |
8384 | 8390 |
8385 EXPECT_TRUE(texture->IsImmutable()); | 8391 EXPECT_TRUE(texture->IsImmutable()); |
8386 // Wait for completion. | 8392 // Wait for completion. |
8387 EXPECT_CALL(*delegate, WaitForTransferCompletion()); | 8393 EXPECT_CALL(*delegate, WaitForTransferCompletion()); |
8388 EXPECT_CALL(*manager, BindCompletedAsyncTransfers()); | 8394 EXPECT_CALL(*manager, BindCompletedAsyncTransfers()); |
8389 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_cmd)); | 8395 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_cmd)); |
8390 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 8396 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
8391 } | 8397 } |
| 8398 |
| 8399 // WaitAllAsyncTexImage2D |
| 8400 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); |
| 8401 DoDeleteTexture(client_texture_id_, kServiceTextureId); |
| 8402 EXPECT_FALSE( |
| 8403 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( |
| 8404 texture_ref)); |
| 8405 texture = NULL; |
| 8406 texture_ref = NULL; |
| 8407 delegate = NULL; |
| 8408 { |
| 8409 // Get a fresh texture since the existing texture cannot be respecified |
| 8410 // asynchronously and AsyncTexSubImage2D does not involve binding. |
| 8411 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 8412 .WillOnce(SetArgumentPointee<1>(kServiceTextureId)); |
| 8413 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 8414 texture_ref = GetTexture(client_texture_id_); |
| 8415 texture = texture_ref->texture(); |
| 8416 texture->SetImmutable(false); |
| 8417 // Create transfer state since it doesn't exist. |
| 8418 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) |
| 8419 .WillOnce(Return( |
| 8420 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) |
| 8421 .RetiresOnSaturation(); |
| 8422 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) |
| 8423 .RetiresOnSaturation(); |
| 8424 // Start async transfer. |
| 8425 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); |
| 8426 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8427 EXPECT_EQ( |
| 8428 delegate, |
| 8429 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( |
| 8430 texture_ref)); |
| 8431 |
| 8432 EXPECT_TRUE(texture->IsImmutable()); |
| 8433 // Wait for completion of all uploads. |
| 8434 EXPECT_CALL(*manager, WaitAllAsyncTexImage2D()).RetiresOnSaturation(); |
| 8435 EXPECT_CALL(*manager, BindCompletedAsyncTransfers()); |
| 8436 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_all_cmd)); |
| 8437 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8438 } |
8392 } | 8439 } |
8393 | 8440 |
8394 TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransferManager) { | 8441 TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransferManager) { |
8395 InitDecoder( | 8442 InitDecoder( |
8396 "GL_CHROMIUM_async_pixel_transfers", // extensions | 8443 "GL_CHROMIUM_async_pixel_transfers", // extensions |
8397 "3.0", // gl version | 8444 "3.0", // gl version |
8398 false, false, false, // has alpha/depth/stencil | 8445 false, false, false, // has alpha/depth/stencil |
8399 false, false, false, // request alpha/depth/stencil | 8446 false, false, false, // request alpha/depth/stencil |
8400 true); // bind generates resource | 8447 true); // bind generates resource |
8401 | 8448 |
8402 // Set up the texture. | 8449 // Set up the texture. |
8403 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 8450 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
8404 TextureRef* texture_ref = GetTexture(client_texture_id_); | 8451 TextureRef* texture_ref = GetTexture(client_texture_id_); |
8405 | 8452 |
8406 // Set a mock Async delegate. | 8453 // Set a mock Async delegate. |
8407 StrictMock<gpu::MockAsyncPixelTransferManager>* manager = | 8454 StrictMock<gpu::MockAsyncPixelTransferManager>* manager = |
8408 new StrictMock<gpu::MockAsyncPixelTransferManager>; | 8455 new StrictMock<gpu::MockAsyncPixelTransferManager>; |
8409 manager->Initialize(group().texture_manager()); | 8456 manager->Initialize(group().texture_manager()); |
8410 decoder_->SetAsyncPixelTransferManagerForTest(manager); | 8457 decoder_->SetAsyncPixelTransferManagerForTest(manager); |
8411 StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate = NULL; | 8458 StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate = NULL; |
8412 | 8459 |
8413 AsyncTexImage2DCHROMIUM teximage_cmd; | 8460 AsyncTexImage2DCHROMIUM teximage_cmd; |
8414 teximage_cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, | 8461 teximage_cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, |
8415 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); | 8462 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, |
| 8463 0, 0, 0); |
8416 | 8464 |
8417 // No transfer delegate exists initially. | 8465 // No transfer delegate exists initially. |
8418 EXPECT_FALSE( | 8466 EXPECT_FALSE( |
8419 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | 8467 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( |
8420 texture_ref)); | 8468 texture_ref)); |
8421 | 8469 |
8422 // Create delegate on AsyncTexImage2D. | 8470 // Create delegate on AsyncTexImage2D. |
8423 { | 8471 { |
8424 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | 8472 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) |
8425 .WillOnce(Return( | 8473 .WillOnce(Return( |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9233 // TODO(gman): TexImage2DImmediate | 9281 // TODO(gman): TexImage2DImmediate |
9234 | 9282 |
9235 // TODO(gman): TexSubImage2DImmediate | 9283 // TODO(gman): TexSubImage2DImmediate |
9236 | 9284 |
9237 // TODO(gman): UseProgram | 9285 // TODO(gman): UseProgram |
9238 | 9286 |
9239 // TODO(gman): SwapBuffers | 9287 // TODO(gman): SwapBuffers |
9240 | 9288 |
9241 } // namespace gles2 | 9289 } // namespace gles2 |
9242 } // namespace gpu | 9290 } // namespace gpu |
OLD | NEW |