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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 14188053: gpu: Change Produce/ConsumeTexture to allow texture sharing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months 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 | Annotate | Revision Log
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"
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 kServiceRenderbufferId)) 2080 kServiceRenderbufferId))
2081 .Times(1) 2081 .Times(1)
2082 .RetiresOnSaturation(); 2082 .RetiresOnSaturation();
2083 EXPECT_CALL(*gl_, GetError()) 2083 EXPECT_CALL(*gl_, GetError())
2084 .WillOnce(Return(GL_NO_ERROR)) 2084 .WillOnce(Return(GL_NO_ERROR))
2085 .RetiresOnSaturation(); 2085 .RetiresOnSaturation();
2086 EXPECT_CALL(*gl_, GetError()) 2086 EXPECT_CALL(*gl_, GetError())
2087 .WillOnce(Return(GL_NO_ERROR)) 2087 .WillOnce(Return(GL_NO_ERROR))
2088 .WillOnce(Return(GL_NO_ERROR)) 2088 .WillOnce(Return(GL_NO_ERROR))
2089 .RetiresOnSaturation(); 2089 .RetiresOnSaturation();
2090 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(
2091 GL_FRAMEBUFFER,
2092 GL_COLOR_ATTACHMENT0,
2093 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, _))
2094 .WillOnce(SetArgumentPointee<3>(kServiceRenderbufferId))
2095 .RetiresOnSaturation();
2096 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(
2097 GL_FRAMEBUFFER,
2098 GL_COLOR_ATTACHMENT0,
2099 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, _))
2100 .WillOnce(SetArgumentPointee<3>(GL_RENDERBUFFER))
2101 .RetiresOnSaturation();
2102 GetFramebufferAttachmentParameteriv::Result* result = 2090 GetFramebufferAttachmentParameteriv::Result* result =
2103 static_cast<GetFramebufferAttachmentParameteriv::Result*>( 2091 static_cast<GetFramebufferAttachmentParameteriv::Result*>(
2104 shared_memory_address_); 2092 shared_memory_address_);
2105 result->size = 0; 2093 result->size = 0;
2106 const GLint* result_value = result->GetData(); 2094 const GLint* result_value = result->GetData();
2107 FramebufferRenderbuffer fbrb_cmd; 2095 FramebufferRenderbuffer fbrb_cmd;
2108 GetFramebufferAttachmentParameteriv cmd; 2096 GetFramebufferAttachmentParameteriv cmd;
2109 fbrb_cmd.Init( 2097 fbrb_cmd.Init(
2110 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 2098 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
2111 client_renderbuffer_id_); 2099 client_renderbuffer_id_);
(...skipping 18 matching lines...) Expand all
2130 kServiceTextureId, 0)) 2118 kServiceTextureId, 0))
2131 .Times(1) 2119 .Times(1)
2132 .RetiresOnSaturation(); 2120 .RetiresOnSaturation();
2133 EXPECT_CALL(*gl_, GetError()) 2121 EXPECT_CALL(*gl_, GetError())
2134 .WillOnce(Return(GL_NO_ERROR)) 2122 .WillOnce(Return(GL_NO_ERROR))
2135 .RetiresOnSaturation(); 2123 .RetiresOnSaturation();
2136 EXPECT_CALL(*gl_, GetError()) 2124 EXPECT_CALL(*gl_, GetError())
2137 .WillOnce(Return(GL_NO_ERROR)) 2125 .WillOnce(Return(GL_NO_ERROR))
2138 .WillOnce(Return(GL_NO_ERROR)) 2126 .WillOnce(Return(GL_NO_ERROR))
2139 .RetiresOnSaturation(); 2127 .RetiresOnSaturation();
2140 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(
2141 GL_FRAMEBUFFER,
2142 GL_COLOR_ATTACHMENT0,
2143 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, _))
2144 .WillOnce(SetArgumentPointee<3>(kServiceTextureId))
2145 .RetiresOnSaturation();
2146 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(
2147 GL_FRAMEBUFFER,
2148 GL_COLOR_ATTACHMENT0,
2149 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, _))
2150 .WillOnce(SetArgumentPointee<3>(GL_TEXTURE))
2151 .RetiresOnSaturation();
2152 GetFramebufferAttachmentParameteriv::Result* result = 2128 GetFramebufferAttachmentParameteriv::Result* result =
2153 static_cast<GetFramebufferAttachmentParameteriv::Result*>( 2129 static_cast<GetFramebufferAttachmentParameteriv::Result*>(
2154 shared_memory_address_); 2130 shared_memory_address_);
2155 result->SetNumResults(0); 2131 result->SetNumResults(0);
2156 const GLint* result_value = result->GetData(); 2132 const GLint* result_value = result->GetData();
2157 FramebufferTexture2D fbtex_cmd; 2133 FramebufferTexture2D fbtex_cmd;
2158 GetFramebufferAttachmentParameteriv cmd; 2134 GetFramebufferAttachmentParameteriv cmd;
2159 fbtex_cmd.Init( 2135 fbtex_cmd.Init(
2160 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, 2136 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_,
2161 0); 2137 0);
(...skipping 3802 matching lines...) Expand 10 before | Expand all | Expand 10 after
5964 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5940 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5965 5941
5966 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; 5942 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM];
5967 group().mailbox_manager()->GenerateMailboxName( 5943 group().mailbox_manager()->GenerateMailboxName(
5968 reinterpret_cast<MailboxName*>(mailbox)); 5944 reinterpret_cast<MailboxName*>(mailbox));
5969 5945
5970 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); 5946 memcpy(shared_memory_address_, mailbox, sizeof(mailbox));
5971 5947
5972 EXPECT_EQ(kServiceTextureId, texture_ref->service_id()); 5948 EXPECT_EQ(kServiceTextureId, texture_ref->service_id());
5973 5949
5974 // Assigns and binds new service side texture ID.
5975 EXPECT_CALL(*gl_, GenTextures(1, _))
5976 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
5977 .RetiresOnSaturation();
5978 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId))
5979 .Times(1)
5980 .RetiresOnSaturation();
5981
5982 ProduceTextureCHROMIUM produce_cmd; 5950 ProduceTextureCHROMIUM produce_cmd;
5983 produce_cmd.Init( 5951 produce_cmd.Init(
5984 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); 5952 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset);
5985 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); 5953 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd));
5986 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5954 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5987 5955
5956 // Create new texture for consume.
5957 EXPECT_CALL(*gl_, GenTextures(_, _))
5958 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
5959 .RetiresOnSaturation();
5960 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, kNewClientId, kNewServiceId);
5961
5988 // Assigns and binds original service size texture ID. 5962 // Assigns and binds original service size texture ID.
5989 EXPECT_CALL(*gl_, DeleteTextures(1, _)) 5963 EXPECT_CALL(*gl_, DeleteTextures(1, _))
5990 .Times(1) 5964 .Times(1)
5991 .RetiresOnSaturation(); 5965 .RetiresOnSaturation();
5992 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) 5966 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId))
5993 .Times(1) 5967 .Times(1)
5994 .RetiresOnSaturation(); 5968 .RetiresOnSaturation();
5995 5969
5996 // TextureManager::Restore will set TexParameters.
5997 EXPECT_CALL(*gl_, TexParameteri(
5998 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR))
5999 .Times(1)
6000 .RetiresOnSaturation();
6001 EXPECT_CALL(*gl_, TexParameteri(
6002 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR))
6003 .Times(1)
6004 .RetiresOnSaturation();
6005 EXPECT_CALL(*gl_, TexParameteri(
6006 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE))
6007 .Times(1)
6008 .RetiresOnSaturation();
6009 EXPECT_CALL(*gl_, TexParameteri(
6010 GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE))
6011 .Times(1)
6012 .RetiresOnSaturation();
6013 #if 0
6014 EXPECT_CALL(*gl_, TexParameteri(
6015 GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_NONE))
6016 .Times(1)
6017 .RetiresOnSaturation();
6018 #endif
6019
6020 // Shared mem got clobbered from GetError() above. 5970 // Shared mem got clobbered from GetError() above.
6021 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); 5971 memcpy(shared_memory_address_, mailbox, sizeof(mailbox));
6022 ConsumeTextureCHROMIUM consume_cmd; 5972 ConsumeTextureCHROMIUM consume_cmd;
6023 consume_cmd.Init( 5973 consume_cmd.Init(
6024 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); 5974 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset);
6025 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); 5975 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd));
6026 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5976 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6027 5977
6028 // Service ID is restored. 5978 // Service ID is restored.
6029 EXPECT_EQ(kServiceTextureId, texture_ref->service_id()); 5979 EXPECT_EQ(kServiceTextureId, texture_ref->service_id());
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
7398 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 7348 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7399 0, 0); 7349 0, 0);
7400 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 7350 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7401 0, 0); 7351 0, 0);
7402 TextureRef* texture_ref = group().texture_manager()->GetTexture( 7352 TextureRef* texture_ref = group().texture_manager()->GetTexture(
7403 client_texture_id_); 7353 client_texture_id_);
7404 ASSERT_TRUE(texture_ref != NULL); 7354 ASSERT_TRUE(texture_ref != NULL);
7405 Texture* texture = texture_ref->texture(); 7355 Texture* texture = texture_ref->texture();
7406 EXPECT_EQ(kServiceTextureId, texture->service_id()); 7356 EXPECT_EQ(kServiceTextureId, texture->service_id());
7407 7357
7408 // Assigns and binds new service side texture ID.
7409 EXPECT_CALL(*gl_, GenTextures(1, _))
7410 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
7411 .RetiresOnSaturation();
7412 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kNewServiceId))
7413 .Times(1)
7414 .RetiresOnSaturation();
7415
7416 ProduceTextureCHROMIUM produce_cmd; 7358 ProduceTextureCHROMIUM produce_cmd;
7417 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); 7359 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset);
7418 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); 7360 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd));
7361 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7419 7362
7420 // Texture is zero-by-zero. 7363 // Texture didn't change.
7421 GLsizei width; 7364 GLsizei width;
7422 GLsizei height; 7365 GLsizei height;
7423 GLenum type; 7366 GLenum type;
7424 GLenum internal_format; 7367 GLenum internal_format;
7425 7368
7426 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); 7369 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7427 EXPECT_EQ(0, width); 7370 EXPECT_EQ(3, width);
7428 EXPECT_EQ(0, height); 7371 EXPECT_EQ(1, height);
7429 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); 7372 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
7430 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); 7373 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
7431 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); 7374 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
7432 7375
7433 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); 7376 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
7434 EXPECT_EQ(0, width); 7377 EXPECT_EQ(2, width);
7435 EXPECT_EQ(0, height); 7378 EXPECT_EQ(4, height);
7436 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); 7379 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format));
7437 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); 7380 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
7438 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); 7381 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
7439 7382
7440 // Service ID has changed. 7383 // Service ID has not changed.
7441 EXPECT_EQ(kNewServiceId, texture->service_id()); 7384 EXPECT_EQ(kServiceTextureId, texture->service_id());
7385
7386 // Create new texture for consume.
7387 EXPECT_CALL(*gl_, GenTextures(_, _))
7388 .WillOnce(SetArgumentPointee<1>(kNewServiceId))
7389 .RetiresOnSaturation();
7390 DoBindTexture(GL_TEXTURE_2D, kNewClientId, kNewServiceId);
7442 7391
7443 // Assigns and binds original service size texture ID. 7392 // Assigns and binds original service size texture ID.
7444 EXPECT_CALL(*gl_, DeleteTextures(1, _)) 7393 EXPECT_CALL(*gl_, DeleteTextures(1, _))
7445 .Times(1) 7394 .Times(1)
7446 .RetiresOnSaturation(); 7395 .RetiresOnSaturation();
7447 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) 7396 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
7448 .Times(1) 7397 .Times(1)
7449 .RetiresOnSaturation(); 7398 .RetiresOnSaturation();
7450 7399
7451 // TextureManager::Restore will set TexParameters. 7400 memcpy(shared_memory_address_, mailbox, sizeof(mailbox));
7452 EXPECT_CALL(*gl_, TexParameteri(
7453 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR))
7454 .Times(1)
7455 .RetiresOnSaturation();
7456 EXPECT_CALL(*gl_, TexParameteri(
7457 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR))
7458 .Times(1)
7459 .RetiresOnSaturation();
7460 EXPECT_CALL(*gl_, TexParameteri(
7461 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT))
7462 .Times(1)
7463 .RetiresOnSaturation();
7464 EXPECT_CALL(*gl_, TexParameteri(
7465 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT))
7466 .Times(1)
7467 .RetiresOnSaturation();
7468 #if 0
7469 EXPECT_CALL(*gl_, TexParameteri(
7470 GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_NONE))
7471 .Times(1)
7472 .RetiresOnSaturation();
7473 #endif
7474
7475 ConsumeTextureCHROMIUM consume_cmd; 7401 ConsumeTextureCHROMIUM consume_cmd;
7476 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); 7402 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset);
7477 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); 7403 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd));
7404 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7478 7405
7479 // Texture is redefined. 7406 // Texture is redefined.
7480 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); 7407 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
7481 EXPECT_EQ(3, width); 7408 EXPECT_EQ(3, width);
7482 EXPECT_EQ(1, height); 7409 EXPECT_EQ(1, height);
7483 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); 7410 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
7484 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); 7411 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
7485 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); 7412 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
7486 7413
7487 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); 7414 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height));
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
8641 // TODO(gman): TexImage2DImmediate 8568 // TODO(gman): TexImage2DImmediate
8642 8569
8643 // TODO(gman): TexSubImage2DImmediate 8570 // TODO(gman): TexSubImage2DImmediate
8644 8571
8645 // TODO(gman): UseProgram 8572 // TODO(gman): UseProgram
8646 8573
8647 // TODO(gman): SwapBuffers 8574 // TODO(gman): SwapBuffers
8648 8575
8649 } // namespace gles2 8576 } // namespace gles2
8650 } // namespace gpu 8577 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698