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

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

Issue 240273006: Revert of gpu: Add CHROMIUM_sync_query extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/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 7094 matching lines...) Expand 10 before | Expand all | Expand 10 after
7105 GLenum type; 7105 GLenum type;
7106 bool is_gl; 7106 bool is_gl;
7107 }; 7107 };
7108 7108
7109 const QueryType kQueryTypes[] = { 7109 const QueryType kQueryTypes[] = {
7110 { GL_COMMANDS_ISSUED_CHROMIUM, false }, 7110 { GL_COMMANDS_ISSUED_CHROMIUM, false },
7111 { GL_LATENCY_QUERY_CHROMIUM, false }, 7111 { GL_LATENCY_QUERY_CHROMIUM, false },
7112 { GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false }, 7112 { GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM, false },
7113 { GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false }, 7113 { GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, false },
7114 { GL_GET_ERROR_QUERY_CHROMIUM, false }, 7114 { GL_GET_ERROR_QUERY_CHROMIUM, false },
7115 { GL_COMMANDS_COMPLETED_CHROMIUM, false },
7116 { GL_ANY_SAMPLES_PASSED_EXT, true }, 7115 { GL_ANY_SAMPLES_PASSED_EXT, true },
7117 }; 7116 };
7118 7117
7119 static void CheckBeginEndQueryBadMemoryFails( 7118 static void CheckBeginEndQueryBadMemoryFails(
7120 GLES2DecoderTestBase* test, 7119 GLES2DecoderTestBase* test,
7121 GLuint client_id, 7120 GLuint client_id,
7122 GLuint service_id, 7121 GLuint service_id,
7123 const QueryType& query_type, 7122 const QueryType& query_type,
7124 int32 shm_id, 7123 int32 shm_id,
7125 uint32 shm_offset) { 7124 uint32 shm_offset) {
7126 // We need to reset the decoder on each iteration, because we lose the 7125 // We need to reset the decoder on each iteration, because we lose the
7127 // context every time. 7126 // context every time.
7128 GLES2DecoderTestBase::InitState init; 7127 GLES2DecoderTestBase::InitState init;
7129 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; 7128 init.extensions = "GL_EXT_occlusion_query_boolean";
7130 init.gl_version = "opengl es 2.0"; 7129 init.gl_version = "opengl es 2.0";
7131 init.has_alpha = true; 7130 init.has_alpha = true;
7132 init.request_alpha = true; 7131 init.request_alpha = true;
7133 init.bind_generates_resource = true; 7132 init.bind_generates_resource = true;
7134 test->InitDecoder(init); 7133 test->InitDecoder(init);
7135 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); 7134 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock();
7136 7135
7137 BeginQueryEXT begin_cmd; 7136 BeginQueryEXT begin_cmd;
7138 7137
7139 test->GenHelper<GenQueriesEXTImmediate>(client_id); 7138 test->GenHelper<GenQueriesEXTImmediate>(client_id);
(...skipping 14 matching lines...) Expand all
7154 if (query_type.is_gl) { 7153 if (query_type.is_gl) {
7155 EXPECT_CALL(*gl, EndQueryARB(query_type.type)) 7154 EXPECT_CALL(*gl, EndQueryARB(query_type.type))
7156 .Times(1) 7155 .Times(1)
7157 .RetiresOnSaturation(); 7156 .RetiresOnSaturation();
7158 } 7157 }
7159 if (query_type.type == GL_GET_ERROR_QUERY_CHROMIUM) { 7158 if (query_type.type == GL_GET_ERROR_QUERY_CHROMIUM) {
7160 EXPECT_CALL(*gl, GetError()) 7159 EXPECT_CALL(*gl, GetError())
7161 .WillOnce(Return(GL_NO_ERROR)) 7160 .WillOnce(Return(GL_NO_ERROR))
7162 .RetiresOnSaturation(); 7161 .RetiresOnSaturation();
7163 } 7162 }
7164 GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef);
7165 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) {
7166 EXPECT_CALL(*gl, Flush()).RetiresOnSaturation();
7167 EXPECT_CALL(*gl, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0))
7168 .WillOnce(Return(kGlSync))
7169 .RetiresOnSaturation();
7170 }
7171 7163
7172 EndQueryEXT end_cmd; 7164 EndQueryEXT end_cmd;
7173 end_cmd.Init(query_type.type, 1); 7165 end_cmd.Init(query_type.type, 1);
7174 error::Error error2 = test->ExecuteCmd(end_cmd); 7166 error::Error error2 = test->ExecuteCmd(end_cmd);
7175 7167
7176 if (query_type.is_gl) { 7168 if (query_type.is_gl) {
7177 EXPECT_CALL(*gl, 7169 EXPECT_CALL(*gl,
7178 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) 7170 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _))
7179 .WillOnce(SetArgumentPointee<2>(1)) 7171 .WillOnce(SetArgumentPointee<2>(1))
7180 .RetiresOnSaturation(); 7172 .RetiresOnSaturation();
7181 EXPECT_CALL(*gl, 7173 EXPECT_CALL(*gl,
7182 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _)) 7174 GetQueryObjectuivARB(service_id, GL_QUERY_RESULT_EXT, _))
7183 .WillOnce(SetArgumentPointee<2>(1)) 7175 .WillOnce(SetArgumentPointee<2>(1))
7184 .RetiresOnSaturation(); 7176 .RetiresOnSaturation();
7185 } 7177 }
7186 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) {
7187 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _))
7188 .WillOnce(Return(GL_ALREADY_SIGNALED))
7189 .RetiresOnSaturation();
7190 }
7191 7178
7192 QueryManager* query_manager = test->GetDecoder()->GetQueryManager(); 7179 QueryManager* query_manager = test->GetDecoder()->GetQueryManager();
7193 ASSERT_TRUE(query_manager != NULL); 7180 ASSERT_TRUE(query_manager != NULL);
7194 bool process_success = query_manager->ProcessPendingQueries(); 7181 bool process_success = query_manager->ProcessPendingQueries();
7195 7182
7196 EXPECT_TRUE(error1 != error::kNoError || 7183 EXPECT_TRUE(error1 != error::kNoError ||
7197 error2 != error::kNoError || 7184 error2 != error::kNoError ||
7198 !process_success); 7185 !process_success);
7199 7186
7200 if (query_type.is_gl) { 7187 if (query_type.is_gl) {
7201 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)) 7188 EXPECT_CALL(*gl, DeleteQueriesARB(1, _))
7202 .Times(1) 7189 .Times(1)
7203 .RetiresOnSaturation(); 7190 .RetiresOnSaturation();
7204 } 7191 }
7205 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM)
7206 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation();
7207 test->ResetDecoder(); 7192 test->ResetDecoder();
7208 } 7193 }
7209 7194
7210 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { 7195 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) {
7211 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { 7196 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) {
7212 CheckBeginEndQueryBadMemoryFails( 7197 CheckBeginEndQueryBadMemoryFails(
7213 this, kNewClientId, kNewServiceId, 7198 this, kNewClientId, kNewServiceId,
7214 kQueryTypes[i], 7199 kQueryTypes[i],
7215 kInvalidSharedMemoryId, kSharedMemoryOffset); 7200 kInvalidSharedMemoryId, kSharedMemoryOffset);
7216 } 7201 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
7284 7269
7285 EndQueryEXT end_cmd; 7270 EndQueryEXT end_cmd;
7286 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); 7271 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1);
7287 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 7272 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7288 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7273 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7289 EXPECT_FALSE(query->pending()); 7274 EXPECT_FALSE(query->pending());
7290 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), 7275 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE),
7291 static_cast<GLenum>(sync->result)); 7276 static_cast<GLenum>(sync->result));
7292 } 7277 }
7293 7278
7294 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTCommandsCompletedCHROMIUM) {
7295 InitState init;
7296 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync";
7297 init.gl_version = "opengl es 2.0";
7298 init.has_alpha = true;
7299 init.request_alpha = true;
7300 init.bind_generates_resource = true;
7301 InitDecoder(init);
7302
7303 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
7304
7305 BeginQueryEXT begin_cmd;
7306 begin_cmd.Init(GL_COMMANDS_COMPLETED_CHROMIUM,
7307 kNewClientId,
7308 kSharedMemoryId,
7309 kSharedMemoryOffset);
7310 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
7311 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7312
7313 QueryManager* query_manager = decoder_->GetQueryManager();
7314 ASSERT_TRUE(query_manager != NULL);
7315 QueryManager::Query* query = query_manager->GetQuery(kNewClientId);
7316 ASSERT_TRUE(query != NULL);
7317 EXPECT_FALSE(query->pending());
7318
7319 GLsync kGlSync = reinterpret_cast<GLsync>(0xdeadbeef);
7320 EXPECT_CALL(*gl_, Flush()).RetiresOnSaturation();
7321 EXPECT_CALL(*gl_, FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0))
7322 .WillOnce(Return(kGlSync))
7323 .RetiresOnSaturation();
7324
7325 EndQueryEXT end_cmd;
7326 end_cmd.Init(GL_COMMANDS_COMPLETED_CHROMIUM, 1);
7327 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7328 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7329 EXPECT_TRUE(query->pending());
7330
7331 EXPECT_CALL(*gl_, ClientWaitSync(kGlSync, _, _))
7332 .WillOnce(Return(GL_TIMEOUT_EXPIRED))
7333 .RetiresOnSaturation();
7334 bool process_success = query_manager->ProcessPendingQueries();
7335
7336 EXPECT_TRUE(process_success);
7337 EXPECT_TRUE(query->pending());
7338
7339 EXPECT_CALL(*gl_, ClientWaitSync(kGlSync, _, _))
7340 .WillOnce(Return(GL_ALREADY_SIGNALED))
7341 .RetiresOnSaturation();
7342 process_success = query_manager->ProcessPendingQueries();
7343
7344 EXPECT_TRUE(process_success);
7345 EXPECT_FALSE(query->pending());
7346 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_);
7347 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result));
7348
7349 EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation();
7350 ResetDecoder();
7351 }
7352
7353 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { 7279 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) {
7354 Mailbox mailbox = Mailbox::Generate(); 7280 Mailbox mailbox = Mailbox::Generate();
7355 7281
7356 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); 7282 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name));
7357 7283
7358 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 7284 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
7359 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 7285 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7360 0, 0); 7286 0, 0);
7361 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 7287 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7362 0, 0); 7288 0, 0);
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after
9519 // TODO(gman): TexImage2DImmediate 9445 // TODO(gman): TexImage2DImmediate
9520 9446
9521 // TODO(gman): TexSubImage2DImmediate 9447 // TODO(gman): TexSubImage2DImmediate
9522 9448
9523 // TODO(gman): UseProgram 9449 // TODO(gman): UseProgram
9524 9450
9525 // TODO(gman): SwapBuffers 9451 // TODO(gman): SwapBuffers
9526 9452
9527 } // namespace gles2 9453 } // namespace gles2
9528 } // namespace gpu 9454 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698