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 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ |
7 | 7 |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 ShaderTranslatorCache(); | 29 ShaderTranslatorCache(); |
30 | 30 |
31 // ShaderTranslator::DestructionObserver implementation | 31 // ShaderTranslator::DestructionObserver implementation |
32 void OnDestruct(ShaderTranslator* translator) override; | 32 void OnDestruct(ShaderTranslator* translator) override; |
33 | 33 |
34 scoped_refptr<ShaderTranslator> GetTranslator( | 34 scoped_refptr<ShaderTranslator> GetTranslator( |
35 sh::GLenum shader_type, | 35 sh::GLenum shader_type, |
36 ShShaderSpec shader_spec, | 36 ShShaderSpec shader_spec, |
37 const ShBuiltInResources* resources, | 37 const ShBuiltInResources* resources, |
38 ShaderTranslatorInterface::GlslImplementationType | 38 ShShaderOutput shader_output_language, |
39 glsl_implementation_type, | |
40 ShCompileOptions driver_bug_workarounds); | 39 ShCompileOptions driver_bug_workarounds); |
41 | 40 |
42 private: | 41 private: |
43 friend class base::RefCounted<ShaderTranslatorCache>; | 42 friend class base::RefCounted<ShaderTranslatorCache>; |
44 friend class ShaderTranslatorCacheTest_InitParamComparable_Test; | 43 friend class ShaderTranslatorCacheTest_InitParamComparable_Test; |
45 ~ShaderTranslatorCache() override; | 44 ~ShaderTranslatorCache() override; |
46 | 45 |
47 // Parameters passed into ShaderTranslator::Init | 46 // Parameters passed into ShaderTranslator::Init |
48 struct ShaderTranslatorInitParams { | 47 struct ShaderTranslatorInitParams { |
49 sh::GLenum shader_type; | 48 sh::GLenum shader_type; |
50 ShShaderSpec shader_spec; | 49 ShShaderSpec shader_spec; |
51 ShBuiltInResources resources; | 50 ShBuiltInResources resources; |
52 ShaderTranslatorInterface::GlslImplementationType | 51 ShShaderOutput shader_output_language; |
53 glsl_implementation_type; | |
54 ShCompileOptions driver_bug_workarounds; | 52 ShCompileOptions driver_bug_workarounds; |
55 | 53 |
56 ShaderTranslatorInitParams(sh::GLenum shader_type, | 54 ShaderTranslatorInitParams(sh::GLenum shader_type, |
57 ShShaderSpec shader_spec, | 55 ShShaderSpec shader_spec, |
58 const ShBuiltInResources& resources, | 56 const ShBuiltInResources& resources, |
59 ShaderTranslatorInterface::GlslImplementationType | 57 ShShaderOutput shader_output_language, |
60 glsl_implementation_type, | |
61 ShCompileOptions driver_bug_workarounds) { | 58 ShCompileOptions driver_bug_workarounds) { |
62 memset(this, 0, sizeof(*this)); | 59 memset(this, 0, sizeof(*this)); |
63 this->shader_type = shader_type; | 60 this->shader_type = shader_type; |
64 this->shader_spec = shader_spec; | 61 this->shader_spec = shader_spec; |
65 this->resources = resources; | 62 this->resources = resources; |
66 this->glsl_implementation_type = glsl_implementation_type; | 63 this->shader_output_language = shader_output_language; |
67 this->driver_bug_workarounds = driver_bug_workarounds; | 64 this->driver_bug_workarounds = driver_bug_workarounds; |
68 } | 65 } |
69 | 66 |
70 ShaderTranslatorInitParams(const ShaderTranslatorInitParams& params) { | 67 ShaderTranslatorInitParams(const ShaderTranslatorInitParams& params) { |
71 memcpy(this, ¶ms, sizeof(*this)); | 68 memcpy(this, ¶ms, sizeof(*this)); |
72 } | 69 } |
73 | 70 |
74 bool operator== (const ShaderTranslatorInitParams& params) const { | 71 bool operator== (const ShaderTranslatorInitParams& params) const { |
75 return memcmp(¶ms, this, sizeof(*this)) == 0; | 72 return memcmp(¶ms, this, sizeof(*this)) == 0; |
76 } | 73 } |
(...skipping 10 matching lines...) Expand all Loading... |
87 typedef std::map<ShaderTranslatorInitParams, ShaderTranslator* > Cache; | 84 typedef std::map<ShaderTranslatorInitParams, ShaderTranslator* > Cache; |
88 Cache cache_; | 85 Cache cache_; |
89 | 86 |
90 DISALLOW_COPY_AND_ASSIGN(ShaderTranslatorCache); | 87 DISALLOW_COPY_AND_ASSIGN(ShaderTranslatorCache); |
91 }; | 88 }; |
92 | 89 |
93 } // namespace gles2 | 90 } // namespace gles2 |
94 } // namespace gpu | 91 } // namespace gpu |
95 | 92 |
96 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ | 93 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ |
OLD | NEW |