| 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 <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
| 6 | 6 |
| 7 #include "gpu/command_buffer/service/shader_translator.h" | 7 #include "gpu/command_buffer/service/shader_translator.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace gpu { | 10 namespace gpu { |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 EXPECT_STREQ("bar[0].foo.color[0]", original_name.c_str()); | 275 EXPECT_STREQ("bar[0].foo.color[0]", original_name.c_str()); |
| 276 // Second uniform. | 276 // Second uniform. |
| 277 EXPECT_TRUE(iter->second.findInfoByMappedName( | 277 EXPECT_TRUE(iter->second.findInfoByMappedName( |
| 278 "bar[1].foo.color[0]", &info, &original_name)); | 278 "bar[1].foo.color[0]", &info, &original_name)); |
| 279 EXPECT_EQ(static_cast<GLenum>(GL_FLOAT_VEC4), info->type); | 279 EXPECT_EQ(static_cast<GLenum>(GL_FLOAT_VEC4), info->type); |
| 280 EXPECT_EQ(1u, info->arraySize); | 280 EXPECT_EQ(1u, info->arraySize); |
| 281 EXPECT_STREQ("color", info->name.c_str()); | 281 EXPECT_STREQ("color", info->name.c_str()); |
| 282 EXPECT_STREQ("bar[1].foo.color[0]", original_name.c_str()); | 282 EXPECT_STREQ("bar[1].foo.color[0]", original_name.c_str()); |
| 283 } | 283 } |
| 284 | 284 |
| 285 #if defined(OS_MACOSX) | |
| 286 TEST_F(ShaderTranslatorTest, BuiltInFunctionEmulation) { | |
| 287 // This test might become invalid in the future when ANGLE Translator is no | |
| 288 // longer emulate dot(float, float) in Mac, or the emulated function name is | |
| 289 // no longer webgl_dot_emu. | |
| 290 const char* shader = | |
| 291 "void main() {\n" | |
| 292 " gl_Position = vec4(dot(1.0, 1.0), 1.0, 1.0, 1.0);\n" | |
| 293 "}"; | |
| 294 | |
| 295 std::string info_log, translated_source; | |
| 296 int shader_version; | |
| 297 AttributeMap attrib_map; | |
| 298 UniformMap uniform_map; | |
| 299 VaryingMap varying_map; | |
| 300 NameMap name_map; | |
| 301 EXPECT_TRUE(vertex_translator_->Translate(shader, | |
| 302 &info_log, | |
| 303 &translated_source, | |
| 304 &shader_version, | |
| 305 &attrib_map, | |
| 306 &uniform_map, | |
| 307 &varying_map, | |
| 308 &name_map)); | |
| 309 // Info log must be NULL. | |
| 310 EXPECT_TRUE(info_log.empty()); | |
| 311 // Translated shader must be valid and non-empty. | |
| 312 ASSERT_FALSE(translated_source.empty()); | |
| 313 EXPECT_TRUE(strstr(translated_source.c_str(), | |
| 314 "webgl_dot_emu") != NULL); | |
| 315 } | |
| 316 #endif | |
| 317 | |
| 318 TEST_F(ShaderTranslatorTest, OptionsString) { | 285 TEST_F(ShaderTranslatorTest, OptionsString) { |
| 319 scoped_refptr<ShaderTranslator> translator_1 = new ShaderTranslator(); | 286 scoped_refptr<ShaderTranslator> translator_1 = new ShaderTranslator(); |
| 320 scoped_refptr<ShaderTranslator> translator_2 = new ShaderTranslator(); | 287 scoped_refptr<ShaderTranslator> translator_2 = new ShaderTranslator(); |
| 321 scoped_refptr<ShaderTranslator> translator_3 = new ShaderTranslator(); | 288 scoped_refptr<ShaderTranslator> translator_3 = new ShaderTranslator(); |
| 322 | 289 |
| 323 ShBuiltInResources resources; | 290 ShBuiltInResources resources; |
| 324 ShInitBuiltInResources(&resources); | 291 ShInitBuiltInResources(&resources); |
| 325 | 292 |
| 326 ASSERT_TRUE(translator_1->Init( | 293 ASSERT_TRUE(translator_1->Init( |
| 327 GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources, | 294 GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 348 | 315 |
| 349 EXPECT_EQ(options_1, options_2); | 316 EXPECT_EQ(options_1, options_2); |
| 350 EXPECT_NE(options_1, options_3); | 317 EXPECT_NE(options_1, options_3); |
| 351 EXPECT_NE(options_1, options_4); | 318 EXPECT_NE(options_1, options_4); |
| 352 EXPECT_NE(options_3, options_4); | 319 EXPECT_NE(options_3, options_4); |
| 353 } | 320 } |
| 354 | 321 |
| 355 } // namespace gles2 | 322 } // namespace gles2 |
| 356 } // namespace gpu | 323 } // namespace gpu |
| 357 | 324 |
| OLD | NEW |