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/program_manager_unittest.cc

Issue 10635011: Add glBindUniformLocationCHROMIUM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | gpu/command_buffer/service/test_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/program_manager.h" 5 #include "gpu/command_buffer/service/program_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 static const char* kUniform3GoodName; 172 static const char* kUniform3GoodName;
173 static const GLint kUniform1Size = 1; 173 static const GLint kUniform1Size = 1;
174 static const GLint kUniform2Size = 3; 174 static const GLint kUniform2Size = 3;
175 static const GLint kUniform3Size = 2; 175 static const GLint kUniform3Size = 2;
176 static const GLint kUniform1FakeLocation = 0; // These are hard coded 176 static const GLint kUniform1FakeLocation = 0; // These are hard coded
177 static const GLint kUniform2FakeLocation = 1; // to match 177 static const GLint kUniform2FakeLocation = 1; // to match
178 static const GLint kUniform3FakeLocation = 2; // ProgramManager. 178 static const GLint kUniform3FakeLocation = 2; // ProgramManager.
179 static const GLint kUniform1RealLocation = 11; 179 static const GLint kUniform1RealLocation = 11;
180 static const GLint kUniform2RealLocation = 22; 180 static const GLint kUniform2RealLocation = 22;
181 static const GLint kUniform3RealLocation = 33; 181 static const GLint kUniform3RealLocation = 33;
182 static const GLint kUniform1DesiredLocation = -1;
183 static const GLint kUniform2DesiredLocation = -1;
184 static const GLint kUniform3DesiredLocation = -1;
182 static const GLenum kUniform1Type = GL_FLOAT_VEC4; 185 static const GLenum kUniform1Type = GL_FLOAT_VEC4;
183 static const GLenum kUniform2Type = GL_INT_VEC2; 186 static const GLenum kUniform2Type = GL_INT_VEC2;
184 static const GLenum kUniform3Type = GL_FLOAT_VEC3; 187 static const GLenum kUniform3Type = GL_FLOAT_VEC3;
185 static const GLint kInvalidUniformLocation = 30; 188 static const GLint kInvalidUniformLocation = 30;
186 static const GLint kBadUniformIndex = 1000; 189 static const GLint kBadUniformIndex = 1000;
187 190
188 static const size_t kNumAttribs; 191 static const size_t kNumAttribs;
189 static const size_t kNumUniforms; 192 static const size_t kNumUniforms;
190 193
191 protected: 194 protected:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 const GLint ProgramManagerWithShaderTest::kBadAttribIndex; 296 const GLint ProgramManagerWithShaderTest::kBadAttribIndex;
294 const GLint ProgramManagerWithShaderTest::kUniform1Size; 297 const GLint ProgramManagerWithShaderTest::kUniform1Size;
295 const GLint ProgramManagerWithShaderTest::kUniform2Size; 298 const GLint ProgramManagerWithShaderTest::kUniform2Size;
296 const GLint ProgramManagerWithShaderTest::kUniform3Size; 299 const GLint ProgramManagerWithShaderTest::kUniform3Size;
297 const GLint ProgramManagerWithShaderTest::kUniform1FakeLocation; 300 const GLint ProgramManagerWithShaderTest::kUniform1FakeLocation;
298 const GLint ProgramManagerWithShaderTest::kUniform2FakeLocation; 301 const GLint ProgramManagerWithShaderTest::kUniform2FakeLocation;
299 const GLint ProgramManagerWithShaderTest::kUniform3FakeLocation; 302 const GLint ProgramManagerWithShaderTest::kUniform3FakeLocation;
300 const GLint ProgramManagerWithShaderTest::kUniform1RealLocation; 303 const GLint ProgramManagerWithShaderTest::kUniform1RealLocation;
301 const GLint ProgramManagerWithShaderTest::kUniform2RealLocation; 304 const GLint ProgramManagerWithShaderTest::kUniform2RealLocation;
302 const GLint ProgramManagerWithShaderTest::kUniform3RealLocation; 305 const GLint ProgramManagerWithShaderTest::kUniform3RealLocation;
306 const GLint ProgramManagerWithShaderTest::kUniform1DesiredLocation;
307 const GLint ProgramManagerWithShaderTest::kUniform2DesiredLocation;
308 const GLint ProgramManagerWithShaderTest::kUniform3DesiredLocation;
303 const GLenum ProgramManagerWithShaderTest::kUniform1Type; 309 const GLenum ProgramManagerWithShaderTest::kUniform1Type;
304 const GLenum ProgramManagerWithShaderTest::kUniform2Type; 310 const GLenum ProgramManagerWithShaderTest::kUniform2Type;
305 const GLenum ProgramManagerWithShaderTest::kUniform3Type; 311 const GLenum ProgramManagerWithShaderTest::kUniform3Type;
306 const GLint ProgramManagerWithShaderTest::kInvalidUniformLocation; 312 const GLint ProgramManagerWithShaderTest::kInvalidUniformLocation;
307 const GLint ProgramManagerWithShaderTest::kBadUniformIndex; 313 const GLint ProgramManagerWithShaderTest::kBadUniformIndex;
308 #endif 314 #endif
309 315
310 const size_t ProgramManagerWithShaderTest::kNumAttribs = 316 const size_t ProgramManagerWithShaderTest::kNumAttribs =
311 arraysize(ProgramManagerWithShaderTest::kAttribs); 317 arraysize(ProgramManagerWithShaderTest::kAttribs);
312 318
313 ProgramManagerWithShaderTest::UniformInfo 319 ProgramManagerWithShaderTest::UniformInfo
314 ProgramManagerWithShaderTest::kUniforms[] = { 320 ProgramManagerWithShaderTest::kUniforms[] = {
315 { kUniform1Name, 321 { kUniform1Name,
316 kUniform1Size, 322 kUniform1Size,
317 kUniform1Type, 323 kUniform1Type,
318 kUniform1FakeLocation, 324 kUniform1FakeLocation,
319 kUniform1RealLocation, 325 kUniform1RealLocation,
326 kUniform1DesiredLocation,
320 kUniform1Name, 327 kUniform1Name,
321 }, 328 },
322 { kUniform2Name, 329 { kUniform2Name,
323 kUniform2Size, 330 kUniform2Size,
324 kUniform2Type, 331 kUniform2Type,
325 kUniform2FakeLocation, 332 kUniform2FakeLocation,
326 kUniform2RealLocation, 333 kUniform2RealLocation,
334 kUniform2DesiredLocation,
327 kUniform2Name, 335 kUniform2Name,
328 }, 336 },
329 { kUniform3BadName, 337 { kUniform3BadName,
330 kUniform3Size, 338 kUniform3Size,
331 kUniform3Type, 339 kUniform3Type,
332 kUniform3FakeLocation, 340 kUniform3FakeLocation,
333 kUniform3RealLocation, 341 kUniform3RealLocation,
342 kUniform3DesiredLocation,
334 kUniform3GoodName, 343 kUniform3GoodName,
335 }, 344 },
336 }; 345 };
337 346
338 const size_t ProgramManagerWithShaderTest::kNumUniforms = 347 const size_t ProgramManagerWithShaderTest::kNumUniforms =
339 arraysize(ProgramManagerWithShaderTest::kUniforms); 348 arraysize(ProgramManagerWithShaderTest::kUniforms);
340 349
341 const char* ProgramManagerWithShaderTest::kAttrib1Name = "attrib1"; 350 const char* ProgramManagerWithShaderTest::kAttrib1Name = "attrib1";
342 const char* ProgramManagerWithShaderTest::kAttrib2Name = "attrib2"; 351 const char* ProgramManagerWithShaderTest::kAttrib2Name = "attrib2";
343 const char* ProgramManagerWithShaderTest::kAttrib3Name = "attrib3"; 352 const char* ProgramManagerWithShaderTest::kAttrib3Name = "attrib3";
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 program_info->GetUniformFakeLocation(kUniform3BadName)); 485 program_info->GetUniformFakeLocation(kUniform3BadName));
477 // Check we can get uniform2 as "uniform2" even though the name is 486 // Check we can get uniform2 as "uniform2" even though the name is
478 // "uniform2[0]" 487 // "uniform2[0]"
479 EXPECT_EQ(kUniform2FakeLocation, 488 EXPECT_EQ(kUniform2FakeLocation,
480 program_info->GetUniformFakeLocation("uniform2")); 489 program_info->GetUniformFakeLocation("uniform2"));
481 // Check we can get uniform3 as "uniform3[0]" even though we simulated GL 490 // Check we can get uniform3 as "uniform3[0]" even though we simulated GL
482 // returning "uniform3" 491 // returning "uniform3"
483 EXPECT_EQ(kUniform3FakeLocation, 492 EXPECT_EQ(kUniform3FakeLocation,
484 program_info->GetUniformFakeLocation(kUniform3GoodName)); 493 program_info->GetUniformFakeLocation(kUniform3GoodName));
485 // Check that we can get the locations of the array elements > 1 494 // Check that we can get the locations of the array elements > 1
486 EXPECT_EQ(GLES2Util::MakeFakeLocation(kUniform2FakeLocation, 1), 495 EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 1),
487 program_info->GetUniformFakeLocation("uniform2[1]")); 496 program_info->GetUniformFakeLocation("uniform2[1]"));
488 EXPECT_EQ(GLES2Util::MakeFakeLocation(kUniform2FakeLocation, 2), 497 EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 2),
489 program_info->GetUniformFakeLocation("uniform2[2]")); 498 program_info->GetUniformFakeLocation("uniform2[2]"));
490 EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform2[3]")); 499 EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform2[3]"));
491 EXPECT_EQ(GLES2Util::MakeFakeLocation(kUniform3FakeLocation, 1), 500 EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform3FakeLocation, 1),
492 program_info->GetUniformFakeLocation("uniform3[1]")); 501 program_info->GetUniformFakeLocation("uniform3[1]"));
493 EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform3[2]")); 502 EXPECT_EQ(-1, program_info->GetUniformFakeLocation("uniform3[2]"));
494 } 503 }
495 504
496 TEST_F(ProgramManagerWithShaderTest, GetUniformInfoByFakeLocation) { 505 TEST_F(ProgramManagerWithShaderTest, GetUniformInfoByFakeLocation) {
497 const GLint kInvalidLocation = 1234; 506 const GLint kInvalidLocation = 1234;
498 const ProgramManager::ProgramInfo::UniformInfo* info; 507 const ProgramManager::ProgramInfo::UniformInfo* info;
499 const ProgramManager::ProgramInfo* program_info = 508 const ProgramManager::ProgramInfo* program_info =
500 manager_.GetProgramInfo(kClientProgramId); 509 manager_.GetProgramInfo(kClientProgramId);
501 GLint real_location = -1; 510 GLint real_location = -1;
(...skipping 24 matching lines...) Expand all
526 // that start with "gl_". Our implementation catches these and does not allow 535 // that start with "gl_". Our implementation catches these and does not allow
527 // them back to client. 536 // them back to client.
528 TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsGLUnderscoreUniform) { 537 TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsGLUnderscoreUniform) {
529 static const char* kUniform2Name = "gl_longNameWeCanCheckFor"; 538 static const char* kUniform2Name = "gl_longNameWeCanCheckFor";
530 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { 539 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = {
531 { kUniform1Name, 540 { kUniform1Name,
532 kUniform1Size, 541 kUniform1Size,
533 kUniform1Type, 542 kUniform1Type,
534 kUniform1FakeLocation, 543 kUniform1FakeLocation,
535 kUniform1RealLocation, 544 kUniform1RealLocation,
545 kUniform1DesiredLocation,
536 kUniform1Name, 546 kUniform1Name,
537 }, 547 },
538 { kUniform2Name, 548 { kUniform2Name,
539 kUniform2Size, 549 kUniform2Size,
540 kUniform2Type, 550 kUniform2Type,
541 kUniform2FakeLocation, 551 kUniform2FakeLocation,
542 kUniform2RealLocation, 552 kUniform2RealLocation,
553 kUniform2DesiredLocation,
543 kUniform2Name, 554 kUniform2Name,
544 }, 555 },
545 { kUniform3BadName, 556 { kUniform3BadName,
546 kUniform3Size, 557 kUniform3Size,
547 kUniform3Type, 558 kUniform3Type,
548 kUniform3FakeLocation, 559 kUniform3FakeLocation,
549 kUniform3RealLocation, 560 kUniform3RealLocation,
561 kUniform3DesiredLocation,
550 kUniform3GoodName, 562 kUniform3GoodName,
551 }, 563 },
552 }; 564 };
553 const size_t kNumUniforms = arraysize(kUniforms); 565 const size_t kNumUniforms = arraysize(kUniforms);
554 static const GLuint kClientProgramId = 1234; 566 static const GLuint kClientProgramId = 1234;
555 static const GLuint kServiceProgramId = 5679; 567 static const GLuint kServiceProgramId = 5679;
556 const GLuint kVShaderClientId = 2001; 568 const GLuint kVShaderClientId = 2001;
557 const GLuint kFShaderClientId = 2002; 569 const GLuint kFShaderClientId = 2002;
558 const GLuint kVShaderServiceId = 3001; 570 const GLuint kVShaderServiceId = 3001;
559 const GLuint kFShaderServiceId = 3002; 571 const GLuint kFShaderServiceId = 3002;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, 640 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },
629 { kAttrib2Name, kAttrib2Size, kAttrib2BadType, kAttrib2Location, }, 641 { kAttrib2Name, kAttrib2Size, kAttrib2BadType, kAttrib2Location, },
630 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, 642 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, },
631 }; 643 };
632 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { 644 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = {
633 { kUniform1Name, 645 { kUniform1Name,
634 kUniform1Size, 646 kUniform1Size,
635 kUniform1Type, 647 kUniform1Type,
636 kUniform1FakeLocation, 648 kUniform1FakeLocation,
637 kUniform1RealLocation, 649 kUniform1RealLocation,
650 kUniform1DesiredLocation,
638 kUniform1Name, 651 kUniform1Name,
639 }, 652 },
640 { kUniform2Name, 653 { kUniform2Name,
641 kUniform2Size, 654 kUniform2Size,
642 kUniform2BadType, 655 kUniform2BadType,
643 kUniform2FakeLocation, 656 kUniform2FakeLocation,
644 kUniform2RealLocation, 657 kUniform2RealLocation,
658 kUniform2DesiredLocation,
645 kUniform2Name, 659 kUniform2Name,
646 }, 660 },
647 { kUniform3BadName, 661 { kUniform3BadName,
648 kUniform3Size, 662 kUniform3Size,
649 kUniform3Type, 663 kUniform3Type,
650 kUniform3FakeLocation, 664 kUniform3FakeLocation,
651 kUniform3RealLocation, 665 kUniform3RealLocation,
666 kUniform3DesiredLocation,
652 kUniform3GoodName, 667 kUniform3GoodName,
653 }, 668 },
654 }; 669 };
655 const size_t kNumAttribs= arraysize(kAttribs); 670 const size_t kNumAttribs= arraysize(kAttribs);
656 const size_t kNumUniforms = arraysize(kUniforms); 671 const size_t kNumUniforms = arraysize(kUniforms);
657 static const GLuint kClientProgramId = 1234; 672 static const GLuint kClientProgramId = 1234;
658 static const GLuint kServiceProgramId = 5679; 673 static const GLuint kServiceProgramId = 5679;
659 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, 674 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
660 kServiceProgramId); 675 kServiceProgramId);
661 ProgramManager::ProgramInfo* program_info = manager_.CreateProgramInfo( 676 ProgramManager::ProgramInfo* program_info = manager_.CreateProgramInfo(
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 } 843 }
829 // TODO(gman): Don't assume these are in order. 844 // TODO(gman): Don't assume these are in order.
830 for (uint32 ii = 0; ii < header->num_uniforms; ++ii) { 845 for (uint32 ii = 0; ii < header->num_uniforms; ++ii) {
831 const UniformInfo& expected = kUniforms[ii]; 846 const UniformInfo& expected = kUniforms[ii];
832 EXPECT_EQ(expected.size, input->size); 847 EXPECT_EQ(expected.size, input->size);
833 EXPECT_EQ(expected.type, input->type); 848 EXPECT_EQ(expected.type, input->type);
834 const int32* locations = bucket.GetDataAs<const int32*>( 849 const int32* locations = bucket.GetDataAs<const int32*>(
835 input->location_offset, sizeof(int32) * input->size); 850 input->location_offset, sizeof(int32) * input->size);
836 ASSERT_TRUE(locations != NULL); 851 ASSERT_TRUE(locations != NULL);
837 for (int32 jj = 0; jj < input->size; ++jj) { 852 for (int32 jj = 0; jj < input->size; ++jj) {
838 EXPECT_EQ(GLES2Util::SwizzleLocation( 853 EXPECT_EQ(
839 GLES2Util::MakeFakeLocation(expected.fake_location, jj)), 854 ProgramManager::MakeFakeLocation(expected.fake_location, jj),
840 locations[jj]); 855 locations[jj]);
841 } 856 }
842 const char* name_buf = bucket.GetDataAs<const char*>( 857 const char* name_buf = bucket.GetDataAs<const char*>(
843 input->name_offset, input->name_length); 858 input->name_offset, input->name_length);
844 ASSERT_TRUE(name_buf != NULL); 859 ASSERT_TRUE(name_buf != NULL);
845 std::string name(name_buf, input->name_length); 860 std::string name(name_buf, input->name_length);
846 EXPECT_STREQ(expected.good_name, name.c_str()); 861 EXPECT_STREQ(expected.good_name, name.c_str());
847 ++input; 862 ++input;
848 } 863 }
849 EXPECT_EQ(header->num_attribs + header->num_uniforms, 864 EXPECT_EQ(header->num_attribs + header->num_uniforms,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, 966 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },
952 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, 967 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, },
953 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, 968 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, },
954 }; 969 };
955 ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { 970 ProgramManagerWithShaderTest::UniformInfo kUniforms[] = {
956 { kUniform1Name, 971 { kUniform1Name,
957 kUniform1Size, 972 kUniform1Size,
958 kUniform1Type, 973 kUniform1Type,
959 kUniform1FakeLocation, 974 kUniform1FakeLocation,
960 kUniform1RealLocation, 975 kUniform1RealLocation,
976 kUniform1DesiredLocation,
961 kUniform1Name, 977 kUniform1Name,
962 }, 978 },
963 { kUniform2Name, 979 { kUniform2Name,
964 kUniform2Size, 980 kUniform2Size,
965 kSamplerTypes[ii], 981 kSamplerTypes[ii],
966 kUniform2FakeLocation, 982 kUniform2FakeLocation,
967 kUniform2RealLocation, 983 kUniform2RealLocation,
984 kUniform2DesiredLocation,
968 kUniform2Name, 985 kUniform2Name,
969 }, 986 },
970 { kUniform3BadName, 987 { kUniform3BadName,
971 kUniform3Size, 988 kUniform3Size,
972 kUniform3Type, 989 kUniform3Type,
973 kUniform3FakeLocation, 990 kUniform3FakeLocation,
974 kUniform3RealLocation, 991 kUniform3RealLocation,
992 kUniform3DesiredLocation,
975 kUniform3GoodName, 993 kUniform3GoodName,
976 }, 994 },
977 }; 995 };
978 const size_t kNumAttribs = arraysize(kAttribs); 996 const size_t kNumAttribs = arraysize(kAttribs);
979 const size_t kNumUniforms = arraysize(kUniforms); 997 const size_t kNumUniforms = arraysize(kUniforms);
980 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, 998 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
981 kServiceProgramId); 999 kServiceProgramId);
982 program_info->Link(); 1000 program_info->Link();
983 SetupExpectationsForClearingUniforms(kUniforms, kNumUniforms); 1001 SetupExpectationsForClearingUniforms(kUniforms, kNumUniforms);
984 manager_.ClearUniforms(program_info); 1002 manager_.ClearUniforms(program_info);
985 } 1003 }
986 } 1004 }
987 1005
988 TEST_F(ProgramManagerWithShaderTest, UniformsAreSorted) { 1006 TEST_F(ProgramManagerWithShaderTest, BindUniformLocation) {
989 const GLuint kVShaderClientId = 2001; 1007 const GLuint kVShaderClientId = 2001;
990 const GLuint kFShaderClientId = 2002; 1008 const GLuint kFShaderClientId = 2002;
991 const GLuint kVShaderServiceId = 3001; 1009 const GLuint kVShaderServiceId = 3001;
992 const GLuint kFShaderServiceId = 3002; 1010 const GLuint kFShaderServiceId = 3002;
1011
1012 const GLint kUniform1DesiredLocation = 10;
1013 const GLint kUniform2DesiredLocation = -1;
1014 const GLint kUniform3DesiredLocation = 5;
1015
993 ShaderManager::ShaderInfo* vshader = shader_manager_.CreateShaderInfo( 1016 ShaderManager::ShaderInfo* vshader = shader_manager_.CreateShaderInfo(
994 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); 1017 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER);
995 ASSERT_TRUE(vshader != NULL); 1018 ASSERT_TRUE(vshader != NULL);
996 vshader->SetStatus(true, "", NULL); 1019 vshader->SetStatus(true, NULL, NULL);
997 ShaderManager::ShaderInfo* fshader = shader_manager_.CreateShaderInfo( 1020 ShaderManager::ShaderInfo* fshader = shader_manager_.CreateShaderInfo(
998 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); 1021 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER);
999 ASSERT_TRUE(fshader != NULL); 1022 ASSERT_TRUE(fshader != NULL);
1000 fshader->SetStatus(true, "", NULL); 1023 fshader->SetStatus(true, NULL, NULL);
1024 static const GLuint kClientProgramId = 1234;
1025 static const GLuint kServiceProgramId = 5679;
1026 ProgramManager::ProgramInfo* program_info = manager_.CreateProgramInfo(
1027 kClientProgramId, kServiceProgramId);
1028 ASSERT_TRUE(program_info != NULL);
1029 EXPECT_TRUE(program_info->AttachShader(&shader_manager_, vshader));
1030 EXPECT_TRUE(program_info->AttachShader(&shader_manager_, fshader));
1031 EXPECT_TRUE(program_info->SetUniformLocationBinding(
1032 kUniform1Name, kUniform1DesiredLocation));
1033 EXPECT_TRUE(program_info->SetUniformLocationBinding(
1034 kUniform3BadName, kUniform3DesiredLocation));
1035
1001 static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = { 1036 static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = {
1002 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, 1037 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },
1003 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, 1038 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, },
1004 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, 1039 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, },
1005 }; 1040 };
1006 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { 1041 ProgramManagerWithShaderTest::UniformInfo kUniforms[] = {
1042 { kUniform1Name,
1043 kUniform1Size,
1044 kUniform1Type,
1045 kUniform1FakeLocation,
1046 kUniform1RealLocation,
1047 kUniform1DesiredLocation,
1048 kUniform1Name,
1049 },
1007 { kUniform2Name, 1050 { kUniform2Name,
1008 kUniform2Size, 1051 kUniform2Size,
1009 kUniform2Type, 1052 kUniform2Type,
1010 kUniform2FakeLocation, 1053 kUniform2FakeLocation,
1011 kUniform2RealLocation, 1054 kUniform2RealLocation,
1055 kUniform2DesiredLocation,
1012 kUniform2Name, 1056 kUniform2Name,
1013 }, 1057 },
1014 { kUniform3GoodName, 1058 { kUniform3BadName,
1015 kUniform3Size, 1059 kUniform3Size,
1016 kUniform3Type, 1060 kUniform3Type,
1017 kUniform3FakeLocation, 1061 kUniform3FakeLocation,
1018 kUniform3RealLocation, 1062 kUniform3RealLocation,
1063 kUniform3DesiredLocation,
1019 kUniform3GoodName, 1064 kUniform3GoodName,
1020 }, 1065 },
1021 { kUniform1Name,
1022 kUniform1Size,
1023 kUniform1Type,
1024 kUniform1FakeLocation,
1025 kUniform1RealLocation,
1026 kUniform1Name,
1027 },
1028 }; 1066 };
1029 const size_t kNumAttribs= arraysize(kAttribs); 1067
1068 const size_t kNumAttribs = arraysize(kAttribs);
1030 const size_t kNumUniforms = arraysize(kUniforms); 1069 const size_t kNumUniforms = arraysize(kUniforms);
1031 static const GLuint kClientProgramId = 1234;
1032 static const GLuint kServiceProgramId = 5679;
1033 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, 1070 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
1034 kServiceProgramId); 1071 kServiceProgramId);
1035 ProgramManager::ProgramInfo* program_info = manager_.CreateProgramInfo(
1036 kClientProgramId, kServiceProgramId);
1037 ASSERT_TRUE(program_info != NULL);
1038 EXPECT_TRUE(program_info->AttachShader(&shader_manager_, vshader));
1039 EXPECT_TRUE(program_info->AttachShader(&shader_manager_, fshader));
1040 program_info->Link(); 1072 program_info->Link();
1041 // Check Uniforms 1073
1042 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 1074 EXPECT_EQ(kUniform1DesiredLocation,
1043 program_info->GetUniformInfo(0); 1075 program_info->GetUniformFakeLocation(kUniform1Name));
1044 ASSERT_TRUE(uniform_info != NULL); 1076 EXPECT_EQ(kUniform3DesiredLocation,
1045 EXPECT_STREQ(kUniform1Name, uniform_info->name.c_str()); 1077 program_info->GetUniformFakeLocation(kUniform3BadName));
1046 EXPECT_EQ(0, uniform_info->fake_location_base); 1078 EXPECT_EQ(kUniform3DesiredLocation,
1047 uniform_info = program_info->GetUniformInfo(1); 1079 program_info->GetUniformFakeLocation(kUniform3GoodName));
1048 ASSERT_TRUE(uniform_info != NULL);
1049 EXPECT_STREQ(kUniform2Name, uniform_info->name.c_str());
1050 EXPECT_EQ(1, uniform_info->fake_location_base);
1051 uniform_info = program_info->GetUniformInfo(2);
1052 ASSERT_TRUE(uniform_info != NULL);
1053 EXPECT_STREQ(kUniform3GoodName, uniform_info->name.c_str());
1054 EXPECT_EQ(2, uniform_info->fake_location_base);
1055 } 1080 }
1056 1081
1057 } // namespace gles2 1082 } // namespace gles2
1058 } // namespace gpu 1083 } // namespace gpu
1059 1084
1060 1085
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | gpu/command_buffer/service/test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698