Chromium Code Reviews| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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)); |
| 8357 delegate = NULL; | 8361 delegate = NULL; |
| 8358 } | 8362 } |
| 8359 | 8363 |
| 8360 // WaitAsyncTexImage2D | 8364 // WaitAsyncTexImage2D |
| 8361 { | 8365 { |
| 8362 // Get a fresh texture since the existing texture cannot be respecified | 8366 // Get a fresh texture since the existing texture cannot be respecified |
| 8363 // asynchronously and AsyncTexSubImage2D does not involved binding. | 8367 // asynchronously and AsyncTexSubImage2D does not involve binding. |
| 8364 EXPECT_CALL(*gl_, GenTextures(1, _)) | 8368 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 8365 .WillOnce(SetArgumentPointee<1>(kServiceTextureId)); | 8369 .WillOnce(SetArgumentPointee<1>(kServiceTextureId)); |
| 8366 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 8370 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 8367 texture_ref = GetTexture(client_texture_id_); | 8371 texture_ref = GetTexture(client_texture_id_); |
| 8368 texture = texture_ref->texture(); | 8372 texture = texture_ref->texture(); |
| 8369 texture->SetImmutable(false); | 8373 texture->SetImmutable(false); |
| 8370 // Create transfer state since it doesn't exist. | 8374 // Create transfer state since it doesn't exist. |
| 8371 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | 8375 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) |
| 8372 .WillOnce(Return( | 8376 .WillOnce(Return( |
| 8373 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) | 8377 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) |
| 8374 .RetiresOnSaturation(); | 8378 .RetiresOnSaturation(); |
| 8375 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) | 8379 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) |
| 8376 .RetiresOnSaturation(); | 8380 .RetiresOnSaturation(); |
| 8377 // Start async transfer. | 8381 // Start async transfer. |
| 8378 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); | 8382 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); |
| 8379 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 8383 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8380 EXPECT_EQ( | 8384 EXPECT_EQ( |
| 8381 delegate, | 8385 delegate, |
| 8382 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | 8386 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( |
| 8383 texture_ref)); | 8387 texture_ref)); |
| 8384 | 8388 |
| 8385 EXPECT_TRUE(texture->IsImmutable()); | 8389 EXPECT_TRUE(texture->IsImmutable()); |
| 8386 // Wait for completion. | 8390 // Wait for completion. |
| 8387 EXPECT_CALL(*delegate, WaitForTransferCompletion()); | 8391 EXPECT_CALL(*delegate, WaitForTransferCompletion()); |
| 8388 EXPECT_CALL(*manager, BindCompletedAsyncTransfers()); | 8392 EXPECT_CALL(*manager, BindCompletedAsyncTransfers()); |
| 8389 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_cmd)); | 8393 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_cmd)); |
| 8390 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 8394 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 8391 } | 8395 } |
| 8396 | |
| 8397 // WaitAllAsyncTexImage2D | |
| 8398 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); | |
| 8399 DoDeleteTexture(client_texture_id_, kServiceTextureId); | |
| 8400 EXPECT_FALSE( | |
| 8401 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8402 texture_ref)); | |
|
piman
2014/03/28 20:04:35
nit: actually, texture_ref should probably be a sc
jadahl
2014/03/28 20:11:38
Do you want that change in this patch? It'll chang
piman
2014/03/28 20:22:49
Either that or add a comment to indicate that text
jadahl
2014/03/28 20:25:00
Tests also assume no reference is held, and fail b
| |
| 8403 delegate = NULL; | |
| 8404 { | |
| 8405 // Get a fresh texture since the existing texture cannot be respecified | |
| 8406 // asynchronously and AsyncTexSubImage2D does not involve binding. | |
| 8407 EXPECT_CALL(*gl_, GenTextures(1, _)) | |
| 8408 .WillOnce(SetArgumentPointee<1>(kServiceTextureId)); | |
| 8409 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 8410 texture_ref = GetTexture(client_texture_id_); | |
| 8411 texture = texture_ref->texture(); | |
| 8412 texture->SetImmutable(false); | |
| 8413 // Create transfer state since it doesn't exist. | |
| 8414 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | |
| 8415 .WillOnce(Return( | |
| 8416 delegate = new StrictMock<gpu::MockAsyncPixelTransferDelegate>)) | |
| 8417 .RetiresOnSaturation(); | |
| 8418 EXPECT_CALL(*delegate, AsyncTexImage2D(_, _, _)) | |
| 8419 .RetiresOnSaturation(); | |
| 8420 // Start async transfer. | |
| 8421 EXPECT_EQ(error::kNoError, ExecuteCmd(teximage_cmd)); | |
| 8422 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8423 EXPECT_EQ( | |
| 8424 delegate, | |
| 8425 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | |
| 8426 texture_ref)); | |
| 8427 | |
| 8428 EXPECT_TRUE(texture->IsImmutable()); | |
| 8429 // Wait for completion of all uploads. | |
| 8430 EXPECT_CALL(*manager, WaitAllAsyncTexImage2D()).RetiresOnSaturation(); | |
| 8431 EXPECT_CALL(*manager, BindCompletedAsyncTransfers()); | |
| 8432 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_all_cmd)); | |
| 8433 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 8434 } | |
| 8392 } | 8435 } |
| 8393 | 8436 |
| 8394 TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransferManager) { | 8437 TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransferManager) { |
| 8395 InitDecoder( | 8438 InitDecoder( |
| 8396 "GL_CHROMIUM_async_pixel_transfers", // extensions | 8439 "GL_CHROMIUM_async_pixel_transfers", // extensions |
| 8397 "3.0", // gl version | 8440 "3.0", // gl version |
| 8398 false, false, false, // has alpha/depth/stencil | 8441 false, false, false, // has alpha/depth/stencil |
| 8399 false, false, false, // request alpha/depth/stencil | 8442 false, false, false, // request alpha/depth/stencil |
| 8400 true); // bind generates resource | 8443 true); // bind generates resource |
| 8401 | 8444 |
| 8402 // Set up the texture. | 8445 // Set up the texture. |
| 8403 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 8446 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 8404 TextureRef* texture_ref = GetTexture(client_texture_id_); | 8447 TextureRef* texture_ref = GetTexture(client_texture_id_); |
| 8405 | 8448 |
| 8406 // Set a mock Async delegate. | 8449 // Set a mock Async delegate. |
| 8407 StrictMock<gpu::MockAsyncPixelTransferManager>* manager = | 8450 StrictMock<gpu::MockAsyncPixelTransferManager>* manager = |
| 8408 new StrictMock<gpu::MockAsyncPixelTransferManager>; | 8451 new StrictMock<gpu::MockAsyncPixelTransferManager>; |
| 8409 manager->Initialize(group().texture_manager()); | 8452 manager->Initialize(group().texture_manager()); |
| 8410 decoder_->SetAsyncPixelTransferManagerForTest(manager); | 8453 decoder_->SetAsyncPixelTransferManagerForTest(manager); |
| 8411 StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate = NULL; | 8454 StrictMock<gpu::MockAsyncPixelTransferDelegate>* delegate = NULL; |
| 8412 | 8455 |
| 8413 AsyncTexImage2DCHROMIUM teximage_cmd; | 8456 AsyncTexImage2DCHROMIUM teximage_cmd; |
| 8414 teximage_cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, | 8457 teximage_cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, |
| 8415 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset); | 8458 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset, |
| 8459 0, 0, 0); | |
| 8416 | 8460 |
| 8417 // No transfer delegate exists initially. | 8461 // No transfer delegate exists initially. |
| 8418 EXPECT_FALSE( | 8462 EXPECT_FALSE( |
| 8419 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( | 8463 decoder_->GetAsyncPixelTransferManager()->GetPixelTransferDelegate( |
| 8420 texture_ref)); | 8464 texture_ref)); |
| 8421 | 8465 |
| 8422 // Create delegate on AsyncTexImage2D. | 8466 // Create delegate on AsyncTexImage2D. |
| 8423 { | 8467 { |
| 8424 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) | 8468 EXPECT_CALL(*manager, CreatePixelTransferDelegateImpl(texture_ref, _)) |
| 8425 .WillOnce(Return( | 8469 .WillOnce(Return( |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9233 // TODO(gman): TexImage2DImmediate | 9277 // TODO(gman): TexImage2DImmediate |
| 9234 | 9278 |
| 9235 // TODO(gman): TexSubImage2DImmediate | 9279 // TODO(gman): TexSubImage2DImmediate |
| 9236 | 9280 |
| 9237 // TODO(gman): UseProgram | 9281 // TODO(gman): UseProgram |
| 9238 | 9282 |
| 9239 // TODO(gman): SwapBuffers | 9283 // TODO(gman): SwapBuffers |
| 9240 | 9284 |
| 9241 } // namespace gles2 | 9285 } // namespace gles2 |
| 9242 } // namespace gpu | 9286 } // namespace gpu |
| OLD | NEW |