OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 // GL_FLOAT_VEC2 when they should return GL_FLOAT_MAT2. Check we handle this. | 616 // GL_FLOAT_VEC2 when they should return GL_FLOAT_MAT2. Check we handle this. |
617 TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { | 617 TEST_F(ProgramManagerWithShaderTest, GLDriverReturnsWrongTypeInfo) { |
618 static GLenum kAttrib2BadType = GL_FLOAT_VEC2; | 618 static GLenum kAttrib2BadType = GL_FLOAT_VEC2; |
619 static GLenum kAttrib2GoodType = GL_FLOAT_MAT2; | 619 static GLenum kAttrib2GoodType = GL_FLOAT_MAT2; |
620 static GLenum kUniform2BadType = GL_FLOAT_VEC3; | 620 static GLenum kUniform2BadType = GL_FLOAT_VEC3; |
621 static GLenum kUniform2GoodType = GL_FLOAT_MAT3; | 621 static GLenum kUniform2GoodType = GL_FLOAT_MAT3; |
622 MockShaderTranslator shader_translator; | 622 MockShaderTranslator shader_translator; |
623 ShaderTranslator::VariableMap attrib_map; | 623 ShaderTranslator::VariableMap attrib_map; |
624 ShaderTranslator::VariableMap uniform_map; | 624 ShaderTranslator::VariableMap uniform_map; |
625 attrib_map[kAttrib1Name] = ShaderTranslatorInterface::VariableInfo( | 625 attrib_map[kAttrib1Name] = ShaderTranslatorInterface::VariableInfo( |
626 kAttrib1Type, kAttrib1Size); | 626 kAttrib1Type, kAttrib1Size, kAttrib1Name); |
627 attrib_map[kAttrib2Name] = ShaderTranslatorInterface::VariableInfo( | 627 attrib_map[kAttrib2Name] = ShaderTranslatorInterface::VariableInfo( |
628 kAttrib2GoodType, kAttrib2Size); | 628 kAttrib2GoodType, kAttrib2Size, kAttrib2Name); |
629 attrib_map[kAttrib3Name] = ShaderTranslatorInterface::VariableInfo( | 629 attrib_map[kAttrib3Name] = ShaderTranslatorInterface::VariableInfo( |
630 kAttrib3Type, kAttrib3Size); | 630 kAttrib3Type, kAttrib3Size, kAttrib3Name); |
631 uniform_map[kUniform1Name] = ShaderTranslatorInterface::VariableInfo( | 631 uniform_map[kUniform1Name] = ShaderTranslatorInterface::VariableInfo( |
632 kUniform1Type, kUniform1Size); | 632 kUniform1Type, kUniform1Size, kUniform1Name); |
633 uniform_map[kUniform2Name] = ShaderTranslatorInterface::VariableInfo( | 633 uniform_map[kUniform2Name] = ShaderTranslatorInterface::VariableInfo( |
634 kUniform2GoodType, kUniform2Size); | 634 kUniform2GoodType, kUniform2Size, kUniform2Name); |
635 uniform_map[kUniform3GoodName] = ShaderTranslatorInterface::VariableInfo( | 635 uniform_map[kUniform3GoodName] = ShaderTranslatorInterface::VariableInfo( |
636 kUniform3Type, kUniform3Size); | 636 kUniform3Type, kUniform3Size, kUniform3GoodName); |
637 EXPECT_CALL(shader_translator, attrib_map()) | 637 EXPECT_CALL(shader_translator, attrib_map()) |
638 .WillRepeatedly(ReturnRef(attrib_map)); | 638 .WillRepeatedly(ReturnRef(attrib_map)); |
639 EXPECT_CALL(shader_translator, uniform_map()) | 639 EXPECT_CALL(shader_translator, uniform_map()) |
640 .WillRepeatedly(ReturnRef(uniform_map)); | 640 .WillRepeatedly(ReturnRef(uniform_map)); |
641 const GLuint kVShaderClientId = 2001; | 641 const GLuint kVShaderClientId = 2001; |
642 const GLuint kFShaderClientId = 2002; | 642 const GLuint kFShaderClientId = 2002; |
643 const GLuint kVShaderServiceId = 3001; | 643 const GLuint kVShaderServiceId = 3001; |
644 const GLuint kFShaderServiceId = 3002; | 644 const GLuint kFShaderServiceId = 3002; |
645 ShaderManager::ShaderInfo* vshader = shader_manager_.CreateShaderInfo( | 645 ShaderManager::ShaderInfo* vshader = shader_manager_.CreateShaderInfo( |
646 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); | 646 kVShaderClientId, kVShaderServiceId, GL_VERTEX_SHADER); |
(...skipping 30 matching lines...) Expand all Loading... |
677 for (unsigned index = 0; index < kNumAttribs; ++index) { | 677 for (unsigned index = 0; index < kNumAttribs; ++index) { |
678 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = | 678 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = |
679 program_info->GetAttribInfo(index); | 679 program_info->GetAttribInfo(index); |
680 ASSERT_TRUE(attrib_info != NULL); | 680 ASSERT_TRUE(attrib_info != NULL); |
681 ShaderTranslator::VariableMap::const_iterator it = attrib_map.find( | 681 ShaderTranslator::VariableMap::const_iterator it = attrib_map.find( |
682 attrib_info->name); | 682 attrib_info->name); |
683 ASSERT_TRUE(it != attrib_map.end()); | 683 ASSERT_TRUE(it != attrib_map.end()); |
684 EXPECT_EQ(it->first, attrib_info->name); | 684 EXPECT_EQ(it->first, attrib_info->name); |
685 EXPECT_EQ(static_cast<GLenum>(it->second.type), attrib_info->type); | 685 EXPECT_EQ(static_cast<GLenum>(it->second.type), attrib_info->type); |
686 EXPECT_EQ(it->second.size, attrib_info->size); | 686 EXPECT_EQ(it->second.size, attrib_info->size); |
| 687 EXPECT_EQ(it->second.name, attrib_info->name); |
687 } | 688 } |
688 // Check Uniforms | 689 // Check Uniforms |
689 for (unsigned index = 0; index < kNumUniforms; ++index) { | 690 for (unsigned index = 0; index < kNumUniforms; ++index) { |
690 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = | 691 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = |
691 program_info->GetUniformInfo(index); | 692 program_info->GetUniformInfo(index); |
692 ASSERT_TRUE(uniform_info != NULL); | 693 ASSERT_TRUE(uniform_info != NULL); |
693 ShaderTranslator::VariableMap::const_iterator it = uniform_map.find( | 694 ShaderTranslator::VariableMap::const_iterator it = uniform_map.find( |
694 uniform_info->name); | 695 uniform_info->name); |
695 ASSERT_TRUE(it != uniform_map.end()); | 696 ASSERT_TRUE(it != uniform_map.end()); |
696 EXPECT_EQ(it->first, uniform_info->name); | 697 EXPECT_EQ(it->first, uniform_info->name); |
697 EXPECT_EQ(static_cast<GLenum>(it->second.type), uniform_info->type); | 698 EXPECT_EQ(static_cast<GLenum>(it->second.type), uniform_info->type); |
698 EXPECT_EQ(it->second.size, uniform_info->size); | 699 EXPECT_EQ(it->second.size, uniform_info->size); |
| 700 EXPECT_EQ(it->second.name, uniform_info->name); |
699 } | 701 } |
700 } | 702 } |
701 | 703 |
702 TEST_F(ProgramManagerWithShaderTest, ProgramInfoUseCount) { | 704 TEST_F(ProgramManagerWithShaderTest, ProgramInfoUseCount) { |
703 static const GLuint kClientProgramId = 124; | 705 static const GLuint kClientProgramId = 124; |
704 static const GLuint kServiceProgramId = 457; | 706 static const GLuint kServiceProgramId = 457; |
705 ProgramManager::ProgramInfo* program_info = manager_.CreateProgramInfo( | 707 ProgramManager::ProgramInfo* program_info = manager_.CreateProgramInfo( |
706 kClientProgramId, kServiceProgramId); | 708 kClientProgramId, kServiceProgramId); |
707 ASSERT_TRUE(program_info != NULL); | 709 ASSERT_TRUE(program_info != NULL); |
708 EXPECT_FALSE(program_info->CanLink()); | 710 EXPECT_FALSE(program_info->CanLink()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 info2 = manager_.GetProgramInfo(kClientProgramId); | 792 info2 = manager_.GetProgramInfo(kClientProgramId); |
791 EXPECT_TRUE(info2 == NULL); | 793 EXPECT_TRUE(info2 == NULL); |
792 EXPECT_FALSE(vshader->InUse()); | 794 EXPECT_FALSE(vshader->InUse()); |
793 EXPECT_FALSE(fshader->InUse()); | 795 EXPECT_FALSE(fshader->InUse()); |
794 } | 796 } |
795 | 797 |
796 } // namespace gles2 | 798 } // namespace gles2 |
797 } // namespace gpu | 799 } // namespace gpu |
798 | 800 |
799 | 801 |
OLD | NEW |