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 "gpu/command_buffer/service/program_cache.h" | 5 #include "gpu/command_buffer/service/program_cache.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "gpu/command_buffer/service/shader_manager.h" | 9 #include "gpu/command_buffer/service/shader_manager.h" |
| 10 #include "third_party/angle/src/common/version.h" |
10 | 11 |
11 namespace gpu { | 12 namespace gpu { |
12 namespace gles2 { | 13 namespace gles2 { |
13 | 14 |
14 ProgramCache::ProgramCache() {} | 15 ProgramCache::ProgramCache() {} |
15 ProgramCache::~ProgramCache() {} | 16 ProgramCache::~ProgramCache() {} |
16 | 17 |
17 void ProgramCache::Clear() { | 18 void ProgramCache::Clear() { |
18 ClearBackend(); | 19 ClearBackend(); |
19 link_status_.clear(); | 20 link_status_.clear(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 108 |
108 void ProgramCache::ComputeProgramHash( | 109 void ProgramCache::ComputeProgramHash( |
109 const char* hashed_shader_0, | 110 const char* hashed_shader_0, |
110 const char* hashed_shader_1, | 111 const char* hashed_shader_1, |
111 const std::map<std::string, GLint>* bind_attrib_location_map, | 112 const std::map<std::string, GLint>* bind_attrib_location_map, |
112 const std::vector<std::string>& transform_feedback_varyings, | 113 const std::vector<std::string>& transform_feedback_varyings, |
113 GLenum transform_feedback_buffer_mode, | 114 GLenum transform_feedback_buffer_mode, |
114 char* result) const { | 115 char* result) const { |
115 const size_t shader0_size = kHashLength; | 116 const size_t shader0_size = kHashLength; |
116 const size_t shader1_size = kHashLength; | 117 const size_t shader1_size = kHashLength; |
| 118 const size_t angle_commit_size = ANGLE_COMMIT_HASH_SIZE; |
117 const size_t map_size = CalculateMapSize(bind_attrib_location_map); | 119 const size_t map_size = CalculateMapSize(bind_attrib_location_map); |
118 const size_t var_size = CalculateVaryingsSize(transform_feedback_varyings); | 120 const size_t var_size = CalculateVaryingsSize(transform_feedback_varyings); |
119 const size_t total_size = shader0_size + shader1_size + map_size + var_size | 121 const size_t total_size = shader0_size + shader1_size + angle_commit_size |
120 + sizeof(transform_feedback_buffer_mode); | 122 + map_size + var_size + sizeof(transform_feedback_buffer_mode); |
121 | 123 |
122 scoped_ptr<unsigned char[]> buffer(new unsigned char[total_size]); | 124 scoped_ptr<unsigned char[]> buffer(new unsigned char[total_size]); |
123 memcpy(buffer.get(), hashed_shader_0, shader0_size); | 125 memcpy(buffer.get(), hashed_shader_0, shader0_size); |
124 memcpy(&buffer[shader0_size], hashed_shader_1, shader1_size); | 126 memcpy(&buffer[shader0_size], hashed_shader_1, shader1_size); |
125 size_t current_pos = shader0_size + shader1_size; | 127 size_t current_pos = shader0_size + shader1_size; |
| 128 memcpy(&buffer[current_pos], ANGLE_COMMIT_HASH, angle_commit_size); |
| 129 current_pos += angle_commit_size; |
126 if (map_size != 0) { | 130 if (map_size != 0) { |
127 // copy our map | 131 // copy our map |
128 for (auto it = bind_attrib_location_map->begin(); | 132 for (auto it = bind_attrib_location_map->begin(); |
129 it != bind_attrib_location_map->end(); | 133 it != bind_attrib_location_map->end(); |
130 ++it) { | 134 ++it) { |
131 const size_t name_size = it->first.length(); | 135 const size_t name_size = it->first.length(); |
132 memcpy(&buffer.get()[current_pos], it->first.c_str(), name_size); | 136 memcpy(&buffer.get()[current_pos], it->first.c_str(), name_size); |
133 current_pos += name_size; | 137 current_pos += name_size; |
134 const GLint value = it->second; | 138 const GLint value = it->second; |
135 buffer[current_pos++] = value >> 24; | 139 buffer[current_pos++] = value >> 24; |
(...skipping 13 matching lines...) Expand all Loading... |
149 } | 153 } |
150 } | 154 } |
151 memcpy(&buffer[current_pos], &transform_feedback_buffer_mode, | 155 memcpy(&buffer[current_pos], &transform_feedback_buffer_mode, |
152 sizeof(transform_feedback_buffer_mode)); | 156 sizeof(transform_feedback_buffer_mode)); |
153 base::SHA1HashBytes(buffer.get(), | 157 base::SHA1HashBytes(buffer.get(), |
154 total_size, reinterpret_cast<unsigned char*>(result)); | 158 total_size, reinterpret_cast<unsigned char*>(result)); |
155 } | 159 } |
156 | 160 |
157 } // namespace gles2 | 161 } // namespace gles2 |
158 } // namespace gpu | 162 } // namespace gpu |
OLD | NEW |