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

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

Issue 619723008: Switch to use ANGLE's new APIs to query shader variables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 static const GLuint kFragmentShaderClientId = 202; 144 static const GLuint kFragmentShaderClientId = 202;
145 static const GLuint kVertexShaderServiceId = 301; 145 static const GLuint kVertexShaderServiceId = 301;
146 static const GLuint kFragmentShaderServiceId = 302; 146 static const GLuint kFragmentShaderServiceId = 302;
147 147
148 static const char* kAttrib1Name; 148 static const char* kAttrib1Name;
149 static const char* kAttrib2Name; 149 static const char* kAttrib2Name;
150 static const char* kAttrib3Name; 150 static const char* kAttrib3Name;
151 static const GLint kAttrib1Size = 1; 151 static const GLint kAttrib1Size = 1;
152 static const GLint kAttrib2Size = 1; 152 static const GLint kAttrib2Size = 1;
153 static const GLint kAttrib3Size = 1; 153 static const GLint kAttrib3Size = 1;
154 static const int kAttrib1Precision = SH_PRECISION_MEDIUMP; 154 static const GLenum kAttrib1Precision = GL_MEDIUM_FLOAT;
155 static const int kAttrib2Precision = SH_PRECISION_HIGHP; 155 static const GLenum kAttrib2Precision = GL_HIGH_FLOAT;
156 static const int kAttrib3Precision = SH_PRECISION_LOWP; 156 static const GLenum kAttrib3Precision = GL_LOW_FLOAT;
157 static const int kAttribStaticUse = 0; 157 static const bool kAttribStaticUse = false;
158 static const GLint kAttrib1Location = 0; 158 static const GLint kAttrib1Location = 0;
159 static const GLint kAttrib2Location = 1; 159 static const GLint kAttrib2Location = 1;
160 static const GLint kAttrib3Location = 2; 160 static const GLint kAttrib3Location = 2;
161 static const GLenum kAttrib1Type = GL_FLOAT_VEC4; 161 static const GLenum kAttrib1Type = GL_FLOAT_VEC4;
162 static const GLenum kAttrib2Type = GL_FLOAT_VEC2; 162 static const GLenum kAttrib2Type = GL_FLOAT_VEC2;
163 static const GLenum kAttrib3Type = GL_FLOAT_VEC3; 163 static const GLenum kAttrib3Type = GL_FLOAT_VEC3;
164 static const GLint kInvalidAttribLocation = 30; 164 static const GLint kInvalidAttribLocation = 30;
165 static const GLint kBadAttribIndex = kNumVertexAttribs; 165 static const GLint kBadAttribIndex = kNumVertexAttribs;
166 166
167 static const char* kUniform1Name; 167 static const char* kUniform1Name;
168 static const char* kUniform2Name; 168 static const char* kUniform2Name;
169 static const char* kUniform3BadName; 169 static const char* kUniform2NameWithArrayIndex;
170 static const char* kUniform3GoodName; 170 static const char* kUniform3Name;
171 static const char* kUniform3NameWithArrayIndex;
171 static const GLint kUniform1Size = 1; 172 static const GLint kUniform1Size = 1;
172 static const GLint kUniform2Size = 3; 173 static const GLint kUniform2Size = 3;
173 static const GLint kUniform3Size = 2; 174 static const GLint kUniform3Size = 2;
174 static const int kUniform1Precision = SH_PRECISION_LOWP; 175 static const int kUniform1Precision = SH_PRECISION_LOWP;
175 static const int kUniform2Precision = SH_PRECISION_MEDIUMP; 176 static const int kUniform2Precision = SH_PRECISION_MEDIUMP;
176 static const int kUniform3Precision = SH_PRECISION_HIGHP; 177 static const int kUniform3Precision = SH_PRECISION_HIGHP;
177 static const int kUniform1StaticUse = 1; 178 static const int kUniform1StaticUse = 1;
178 static const int kUniform2StaticUse = 1; 179 static const int kUniform2StaticUse = 1;
179 static const int kUniform3StaticUse = 1; 180 static const int kUniform3StaticUse = 1;
180 static const GLint kUniform1FakeLocation = 0; // These are hard coded 181 static const GLint kUniform1FakeLocation = 0; // These are hard coded
(...skipping 18 matching lines...) Expand all
199 typedef TestHelper::AttribInfo AttribInfo; 200 typedef TestHelper::AttribInfo AttribInfo;
200 typedef TestHelper::UniformInfo UniformInfo; 201 typedef TestHelper::UniformInfo UniformInfo;
201 202
202 typedef enum { 203 typedef enum {
203 kVarUniform, 204 kVarUniform,
204 kVarVarying, 205 kVarVarying,
205 kVarAttribute 206 kVarAttribute
206 } VarCategory; 207 } VarCategory;
207 208
208 typedef struct { 209 typedef struct {
209 int type; 210 GLenum type;
210 int size; 211 GLint size;
211 int precision; 212 GLenum precision;
212 int static_use; 213 bool static_use;
213 std::string name; 214 std::string name;
214 VarCategory category; 215 VarCategory category;
215 } VarInfo; 216 } VarInfo;
216 217
217 virtual void SetUp() { 218 virtual void SetUp() {
218 GpuServiceTest::SetUp(); 219 GpuServiceTest::SetUp();
219 220
220 SetupDefaultShaderExpectations(); 221 SetupDefaultShaderExpectations();
221 222
222 Shader* vertex_shader = shader_manager_.CreateShader( 223 Shader* vertex_shader = shader_manager_.CreateShader(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 Program* SetupShaderVariableTest(const VarInfo* vertex_variables, 277 Program* SetupShaderVariableTest(const VarInfo* vertex_variables,
277 size_t vertex_variable_size, 278 size_t vertex_variable_size,
278 const VarInfo* fragment_variables, 279 const VarInfo* fragment_variables,
279 size_t fragment_variable_size) { 280 size_t fragment_variable_size) {
280 // Set up shader 281 // Set up shader
281 const GLuint kVShaderClientId = 1; 282 const GLuint kVShaderClientId = 1;
282 const GLuint kVShaderServiceId = 11; 283 const GLuint kVShaderServiceId = 11;
283 const GLuint kFShaderClientId = 2; 284 const GLuint kFShaderClientId = 2;
284 const GLuint kFShaderServiceId = 12; 285 const GLuint kFShaderServiceId = 12;
285 286
286 ShaderTranslator::VariableMap vertex_attrib_map; 287 AttributeMap vertex_attrib_map;
287 ShaderTranslator::VariableMap vertex_uniform_map; 288 UniformMap vertex_uniform_map;
288 ShaderTranslator::VariableMap vertex_varying_map; 289 VaryingMap vertex_varying_map;
289 for (size_t ii = 0; ii < vertex_variable_size; ++ii) { 290 for (size_t ii = 0; ii < vertex_variable_size; ++ii) {
290 ShaderTranslator::VariableMap* map = NULL;
291 switch (vertex_variables[ii].category) { 291 switch (vertex_variables[ii].category) {
292 case kVarAttribute: 292 case kVarAttribute:
293 map = &vertex_attrib_map; 293 vertex_attrib_map[vertex_variables[ii].name] =
294 TestHelper::ConstructAttribute(
295 vertex_variables[ii].type,
296 vertex_variables[ii].size,
297 vertex_variables[ii].precision,
298 vertex_variables[ii].static_use,
299 vertex_variables[ii].name);
294 break; 300 break;
295 case kVarUniform: 301 case kVarUniform:
296 map = &vertex_uniform_map; 302 vertex_uniform_map[vertex_variables[ii].name] =
303 TestHelper::ConstructUniform(
304 vertex_variables[ii].type,
305 vertex_variables[ii].size,
306 vertex_variables[ii].precision,
307 vertex_variables[ii].static_use,
308 vertex_variables[ii].name);
297 break; 309 break;
298 case kVarVarying: 310 case kVarVarying:
299 map = &vertex_varying_map; 311 vertex_varying_map[vertex_variables[ii].name] =
312 TestHelper::ConstructVarying(
313 vertex_variables[ii].type,
314 vertex_variables[ii].size,
315 vertex_variables[ii].precision,
316 vertex_variables[ii].static_use,
317 vertex_variables[ii].name);
300 break; 318 break;
301 default: 319 default:
302 NOTREACHED(); 320 NOTREACHED();
303 } 321 }
304 (*map)[vertex_variables[ii].name] =
305 ShaderTranslator::VariableInfo(vertex_variables[ii].type,
306 vertex_variables[ii].size,
307 vertex_variables[ii].precision,
308 vertex_variables[ii].static_use,
309 vertex_variables[ii].name);
310 } 322 }
311 323
312 ShaderTranslator::VariableMap frag_attrib_map; 324 AttributeMap frag_attrib_map;
313 ShaderTranslator::VariableMap frag_uniform_map; 325 UniformMap frag_uniform_map;
314 ShaderTranslator::VariableMap frag_varying_map; 326 VaryingMap frag_varying_map;
315 for (size_t ii = 0; ii < fragment_variable_size; ++ii) { 327 for (size_t ii = 0; ii < fragment_variable_size; ++ii) {
316 ShaderTranslator::VariableMap* map = NULL;
317 switch (fragment_variables[ii].category) { 328 switch (fragment_variables[ii].category) {
318 case kVarAttribute: 329 case kVarAttribute:
319 map = &frag_attrib_map; 330 frag_attrib_map[fragment_variables[ii].name] =
331 TestHelper::ConstructAttribute(
332 fragment_variables[ii].type,
333 fragment_variables[ii].size,
334 fragment_variables[ii].precision,
335 fragment_variables[ii].static_use,
336 fragment_variables[ii].name);
320 break; 337 break;
321 case kVarUniform: 338 case kVarUniform:
322 map = &frag_uniform_map; 339 frag_uniform_map[fragment_variables[ii].name] =
340 TestHelper::ConstructUniform(
341 fragment_variables[ii].type,
342 fragment_variables[ii].size,
343 fragment_variables[ii].precision,
344 fragment_variables[ii].static_use,
345 fragment_variables[ii].name);
323 break; 346 break;
324 case kVarVarying: 347 case kVarVarying:
325 map = &frag_varying_map; 348 frag_varying_map[fragment_variables[ii].name] =
349 TestHelper::ConstructVarying(
350 fragment_variables[ii].type,
351 fragment_variables[ii].size,
352 fragment_variables[ii].precision,
353 fragment_variables[ii].static_use,
354 fragment_variables[ii].name);
326 break; 355 break;
327 default: 356 default:
328 NOTREACHED(); 357 NOTREACHED();
329 } 358 }
330 (*map)[fragment_variables[ii].name] =
331 ShaderTranslator::VariableInfo(fragment_variables[ii].type,
332 fragment_variables[ii].size,
333 fragment_variables[ii].precision,
334 fragment_variables[ii].static_use,
335 fragment_variables[ii].name);
336 } 359 }
337 360
338 // Check we can create shader. 361 // Check we can create shader.
339 Shader* vshader = shader_manager_.CreateShader( 362 Shader* vshader = shader_manager_.CreateShader(
340 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); 363 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER);
341 Shader* fshader = shader_manager_.CreateShader( 364 Shader* fshader = shader_manager_.CreateShader(
342 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); 365 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER);
343 // Check shader got created. 366 // Check shader got created.
344 EXPECT_TRUE(vshader != NULL && fshader != NULL); 367 EXPECT_TRUE(vshader != NULL && fshader != NULL);
345 // Set Status 368 // Set Status
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 kUniform1RealLocation, 450 kUniform1RealLocation,
428 kUniform1DesiredLocation, 451 kUniform1DesiredLocation,
429 kUniform1Name, 452 kUniform1Name,
430 }, 453 },
431 { kUniform2Name, 454 { kUniform2Name,
432 kUniform2Size, 455 kUniform2Size,
433 kUniform2Type, 456 kUniform2Type,
434 kUniform2FakeLocation, 457 kUniform2FakeLocation,
435 kUniform2RealLocation, 458 kUniform2RealLocation,
436 kUniform2DesiredLocation, 459 kUniform2DesiredLocation,
437 kUniform2Name, 460 kUniform2NameWithArrayIndex,
438 }, 461 },
439 { kUniform3BadName, 462 { kUniform3Name,
440 kUniform3Size, 463 kUniform3Size,
441 kUniform3Type, 464 kUniform3Type,
442 kUniform3FakeLocation, 465 kUniform3FakeLocation,
443 kUniform3RealLocation, 466 kUniform3RealLocation,
444 kUniform3DesiredLocation, 467 kUniform3DesiredLocation,
445 kUniform3GoodName, 468 kUniform3NameWithArrayIndex,
446 }, 469 },
447 }; 470 };
448 471
449 const size_t ProgramManagerWithShaderTest::kNumUniforms = 472 const size_t ProgramManagerWithShaderTest::kNumUniforms =
450 arraysize(ProgramManagerWithShaderTest::kUniforms); 473 arraysize(ProgramManagerWithShaderTest::kUniforms);
451 474
452 const char* ProgramManagerWithShaderTest::kAttrib1Name = "attrib1"; 475 const char* ProgramManagerWithShaderTest::kAttrib1Name = "attrib1";
453 const char* ProgramManagerWithShaderTest::kAttrib2Name = "attrib2"; 476 const char* ProgramManagerWithShaderTest::kAttrib2Name = "attrib2";
454 const char* ProgramManagerWithShaderTest::kAttrib3Name = "attrib3"; 477 const char* ProgramManagerWithShaderTest::kAttrib3Name = "attrib3";
455 const char* ProgramManagerWithShaderTest::kUniform1Name = "uniform1"; 478 const char* ProgramManagerWithShaderTest::kUniform1Name = "uniform1";
456 // Correctly has array spec. 479 const char* ProgramManagerWithShaderTest::kUniform2Name = "uniform2";
457 const char* ProgramManagerWithShaderTest::kUniform2Name = "uniform2[0]"; 480 const char* ProgramManagerWithShaderTest::kUniform2NameWithArrayIndex =
458 // Incorrectly missing array spec. 481 "uniform2[0]";
459 const char* ProgramManagerWithShaderTest::kUniform3BadName = "uniform3"; 482 const char* ProgramManagerWithShaderTest::kUniform3Name = "uniform3";
460 const char* ProgramManagerWithShaderTest::kUniform3GoodName = "uniform3[0]"; 483 const char* ProgramManagerWithShaderTest::kUniform3NameWithArrayIndex =
484 "uniform3[0]";
461 485
462 TEST_F(ProgramManagerWithShaderTest, GetAttribInfos) { 486 TEST_F(ProgramManagerWithShaderTest, GetAttribInfos) {
463 const Program* program = manager_.GetProgram(kClientProgramId); 487 const Program* program = manager_.GetProgram(kClientProgramId);
464 ASSERT_TRUE(program != NULL); 488 ASSERT_TRUE(program != NULL);
465 const Program::AttribInfoVector& infos = 489 const Program::AttribInfoVector& infos =
466 program->GetAttribInfos(); 490 program->GetAttribInfos();
467 ASSERT_EQ(kNumAttribs, infos.size()); 491 ASSERT_EQ(kNumAttribs, infos.size());
468 for (size_t ii = 0; ii < kNumAttribs; ++ii) { 492 for (size_t ii = 0; ii < kNumAttribs; ++ii) {
469 const Program::VertexAttrib& info = infos[ii]; 493 const Program::VertexAttrib& info = infos[ii];
470 const AttribInfo& expected = kAttribs[ii]; 494 const AttribInfo& expected = kAttribs[ii];
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 ASSERT_TRUE(info != NULL); 531 ASSERT_TRUE(info != NULL);
508 EXPECT_EQ(kUniform1Size, info->size); 532 EXPECT_EQ(kUniform1Size, info->size);
509 EXPECT_EQ(kUniform1Type, info->type); 533 EXPECT_EQ(kUniform1Type, info->type);
510 EXPECT_EQ(kUniform1RealLocation, info->element_locations[0]); 534 EXPECT_EQ(kUniform1RealLocation, info->element_locations[0]);
511 EXPECT_STREQ(kUniform1Name, info->name.c_str()); 535 EXPECT_STREQ(kUniform1Name, info->name.c_str());
512 info = program->GetUniformInfo(1); 536 info = program->GetUniformInfo(1);
513 ASSERT_TRUE(info != NULL); 537 ASSERT_TRUE(info != NULL);
514 EXPECT_EQ(kUniform2Size, info->size); 538 EXPECT_EQ(kUniform2Size, info->size);
515 EXPECT_EQ(kUniform2Type, info->type); 539 EXPECT_EQ(kUniform2Type, info->type);
516 EXPECT_EQ(kUniform2RealLocation, info->element_locations[0]); 540 EXPECT_EQ(kUniform2RealLocation, info->element_locations[0]);
517 EXPECT_STREQ(kUniform2Name, info->name.c_str()); 541 EXPECT_STREQ(kUniform2NameWithArrayIndex, info->name.c_str());
518 info = program->GetUniformInfo(2); 542 info = program->GetUniformInfo(2);
519 // We emulate certain OpenGL drivers by supplying the name without 543 // We emulate certain OpenGL drivers by supplying the name without
520 // the array spec. Our implementation should correctly add the required spec. 544 // the array spec. Our implementation should correctly add the required spec.
521 ASSERT_TRUE(info != NULL); 545 ASSERT_TRUE(info != NULL);
522 EXPECT_EQ(kUniform3Size, info->size); 546 EXPECT_EQ(kUniform3Size, info->size);
523 EXPECT_EQ(kUniform3Type, info->type); 547 EXPECT_EQ(kUniform3Type, info->type);
524 EXPECT_EQ(kUniform3RealLocation, info->element_locations[0]); 548 EXPECT_EQ(kUniform3RealLocation, info->element_locations[0]);
525 EXPECT_STREQ(kUniform3GoodName, info->name.c_str()); 549 EXPECT_STREQ(kUniform3NameWithArrayIndex, info->name.c_str());
526 EXPECT_TRUE(program->GetUniformInfo(kInvalidIndex) == NULL); 550 EXPECT_TRUE(program->GetUniformInfo(kInvalidIndex) == NULL);
527 } 551 }
528 552
529 TEST_F(ProgramManagerWithShaderTest, AttachDetachShader) { 553 TEST_F(ProgramManagerWithShaderTest, AttachDetachShader) {
530 static const GLuint kClientProgramId = 124; 554 static const GLuint kClientProgramId = 124;
531 static const GLuint kServiceProgramId = 457; 555 static const GLuint kServiceProgramId = 457;
532 Program* program = manager_.CreateProgram( 556 Program* program = manager_.CreateProgram(
533 kClientProgramId, kServiceProgramId); 557 kClientProgramId, kServiceProgramId);
534 ASSERT_TRUE(program != NULL); 558 ASSERT_TRUE(program != NULL);
535 EXPECT_FALSE(program->CanLink()); 559 EXPECT_FALSE(program->CanLink());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 Program::UniformInfo* uniform = const_cast<Program::UniformInfo*>( 603 Program::UniformInfo* uniform = const_cast<Program::UniformInfo*>(
580 program->GetUniformInfo(2)); 604 program->GetUniformInfo(2));
581 ASSERT_TRUE(uniform != NULL && kUniform3Size == 2); 605 ASSERT_TRUE(uniform != NULL && kUniform3Size == 2);
582 EXPECT_EQ(kUniform3Size, uniform->size); 606 EXPECT_EQ(kUniform3Size, uniform->size);
583 uniform->element_locations[1] = -1; 607 uniform->element_locations[1] = -1;
584 EXPECT_EQ(kUniform1FakeLocation, 608 EXPECT_EQ(kUniform1FakeLocation,
585 program->GetUniformFakeLocation(kUniform1Name)); 609 program->GetUniformFakeLocation(kUniform1Name));
586 EXPECT_EQ(kUniform2FakeLocation, 610 EXPECT_EQ(kUniform2FakeLocation,
587 program->GetUniformFakeLocation(kUniform2Name)); 611 program->GetUniformFakeLocation(kUniform2Name));
588 EXPECT_EQ(kUniform3FakeLocation, 612 EXPECT_EQ(kUniform3FakeLocation,
589 program->GetUniformFakeLocation(kUniform3BadName)); 613 program->GetUniformFakeLocation(kUniform3Name));
590 // Check we can get uniform2 as "uniform2" even though the name is 614 // Check we can get uniform2 as "uniform2" even though the name is
591 // "uniform2[0]" 615 // "uniform2[0]"
592 EXPECT_EQ(kUniform2FakeLocation, 616 EXPECT_EQ(kUniform2FakeLocation,
593 program->GetUniformFakeLocation("uniform2")); 617 program->GetUniformFakeLocation("uniform2"));
594 // Check we can get uniform3 as "uniform3[0]" even though we simulated GL 618 // Check we can get uniform3 as "uniform3[0]" even though we simulated GL
595 // returning "uniform3" 619 // returning "uniform3"
596 EXPECT_EQ(kUniform3FakeLocation, 620 EXPECT_EQ(kUniform3FakeLocation,
597 program->GetUniformFakeLocation(kUniform3GoodName)); 621 program->GetUniformFakeLocation(kUniform3NameWithArrayIndex));
598 // Check that we can get the locations of the array elements > 1 622 // Check that we can get the locations of the array elements > 1
599 EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 1), 623 EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 1),
600 program->GetUniformFakeLocation("uniform2[1]")); 624 program->GetUniformFakeLocation("uniform2[1]"));
601 EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 2), 625 EXPECT_EQ(ProgramManager::MakeFakeLocation(kUniform2FakeLocation, 2),
602 program->GetUniformFakeLocation("uniform2[2]")); 626 program->GetUniformFakeLocation("uniform2[2]"));
603 EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform2[3]")); 627 EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform2[3]"));
604 EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform3[1]")); 628 EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform3[1]"));
605 EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform3[2]")); 629 EXPECT_EQ(-1, program->GetUniformFakeLocation("uniform3[2]"));
606 } 630 }
607 631
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 kUniform1RealLocation, 670 kUniform1RealLocation,
647 kUniform1DesiredLocation, 671 kUniform1DesiredLocation,
648 kUniform1Name, 672 kUniform1Name,
649 }, 673 },
650 { kUniform2Name, 674 { kUniform2Name,
651 kUniform2Size, 675 kUniform2Size,
652 kUniform2Type, 676 kUniform2Type,
653 kUniform2FakeLocation, 677 kUniform2FakeLocation,
654 kUniform2RealLocation, 678 kUniform2RealLocation,
655 kUniform2DesiredLocation, 679 kUniform2DesiredLocation,
656 kUniform2Name, 680 kUniform2NameWithArrayIndex,
657 }, 681 },
658 { kUniform3BadName, 682 { kUniform3Name,
659 kUniform3Size, 683 kUniform3Size,
660 kUniform3Type, 684 kUniform3Type,
661 kUniform3FakeLocation, 685 kUniform3FakeLocation,
662 kUniform3RealLocation, 686 kUniform3RealLocation,
663 kUniform3DesiredLocation, 687 kUniform3DesiredLocation,
664 kUniform3GoodName, 688 kUniform3NameWithArrayIndex,
665 }, 689 },
666 }; 690 };
667 const size_t kNumUniforms = arraysize(kUniforms); 691 const size_t kNumUniforms = arraysize(kUniforms);
668 static const GLuint kClientProgramId = 1234; 692 static const GLuint kClientProgramId = 1234;
669 static const GLuint kServiceProgramId = 5679; 693 static const GLuint kServiceProgramId = 5679;
670 const GLuint kVShaderClientId = 2001; 694 const GLuint kVShaderClientId = 2001;
671 const GLuint kFShaderClientId = 2002; 695 const GLuint kFShaderClientId = 2002;
672 const GLuint kVShaderServiceId = 3001; 696 const GLuint kVShaderServiceId = 3001;
673 const GLuint kFShaderServiceId = 3002; 697 const GLuint kFShaderServiceId = 3002;
674 SetupShader( 698 SetupShader(
(...skipping 16 matching lines...) Expand all
691 GLint value = 0; 715 GLint value = 0;
692 program->GetProgramiv(GL_ACTIVE_ATTRIBUTES, &value); 716 program->GetProgramiv(GL_ACTIVE_ATTRIBUTES, &value);
693 EXPECT_EQ(3, value); 717 EXPECT_EQ(3, value);
694 // Check that we skipped the "gl_" uniform. 718 // Check that we skipped the "gl_" uniform.
695 program->GetProgramiv(GL_ACTIVE_UNIFORMS, &value); 719 program->GetProgramiv(GL_ACTIVE_UNIFORMS, &value);
696 EXPECT_EQ(2, value); 720 EXPECT_EQ(2, value);
697 // Check that our max length adds room for the array spec and is not as long 721 // Check that our max length adds room for the array spec and is not as long
698 // as the "gl_" uniform we skipped. 722 // as the "gl_" uniform we skipped.
699 // +4u is to account for "gl_" and NULL terminator. 723 // +4u is to account for "gl_" and NULL terminator.
700 program->GetProgramiv(GL_ACTIVE_UNIFORM_MAX_LENGTH, &value); 724 program->GetProgramiv(GL_ACTIVE_UNIFORM_MAX_LENGTH, &value);
701 EXPECT_EQ(strlen(kUniform3BadName) + 4u, static_cast<size_t>(value)); 725 EXPECT_EQ(strlen(kUniform3Name) + 4u, static_cast<size_t>(value));
702 } 726 }
703 727
704 // Test the bug comparing similar array names is fixed. 728 // Test the bug comparing similar array names is fixed.
705 TEST_F(ProgramManagerWithShaderTest, SimilarArrayNames) { 729 TEST_F(ProgramManagerWithShaderTest, SimilarArrayNames) {
706 static const char* kUniform2Name = "u_nameLong[0]"; 730 static const char* kUniform2Name = "u_nameLong[0]";
707 static const char* kUniform3Name = "u_name[0]"; 731 static const char* kUniform3Name = "u_name[0]";
708 static const GLint kUniform2Size = 2; 732 static const GLint kUniform2Size = 2;
709 static const GLint kUniform3Size = 2; 733 static const GLint kUniform3Size = 2;
710 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { 734 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = {
711 { kUniform1Name, 735 { kUniform1Name,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 program->GetUniformFakeLocation(kUniform3Name)); 789 program->GetUniformFakeLocation(kUniform3Name));
766 } 790 }
767 791
768 // Some GL drivers incorrectly return the wrong type. For example they return 792 // Some GL drivers incorrectly return the wrong type. For example they return
769 // GL_FLOAT_VEC2 when they should return GL_FLOAT_MAT2. Check we handle this. 793 // GL_FLOAT_VEC2 when they should return GL_FLOAT_MAT2. Check we handle this.
770 TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { 794 TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) {
771 static GLenum kAttrib2BadType = GL_FLOAT_VEC2; 795 static GLenum kAttrib2BadType = GL_FLOAT_VEC2;
772 static GLenum kAttrib2GoodType = GL_FLOAT_MAT2; 796 static GLenum kAttrib2GoodType = GL_FLOAT_MAT2;
773 static GLenum kUniform2BadType = GL_FLOAT_VEC3; 797 static GLenum kUniform2BadType = GL_FLOAT_VEC3;
774 static GLenum kUniform2GoodType = GL_FLOAT_MAT3; 798 static GLenum kUniform2GoodType = GL_FLOAT_MAT3;
775 ShaderTranslator::VariableMap attrib_map; 799 AttributeMap attrib_map;
776 ShaderTranslator::VariableMap uniform_map; 800 UniformMap uniform_map;
777 ShaderTranslator::VariableMap varying_map; 801 VaryingMap varying_map;
778 attrib_map[kAttrib1Name] = ShaderTranslatorInterface::VariableInfo( 802 attrib_map[kAttrib1Name] = TestHelper::ConstructAttribute(
779 kAttrib1Type, kAttrib1Size, kAttrib1Precision, 803 kAttrib1Type, kAttrib1Size, kAttrib1Precision,
780 kAttribStaticUse, kAttrib1Name); 804 kAttribStaticUse, kAttrib1Name);
781 attrib_map[kAttrib2Name] = ShaderTranslatorInterface::VariableInfo( 805 attrib_map[kAttrib2Name] = TestHelper::ConstructAttribute(
782 kAttrib2GoodType, kAttrib2Size, kAttrib2Precision, 806 kAttrib2GoodType, kAttrib2Size, kAttrib2Precision,
783 kAttribStaticUse, kAttrib2Name); 807 kAttribStaticUse, kAttrib2Name);
784 attrib_map[kAttrib3Name] = ShaderTranslatorInterface::VariableInfo( 808 attrib_map[kAttrib3Name] = TestHelper::ConstructAttribute(
785 kAttrib3Type, kAttrib3Size, kAttrib3Precision, 809 kAttrib3Type, kAttrib3Size, kAttrib3Precision,
786 kAttribStaticUse, kAttrib3Name); 810 kAttribStaticUse, kAttrib3Name);
787 uniform_map[kUniform1Name] = ShaderTranslatorInterface::VariableInfo( 811 uniform_map[kUniform1Name] = TestHelper::ConstructUniform(
788 kUniform1Type, kUniform1Size, kUniform1Precision, 812 kUniform1Type, kUniform1Size, kUniform1Precision,
789 kUniform1StaticUse, kUniform1Name); 813 kUniform1StaticUse, kUniform1Name);
790 uniform_map[kUniform2Name] = ShaderTranslatorInterface::VariableInfo( 814 uniform_map[kUniform2Name] = TestHelper::ConstructUniform(
791 kUniform2GoodType, kUniform2Size, kUniform2Precision, 815 kUniform2GoodType, kUniform2Size, kUniform2Precision,
792 kUniform2StaticUse, kUniform2Name); 816 kUniform2StaticUse, kUniform2Name);
793 uniform_map[kUniform3GoodName] = ShaderTranslatorInterface::VariableInfo( 817 uniform_map[kUniform3Name] = TestHelper::ConstructUniform(
794 kUniform3Type, kUniform3Size, kUniform3Precision, 818 kUniform3Type, kUniform3Size, kUniform3Precision,
795 kUniform3StaticUse, kUniform3GoodName); 819 kUniform3StaticUse, kUniform3Name);
796 const GLuint kVShaderClientId = 2001; 820 const GLuint kVShaderClientId = 2001;
797 const GLuint kFShaderClientId = 2002; 821 const GLuint kFShaderClientId = 2002;
798 const GLuint kVShaderServiceId = 3001; 822 const GLuint kVShaderServiceId = 3001;
799 const GLuint kFShaderServiceId = 3002; 823 const GLuint kFShaderServiceId = 3002;
800 Shader* vshader = shader_manager_.CreateShader( 824 Shader* vshader = shader_manager_.CreateShader(
801 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); 825 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER);
802 ASSERT_TRUE(vshader != NULL); 826 ASSERT_TRUE(vshader != NULL);
803 TestHelper::SetShaderStates( 827 TestHelper::SetShaderStates(
804 gl_.get(), vshader, true, NULL, NULL, 828 gl_.get(), vshader, true, NULL, NULL,
805 &attrib_map, &uniform_map, &varying_map, NULL); 829 &attrib_map, &uniform_map, &varying_map, NULL);
(...skipping 16 matching lines...) Expand all
822 kUniform1RealLocation, 846 kUniform1RealLocation,
823 kUniform1DesiredLocation, 847 kUniform1DesiredLocation,
824 kUniform1Name, 848 kUniform1Name,
825 }, 849 },
826 { kUniform2Name, 850 { kUniform2Name,
827 kUniform2Size, 851 kUniform2Size,
828 kUniform2BadType, 852 kUniform2BadType,
829 kUniform2FakeLocation, 853 kUniform2FakeLocation,
830 kUniform2RealLocation, 854 kUniform2RealLocation,
831 kUniform2DesiredLocation, 855 kUniform2DesiredLocation,
832 kUniform2Name, 856 kUniform2NameWithArrayIndex,
833 }, 857 },
834 { kUniform3BadName, 858 { kUniform3Name,
835 kUniform3Size, 859 kUniform3Size,
836 kUniform3Type, 860 kUniform3Type,
837 kUniform3FakeLocation, 861 kUniform3FakeLocation,
838 kUniform3RealLocation, 862 kUniform3RealLocation,
839 kUniform3DesiredLocation, 863 kUniform3DesiredLocation,
840 kUniform3GoodName, 864 kUniform3NameWithArrayIndex,
841 }, 865 },
842 }; 866 };
843 const size_t kNumAttribs= arraysize(kAttribs); 867 const size_t kNumAttribs= arraysize(kAttribs);
844 const size_t kNumUniforms = arraysize(kUniforms); 868 const size_t kNumUniforms = arraysize(kUniforms);
845 static const GLuint kClientProgramId = 1234; 869 static const GLuint kClientProgramId = 1234;
846 static const GLuint kServiceProgramId = 5679; 870 static const GLuint kServiceProgramId = 5679;
847 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, 871 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
848 kServiceProgramId); 872 kServiceProgramId);
849 Program* program = manager_.CreateProgram( 873 Program* program = manager_.CreateProgram(
850 kClientProgramId, kServiceProgramId); 874 kClientProgramId, kServiceProgramId);
851 ASSERT_TRUE(program!= NULL); 875 ASSERT_TRUE(program!= NULL);
852 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); 876 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader));
853 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); 877 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader));
854 program->Link(NULL, NULL, NULL, Program::kCountOnlyStaticallyUsed, 878 program->Link(NULL, NULL, NULL, Program::kCountOnlyStaticallyUsed,
855 base::Bind(&ShaderCacheCb)); 879 base::Bind(&ShaderCacheCb));
856 // Check that we got the good type, not the bad. 880 // Check that we got the good type, not the bad.
857 // Check Attribs 881 // Check Attribs
858 for (unsigned index = 0; index < kNumAttribs; ++index) { 882 for (unsigned index = 0; index < kNumAttribs; ++index) {
859 const Program::VertexAttrib* attrib_info = 883 const Program::VertexAttrib* attrib_info =
860 program->GetAttribInfo(index); 884 program->GetAttribInfo(index);
861 ASSERT_TRUE(attrib_info != NULL); 885 ASSERT_TRUE(attrib_info != NULL);
862 ShaderTranslator::VariableMap::const_iterator it = attrib_map.find( 886 size_t pos = attrib_info->name.find_first_of("[.");
863 attrib_info->name); 887 std::string top_name;
888 if (pos == std::string::npos)
889 top_name = attrib_info->name;
890 else
891 top_name = attrib_info->name.substr(0, pos);
892 AttributeMap::const_iterator it = attrib_map.find(top_name);
864 ASSERT_TRUE(it != attrib_map.end()); 893 ASSERT_TRUE(it != attrib_map.end());
865 EXPECT_EQ(it->first, attrib_info->name); 894 const sh::ShaderVariable* info;
866 EXPECT_EQ(static_cast<GLenum>(it->second.type), attrib_info->type); 895 std::string original_name;
867 EXPECT_EQ(it->second.size, attrib_info->size); 896 EXPECT_TRUE(it->second.findInfoByMappedName(
868 EXPECT_EQ(it->second.name, attrib_info->name); 897 attrib_info->name, &info, &original_name));
898 EXPECT_EQ(info->type, attrib_info->type);
899 EXPECT_EQ(info->arraySize, attrib_info->size);
900 EXPECT_STREQ(original_name.c_str(), attrib_info->name.c_str());
Ken Russell (switch to Gerrit) 2014/10/07 03:35:26 Can you not use EXPECT_EQ(original_name, attrib_in
Zhenyao Mo 2014/10/07 18:23:41 I guess no good reason. It's just my habit to use
869 } 901 }
870 // Check Uniforms 902 // Check Uniforms
871 for (unsigned index = 0; index < kNumUniforms; ++index) { 903 for (unsigned index = 0; index < kNumUniforms; ++index) {
872 const Program::UniformInfo* uniform_info = 904 const Program::UniformInfo* uniform_info = program->GetUniformInfo(index);
873 program->GetUniformInfo(index);
874 ASSERT_TRUE(uniform_info != NULL); 905 ASSERT_TRUE(uniform_info != NULL);
875 ShaderTranslator::VariableMap::const_iterator it = uniform_map.find( 906 size_t pos = uniform_info->name.find_first_of("[.");
876 uniform_info->name); 907 std::string top_name;
908 if (pos == std::string::npos)
909 top_name = uniform_info->name;
910 else
911 top_name = uniform_info->name.substr(0, pos);
912 UniformMap::const_iterator it = uniform_map.find(top_name);
877 ASSERT_TRUE(it != uniform_map.end()); 913 ASSERT_TRUE(it != uniform_map.end());
878 EXPECT_EQ(it->first, uniform_info->name); 914 const sh::ShaderVariable* info;
879 EXPECT_EQ(static_cast<GLenum>(it->second.type), uniform_info->type); 915 std::string original_name;
880 EXPECT_EQ(it->second.size, uniform_info->size); 916 EXPECT_TRUE(it->second.findInfoByMappedName(
881 EXPECT_EQ(it->second.name, uniform_info->name); 917 uniform_info->name, &info, &original_name));
918 EXPECT_EQ(info->type, uniform_info->type);
919 EXPECT_EQ(info->arraySize, uniform_info->size);
920 EXPECT_STREQ(original_name.c_str(), uniform_info->name.c_str());
882 } 921 }
883 } 922 }
884 923
885 TEST_F(ProgramManagerWithShaderTest, ProgramInfoUseCount) { 924 TEST_F(ProgramManagerWithShaderTest, ProgramInfoUseCount) {
886 static const GLuint kClientProgramId = 124; 925 static const GLuint kClientProgramId = 124;
887 static const GLuint kServiceProgramId = 457; 926 static const GLuint kServiceProgramId = 457;
888 Program* program = manager_.CreateProgram( 927 Program* program = manager_.CreateProgram(
889 kClientProgramId, kServiceProgramId); 928 kClientProgramId, kServiceProgramId);
890 ASSERT_TRUE(program != NULL); 929 ASSERT_TRUE(program != NULL);
891 EXPECT_FALSE(program->CanLink()); 930 EXPECT_FALSE(program->CanLink());
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 ++input; 1118 ++input;
1080 } 1119 }
1081 } 1120 }
1082 1121
1083 TEST_F(ProgramManagerWithShaderTest, BindAttribLocationConflicts) { 1122 TEST_F(ProgramManagerWithShaderTest, BindAttribLocationConflicts) {
1084 // Set up shader 1123 // Set up shader
1085 const GLuint kVShaderClientId = 1; 1124 const GLuint kVShaderClientId = 1;
1086 const GLuint kVShaderServiceId = 11; 1125 const GLuint kVShaderServiceId = 11;
1087 const GLuint kFShaderClientId = 2; 1126 const GLuint kFShaderClientId = 2;
1088 const GLuint kFShaderServiceId = 12; 1127 const GLuint kFShaderServiceId = 12;
1089 ShaderTranslator::VariableMap attrib_map; 1128 AttributeMap attrib_map;
1090 for (uint32 ii = 0; ii < kNumAttribs; ++ii) { 1129 for (uint32 ii = 0; ii < kNumAttribs; ++ii) {
1091 attrib_map[kAttribs[ii].name] = ShaderTranslatorInterface::VariableInfo( 1130 attrib_map[kAttribs[ii].name] = TestHelper::ConstructAttribute(
1092 kAttribs[ii].type, 1131 kAttribs[ii].type,
1093 kAttribs[ii].size, 1132 kAttribs[ii].size,
1094 SH_PRECISION_MEDIUMP, 1133 SH_PRECISION_MEDIUMP,
1095 kAttribStaticUse, 1134 kAttribStaticUse,
1096 kAttribs[ii].name); 1135 kAttribs[ii].name);
1097 } 1136 }
1098 // Check we can create shader. 1137 // Check we can create shader.
1099 Shader* vshader = shader_manager_.CreateShader( 1138 Shader* vshader = shader_manager_.CreateShader(
1100 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); 1139 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER);
1101 Shader* fshader = shader_manager_.CreateShader( 1140 Shader* fshader = shader_manager_.CreateShader(
1102 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); 1141 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER);
1103 // Check shader got created. 1142 // Check shader got created.
1104 ASSERT_TRUE(vshader != NULL && fshader != NULL); 1143 ASSERT_TRUE(vshader != NULL && fshader != NULL);
1105 // Set Status 1144 // Set Status
1106 TestHelper::SetShaderStates( 1145 TestHelper::SetShaderStates(
1107 gl_.get(), vshader, true, NULL, NULL, &attrib_map, NULL, NULL, NULL); 1146 gl_.get(), vshader, true, NULL, NULL, &attrib_map, NULL, NULL, NULL);
1108 // Check attrib infos got copied. 1147 // Check attrib infos got copied.
1109 for (ShaderTranslator::VariableMap::const_iterator it = attrib_map.begin(); 1148 for (AttributeMap::const_iterator it = attrib_map.begin();
1110 it != attrib_map.end(); ++it) { 1149 it != attrib_map.end(); ++it) {
1111 const Shader::VariableInfo* variable_info = 1150 const sh::Attribute* variable_info =
1112 vshader->GetAttribInfo(it->first); 1151 vshader->GetAttribInfo(it->first);
1113 ASSERT_TRUE(variable_info != NULL); 1152 ASSERT_TRUE(variable_info != NULL);
1114 EXPECT_EQ(it->second.type, variable_info->type); 1153 EXPECT_EQ(it->second.type, variable_info->type);
1115 EXPECT_EQ(it->second.size, variable_info->size); 1154 EXPECT_EQ(it->second.arraySize, variable_info->arraySize);
1116 EXPECT_EQ(it->second.precision, variable_info->precision); 1155 EXPECT_EQ(it->second.precision, variable_info->precision);
1117 EXPECT_EQ(it->second.static_use, variable_info->static_use); 1156 EXPECT_EQ(it->second.staticUse, variable_info->staticUse);
1118 EXPECT_EQ(it->second.name, variable_info->name); 1157 EXPECT_EQ(it->second.name, variable_info->name);
1119 } 1158 }
1120 TestHelper::SetShaderStates( 1159 TestHelper::SetShaderStates(
1121 gl_.get(), fshader, true, NULL, NULL, &attrib_map, NULL, NULL, NULL); 1160 gl_.get(), fshader, true, NULL, NULL, &attrib_map, NULL, NULL, NULL);
1122 1161
1123 // Set up program 1162 // Set up program
1124 const GLuint kClientProgramId = 6666; 1163 const GLuint kClientProgramId = 6666;
1125 const GLuint kServiceProgramId = 8888; 1164 const GLuint kServiceProgramId = 8888;
1126 Program* program = 1165 Program* program =
1127 manager_.CreateProgram(kClientProgramId, kServiceProgramId); 1166 manager_.CreateProgram(kClientProgramId, kServiceProgramId);
(...skipping 21 matching lines...) Expand all
1149 EXPECT_TRUE(LinkAsExpected(program, false)); 1188 EXPECT_TRUE(LinkAsExpected(program, false));
1150 } 1189 }
1151 1190
1152 TEST_F(ProgramManagerWithShaderTest, UniformsPrecisionMismatch) { 1191 TEST_F(ProgramManagerWithShaderTest, UniformsPrecisionMismatch) {
1153 // Set up shader 1192 // Set up shader
1154 const GLuint kVShaderClientId = 1; 1193 const GLuint kVShaderClientId = 1;
1155 const GLuint kVShaderServiceId = 11; 1194 const GLuint kVShaderServiceId = 11;
1156 const GLuint kFShaderClientId = 2; 1195 const GLuint kFShaderClientId = 2;
1157 const GLuint kFShaderServiceId = 12; 1196 const GLuint kFShaderServiceId = 12;
1158 1197
1159 ShaderTranslator::VariableMap vertex_uniform_map; 1198 UniformMap vertex_uniform_map;
1160 vertex_uniform_map["a"] = ShaderTranslator::VariableInfo( 1199 vertex_uniform_map["a"] = TestHelper::ConstructUniform(
1161 1, 3, SH_PRECISION_MEDIUMP, 1, "a"); 1200 GL_FLOAT, 3, GL_MEDIUM_FLOAT, true, "a");
1162 ShaderTranslator::VariableMap frag_uniform_map; 1201 UniformMap frag_uniform_map;
1163 frag_uniform_map["a"] = ShaderTranslator::VariableInfo( 1202 frag_uniform_map["a"] = TestHelper::ConstructUniform(
1164 1, 3, SH_PRECISION_LOWP, 1, "a"); 1203 GL_FLOAT, 3, GL_LOW_FLOAT, true, "a");
1165 1204
1166 // Check we can create shader. 1205 // Check we can create shader.
1167 Shader* vshader = shader_manager_.CreateShader( 1206 Shader* vshader = shader_manager_.CreateShader(
1168 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); 1207 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER);
1169 Shader* fshader = shader_manager_.CreateShader( 1208 Shader* fshader = shader_manager_.CreateShader(
1170 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); 1209 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER);
1171 // Check shader got created. 1210 // Check shader got created.
1172 ASSERT_TRUE(vshader != NULL && fshader != NULL); 1211 ASSERT_TRUE(vshader != NULL && fshader != NULL);
1173 // Set Status 1212 // Set Status
1174 TestHelper::SetShaderStates( 1213 TestHelper::SetShaderStates(
(...skipping 16 matching lines...) Expand all
1191 1230
1192 EXPECT_TRUE(program->DetectUniformsMismatch(&conflicting_name)); 1231 EXPECT_TRUE(program->DetectUniformsMismatch(&conflicting_name));
1193 EXPECT_EQ("a", conflicting_name); 1232 EXPECT_EQ("a", conflicting_name);
1194 EXPECT_TRUE(LinkAsExpected(program, false)); 1233 EXPECT_TRUE(LinkAsExpected(program, false));
1195 } 1234 }
1196 1235
1197 // If a varying has different type in the vertex and fragment 1236 // If a varying has different type in the vertex and fragment
1198 // shader, linking should fail. 1237 // shader, linking should fail.
1199 TEST_F(ProgramManagerWithShaderTest, VaryingTypeMismatch) { 1238 TEST_F(ProgramManagerWithShaderTest, VaryingTypeMismatch) {
1200 const VarInfo kVertexVarying = 1239 const VarInfo kVertexVarying =
1201 { GL_FLOAT_VEC3, 1, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }; 1240 { GL_FLOAT_VEC3, 1, GL_MEDIUM_FLOAT, true, "a", kVarVarying };
1202 const VarInfo kFragmentVarying = 1241 const VarInfo kFragmentVarying =
1203 { GL_FLOAT_VEC4, 1, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }; 1242 { GL_FLOAT_VEC4, 1, GL_MEDIUM_FLOAT, true, "a", kVarVarying };
1204 Program* program = SetupShaderVariableTest( 1243 Program* program = SetupShaderVariableTest(
1205 &kVertexVarying, 1, &kFragmentVarying, 1); 1244 &kVertexVarying, 1, &kFragmentVarying, 1);
1206 1245
1207 std::string conflicting_name; 1246 std::string conflicting_name;
1208 1247
1209 EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name)); 1248 EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name));
1210 EXPECT_EQ("a", conflicting_name); 1249 EXPECT_EQ("a", conflicting_name);
1211 EXPECT_TRUE(LinkAsExpected(program, false)); 1250 EXPECT_TRUE(LinkAsExpected(program, false));
1212 } 1251 }
1213 1252
1214 // If a varying has different array size in the vertex and fragment 1253 // If a varying has different array size in the vertex and fragment
1215 // shader, linking should fail. 1254 // shader, linking should fail.
1216 TEST_F(ProgramManagerWithShaderTest, VaryingArraySizeMismatch) { 1255 TEST_F(ProgramManagerWithShaderTest, VaryingArraySizeMismatch) {
1217 const VarInfo kVertexVarying = 1256 const VarInfo kVertexVarying =
1218 { GL_FLOAT, 2, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }; 1257 { GL_FLOAT, 2, GL_MEDIUM_FLOAT, true, "a", kVarVarying };
1219 const VarInfo kFragmentVarying = 1258 const VarInfo kFragmentVarying =
1220 { GL_FLOAT, 3, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }; 1259 { GL_FLOAT, 3, GL_MEDIUM_FLOAT, true, "a", kVarVarying };
1221 Program* program = SetupShaderVariableTest( 1260 Program* program = SetupShaderVariableTest(
1222 &kVertexVarying, 1, &kFragmentVarying, 1); 1261 &kVertexVarying, 1, &kFragmentVarying, 1);
1223 1262
1224 std::string conflicting_name; 1263 std::string conflicting_name;
1225 1264
1226 EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name)); 1265 EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name));
1227 EXPECT_EQ("a", conflicting_name); 1266 EXPECT_EQ("a", conflicting_name);
1228 EXPECT_TRUE(LinkAsExpected(program, false)); 1267 EXPECT_TRUE(LinkAsExpected(program, false));
1229 } 1268 }
1230 1269
1231 // If a varying has different precision in the vertex and fragment 1270 // If a varying has different precision in the vertex and fragment
1232 // shader, linking should succeed. 1271 // shader, linking should succeed.
1233 TEST_F(ProgramManagerWithShaderTest, VaryingPrecisionMismatch) { 1272 TEST_F(ProgramManagerWithShaderTest, VaryingPrecisionMismatch) {
1234 const VarInfo kVertexVarying = 1273 const VarInfo kVertexVarying =
1235 { GL_FLOAT, 2, SH_PRECISION_HIGHP, 1, "a", kVarVarying }; 1274 { GL_FLOAT, 2, GL_HIGH_FLOAT, true, "a", kVarVarying };
1236 const VarInfo kFragmentVarying = 1275 const VarInfo kFragmentVarying =
1237 { GL_FLOAT, 2, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }; 1276 { GL_FLOAT, 2, GL_MEDIUM_FLOAT, true, "a", kVarVarying };
1238 Program* program = SetupShaderVariableTest( 1277 Program* program = SetupShaderVariableTest(
1239 &kVertexVarying, 1, &kFragmentVarying, 1); 1278 &kVertexVarying, 1, &kFragmentVarying, 1);
1240 1279
1241 std::string conflicting_name; 1280 std::string conflicting_name;
1242 1281
1243 EXPECT_FALSE(program->DetectVaryingsMismatch(&conflicting_name)); 1282 EXPECT_FALSE(program->DetectVaryingsMismatch(&conflicting_name));
1244 EXPECT_TRUE(conflicting_name.empty()); 1283 EXPECT_TRUE(conflicting_name.empty());
1245 EXPECT_TRUE(LinkAsExpected(program, true)); 1284 EXPECT_TRUE(LinkAsExpected(program, true));
1246 } 1285 }
1247 1286
1248 // If a varying is statically used in fragment shader but not 1287 // If a varying is statically used in fragment shader but not
1249 // declared in vertex shader, link should fail. 1288 // declared in vertex shader, link should fail.
1250 TEST_F(ProgramManagerWithShaderTest, VaryingMissing) { 1289 TEST_F(ProgramManagerWithShaderTest, VaryingMissing) {
1251 const VarInfo kFragmentVarying = 1290 const VarInfo kFragmentVarying =
1252 { GL_FLOAT, 3, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }; 1291 { GL_FLOAT, 3, GL_MEDIUM_FLOAT, true, "a", kVarVarying };
1253 Program* program = SetupShaderVariableTest( 1292 Program* program = SetupShaderVariableTest(
1254 NULL, 0, &kFragmentVarying, 1); 1293 NULL, 0, &kFragmentVarying, 1);
1255 1294
1256 std::string conflicting_name; 1295 std::string conflicting_name;
1257 1296
1258 EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name)); 1297 EXPECT_TRUE(program->DetectVaryingsMismatch(&conflicting_name));
1259 EXPECT_EQ("a", conflicting_name); 1298 EXPECT_EQ("a", conflicting_name);
1260 EXPECT_TRUE(LinkAsExpected(program, false)); 1299 EXPECT_TRUE(LinkAsExpected(program, false));
1261 } 1300 }
1262 1301
1263 // If a varying is declared but not statically used in fragment 1302 // If a varying is declared but not statically used in fragment
1264 // shader, even if it's not declared in vertex shader, link should 1303 // shader, even if it's not declared in vertex shader, link should
1265 // succeed. 1304 // succeed.
1266 TEST_F(ProgramManagerWithShaderTest, InactiveVarying) { 1305 TEST_F(ProgramManagerWithShaderTest, InactiveVarying) {
1267 const VarInfo kFragmentVarying = 1306 const VarInfo kFragmentVarying =
1268 { GL_FLOAT, 3, SH_PRECISION_MEDIUMP, 0, "a", kVarVarying }; 1307 { GL_FLOAT, 3, GL_MEDIUM_FLOAT, false, "a", kVarVarying };
1269 Program* program = SetupShaderVariableTest( 1308 Program* program = SetupShaderVariableTest(
1270 NULL, 0, &kFragmentVarying, 1); 1309 NULL, 0, &kFragmentVarying, 1);
1271 1310
1272 std::string conflicting_name; 1311 std::string conflicting_name;
1273 1312
1274 EXPECT_FALSE(program->DetectVaryingsMismatch(&conflicting_name)); 1313 EXPECT_FALSE(program->DetectVaryingsMismatch(&conflicting_name));
1275 EXPECT_TRUE(conflicting_name.empty()); 1314 EXPECT_TRUE(conflicting_name.empty());
1276 EXPECT_TRUE(LinkAsExpected(program, true)); 1315 EXPECT_TRUE(LinkAsExpected(program, true));
1277 } 1316 }
1278 1317
1279 // Uniforms and attributes are both global variables, thus sharing 1318 // Uniforms and attributes are both global variables, thus sharing
1280 // the same namespace. Any name conflicts should cause link 1319 // the same namespace. Any name conflicts should cause link
1281 // failure. 1320 // failure.
1282 TEST_F(ProgramManagerWithShaderTest, AttribUniformNameConflict) { 1321 TEST_F(ProgramManagerWithShaderTest, AttribUniformNameConflict) {
1283 const VarInfo kVertexAttribute = 1322 const VarInfo kVertexAttribute =
1284 { GL_FLOAT_VEC4, 1, SH_PRECISION_MEDIUMP, 1, "a", kVarAttribute }; 1323 { GL_FLOAT_VEC4, 1, GL_MEDIUM_FLOAT, true, "a", kVarAttribute };
1285 const VarInfo kFragmentUniform = 1324 const VarInfo kFragmentUniform =
1286 { GL_FLOAT_VEC4, 1, SH_PRECISION_MEDIUMP, 1, "a", kVarUniform }; 1325 { GL_FLOAT_VEC4, 1, GL_MEDIUM_FLOAT, true, "a", kVarUniform };
1287 Program* program = SetupShaderVariableTest( 1326 Program* program = SetupShaderVariableTest(
1288 &kVertexAttribute, 1, &kFragmentUniform, 1); 1327 &kVertexAttribute, 1, &kFragmentUniform, 1);
1289 1328
1290 std::string conflicting_name; 1329 std::string conflicting_name;
1291 1330
1292 EXPECT_TRUE(program->DetectGlobalNameConflicts(&conflicting_name)); 1331 EXPECT_TRUE(program->DetectGlobalNameConflicts(&conflicting_name));
1293 EXPECT_EQ("a", conflicting_name); 1332 EXPECT_EQ("a", conflicting_name);
1294 EXPECT_TRUE(LinkAsExpected(program, false)); 1333 EXPECT_TRUE(LinkAsExpected(program, false));
1295 } 1334 }
1296 1335
1297 // Varyings go over 8 rows. 1336 // Varyings go over 8 rows.
1298 TEST_F(ProgramManagerWithShaderTest, TooManyVaryings) { 1337 TEST_F(ProgramManagerWithShaderTest, TooManyVaryings) {
1299 const VarInfo kVertexVaryings[] = { 1338 const VarInfo kVertexVaryings[] = {
1300 { GL_FLOAT_VEC4, 4, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }, 1339 { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying },
1301 { GL_FLOAT_VEC4, 5, SH_PRECISION_MEDIUMP, 1, "b", kVarVarying } 1340 { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying }
1302 }; 1341 };
1303 const VarInfo kFragmentVaryings[] = { 1342 const VarInfo kFragmentVaryings[] = {
1304 { GL_FLOAT_VEC4, 4, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }, 1343 { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying },
1305 { GL_FLOAT_VEC4, 5, SH_PRECISION_MEDIUMP, 1, "b", kVarVarying } 1344 { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying }
1306 }; 1345 };
1307 Program* program = SetupShaderVariableTest( 1346 Program* program = SetupShaderVariableTest(
1308 kVertexVaryings, 2, kFragmentVaryings, 2); 1347 kVertexVaryings, 2, kFragmentVaryings, 2);
1309 1348
1310 EXPECT_FALSE( 1349 EXPECT_FALSE(
1311 program->CheckVaryingsPacking(Program::kCountOnlyStaticallyUsed)); 1350 program->CheckVaryingsPacking(Program::kCountOnlyStaticallyUsed));
1312 EXPECT_TRUE(LinkAsExpected(program, false)); 1351 EXPECT_TRUE(LinkAsExpected(program, false));
1313 } 1352 }
1314 1353
1315 // Varyings go over 8 rows but some are inactive 1354 // Varyings go over 8 rows but some are inactive
1316 TEST_F(ProgramManagerWithShaderTest, TooManyInactiveVaryings) { 1355 TEST_F(ProgramManagerWithShaderTest, TooManyInactiveVaryings) {
1317 const VarInfo kVertexVaryings[] = { 1356 const VarInfo kVertexVaryings[] = {
1318 { GL_FLOAT_VEC4, 4, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }, 1357 { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying },
1319 { GL_FLOAT_VEC4, 5, SH_PRECISION_MEDIUMP, 1, "b", kVarVarying } 1358 { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying }
1320 }; 1359 };
1321 const VarInfo kFragmentVaryings[] = { 1360 const VarInfo kFragmentVaryings[] = {
1322 { GL_FLOAT_VEC4, 4, SH_PRECISION_MEDIUMP, 0, "a", kVarVarying }, 1361 { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, false, "a", kVarVarying },
1323 { GL_FLOAT_VEC4, 5, SH_PRECISION_MEDIUMP, 1, "b", kVarVarying } 1362 { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying }
1324 }; 1363 };
1325 Program* program = SetupShaderVariableTest( 1364 Program* program = SetupShaderVariableTest(
1326 kVertexVaryings, 2, kFragmentVaryings, 2); 1365 kVertexVaryings, 2, kFragmentVaryings, 2);
1327 1366
1328 EXPECT_TRUE( 1367 EXPECT_TRUE(
1329 program->CheckVaryingsPacking(Program::kCountOnlyStaticallyUsed)); 1368 program->CheckVaryingsPacking(Program::kCountOnlyStaticallyUsed));
1330 EXPECT_TRUE(LinkAsExpected(program, true)); 1369 EXPECT_TRUE(LinkAsExpected(program, true));
1331 } 1370 }
1332 1371
1333 // Varyings go over 8 rows but some are inactive. 1372 // Varyings go over 8 rows but some are inactive.
1334 // However, we still fail the check if kCountAll option is used. 1373 // However, we still fail the check if kCountAll option is used.
1335 TEST_F(ProgramManagerWithShaderTest, CountAllVaryingsInPacking) { 1374 TEST_F(ProgramManagerWithShaderTest, CountAllVaryingsInPacking) {
1336 const VarInfo kVertexVaryings[] = { 1375 const VarInfo kVertexVaryings[] = {
1337 { GL_FLOAT_VEC4, 4, SH_PRECISION_MEDIUMP, 1, "a", kVarVarying }, 1376 { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, true, "a", kVarVarying },
1338 { GL_FLOAT_VEC4, 5, SH_PRECISION_MEDIUMP, 1, "b", kVarVarying } 1377 { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying }
1339 }; 1378 };
1340 const VarInfo kFragmentVaryings[] = { 1379 const VarInfo kFragmentVaryings[] = {
1341 { GL_FLOAT_VEC4, 4, SH_PRECISION_MEDIUMP, 0, "a", kVarVarying }, 1380 { GL_FLOAT_VEC4, 4, GL_MEDIUM_FLOAT, false, "a", kVarVarying },
1342 { GL_FLOAT_VEC4, 5, SH_PRECISION_MEDIUMP, 1, "b", kVarVarying } 1381 { GL_FLOAT_VEC4, 5, GL_MEDIUM_FLOAT, true, "b", kVarVarying }
1343 }; 1382 };
1344 Program* program = SetupShaderVariableTest( 1383 Program* program = SetupShaderVariableTest(
1345 kVertexVaryings, 2, kFragmentVaryings, 2); 1384 kVertexVaryings, 2, kFragmentVaryings, 2);
1346 1385
1347 EXPECT_FALSE(program->CheckVaryingsPacking(Program::kCountAll)); 1386 EXPECT_FALSE(program->CheckVaryingsPacking(Program::kCountAll));
1348 } 1387 }
1349 1388
1350 TEST_F(ProgramManagerWithShaderTest, ClearWithSamplerTypes) { 1389 TEST_F(ProgramManagerWithShaderTest, ClearWithSamplerTypes) {
1351 const GLuint kVShaderClientId = 2001; 1390 const GLuint kVShaderClientId = 2001;
1352 const GLuint kFShaderClientId = 2002; 1391 const GLuint kFShaderClientId = 2002;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 kUniform1RealLocation, 1429 kUniform1RealLocation,
1391 kUniform1DesiredLocation, 1430 kUniform1DesiredLocation,
1392 kUniform1Name, 1431 kUniform1Name,
1393 }, 1432 },
1394 { kUniform2Name, 1433 { kUniform2Name,
1395 kUniform2Size, 1434 kUniform2Size,
1396 kSamplerTypes[ii], 1435 kSamplerTypes[ii],
1397 kUniform2FakeLocation, 1436 kUniform2FakeLocation,
1398 kUniform2RealLocation, 1437 kUniform2RealLocation,
1399 kUniform2DesiredLocation, 1438 kUniform2DesiredLocation,
1400 kUniform2Name, 1439 kUniform2NameWithArrayIndex,
1401 }, 1440 },
1402 { kUniform3BadName, 1441 { kUniform3Name,
1403 kUniform3Size, 1442 kUniform3Size,
1404 kUniform3Type, 1443 kUniform3Type,
1405 kUniform3FakeLocation, 1444 kUniform3FakeLocation,
1406 kUniform3RealLocation, 1445 kUniform3RealLocation,
1407 kUniform3DesiredLocation, 1446 kUniform3DesiredLocation,
1408 kUniform3GoodName, 1447 kUniform3NameWithArrayIndex,
1409 }, 1448 },
1410 }; 1449 };
1411 const size_t kNumAttribs = arraysize(kAttribs); 1450 const size_t kNumAttribs = arraysize(kAttribs);
1412 const size_t kNumUniforms = arraysize(kUniforms); 1451 const size_t kNumUniforms = arraysize(kUniforms);
1413 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, 1452 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
1414 kServiceProgramId); 1453 kServiceProgramId);
1415 program->Link(NULL, NULL, NULL, Program::kCountOnlyStaticallyUsed, 1454 program->Link(NULL, NULL, NULL, Program::kCountOnlyStaticallyUsed,
1416 base::Bind(&ShaderCacheCb)); 1455 base::Bind(&ShaderCacheCb));
1417 SetupExpectationsForClearingUniforms(kUniforms, kNumUniforms); 1456 SetupExpectationsForClearingUniforms(kUniforms, kNumUniforms);
1418 manager_.ClearUniforms(program); 1457 manager_.ClearUniforms(program);
(...skipping 21 matching lines...) Expand all
1440 static const GLuint kClientProgramId = 1234; 1479 static const GLuint kClientProgramId = 1234;
1441 static const GLuint kServiceProgramId = 5679; 1480 static const GLuint kServiceProgramId = 5679;
1442 Program* program = manager_.CreateProgram( 1481 Program* program = manager_.CreateProgram(
1443 kClientProgramId, kServiceProgramId); 1482 kClientProgramId, kServiceProgramId);
1444 ASSERT_TRUE(program != NULL); 1483 ASSERT_TRUE(program != NULL);
1445 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader)); 1484 EXPECT_TRUE(program->AttachShader(&shader_manager_, vshader));
1446 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader)); 1485 EXPECT_TRUE(program->AttachShader(&shader_manager_, fshader));
1447 EXPECT_TRUE(program->SetUniformLocationBinding( 1486 EXPECT_TRUE(program->SetUniformLocationBinding(
1448 kUniform1Name, kUniform1DesiredLocation)); 1487 kUniform1Name, kUniform1DesiredLocation));
1449 EXPECT_TRUE(program->SetUniformLocationBinding( 1488 EXPECT_TRUE(program->SetUniformLocationBinding(
1450 kUniform3BadName, kUniform3DesiredLocation)); 1489 kUniform3Name, kUniform3DesiredLocation));
1451 1490
1452 static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = { 1491 static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = {
1453 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, }, 1492 { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },
1454 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, }, 1493 { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, },
1455 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, }, 1494 { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, },
1456 }; 1495 };
1457 ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { 1496 ProgramManagerWithShaderTest::UniformInfo kUniforms[] = {
1458 { kUniform1Name, 1497 { kUniform1Name,
1459 kUniform1Size, 1498 kUniform1Size,
1460 kUniform1Type, 1499 kUniform1Type,
1461 kUniform1FakeLocation, 1500 kUniform1FakeLocation,
1462 kUniform1RealLocation, 1501 kUniform1RealLocation,
1463 kUniform1DesiredLocation, 1502 kUniform1DesiredLocation,
1464 kUniform1Name, 1503 kUniform1Name,
1465 }, 1504 },
1466 { kUniform2Name, 1505 { kUniform2Name,
1467 kUniform2Size, 1506 kUniform2Size,
1468 kUniform2Type, 1507 kUniform2Type,
1469 kUniform2FakeLocation, 1508 kUniform2FakeLocation,
1470 kUniform2RealLocation, 1509 kUniform2RealLocation,
1471 kUniform2DesiredLocation, 1510 kUniform2DesiredLocation,
1472 kUniform2Name, 1511 kUniform2NameWithArrayIndex,
1473 }, 1512 },
1474 { kUniform3BadName, 1513 { kUniform3Name,
1475 kUniform3Size, 1514 kUniform3Size,
1476 kUniform3Type, 1515 kUniform3Type,
1477 kUniform3FakeLocation, 1516 kUniform3FakeLocation,
1478 kUniform3RealLocation, 1517 kUniform3RealLocation,
1479 kUniform3DesiredLocation, 1518 kUniform3DesiredLocation,
1480 kUniform3GoodName, 1519 kUniform3NameWithArrayIndex,
1481 }, 1520 },
1482 }; 1521 };
1483 1522
1484 const size_t kNumAttribs = arraysize(kAttribs); 1523 const size_t kNumAttribs = arraysize(kAttribs);
1485 const size_t kNumUniforms = arraysize(kUniforms); 1524 const size_t kNumUniforms = arraysize(kUniforms);
1486 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms, 1525 SetupShader(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
1487 kServiceProgramId); 1526 kServiceProgramId);
1488 program->Link(NULL, NULL, NULL, Program::kCountOnlyStaticallyUsed, 1527 program->Link(NULL, NULL, NULL, Program::kCountOnlyStaticallyUsed,
1489 base::Bind(&ShaderCacheCb)); 1528 base::Bind(&ShaderCacheCb));
1490 1529
1491 EXPECT_EQ(kUniform1DesiredLocation, 1530 EXPECT_EQ(kUniform1DesiredLocation,
1492 program->GetUniformFakeLocation(kUniform1Name)); 1531 program->GetUniformFakeLocation(kUniform1Name));
1493 EXPECT_EQ(kUniform3DesiredLocation, 1532 EXPECT_EQ(kUniform3DesiredLocation,
1494 program->GetUniformFakeLocation(kUniform3BadName)); 1533 program->GetUniformFakeLocation(kUniform3Name));
1495 EXPECT_EQ(kUniform3DesiredLocation, 1534 EXPECT_EQ(kUniform3DesiredLocation,
1496 program->GetUniformFakeLocation(kUniform3GoodName)); 1535 program->GetUniformFakeLocation(kUniform3NameWithArrayIndex));
1497 } 1536 }
1498 1537
1499 class ProgramManagerWithCacheTest : public GpuServiceTest { 1538 class ProgramManagerWithCacheTest : public GpuServiceTest {
1500 public: 1539 public:
1501 static const GLuint kClientProgramId = 1; 1540 static const GLuint kClientProgramId = 1;
1502 static const GLuint kServiceProgramId = 10; 1541 static const GLuint kServiceProgramId = 10;
1503 static const GLuint kVertexShaderClientId = 2; 1542 static const GLuint kVertexShaderClientId = 2;
1504 static const GLuint kFragmentShaderClientId = 20; 1543 static const GLuint kFragmentShaderClientId = 20;
1505 static const GLuint kVertexShaderServiceId = 3; 1544 static const GLuint kVertexShaderServiceId = 3;
1506 static const GLuint kFragmentShaderServiceId = 30; 1545 static const GLuint kFragmentShaderServiceId = 30;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 SetExpectationsForProgramLoad(ProgramCache::PROGRAM_LOAD_SUCCESS); 1754 SetExpectationsForProgramLoad(ProgramCache::PROGRAM_LOAD_SUCCESS);
1716 SetExpectationsForNotCachingProgram(); 1755 SetExpectationsForNotCachingProgram();
1717 SetExpectationsForProgramLoadSuccess(); 1756 SetExpectationsForProgramLoadSuccess();
1718 1757
1719 EXPECT_TRUE(program_->Link(NULL, NULL, NULL, 1758 EXPECT_TRUE(program_->Link(NULL, NULL, NULL,
1720 Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb))); 1759 Program::kCountOnlyStaticallyUsed, base::Bind(&ShaderCacheCb)));
1721 } 1760 }
1722 1761
1723 } // namespace gles2 1762 } // namespace gles2
1724 } // namespace gpu 1763 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698