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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
931 input->name_offset, input->name_length); | 931 input->name_offset, input->name_length); |
932 ASSERT_TRUE(name_buf != NULL); | 932 ASSERT_TRUE(name_buf != NULL); |
933 std::string name(name_buf, input->name_length); | 933 std::string name(name_buf, input->name_length); |
934 EXPECT_STREQ(expected.good_name, name.c_str()); | 934 EXPECT_STREQ(expected.good_name, name.c_str()); |
935 ++input; | 935 ++input; |
936 } | 936 } |
937 EXPECT_EQ(header->num_attribs + header->num_uniforms, | 937 EXPECT_EQ(header->num_attribs + header->num_uniforms, |
938 static_cast<uint32>(input - inputs)); | 938 static_cast<uint32>(input - inputs)); |
939 } | 939 } |
940 | 940 |
941 TEST_F(ProgramManagerWithShaderTest, BindAttribLocationConflicts) { | |
942 // Set up shader | |
943 const GLuint kShaderClientId = 1; | |
944 const GLuint kShaderServiceId = 11; | |
945 MockShaderTranslator shader_translator; | |
946 ShaderTranslator::VariableMap attrib_map; | |
947 for (uint32 ii = 0; ii < kNumAttribs; ++ii) { | |
948 attrib_map[kAttribs[ii].name] = ShaderTranslatorInterface::VariableInfo( | |
949 kAttribs[ii].type, kAttribs[ii].size, kAttribs[ii].name); | |
950 } | |
951 ShaderTranslator::VariableMap uniform_map; | |
952 EXPECT_CALL(shader_translator, attrib_map()) | |
953 .WillRepeatedly(ReturnRef(attrib_map)); | |
954 EXPECT_CALL(shader_translator, uniform_map()) | |
955 .WillRepeatedly(ReturnRef(uniform_map)); | |
956 // Check we can create shader. | |
957 ShaderManager::ShaderInfo* shader = shader_manager_.CreateShaderInfo( | |
958 kShaderClientId, kShaderServiceId, GL_VERTEX_SHADER); | |
959 // Check shader got created. | |
960 ASSERT_TRUE(shader != NULL); | |
961 // Set Status | |
962 shader->SetStatus(true, "", &shader_translator); | |
963 // Check attrib infos got copied. | |
964 for (ShaderTranslator::VariableMap::const_iterator it = attrib_map.begin(); | |
965 it != attrib_map.end(); ++it) { | |
966 const ShaderManager::ShaderInfo::VariableInfo* variable_info = | |
967 shader->GetAttribInfo(it->first); | |
968 ASSERT_TRUE(variable_info != NULL); | |
969 EXPECT_EQ(it->second.type, variable_info->type); | |
970 EXPECT_EQ(it->second.size, variable_info->size); | |
971 EXPECT_EQ(it->second.name, variable_info->name); | |
972 } | |
973 | |
974 // Set up prgram | |
greggman
2012/03/02 01:32:36
prgram->program
Zhenyao Mo
2012/03/02 18:58:22
Done.
| |
975 const GLuint kClientProgramId = 6666; | |
976 const GLuint kServiceProgramId = 8888; | |
977 ProgramManager::ProgramInfo* program_info = | |
978 manager_.CreateProgramInfo(kClientProgramId, kServiceProgramId); | |
979 ASSERT_TRUE(program_info != NULL); | |
980 EXPECT_TRUE(program_info->AttachShader(&shader_manager_, shader)); | |
981 | |
982 EXPECT_FALSE(program_info->DetectAttribLocationBindingConflicts()); | |
983 program_info->SetAttribLocationBinding(kAttrib1Name, 0); | |
984 EXPECT_FALSE(program_info->DetectAttribLocationBindingConflicts()); | |
985 program_info->SetAttribLocationBinding("xxx", 0); | |
986 EXPECT_FALSE(program_info->DetectAttribLocationBindingConflicts()); | |
987 program_info->SetAttribLocationBinding(kAttrib2Name, 1); | |
988 EXPECT_FALSE(program_info->DetectAttribLocationBindingConflicts()); | |
989 program_info->SetAttribLocationBinding(kAttrib2Name, 0); | |
990 EXPECT_TRUE(program_info->DetectAttribLocationBindingConflicts()); | |
991 } | |
992 | |
941 } // namespace gles2 | 993 } // namespace gles2 |
942 } // namespace gpu | 994 } // namespace gpu |
943 | 995 |
944 | 996 |
OLD | NEW |