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

Side by Side 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 unified diff | Download patch
OLDNEW
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/atomicops.h" 7 #include "base/atomicops.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" 8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/common/id_allocator.h" 10 #include "gpu/command_buffer/common/id_allocator.h"
11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
11 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 12 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
12 #include "gpu/command_buffer/service/context_group.h" 13 #include "gpu/command_buffer/service/context_group.h"
13 #include "gpu/command_buffer/service/gl_surface_mock.h" 14 #include "gpu/command_buffer/service/gl_surface_mock.h"
14 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" 15 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
15 #include "gpu/command_buffer/service/image_manager.h" 16 #include "gpu/command_buffer/service/image_manager.h"
16 #include "gpu/command_buffer/service/mailbox_manager.h" 17 #include "gpu/command_buffer/service/mailbox_manager.h"
17 #include "gpu/command_buffer/service/program_manager.h" 18 #include "gpu/command_buffer/service/program_manager.h"
18 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" 19 #include "gpu/command_buffer/service/stream_texture_manager_mock.h"
19 #include "gpu/command_buffer/service/stream_texture_mock.h" 20 #include "gpu/command_buffer/service/stream_texture_mock.h"
20 #include "gpu/command_buffer/service/test_helper.h" 21 #include "gpu/command_buffer/service/test_helper.h"
(...skipping 7907 matching lines...) Expand 10 before | Expand all | Expand 10 after
7928 7929
7929 // Release image from texture. 7930 // Release image from texture.
7930 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; 7931 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd;
7931 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); 7932 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1);
7932 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); 7933 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd));
7933 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); 7934 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7934 // Image should no longer be set. 7935 // Image should no longer be set.
7935 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 7936 EXPECT_TRUE(info->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
7936 } 7937 }
7937 7938
7939 TEST_F(GLES2DecoderManualInitTest, AsyncPixelsTransfers) {
7940 InitDecoder(
7941 "GL_CHROMIUM_async_pixel_transfers", // extensions
7942 false, false, false, // has alpha/depth/stencil
7943 false, false, false, // request alpha/depth/stencil
7944 true); // bind generates resource
7945
7946 // Set up the texture.
7947 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
7948 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_);
7949
7950 // Set a mock AsyncPixelTransferDelegate
7951 StrictMock<gfx::MockAsyncPixelTransferDelegate>* delegate =
7952 new StrictMock<gfx::MockAsyncPixelTransferDelegate>;
7953 decoder_->SetAsyncPixelTransferDelegate(delegate);
7954
7955 // Set a default mock AsyncPixelTransferState
7956 scoped_refptr<StrictMock<gfx::MockAsyncPixelTransferState> > state =
7957 new StrictMock<gfx::MockAsyncPixelTransferState>;
7958 testing::DefaultValue<
7959 scoped_refptr<gfx::AsyncPixelTransferState> >::Set(state);
7960
7961 // Tex(Sub)Image2D upload commands.
7962 AsyncTexImage2DCHROMIUM texImagecmd;
greggman 2012/12/12 03:51:36 style: variables are under_score
epennerAtGoogle 2012/12/12 04:49:49 Done.
7963 texImagecmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA,
7964 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset);
7965 AsyncTexSubImage2DCHROMIUM texSubImagecmd;
greggman 2012/12/12 03:51:36 style: variables are under_score
epennerAtGoogle 2012/12/12 04:49:49 Done.
7966 texSubImagecmd.Init(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGBA,
7967 GL_UNSIGNED_BYTE, kSharedMemoryId, kSharedMemoryOffset);
7968
7969 // No transfer state exists initially.
7970 EXPECT_FALSE(info->GetAsyncTransferState());
7971
7972 // AsyncTexImage2D
7973 {
7974 // Create transfer state since it doesn't exist.
7975 EXPECT_CALL(*delegate, CreatePixelTransferState(kServiceTextureId))
7976 .WillOnce(Return(state))
7977 .RetiresOnSaturation();
7978 EXPECT_CALL(*delegate, AsyncTexImage2D(state.get(), _, _))
7979 .RetiresOnSaturation();
7980 // Command succeeds.
7981 EXPECT_EQ(error::kNoError, ExecuteCmd(texImagecmd));
7982 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7983 EXPECT_TRUE(info->GetAsyncTransferState());
7984 EXPECT_TRUE(info->IsImmutable());
7985 EXPECT_TRUE(info->SafeToRenderFrom());
7986 }
7987 {
7988 // Async redefinitions are not allowed!
7989 // Command fails.
7990 EXPECT_EQ(error::kNoError, ExecuteCmd(texImagecmd));
7991 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7992 EXPECT_TRUE(info->GetAsyncTransferState());
7993 EXPECT_TRUE(info->IsImmutable());
7994 EXPECT_TRUE(info->SafeToRenderFrom());
7995 }
7996
7997 // AsyncTexSubImage2D
7998 info->SetAsyncTransferState(NULL);
7999 info->SetImmutable(false);
8000 {
8001 // Create transfer state since it doesn't exist.
8002 EXPECT_CALL(*delegate, CreatePixelTransferState(kServiceTextureId))
8003 .WillOnce(Return(state))
8004 .RetiresOnSaturation();
8005 EXPECT_CALL(*delegate, AsyncTexSubImage2D(state.get(), _, _))
8006 .RetiresOnSaturation();
8007 // Command succeeds.
8008 EXPECT_EQ(error::kNoError, ExecuteCmd(texSubImagecmd));
8009 EXPECT_EQ(GL_NO_ERROR, GetGLError());
8010 EXPECT_TRUE(info->GetAsyncTransferState());
8011 EXPECT_TRUE(info->IsImmutable());
8012 EXPECT_TRUE(info->SafeToRenderFrom());
8013 }
8014 {
8015 // No transfer is in progress.
8016 EXPECT_CALL(*state.get(), TransferIsInProgress())
8017 .WillOnce(Return(false))
8018 .RetiresOnSaturation();
8019 EXPECT_CALL(*delegate, AsyncTexSubImage2D(state.get(), _, _))
8020 .RetiresOnSaturation();
8021 // Command succeeds.
8022 EXPECT_EQ(error::kNoError, ExecuteCmd(texSubImagecmd));
8023 EXPECT_EQ(GL_NO_ERROR, GetGLError());
8024 EXPECT_TRUE(info->GetAsyncTransferState());
8025 EXPECT_TRUE(info->IsImmutable());
8026 EXPECT_TRUE(info->SafeToRenderFrom());
8027 }
8028 {
8029 // A transfer is still in progress!
8030 EXPECT_CALL(*state.get(), TransferIsInProgress())
8031 .WillOnce(Return(true))
8032 .RetiresOnSaturation();
8033 // No async call, command fails.
8034 EXPECT_EQ(error::kNoError, ExecuteCmd(texSubImagecmd));
8035 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
8036 EXPECT_TRUE(info->GetAsyncTransferState());
8037 EXPECT_TRUE(info->IsImmutable());
8038 EXPECT_TRUE(info->SafeToRenderFrom());
8039 }
8040
8041 // Lazy binding of the async transfer
8042 {
8043 // We should get a real glBindTexture, followed by
8044 // a lazy bind call on the async state.
8045 testing::InSequence dummy;
8046 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId));
8047 EXPECT_CALL(*state.get(), BindAsyncTransferToTexture(GL_TEXTURE_2D));
8048
8049 BindTexture bindCmd;
greggman 2012/12/12 03:51:36 style: variables are under_score
epennerAtGoogle 2012/12/12 04:49:49 Done.
8050 bindCmd.Init(GL_TEXTURE_2D, client_texture_id_);
8051 EXPECT_EQ(error::kNoError, ExecuteCmd(bindCmd));
8052 EXPECT_EQ(GL_NO_ERROR, GetGLError());
8053 EXPECT_TRUE(info->SafeToRenderFrom());
8054 }
8055 }
8056
8057
7938 // TODO(gman): Complete this test. 8058 // TODO(gman): Complete this test.
7939 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { 8059 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) {
7940 // } 8060 // }
7941 8061
7942 // TODO(gman): BufferData 8062 // TODO(gman): BufferData
7943 8063
7944 // TODO(gman): BufferDataImmediate 8064 // TODO(gman): BufferDataImmediate
7945 8065
7946 // TODO(gman): BufferSubData 8066 // TODO(gman): BufferSubData
7947 8067
(...skipping 16 matching lines...) Expand all
7964 // TODO(gman): TexImage2DImmediate 8084 // TODO(gman): TexImage2DImmediate
7965 8085
7966 // TODO(gman): TexSubImage2DImmediate 8086 // TODO(gman): TexSubImage2DImmediate
7967 8087
7968 // TODO(gman): UseProgram 8088 // TODO(gman): UseProgram
7969 8089
7970 // TODO(gman): SwapBuffers 8090 // TODO(gman): SwapBuffers
7971 8091
7972 } // namespace gles2 8092 } // namespace gles2
7973 } // namespace gpu 8093 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698