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

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

Issue 2610603002: gpu: Use the sh-scoped translator methods. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « gpu/command_buffer/service/shader_translator_cache_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 #include "ui/gl/gl_version_info.h" 9 #include "ui/gl/gl_version_info.h"
10 10
11 namespace gpu { 11 namespace gpu {
12 namespace gles2 { 12 namespace gles2 {
13 13
14 class ShaderTranslatorTest : public testing::Test { 14 class ShaderTranslatorTest : public testing::Test {
15 public: 15 public:
16 ShaderTranslatorTest() { 16 ShaderTranslatorTest() {
17 shader_output_language_ = 17 shader_output_language_ =
18 ShaderTranslator::GetShaderOutputLanguageForContext( 18 ShaderTranslator::GetShaderOutputLanguageForContext(
19 gl::GLVersionInfo("2.0", "", "")); 19 gl::GLVersionInfo("2.0", "", ""));
20 } 20 }
21 21
22 ~ShaderTranslatorTest() override {} 22 ~ShaderTranslatorTest() override {}
23 23
24 protected: 24 protected:
25 void SetUp() override { 25 void SetUp() override {
26 ShBuiltInResources resources; 26 ShBuiltInResources resources;
27 ShInitBuiltInResources(&resources); 27 sh::InitBuiltInResources(&resources);
28 resources.MaxExpressionComplexity = 32; 28 resources.MaxExpressionComplexity = 32;
29 resources.MaxCallStackDepth = 32; 29 resources.MaxCallStackDepth = 32;
30 30
31 vertex_translator_ = new ShaderTranslator(); 31 vertex_translator_ = new ShaderTranslator();
32 fragment_translator_ = new ShaderTranslator(); 32 fragment_translator_ = new ShaderTranslator();
33 33
34 ASSERT_TRUE(vertex_translator_->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, 34 ASSERT_TRUE(vertex_translator_->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC,
35 &resources, shader_output_language_, 35 &resources, shader_output_language_,
36 static_cast<ShCompileOptions>(0), 36 static_cast<ShCompileOptions>(0),
37 false)); 37 false));
(...skipping 18 matching lines...) Expand all
56 shader_output_language_ = 56 shader_output_language_ =
57 ShaderTranslator::GetShaderOutputLanguageForContext( 57 ShaderTranslator::GetShaderOutputLanguageForContext(
58 gl::GLVersionInfo("3.0", "", "")); 58 gl::GLVersionInfo("3.0", "", ""));
59 } 59 }
60 60
61 ~ES3ShaderTranslatorTest() override {} 61 ~ES3ShaderTranslatorTest() override {}
62 62
63 protected: 63 protected:
64 void SetUp() override { 64 void SetUp() override {
65 ShBuiltInResources resources; 65 ShBuiltInResources resources;
66 ShInitBuiltInResources(&resources); 66 sh::InitBuiltInResources(&resources);
67 resources.MaxExpressionComplexity = 32; 67 resources.MaxExpressionComplexity = 32;
68 resources.MaxCallStackDepth = 32; 68 resources.MaxCallStackDepth = 32;
69 69
70 vertex_translator_ = new ShaderTranslator(); 70 vertex_translator_ = new ShaderTranslator();
71 fragment_translator_ = new ShaderTranslator(); 71 fragment_translator_ = new ShaderTranslator();
72 72
73 ASSERT_TRUE(vertex_translator_->Init(GL_VERTEX_SHADER, SH_GLES3_SPEC, 73 ASSERT_TRUE(vertex_translator_->Init(GL_VERTEX_SHADER, SH_GLES3_SPEC,
74 &resources, shader_output_language_, 74 &resources, shader_output_language_,
75 static_cast<ShCompileOptions>(0), 75 static_cast<ShCompileOptions>(0),
76 false)); 76 false));
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 417 }
418 EXPECT_TRUE(iter != interface_block_map.end()); 418 EXPECT_TRUE(iter != interface_block_map.end());
419 } 419 }
420 420
421 TEST_F(ShaderTranslatorTest, OptionsString) { 421 TEST_F(ShaderTranslatorTest, OptionsString) {
422 scoped_refptr<ShaderTranslator> translator_1 = new ShaderTranslator(); 422 scoped_refptr<ShaderTranslator> translator_1 = new ShaderTranslator();
423 scoped_refptr<ShaderTranslator> translator_2 = new ShaderTranslator(); 423 scoped_refptr<ShaderTranslator> translator_2 = new ShaderTranslator();
424 scoped_refptr<ShaderTranslator> translator_3 = new ShaderTranslator(); 424 scoped_refptr<ShaderTranslator> translator_3 = new ShaderTranslator();
425 425
426 ShBuiltInResources resources; 426 ShBuiltInResources resources;
427 ShInitBuiltInResources(&resources); 427 sh::InitBuiltInResources(&resources);
428 428
429 ASSERT_TRUE(translator_1->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources, 429 ASSERT_TRUE(translator_1->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources,
430 SH_GLSL_150_CORE_OUTPUT, 430 SH_GLSL_150_CORE_OUTPUT,
431 static_cast<ShCompileOptions>(0), 431 static_cast<ShCompileOptions>(0),
432 false)); 432 false));
433 ASSERT_TRUE(translator_2->Init(GL_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources, 433 ASSERT_TRUE(translator_2->Init(GL_FRAGMENT_SHADER, SH_GLES2_SPEC, &resources,
434 SH_GLSL_150_CORE_OUTPUT, 434 SH_GLSL_150_CORE_OUTPUT,
435 SH_INIT_OUTPUT_VARIABLES, 435 SH_INIT_OUTPUT_VARIABLES,
436 false)); 436 false));
437 resources.EXT_draw_buffers = 1; 437 resources.EXT_draw_buffers = 1;
(...skipping 19 matching lines...) Expand all
457 457
458 class ShaderTranslatorOutputVersionTest 458 class ShaderTranslatorOutputVersionTest
459 : public testing::TestWithParam<testing::tuple<const char*, const char*>> { 459 : public testing::TestWithParam<testing::tuple<const char*, const char*>> {
460 }; 460 };
461 461
462 // crbug.com/540543 462 // crbug.com/540543
463 // https://bugs.chromium.org/p/angleproject/issues/detail?id=1276 463 // https://bugs.chromium.org/p/angleproject/issues/detail?id=1276
464 // https://bugs.chromium.org/p/angleproject/issues/detail?id=1277 464 // https://bugs.chromium.org/p/angleproject/issues/detail?id=1277
465 TEST_F(ShaderTranslatorOutputVersionTest, DISABLED_CompatibilityOutput) { 465 TEST_F(ShaderTranslatorOutputVersionTest, DISABLED_CompatibilityOutput) {
466 ShBuiltInResources resources; 466 ShBuiltInResources resources;
467 ShInitBuiltInResources(&resources); 467 sh::InitBuiltInResources(&resources);
468 ShCompileOptions compile_options = SH_OBJECT_CODE; 468 ShCompileOptions compile_options = SH_OBJECT_CODE;
469 ShShaderOutput shader_output_language = SH_GLSL_COMPATIBILITY_OUTPUT; 469 ShShaderOutput shader_output_language = SH_GLSL_COMPATIBILITY_OUTPUT;
470 scoped_refptr<ShaderTranslator> vertex_translator = new ShaderTranslator(); 470 scoped_refptr<ShaderTranslator> vertex_translator = new ShaderTranslator();
471 ASSERT_TRUE(vertex_translator->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, 471 ASSERT_TRUE(vertex_translator->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC,
472 &resources, shader_output_language, 472 &resources, shader_output_language,
473 compile_options, 473 compile_options,
474 false)); 474 false));
475 scoped_refptr<ShaderTranslator> fragment_translator = new ShaderTranslator(); 475 scoped_refptr<ShaderTranslator> fragment_translator = new ShaderTranslator();
476 ASSERT_TRUE(fragment_translator->Init(GL_FRAGMENT_SHADER, SH_GLES2_SPEC, 476 ASSERT_TRUE(fragment_translator->Init(GL_FRAGMENT_SHADER, SH_GLES2_SPEC,
477 &resources, shader_output_language, 477 &resources, shader_output_language,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 const char* kShader = 525 const char* kShader =
526 "attribute vec4 vPosition;\n" 526 "attribute vec4 vPosition;\n"
527 "void main() {\n" 527 "void main() {\n"
528 " gl_Position = vPosition;\n" 528 " gl_Position = vPosition;\n"
529 "}"; 529 "}";
530 530
531 gl::GLVersionInfo output_context_version(testing::get<0>(GetParam()), "", ""); 531 gl::GLVersionInfo output_context_version(testing::get<0>(GetParam()), "", "");
532 532
533 scoped_refptr<ShaderTranslator> translator = new ShaderTranslator(); 533 scoped_refptr<ShaderTranslator> translator = new ShaderTranslator();
534 ShBuiltInResources resources; 534 ShBuiltInResources resources;
535 ShInitBuiltInResources(&resources); 535 sh::InitBuiltInResources(&resources);
536 ShCompileOptions compile_options = SH_OBJECT_CODE; 536 ShCompileOptions compile_options = SH_OBJECT_CODE;
537 ShShaderOutput shader_output_language = 537 ShShaderOutput shader_output_language =
538 ShaderTranslator::GetShaderOutputLanguageForContext( 538 ShaderTranslator::GetShaderOutputLanguageForContext(
539 output_context_version); 539 output_context_version);
540 ASSERT_TRUE(translator->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources, 540 ASSERT_TRUE(translator->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources,
541 shader_output_language, compile_options, false)); 541 shader_output_language, compile_options, false));
542 542
543 std::string translated_source; 543 std::string translated_source;
544 int shader_version; 544 int shader_version;
545 EXPECT_TRUE(translator->Translate(kShader, nullptr, &translated_source, 545 EXPECT_TRUE(translator->Translate(kShader, nullptr, &translated_source,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 INSTANTIATE_TEST_CASE_P(OpenGLESContexts, 613 INSTANTIATE_TEST_CASE_P(OpenGLESContexts,
614 ShaderTranslatorOutputVersionTest, 614 ShaderTranslatorOutputVersionTest,
615 testing::Values(make_gl_glsl_tuple("opengl es 2.0", ""), 615 testing::Values(make_gl_glsl_tuple("opengl es 2.0", ""),
616 make_gl_glsl_tuple("opengl es 3.0", ""), 616 make_gl_glsl_tuple("opengl es 3.0", ""),
617 make_gl_glsl_tuple("opengl es 3.1", ""), 617 make_gl_glsl_tuple("opengl es 3.1", ""),
618 make_gl_glsl_tuple("opengl es 3.2", 618 make_gl_glsl_tuple("opengl es 3.2",
619 ""))); 619 "")));
620 620
621 } // namespace gles2 621 } // namespace gles2
622 } // namespace gpu 622 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_translator_cache_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698