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

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

Issue 1165553003: Fine tuning glGetInternalformativ. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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_unittest.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.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 26 matching lines...) Expand all
37 using ::testing::AtLeast; 37 using ::testing::AtLeast;
38 using ::testing::DoAll; 38 using ::testing::DoAll;
39 using ::testing::InSequence; 39 using ::testing::InSequence;
40 using ::testing::Invoke; 40 using ::testing::Invoke;
41 using ::testing::MatcherCast; 41 using ::testing::MatcherCast;
42 using ::testing::Mock; 42 using ::testing::Mock;
43 using ::testing::Pointee; 43 using ::testing::Pointee;
44 using ::testing::Return; 44 using ::testing::Return;
45 using ::testing::SaveArg; 45 using ::testing::SaveArg;
46 using ::testing::SetArrayArgument; 46 using ::testing::SetArrayArgument;
47 using ::testing::SetArgumentPointee;
48 using ::testing::SetArgPointee; 47 using ::testing::SetArgPointee;
49 using ::testing::StrEq; 48 using ::testing::StrEq;
50 using ::testing::StrictMock; 49 using ::testing::StrictMock;
51 50
52 namespace gpu { 51 namespace gpu {
53 namespace gles2 { 52 namespace gles2 {
54 53
55 using namespace cmds; 54 using namespace cmds;
56 55
57 void GLES2DecoderRGBBackbufferTest::SetUp() { 56 void GLES2DecoderRGBBackbufferTest::SetUp() {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 } 274 }
276 275
277 TEST_P(GLES2DecoderTest, IsTexture) { 276 TEST_P(GLES2DecoderTest, IsTexture) {
278 EXPECT_FALSE(DoIsTexture(client_texture_id_)); 277 EXPECT_FALSE(DoIsTexture(client_texture_id_));
279 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 278 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
280 EXPECT_TRUE(DoIsTexture(client_texture_id_)); 279 EXPECT_TRUE(DoIsTexture(client_texture_id_));
281 DoDeleteTexture(client_texture_id_, kServiceTextureId); 280 DoDeleteTexture(client_texture_id_, kServiceTextureId);
282 EXPECT_FALSE(DoIsTexture(client_texture_id_)); 281 EXPECT_FALSE(DoIsTexture(client_texture_id_));
283 } 282 }
284 283
285 TEST_P(GLES2DecoderTest, ClientWaitSyncValid) { 284 TEST_P(GLES3DecoderTest, GetInternalformativValidArgsSamples) {
285 const GLint kNumSampleCounts = 8;
286 typedef cmds::GetInternalformativ::Result Result;
287 Result* result = static_cast<Result*>(shared_memory_address_);
288 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA8,
289 GL_NUM_SAMPLE_COUNTS, 1, _))
290 .WillOnce(SetArgPointee<4>(kNumSampleCounts))
291 .RetiresOnSaturation();
292 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA8,
293 GL_SAMPLES, kNumSampleCounts,
294 result->GetData()))
295 .Times(1)
296 .RetiresOnSaturation();
297 result->size = 0;
298 cmds::GetInternalformativ cmd;
299 cmd.Init(GL_RENDERBUFFER, GL_RGBA8, GL_SAMPLES,
300 shared_memory_id_, shared_memory_offset_);
301 decoder_->set_unsafe_es3_apis_enabled(true);
302 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
303 EXPECT_EQ(kNumSampleCounts, result->GetNumResults());
304 EXPECT_EQ(GL_NO_ERROR, GetGLError());
305 decoder_->set_unsafe_es3_apis_enabled(false);
306 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
307 }
308
309 TEST_P(GLES3DecoderTest, GetInternalformativValidArgsNumSampleCounts) {
310 const GLint kNumSampleCounts = 8;
311 typedef cmds::GetInternalformativ::Result Result;
312 Result* result = static_cast<Result*>(shared_memory_address_);
313 EXPECT_CALL(*gl_, GetInternalformativ(GL_RENDERBUFFER, GL_RGBA8,
314 GL_NUM_SAMPLE_COUNTS, 1, _))
315 .WillOnce(SetArgPointee<4>(kNumSampleCounts))
316 .RetiresOnSaturation();
317 result->size = 0;
318 cmds::GetInternalformativ cmd;
319 cmd.Init(GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS,
320 shared_memory_id_, shared_memory_offset_);
321 decoder_->set_unsafe_es3_apis_enabled(true);
322 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
323 EXPECT_EQ(1, result->GetNumResults());
324 EXPECT_EQ(kNumSampleCounts, result->GetData()[0]);
325 EXPECT_EQ(GL_NO_ERROR, GetGLError());
326 decoder_->set_unsafe_es3_apis_enabled(false);
327 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
328 }
329
330 TEST_P(GLES3DecoderTest, ClientWaitSyncValid) {
286 typedef cmds::ClientWaitSync::Result Result; 331 typedef cmds::ClientWaitSync::Result Result;
287 Result* result = static_cast<Result*>(shared_memory_address_); 332 Result* result = static_cast<Result*>(shared_memory_address_);
288 cmds::ClientWaitSync cmd; 333 cmds::ClientWaitSync cmd;
289 uint32_t v32_0 = 0, v32_1 = 0; 334 uint32_t v32_0 = 0, v32_1 = 0;
290 GLES2Util::MapUint64ToTwoUint32(0, &v32_0, &v32_1); 335 GLES2Util::MapUint64ToTwoUint32(0, &v32_0, &v32_1);
291 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1, 336 cmd.Init(client_sync_id_, GL_SYNC_FLUSH_COMMANDS_BIT, v32_0, v32_1,
292 shared_memory_id_, shared_memory_offset_); 337 shared_memory_id_, shared_memory_offset_);
293 EXPECT_CALL(*gl_, 338 EXPECT_CALL(*gl_,
294 ClientWaitSync(reinterpret_cast<GLsync>(kServiceSyncId), 339 ClientWaitSync(reinterpret_cast<GLsync>(kServiceSyncId),
295 GL_SYNC_FLUSH_COMMANDS_BIT, 0)) 340 GL_SYNC_FLUSH_COMMANDS_BIT, 0))
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // Test id = 0 fails. 499 // Test id = 0 fails.
455 begin_cmd.Init( 500 begin_cmd.Init(
456 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset); 501 GL_ANY_SAMPLES_PASSED_EXT, 0, kSharedMemoryId, kSharedMemoryOffset);
457 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); 502 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
458 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 503 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
459 504
460 GenHelper<GenQueriesEXTImmediate>(kNewClientId); 505 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
461 506
462 // Test valid parameters work. 507 // Test valid parameters work.
463 EXPECT_CALL(*gl_, GenQueries(1, _)) 508 EXPECT_CALL(*gl_, GenQueries(1, _))
464 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) 509 .WillOnce(SetArgPointee<1>(kNewServiceId))
465 .RetiresOnSaturation(); 510 .RetiresOnSaturation();
466 EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId)) 511 EXPECT_CALL(*gl_, BeginQuery(GL_ANY_SAMPLES_PASSED_EXT, kNewServiceId))
467 .Times(1) 512 .Times(1)
468 .RetiresOnSaturation(); 513 .RetiresOnSaturation();
469 514
470 // Query object should not be created untill BeginQueriesEXT. 515 // Query object should not be created untill BeginQueriesEXT.
471 QueryManager* query_manager = decoder_->GetQueryManager(); 516 QueryManager* query_manager = decoder_->GetQueryManager();
472 ASSERT_TRUE(query_manager != NULL); 517 ASSERT_TRUE(query_manager != NULL);
473 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); 518 QueryManager::Query* query = query_manager->GetQuery(kNewClientId);
474 EXPECT_TRUE(query == NULL); 519 EXPECT_TRUE(query == NULL);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 init.bind_generates_resource = true; 590 init.bind_generates_resource = true;
546 test->InitDecoder(init); 591 test->InitDecoder(init);
547 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock(); 592 ::testing::StrictMock< ::gfx::MockGLInterface>* gl = test->GetGLMock();
548 593
549 BeginQueryEXT begin_cmd; 594 BeginQueryEXT begin_cmd;
550 595
551 test->GenHelper<GenQueriesEXTImmediate>(client_id); 596 test->GenHelper<GenQueriesEXTImmediate>(client_id);
552 597
553 if (query_type.is_gl) { 598 if (query_type.is_gl) {
554 EXPECT_CALL(*gl, GenQueries(1, _)) 599 EXPECT_CALL(*gl, GenQueries(1, _))
555 .WillOnce(SetArgumentPointee<1>(service_id)) 600 .WillOnce(SetArgPointee<1>(service_id))
556 .RetiresOnSaturation(); 601 .RetiresOnSaturation();
557 EXPECT_CALL(*gl, BeginQuery(query_type.type, service_id)) 602 EXPECT_CALL(*gl, BeginQuery(query_type.type, service_id))
558 .Times(1) 603 .Times(1)
559 .RetiresOnSaturation(); 604 .RetiresOnSaturation();
560 } 605 }
561 606
562 // Test bad shared memory fails 607 // Test bad shared memory fails
563 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset); 608 begin_cmd.Init(query_type.type, client_id, shm_id, shm_offset);
564 error::Error error1 = test->ExecuteCmd(begin_cmd); 609 error::Error error1 = test->ExecuteCmd(begin_cmd);
565 610
(...skipping 20 matching lines...) Expand all
586 #endif 631 #endif
587 } 632 }
588 633
589 EndQueryEXT end_cmd; 634 EndQueryEXT end_cmd;
590 end_cmd.Init(query_type.type, 1); 635 end_cmd.Init(query_type.type, 1);
591 error::Error error2 = test->ExecuteCmd(end_cmd); 636 error::Error error2 = test->ExecuteCmd(end_cmd);
592 637
593 if (query_type.is_gl) { 638 if (query_type.is_gl) {
594 EXPECT_CALL( 639 EXPECT_CALL(
595 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _)) 640 *gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_AVAILABLE_EXT, _))
596 .WillOnce(SetArgumentPointee<2>(1)) 641 .WillOnce(SetArgPointee<2>(1))
597 .RetiresOnSaturation(); 642 .RetiresOnSaturation();
598 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _)) 643 EXPECT_CALL(*gl, GetQueryObjectuiv(service_id, GL_QUERY_RESULT_EXT, _))
599 .WillOnce(SetArgumentPointee<2>(1)) 644 .WillOnce(SetArgPointee<2>(1))
600 .RetiresOnSaturation(); 645 .RetiresOnSaturation();
601 } 646 }
602 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) { 647 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) {
603 #if DCHECK_IS_ON() 648 #if DCHECK_IS_ON()
604 EXPECT_CALL(*gl, IsSync(kGlSync)) 649 EXPECT_CALL(*gl, IsSync(kGlSync))
605 .WillOnce(Return(GL_TRUE)) 650 .WillOnce(Return(GL_TRUE))
606 .RetiresOnSaturation(); 651 .RetiresOnSaturation();
607 #endif 652 #endif
608 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _)) 653 EXPECT_CALL(*gl, ClientWaitSync(kGlSync, _, _))
609 .WillOnce(Return(GL_ALREADY_SIGNALED)) 654 .WillOnce(Return(GL_ALREADY_SIGNALED))
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 INSTANTIATE_TEST_CASE_P(Service, 1334 INSTANTIATE_TEST_CASE_P(Service,
1290 GLES2DecoderRGBBackbufferTest, 1335 GLES2DecoderRGBBackbufferTest,
1291 ::testing::Bool()); 1336 ::testing::Bool());
1292 1337
1293 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); 1338 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool());
1294 1339
1295 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool()); 1340 INSTANTIATE_TEST_CASE_P(Service, GLES3DecoderTest, ::testing::Bool());
1296 1341
1297 } // namespace gles2 1342 } // namespace gles2
1298 } // namespace gpu 1343 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698