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 #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 gfx::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 ShInitBuiltInResources(&resources); |
28 resources.MaxExpressionComplexity = 32; | 28 resources.MaxExpressionComplexity = 32; |
29 resources.MaxCallStackDepth = 32; | 29 resources.MaxCallStackDepth = 32; |
(...skipping 18 matching lines...) Expand all Loading... |
48 scoped_refptr<ShaderTranslator> vertex_translator_; | 48 scoped_refptr<ShaderTranslator> vertex_translator_; |
49 scoped_refptr<ShaderTranslator> fragment_translator_; | 49 scoped_refptr<ShaderTranslator> fragment_translator_; |
50 ShShaderOutput shader_output_language_; | 50 ShShaderOutput shader_output_language_; |
51 }; | 51 }; |
52 | 52 |
53 class ES3ShaderTranslatorTest : public testing::Test { | 53 class ES3ShaderTranslatorTest : public testing::Test { |
54 public: | 54 public: |
55 ES3ShaderTranslatorTest() { | 55 ES3ShaderTranslatorTest() { |
56 shader_output_language_ = | 56 shader_output_language_ = |
57 ShaderTranslator::GetShaderOutputLanguageForContext( | 57 ShaderTranslator::GetShaderOutputLanguageForContext( |
58 gfx::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 ShInitBuiltInResources(&resources); |
67 resources.MaxExpressionComplexity = 32; | 67 resources.MaxExpressionComplexity = 32; |
68 resources.MaxCallStackDepth = 32; | 68 resources.MaxCallStackDepth = 32; |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 // (version string in test param tuple index 0) produces a GLSL shader that | 520 // (version string in test param tuple index 0) produces a GLSL shader that |
521 // contains correct version string for that context (version directive | 521 // contains correct version string for that context (version directive |
522 // in test param tuple index 1). | 522 // in test param tuple index 1). |
523 | 523 |
524 const char* kShader = | 524 const char* kShader = |
525 "attribute vec4 vPosition;\n" | 525 "attribute vec4 vPosition;\n" |
526 "void main() {\n" | 526 "void main() {\n" |
527 " gl_Position = vPosition;\n" | 527 " gl_Position = vPosition;\n" |
528 "}"; | 528 "}"; |
529 | 529 |
530 gfx::GLVersionInfo output_context_version(testing::get<0>(GetParam()), "", | 530 gl::GLVersionInfo output_context_version(testing::get<0>(GetParam()), "", ""); |
531 ""); | |
532 | 531 |
533 scoped_refptr<ShaderTranslator> translator = new ShaderTranslator(); | 532 scoped_refptr<ShaderTranslator> translator = new ShaderTranslator(); |
534 ShBuiltInResources resources; | 533 ShBuiltInResources resources; |
535 ShInitBuiltInResources(&resources); | 534 ShInitBuiltInResources(&resources); |
536 ShCompileOptions compile_options = SH_OBJECT_CODE; | 535 ShCompileOptions compile_options = SH_OBJECT_CODE; |
537 ShShaderOutput shader_output_language = | 536 ShShaderOutput shader_output_language = |
538 ShaderTranslator::GetShaderOutputLanguageForContext( | 537 ShaderTranslator::GetShaderOutputLanguageForContext( |
539 output_context_version); | 538 output_context_version); |
540 ASSERT_TRUE(translator->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources, | 539 ASSERT_TRUE(translator->Init(GL_VERTEX_SHADER, SH_GLES2_SPEC, &resources, |
541 shader_output_language, compile_options, false)); | 540 shader_output_language, compile_options, false)); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 ShaderTranslatorOutputVersionTest, | 613 ShaderTranslatorOutputVersionTest, |
615 testing::Values(make_gl_glsl_tuple("opengl es 2.0", ""), | 614 testing::Values(make_gl_glsl_tuple("opengl es 2.0", ""), |
616 make_gl_glsl_tuple("opengl es 3.0", ""), | 615 make_gl_glsl_tuple("opengl es 3.0", ""), |
617 make_gl_glsl_tuple("opengl es 3.1", ""), | 616 make_gl_glsl_tuple("opengl es 3.1", ""), |
618 make_gl_glsl_tuple("opengl es 3.2", | 617 make_gl_glsl_tuple("opengl es 3.2", |
619 ""))); | 618 ""))); |
620 | 619 |
621 } // namespace gles2 | 620 } // namespace gles2 |
622 } // namespace gpu | 621 } // namespace gpu |
623 | 622 |
OLD | NEW |