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

Side by Side Diff: gpu/command_buffer/service/shader_translator_cache.h

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
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 #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 23 matching lines...) Expand all
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 ShaderTranslatorInterface::GlslImplementationType
39 glsl_implementation_type, 39 glsl_implementation_type,
40 ShCompileOptions driver_bug_workarounds); 40 ShCompileOptions driver_bug_workarounds);
41 41
42 private: 42 private:
43 friend class base::RefCounted<ShaderTranslatorCache>; 43 friend class base::RefCounted<ShaderTranslatorCache>;
44 friend class ShaderTranslatorCacheTest_InitParamComparable_Test;
44 ~ShaderTranslatorCache() override; 45 ~ShaderTranslatorCache() override;
45 46
46 // Parameters passed into ShaderTranslator::Init 47 // Parameters passed into ShaderTranslator::Init
47 struct ShaderTranslatorInitParams { 48 struct ShaderTranslatorInitParams {
48 sh::GLenum shader_type; 49 sh::GLenum shader_type;
49 ShShaderSpec shader_spec; 50 ShShaderSpec shader_spec;
50 ShBuiltInResources resources; 51 ShBuiltInResources resources;
51 ShaderTranslatorInterface::GlslImplementationType 52 ShaderTranslatorInterface::GlslImplementationType
52 glsl_implementation_type; 53 glsl_implementation_type;
53 ShCompileOptions driver_bug_workarounds; 54 ShCompileOptions driver_bug_workarounds;
54 55
55 ShaderTranslatorInitParams( 56 ShaderTranslatorInitParams(sh::GLenum shader_type,
56 sh::GLenum shader_type, 57 ShShaderSpec shader_spec,
57 ShShaderSpec shader_spec, 58 const ShBuiltInResources& resources,
58 const ShBuiltInResources& resources, 59 ShaderTranslatorInterface::GlslImplementationType
59 ShaderTranslatorInterface::GlslImplementationType 60 glsl_implementation_type,
60 glsl_implementation_type, 61 ShCompileOptions driver_bug_workarounds) {
61 ShCompileOptions driver_bug_workarounds) 62 memset(this, 0, sizeof(*this));
62 : shader_type(shader_type), 63 this->shader_type = shader_type;
63 shader_spec(shader_spec), 64 this->shader_spec = shader_spec;
64 resources(resources), 65 this->resources = resources;
65 glsl_implementation_type(glsl_implementation_type), 66 this->glsl_implementation_type = glsl_implementation_type;
66 driver_bug_workarounds(driver_bug_workarounds) { 67 this->driver_bug_workarounds = driver_bug_workarounds;
67 } 68 }
68 69
69 ShaderTranslatorInitParams(const ShaderTranslatorInitParams& params) { 70 ShaderTranslatorInitParams(const ShaderTranslatorInitParams& params) {
70 memcpy(this, &params, sizeof(*this)); 71 memcpy(this, &params, sizeof(*this));
71 } 72 }
72 73
73 bool operator== (const ShaderTranslatorInitParams& params) const { 74 bool operator== (const ShaderTranslatorInitParams& params) const {
74 return memcmp(&params, this, sizeof(*this)) == 0; 75 return memcmp(&params, this, sizeof(*this)) == 0;
75 } 76 }
76 77
77 bool operator< (const ShaderTranslatorInitParams& params) const { 78 bool operator< (const ShaderTranslatorInitParams& params) const {
78 return memcmp(&params, this, sizeof(*this)) < 0; 79 return memcmp(&params, this, sizeof(*this)) < 0;
79 } 80 }
81
82 private:
83 ShaderTranslatorInitParams();
84 ShaderTranslatorInitParams& operator=(const ShaderTranslatorInitParams&);
80 }; 85 };
81 86
82 typedef std::map<ShaderTranslatorInitParams, ShaderTranslator* > Cache; 87 typedef std::map<ShaderTranslatorInitParams, ShaderTranslator* > Cache;
83 Cache cache_; 88 Cache cache_;
84 89
85 DISALLOW_COPY_AND_ASSIGN(ShaderTranslatorCache); 90 DISALLOW_COPY_AND_ASSIGN(ShaderTranslatorCache);
86 }; 91 };
87 92
88 } // namespace gles2 93 } // namespace gles2
89 } // namespace gpu 94 } // namespace gpu
90 95
91 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ 96 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager_unittest.cc ('k') | gpu/command_buffer/service/shader_translator_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698