gpu: Add ANGLE commit to program cache hash.
ANGLE rejects program binaries compiled from a different ANGLE,
because the program format can change, and other incompatibilities.
Add the commit id to the cache hash so the cache layer can skip
trying to compile these shaders.
This change should mostly affect developers who are testing Chrome
and modifying ANGLE between compiles.
BUG=510151
Review URL: https://codereview.chromium.org/1261353003
Cr-Commit-Position: refs/heads/master@{#341713}
diff --git a/gpu/command_buffer/service/BUILD.gn b/gpu/command_buffer/service/BUILD.gn
index 6749c01..81e9db2 100644
--- a/gpu/command_buffer/service/BUILD.gn
+++ b/gpu/command_buffer/service/BUILD.gn
@@ -152,6 +152,7 @@
"//base/third_party/dynamic_annotations",
"//crypto",
"//gpu/config:config_sources",
+ "//third_party/angle:commit_id",
"//third_party/angle:translator",
"//third_party/protobuf:protobuf_lite",
"//third_party/re2",
diff --git a/gpu/command_buffer/service/program_cache.cc b/gpu/command_buffer/service/program_cache.cc
index 31802de2..ee1a736b 100644
--- a/gpu/command_buffer/service/program_cache.cc
+++ b/gpu/command_buffer/service/program_cache.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/memory/scoped_ptr.h"
#include "gpu/command_buffer/service/shader_manager.h"
+#include "third_party/angle/src/common/version.h"
namespace gpu {
namespace gles2 {
@@ -114,15 +115,18 @@
char* result) const {
const size_t shader0_size = kHashLength;
const size_t shader1_size = kHashLength;
+ const size_t angle_commit_size = ANGLE_COMMIT_HASH_SIZE;
const size_t map_size = CalculateMapSize(bind_attrib_location_map);
const size_t var_size = CalculateVaryingsSize(transform_feedback_varyings);
- const size_t total_size = shader0_size + shader1_size + map_size + var_size
- + sizeof(transform_feedback_buffer_mode);
+ const size_t total_size = shader0_size + shader1_size + angle_commit_size
+ + map_size + var_size + sizeof(transform_feedback_buffer_mode);
scoped_ptr<unsigned char[]> buffer(new unsigned char[total_size]);
memcpy(buffer.get(), hashed_shader_0, shader0_size);
memcpy(&buffer[shader0_size], hashed_shader_1, shader1_size);
size_t current_pos = shader0_size + shader1_size;
+ memcpy(&buffer[current_pos], ANGLE_COMMIT_HASH, angle_commit_size);
+ current_pos += angle_commit_size;
if (map_size != 0) {
// copy our map
for (auto it = bind_attrib_location_map->begin();
diff --git a/gpu/command_buffer_service.gypi b/gpu/command_buffer_service.gypi
index 388fcc3..b633f89 100644
--- a/gpu/command_buffer_service.gypi
+++ b/gpu/command_buffer_service.gypi
@@ -22,6 +22,7 @@
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
'../ui/gl/gl.gyp:gl',
+ '<(angle_path)/src/angle.gyp:commit_id',
'<(angle_path)/src/angle.gyp:translator',
],
'sources': [