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

Side by Side Diff: gpu/command_buffer/client/program_info_manager.h

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
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_CLIENT_PROGRAM_INFO_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_
7 7
8 #include <GLES2/gl2.h> 8 #include <GLES3/gl3.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/gtest_prod_util.h"
14 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "gles2_impl_export.h" 16 #include "gles2_impl_export.h"
16 #include "gpu/command_buffer/client/gles2_implementation.h" 17 #include "gpu/command_buffer/client/gles2_implementation.h"
17 18
18 namespace gpu { 19 namespace gpu {
19 namespace gles2 { 20 namespace gles2 {
20 21
21 // Manages info about OpenGL ES Programs. 22 // Manages info about OpenGL ES Programs.
22 class GLES2_IMPL_EXPORT ProgramInfoManager { 23 class GLES2_IMPL_EXPORT ProgramInfoManager {
23 public: 24 public:
(...skipping 17 matching lines...) Expand all
41 GLES2Implementation* gl, GLuint program, const char* name); 42 GLES2Implementation* gl, GLuint program, const char* name);
42 43
43 bool GetActiveAttrib( 44 bool GetActiveAttrib(
44 GLES2Implementation* gl, GLuint program, GLuint index, GLsizei bufsize, 45 GLES2Implementation* gl, GLuint program, GLuint index, GLsizei bufsize,
45 GLsizei* length, GLint* size, GLenum* type, char* name); 46 GLsizei* length, GLint* size, GLenum* type, char* name);
46 47
47 bool GetActiveUniform( 48 bool GetActiveUniform(
48 GLES2Implementation* gl, GLuint program, GLuint index, GLsizei bufsize, 49 GLES2Implementation* gl, GLuint program, GLuint index, GLsizei bufsize,
49 GLsizei* length, GLint* size, GLenum* type, char* name); 50 GLsizei* length, GLint* size, GLenum* type, char* name);
50 51
52 GLuint GetUniformBlockIndex(
53 GLES2Implementation* gl, GLuint program, const char* name);
54
55 bool GetActiveUniformBlockName(
56 GLES2Implementation* gl, GLuint program, GLuint index,
57 GLsizei buf_size, GLsizei* length, char* name);
58
59 bool GetActiveUniformBlockiv(
60 GLES2Implementation* gl, GLuint program, GLuint index,
61 GLenum pname, GLint* params);
62
51 private: 63 private:
52 class Program { 64 friend class ProgramInfoManagerTest;
65
66 FRIEND_TEST_ALL_PREFIXES(ProgramInfoManagerTest, UpdateES3UniformBlocks);
67
68 enum ProgramInfoType {
69 kES2,
70 kES3UniformBlocks,
71 kNone,
72 };
73
74 // Need GLES2_IMPL_EXPORT for tests.
75 class GLES2_IMPL_EXPORT Program {
53 public: 76 public:
54 struct UniformInfo { 77 struct UniformInfo {
55 UniformInfo(GLsizei _size, GLenum _type, const std::string& _name); 78 UniformInfo(GLsizei _size, GLenum _type, const std::string& _name);
56 ~UniformInfo(); 79 ~UniformInfo();
57 80
58 GLsizei size; 81 GLsizei size;
59 GLenum type; 82 GLenum type;
60 bool is_array; 83 bool is_array;
61 std::string name; 84 std::string name;
62 std::vector<GLint> element_locations; 85 std::vector<GLint> element_locations;
63 }; 86 };
64 struct VertexAttrib { 87 struct VertexAttrib {
65 VertexAttrib(GLsizei _size, GLenum _type, const std::string& _name, 88 VertexAttrib(GLsizei _size, GLenum _type, const std::string& _name,
66 GLint _location); 89 GLint _location);
67 ~VertexAttrib(); 90 ~VertexAttrib();
68 91
69 GLsizei size; 92 GLsizei size;
70 GLenum type; 93 GLenum type;
71 GLint location; 94 GLint location;
72 std::string name; 95 std::string name;
73 }; 96 };
97 struct UniformBlock {
98 UniformBlock();
99 ~UniformBlock();
100
101 GLuint binding;
102 GLuint data_size;
103 std::vector<GLuint> active_uniform_indices;
104 GLboolean referenced_by_vertex_shader;
105 GLboolean referenced_by_fragment_shader;
106 std::string name;
107 };
74 108
75 Program(); 109 Program();
76 ~Program(); 110 ~Program();
77 111
78 const VertexAttrib* GetAttribInfo(GLint index) const; 112 const VertexAttrib* GetAttribInfo(GLint index) const;
79 113
80 GLint GetAttribLocation(const std::string& name) const; 114 GLint GetAttribLocation(const std::string& name) const;
81 115
82 const UniformInfo* GetUniformInfo(GLint index) const; 116 const UniformInfo* GetUniformInfo(GLint index) const;
83 117
84 // Gets the location of a uniform by name. 118 // Gets the location of a uniform by name.
85 GLint GetUniformLocation(const std::string& name) const; 119 GLint GetUniformLocation(const std::string& name) const;
86 120
87 GLint GetFragDataLocation(const std::string& name) const; 121 GLint GetFragDataLocation(const std::string& name) const;
88 void CacheFragDataLocation(const std::string& name, GLint loc); 122 void CacheFragDataLocation(const std::string& name, GLint loc);
89 123
90 bool GetProgramiv(GLenum pname, GLint* params); 124 bool GetProgramiv(GLenum pname, GLint* params);
91 125
92 // Updates the program info after a successful link. 126 // Gets the index of a uniform block by name.
93 void Update(GLES2Implementation* gl, 127 GLuint GetUniformBlockIndex(const std::string& name) const;
94 GLuint program, 128 const UniformBlock* GetUniformBlock(GLuint index) const;
95 const std::vector<int8>& result);
96 129
97 bool cached() const; 130 // Updates the ES2 only program info after a successful link.
131 void UpdateES2(const std::vector<int8>& result);
132
133 // Updates the ES3 UniformBlock info after a successful link.
134 void UpdateES3UniformBlocks(const std::vector<int8>& result);
135
136 bool IsCached(ProgramInfoType type) const;
98 137
99 private: 138 private:
100 bool cached_; 139 bool cached_es2_;
101 140
102 GLsizei max_attrib_name_length_; 141 GLsizei max_attrib_name_length_;
103 142
104 // Attrib by index. 143 // Attrib by index.
105 std::vector<VertexAttrib> attrib_infos_; 144 std::vector<VertexAttrib> attrib_infos_;
106 145
107 GLsizei max_uniform_name_length_; 146 GLsizei max_uniform_name_length_;
108 147
109 // Uniform info by index. 148 // Uniform info by index.
110 std::vector<UniformInfo> uniform_infos_; 149 std::vector<UniformInfo> uniform_infos_;
111 150
112 base::hash_map<std::string, GLint> frag_data_locations_;
113
114 // This is true if glLinkProgram was successful last time it was called. 151 // This is true if glLinkProgram was successful last time it was called.
115 bool link_status_; 152 bool link_status_;
153
154 // BELOW ARE ES3 ONLY INFORMATION.
155
156 bool cached_es3_uniform_blocks_;
157
158 uint32_t active_uniform_block_max_name_length_;
159
160 // Uniform blocks by index.
161 std::vector<UniformBlock> uniform_blocks_;
162
163 base::hash_map<std::string, GLint> frag_data_locations_;
116 }; 164 };
117 165
118 Program* GetProgramInfo(GLES2Implementation* gl, GLuint program); 166 Program* GetProgramInfo(
167 GLES2Implementation* gl, GLuint program, ProgramInfoType type);
119 168
120 typedef base::hash_map<GLuint, Program> ProgramInfoMap; 169 typedef base::hash_map<GLuint, Program> ProgramInfoMap;
121 170
122 ProgramInfoMap program_infos_; 171 ProgramInfoMap program_infos_;
123 172
124 mutable base::Lock lock_; 173 mutable base::Lock lock_;
125 }; 174 };
126 175
127 } // namespace gles2 176 } // namespace gles2
128 } // namespace gpu 177 } // namespace gpu
129 178
130 #endif // GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_ 179 #endif // GPU_COMMAND_BUFFER_CLIENT_PROGRAM_INFO_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_trace_implementation_impl_autogen.h ('k') | gpu/command_buffer/client/program_info_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698