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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 11428140: gpu: Add async pixel transfer interface, stub and tests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Fix lint. Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 1c0ec4e0dc1ee2d2c4f261cf1bddc7aef81eef24..a875f675f427fd1f374f7a4500ff16fc88f3ebf3 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -8,6 +8,7 @@
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/common/id_allocator.h"
+#include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gl_surface_mock.h"
@@ -7935,6 +7936,125 @@ TEST_F(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
}
+TEST_F(GLES2DecoderManualInitTest, AsyncPixelsTransfers) {
+ InitDecoder(
+ "GL_CHROMIUM_async_pixel_transfers", // extensions
+ false, false, false, // has alpha/depth/stencil
+ false, false, false, // request alpha/depth/stencil
+ true); // bind generates resource
+
+ // Set up the texture.
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_);
+
+ // Set a mock AsyncPixelTransferDelegate
+ StrictMock<gfx::MockAsyncPixelTransferDelegate>* delegate =
+ new StrictMock<gfx::MockAsyncPixelTransferDelegate>;
+ decoder_->SetAsyncPixelTransferDelegate(delegate);
+
+ // Set a default mock AsyncPixelTransferState
+ scoped_refptr<StrictMock<gfx::MockAsyncPixelTransferState> > state =
+ new StrictMock<gfx::MockAsyncPixelTransferState>;
+ testing::DefaultValue<
+ scoped_refptr<gfx::AsyncPixelTransferState> >::Set(state);
+
+ // Tex(Sub)Image2D upload commands.
+ AsyncTexImage2DCHROMIUM texImagecmd;
greggman 2012/12/12 03:51:36 style: variables are under_score
epennerAtGoogle 2012/12/12 04:49:49 Done.
+ texImagecmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset);
+ AsyncTexSubImage2DCHROMIUM texSubImagecmd;
greggman 2012/12/12 03:51:36 style: variables are under_score
epennerAtGoogle 2012/12/12 04:49:49 Done.
+ texSubImagecmd.Init(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGBA,
+ GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset);
+
+ // No transfer state exists initially.
+ EXPECT_FALSE(info->GetAsyncTransferState());
+
+ // AsyncTexImage2D
+ {
+ // Create transfer state since it doesn't exist.
+ EXPECT_CALL(*delegate, CreatePixelTransferState(kServiceTextureId))
+ .WillOnce(Return(state))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*delegate, AsyncTexImage2D(state.get(), _, _))
+ .RetiresOnSaturation();
+ // Command succeeds.
+ EXPECT_EQ(error::kNoError, ExecuteCmd(texImagecmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_TRUE(info->GetAsyncTransferState());
+ EXPECT_TRUE(info->IsImmutable());
+ EXPECT_TRUE(info->SafeToRenderFrom());
+ }
+ {
+ // Async redefinitions are not allowed!
+ // Command fails.
+ EXPECT_EQ(error::kNoError, ExecuteCmd(texImagecmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+ EXPECT_TRUE(info->GetAsyncTransferState());
+ EXPECT_TRUE(info->IsImmutable());
+ EXPECT_TRUE(info->SafeToRenderFrom());
+ }
+
+ // AsyncTexSubImage2D
+ info->SetAsyncTransferState(NULL);
+ info->SetImmutable(false);
+ {
+ // Create transfer state since it doesn't exist.
+ EXPECT_CALL(*delegate, CreatePixelTransferState(kServiceTextureId))
+ .WillOnce(Return(state))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*delegate, AsyncTexSubImage2D(state.get(), _, _))
+ .RetiresOnSaturation();
+ // Command succeeds.
+ EXPECT_EQ(error::kNoError, ExecuteCmd(texSubImagecmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_TRUE(info->GetAsyncTransferState());
+ EXPECT_TRUE(info->IsImmutable());
+ EXPECT_TRUE(info->SafeToRenderFrom());
+ }
+ {
+ // No transfer is in progress.
+ EXPECT_CALL(*state.get(), TransferIsInProgress())
+ .WillOnce(Return(false))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*delegate, AsyncTexSubImage2D(state.get(), _, _))
+ .RetiresOnSaturation();
+ // Command succeeds.
+ EXPECT_EQ(error::kNoError, ExecuteCmd(texSubImagecmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_TRUE(info->GetAsyncTransferState());
+ EXPECT_TRUE(info->IsImmutable());
+ EXPECT_TRUE(info->SafeToRenderFrom());
+ }
+ {
+ // A transfer is still in progress!
+ EXPECT_CALL(*state.get(), TransferIsInProgress())
+ .WillOnce(Return(true))
+ .RetiresOnSaturation();
+ // No async call, command fails.
+ EXPECT_EQ(error::kNoError, ExecuteCmd(texSubImagecmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+ EXPECT_TRUE(info->GetAsyncTransferState());
+ EXPECT_TRUE(info->IsImmutable());
+ EXPECT_TRUE(info->SafeToRenderFrom());
+ }
+
+ // Lazy binding of the async transfer
+ {
+ // We should get a real glBindTexture, followed by
+ // a lazy bind call on the async state.
+ testing::InSequence dummy;
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId));
+ EXPECT_CALL(*state.get(), BindAsyncTransferToTexture(GL_TEXTURE_2D));
+
+ BindTexture bindCmd;
greggman 2012/12/12 03:51:36 style: variables are under_score
epennerAtGoogle 2012/12/12 04:49:49 Done.
+ bindCmd.Init(GL_TEXTURE_2D, client_texture_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(bindCmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ EXPECT_TRUE(info->SafeToRenderFrom());
+ }
+}
+
+
// TODO(gman): Complete this test.
// TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) {
// }

Powered by Google App Engine
This is Rietveld 408576698