| OLD | NEW |
| 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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 // Check that we skipped the "gl_" uniform. | 592 // Check that we skipped the "gl_" uniform. |
| 593 program_info->GetProgramiv(GL_ACTIVE_UNIFORMS, &value); | 593 program_info->GetProgramiv(GL_ACTIVE_UNIFORMS, &value); |
| 594 EXPECT_EQ(2, value); | 594 EXPECT_EQ(2, value); |
| 595 // Check that our max length adds room for the array spec and is not as long | 595 // Check that our max length adds room for the array spec and is not as long |
| 596 // as the "gl_" uniform we skipped. | 596 // as the "gl_" uniform we skipped. |
| 597 // +4u is to account for "gl_" and NULL terminator. | 597 // +4u is to account for "gl_" and NULL terminator. |
| 598 program_info->GetProgramiv(GL_ACTIVE_UNIFORM_MAX_LENGTH, &value); | 598 program_info->GetProgramiv(GL_ACTIVE_UNIFORM_MAX_LENGTH, &value); |
| 599 EXPECT_EQ(strlen(kUniform3BadName) + 4u, static_cast<size_t>(value)); | 599 EXPECT_EQ(strlen(kUniform3BadName) + 4u, static_cast<size_t>(value)); |
| 600 } | 600 } |
| 601 | 601 |
| 602 // Test the bug comparing similar array names is fixed. |
| 603 TEST_F(ProgramManagerWithShaderTest, SimilarArrayNames) { |
| 604 static const char* kUniform2Name = "u_nameLong[0]"; |
| 605 static const char* kUniform3Name = "u_name[0]"; |
| 606 static const GLint kUniform2Size = 2; |
| 607 static const GLint kUniform3Size = 2; |
| 608 static ProgramManagerWithShaderTest::UniformInfo kUniforms[] = { |
| 609 { kUniform1Name, |
| 610 kUniform1Size, |
| 611 kUniform1Type, |
| 612 kUniform1FakeLocation, |
| 613 kUniform1RealLocation, |
| 614 kUniform1DesiredLocation, |
| 615 kUniform1Name, |
| 616 }, |
| 617 { kUniform2Name, |
| 618 kUniform2Size, |
| 619 kUniform2Type, |
| 620 kUniform2FakeLocation, |
| 621 kUniform2RealLocation, |
| 622 kUniform2DesiredLocation, |
| 623 kUniform2Name, |
| 624 }, |
| 625 { kUniform3Name, |
| 626 kUniform3Size, |
| 627 kUniform3Type, |
| 628 kUniform3FakeLocation, |
| 629 kUniform3RealLocation, |
| 630 kUniform3DesiredLocation, |
| 631 kUniform3Name, |
| 632 }, |
| 633 }; |
| 634 const size_t kNumUniforms = arraysize(kUniforms); |
| 635 static const GLuint kClientProgramId = 1234; |
| 636 static const GLuint kServiceProgramId = 5679; |
| 637 const GLuint kVShaderClientId = 2001; |
| 638 const GLuint kFShaderClientId = 2002; |
| 639 const GLuint kVShaderServiceId = 3001; |
| 640 const GLuint kFShaderServiceId = 3002; |
| 641 SetupShader( |
| 642 kAttribs, kNumAttribs, kUniforms, kNumUniforms, kServiceProgramId); |
| 643 ShaderManager::ShaderInfo* vshader = shader_manager_.CreateShaderInfo( |
| 644 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); |
| 645 ASSERT_TRUE(vshader != NULL); |
| 646 vshader->SetStatus(true, "", NULL); |
| 647 ShaderManager::ShaderInfo* fshader = shader_manager_.CreateShaderInfo( |
| 648 kFShaderClientId, kFShaderServiceId, GL_FRAGMENT_SHADER); |
| 649 ASSERT_TRUE(fshader != NULL); |
| 650 fshader->SetStatus(true, "", NULL); |
| 651 ProgramManager::ProgramInfo* program_info = |
| 652 manager_.CreateProgramInfo(kClientProgramId, kServiceProgramId); |
| 653 ASSERT_TRUE(program_info != NULL); |
| 654 EXPECT_TRUE(program_info->AttachShader(&shader_manager_, vshader)); |
| 655 EXPECT_TRUE(program_info->AttachShader(&shader_manager_, fshader)); |
| 656 program_info->Link(NULL, NULL, NULL, NULL); |
| 657 |
| 658 // Check that we get the correct locations. |
| 659 EXPECT_EQ(kUniform2FakeLocation, |
| 660 program_info->GetUniformFakeLocation(kUniform2Name)); |
| 661 EXPECT_EQ(kUniform3FakeLocation, |
| 662 program_info->GetUniformFakeLocation(kUniform3Name)); |
| 663 } |
| 664 |
| 602 // Some GL drivers incorrectly return the wrong type. For example they return | 665 // Some GL drivers incorrectly return the wrong type. For example they return |
| 603 // GL_FLOAT_VEC2 when they should return GL_FLOAT_MAT2. Check we handle this. | 666 // GL_FLOAT_VEC2 when they should return GL_FLOAT_MAT2. Check we handle this. |
| 604 TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { | 667 TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { |
| 605 static GLenum kAttrib2BadType = GL_FLOAT_VEC2; | 668 static GLenum kAttrib2BadType = GL_FLOAT_VEC2; |
| 606 static GLenum kAttrib2GoodType = GL_FLOAT_MAT2; | 669 static GLenum kAttrib2GoodType = GL_FLOAT_MAT2; |
| 607 static GLenum kUniform2BadType = GL_FLOAT_VEC3; | 670 static GLenum kUniform2BadType = GL_FLOAT_VEC3; |
| 608 static GLenum kUniform2GoodType = GL_FLOAT_MAT3; | 671 static GLenum kUniform2GoodType = GL_FLOAT_MAT3; |
| 609 MockShaderTranslator shader_translator; | 672 MockShaderTranslator shader_translator; |
| 610 ShaderTranslator::VariableMap attrib_map; | 673 ShaderTranslator::VariableMap attrib_map; |
| 611 ShaderTranslator::VariableMap uniform_map; | 674 ShaderTranslator::VariableMap uniform_map; |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 SetExpectationsForProgramCached(program_info, | 1519 SetExpectationsForProgramCached(program_info, |
| 1457 new_vertex_shader, | 1520 new_vertex_shader, |
| 1458 fragment_shader_); | 1521 fragment_shader_); |
| 1459 SetExpectationsForProgramLink(kNewProgramServiceId); | 1522 SetExpectationsForProgramLink(kNewProgramServiceId); |
| 1460 | 1523 |
| 1461 EXPECT_TRUE(program_info->Link(&shader_manager_, NULL, NULL, info.get())); | 1524 EXPECT_TRUE(program_info->Link(&shader_manager_, NULL, NULL, info.get())); |
| 1462 } | 1525 } |
| 1463 | 1526 |
| 1464 } // namespace gles2 | 1527 } // namespace gles2 |
| 1465 } // namespace gpu | 1528 } // namespace gpu |
| OLD | NEW |