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

Unified Diff: gpu/command_buffer/service/memory_program_cache.cc

Issue 10826073: Added null check for shader source when compiling, and fixed re-caching behavior to spec (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gpu/command_buffer/service/memory_program_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/memory_program_cache.cc
diff --git a/gpu/command_buffer/service/memory_program_cache.cc b/gpu/command_buffer/service/memory_program_cache.cc
index 0a061cb1ed430edd7374cbf93781ec1195e818eb..e669ac4f83bff1ebf9befce164a102f509a2a647 100644
--- a/gpu/command_buffer/service/memory_program_cache.cc
+++ b/gpu/command_buffer/service/memory_program_cache.cc
@@ -88,22 +88,18 @@ void MemoryProgramCache::SaveLinkedProgram(
const ShaderManager::ShaderInfo* shader_a,
const ShaderManager::ShaderInfo* shader_b,
const LocationMap* bind_attrib_location_map) {
- GLsizei length;
GLenum format;
- GLsizei buffer_length = 0;
- glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH_OES, &buffer_length);
- if (static_cast<unsigned int>(buffer_length) > max_size_bytes_) {
+ GLsizei length = 0;
+ glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH_OES, &length);
+ if (length == 0 || static_cast<unsigned int>(length) > max_size_bytes_) {
return;
}
- scoped_array<char> binary(new char[buffer_length]);
+ scoped_array<char> binary(new char[length]);
glGetProgramBinary(program,
- buffer_length,
- &length,
+ length,
+ NULL,
&format,
binary.get());
- if (length == 0) {
- return;
- }
char a_sha[kHashLength];
char b_sha[kHashLength];
@@ -118,7 +114,11 @@ void MemoryProgramCache::SaveLinkedProgram(
const std::string sha_string(sha, sizeof(sha));
if (store_.find(sha_string) != store_.end()) {
- return;
+ const StoreMap::iterator found = store_.find(sha_string);
+ const ProgramCacheValue* evicting = found->second;
+ curr_size_bytes_ -= evicting->length;
+ Evict(sha_string, evicting->shader_0_hash, evicting->shader_1_hash);
+ store_.erase(found);
}
while (curr_size_bytes_ + length > max_size_bytes_) {
« no previous file with comments | « no previous file | gpu/command_buffer/service/memory_program_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698