From 7f1a51c32f9c8c5a44118483c1255328d7983fce Mon Sep 17 00:00:00 2001 From: "gman@chromium.org" Date: Thu, 19 Jul 2012 18:52:02 +0000 Subject: Revert 147328 - Current status of patch: - In-memory cache - maximum in memory limit (currently 6mb) - lru eviction - Cache includes saving the attribute + uniform mappings Wiring: - Added bindings for glProgramBinary and glGetProgramBinary - Plumbed the shader cache from gl_channel_manager to program_manager Refactoring: - moved the meat of DoCompile to the ProgramManager New: - added field to ShaderInfo to store if we have a possible pending cache compile - exposed attrib_map and uniform_map in ShaderInfo for the cache - program_cache base class with in-memory status storage - Simple memory_program_cache implementation, stores programs with lru eviction - Added caching logic to DoCompileShader in gles2_cmd_decoder and Link in program_manager Design doc: https://docs.google.com/document/d/1Vceem-nF4TCICoeGSh7OMXxfGuJEJYblGXRgN9V9hcE/edit BUG=88572 Review URL: https://chromiumcodereview.appspot.com/10534173 TBR=dmurph@chromium.org Review URL: https://chromiumcodereview.appspot.com/10795037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147497 0039d316-1c4b-4281-b951-d872f2087c98 --- gpu/command_buffer/service/program_cache.h | 122 ----------------------------- 1 file changed, 122 deletions(-) delete mode 100644 gpu/command_buffer/service/program_cache.h (limited to 'gpu/command_buffer/service/program_cache.h') diff --git a/gpu/command_buffer/service/program_cache.h b/gpu/command_buffer/service/program_cache.h deleted file mode 100644 index 77f8b13..0000000 --- a/gpu/command_buffer/service/program_cache.h +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ -#define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ - -#include -#include - -#include "base/hash_tables.h" -#include "base/sha1.h" -#include "gpu/command_buffer/common/gles2_cmd_format.h" -#include "gpu/command_buffer/service/shader_manager.h" - -namespace gpu { -namespace gles2 { - -// Program cache base class for caching linked gpu programs -class GPU_EXPORT ProgramCache { - public: - static const size_t kHashLength = base::kSHA1Length; - - typedef std::map LocationMap; - - enum CompiledShaderStatus { - COMPILATION_UNKNOWN, - COMPILATION_SUCCEEDED - }; - - enum LinkedProgramStatus { - LINK_UNKNOWN, - LINK_SUCCEEDED - }; - - enum ProgramLoadResult { - PROGRAM_LOAD_FAILURE, - PROGRAM_LOAD_SUCCESS - }; - - ProgramCache(); - virtual ~ProgramCache(); - - CompiledShaderStatus GetShaderCompilationStatus( - const std::string& shader_src) const; - void ShaderCompilationSucceeded(const std::string& shader_src); - - LinkedProgramStatus GetLinkedProgramStatus( - const std::string& untranslated_a, - const std::string& untranslated_b, - const LocationMap* bind_attrib_location_map) const; - - virtual ProgramLoadResult LoadLinkedProgram( - GLuint program, - ShaderManager::ShaderInfo* shader_a, - ShaderManager::ShaderInfo* shader_b, - const LocationMap* bind_attrib_location_map) const = 0; - virtual void SaveLinkedProgram( - GLuint program, - const ShaderManager::ShaderInfo* shader_a, - const ShaderManager::ShaderInfo* shader_b, - const LocationMap* bind_attrib_location_map) = 0; - - // clears the cache - void Clear(); - - // Only for testing - void LinkedProgramCacheSuccess(const std::string& shader_a, - const std::string& shader_b, - const LocationMap* bind_attrib_location_map); - - protected: - // called by implementing class after a shader was successfully cached - void LinkedProgramCacheSuccess(const std::string& program_hash, - const std::string& shader_a_hash, - const std::string& shader_b_hash); - - // result is not null terminated - void ComputeShaderHash(const std::string& shader, - char* result) const; - - // result is not null terminated. hashed shaders are expected to be - // kHashLength in length - void ComputeProgramHash( - const char* hashed_shader_0, - const char* hashed_shader_1, - const LocationMap* bind_attrib_location_map, - char* result) const; - - void Evict(const std::string& program_hash, - const std::string& shader_0_hash, - const std::string& shader_1_hash); - - private: - struct CompiledShaderInfo { - CompiledShaderInfo() : status(COMPILATION_UNKNOWN), ref_count(0) { } - explicit CompiledShaderInfo(CompiledShaderStatus status_) - : status(status_), - ref_count(0) { } - - CompiledShaderStatus status; - size_t ref_count; - }; - - typedef base::hash_map CompileStatusMap; - typedef base::hash_map LinkStatusMap; - - // called to clear the backend cache - virtual void ClearBackend() = 0; - - CompileStatusMap shader_status_; - LinkStatusMap link_status_; - - DISALLOW_COPY_AND_ASSIGN(ProgramCache); -}; - -} // namespace gles2 -} // namespace gpu - -#endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ -- cgit v1.1