| 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 PROGRAM_LOAD_FAILURE, | 35 PROGRAM_LOAD_FAILURE, |
| 36 PROGRAM_LOAD_SUCCESS | 36 PROGRAM_LOAD_SUCCESS |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 ProgramCache(); | 39 ProgramCache(); |
| 40 virtual ~ProgramCache(); | 40 virtual ~ProgramCache(); |
| 41 | 41 |
| 42 LinkedProgramStatus GetLinkedProgramStatus( | 42 LinkedProgramStatus GetLinkedProgramStatus( |
| 43 const std::string& shader_signature_a, | 43 const std::string& shader_signature_a, |
| 44 const std::string& shader_signature_b, | 44 const std::string& shader_signature_b, |
| 45 const LocationMap* bind_attrib_location_map) const; | 45 const LocationMap* bind_attrib_location_map, |
| 46 const std::vector<std::string>& transform_feedback_varyings, |
| 47 GLenum transform_feedback_buffer_mode) const; |
| 46 | 48 |
| 47 // Loads the linked program from the cache. If the program is not found or | 49 // Loads the linked program from the cache. If the program is not found or |
| 48 // there was an error, PROGRAM_LOAD_FAILURE should be returned. | 50 // there was an error, PROGRAM_LOAD_FAILURE should be returned. |
| 49 virtual ProgramLoadResult LoadLinkedProgram( | 51 virtual ProgramLoadResult LoadLinkedProgram( |
| 50 GLuint program, | 52 GLuint program, |
| 51 Shader* shader_a, | 53 Shader* shader_a, |
| 52 Shader* shader_b, | 54 Shader* shader_b, |
| 53 const LocationMap* bind_attrib_location_map, | 55 const LocationMap* bind_attrib_location_map, |
| 56 const std::vector<std::string>& transform_feedback_varyings, |
| 57 GLenum transform_feedback_buffer_mode, |
| 54 const ShaderCacheCallback& shader_callback) = 0; | 58 const ShaderCacheCallback& shader_callback) = 0; |
| 55 | 59 |
| 56 // Saves the program into the cache. If successful, the implementation should | 60 // Saves the program into the cache. If successful, the implementation should |
| 57 // call LinkedProgramCacheSuccess. | 61 // call LinkedProgramCacheSuccess. |
| 58 virtual void SaveLinkedProgram( | 62 virtual void SaveLinkedProgram( |
| 59 GLuint program, | 63 GLuint program, |
| 60 const Shader* shader_a, | 64 const Shader* shader_a, |
| 61 const Shader* shader_b, | 65 const Shader* shader_b, |
| 62 const LocationMap* bind_attrib_location_map, | 66 const LocationMap* bind_attrib_location_map, |
| 67 const std::vector<std::string>& transform_feedback_varyings, |
| 68 GLenum transform_feedback_buffer_mode, |
| 63 const ShaderCacheCallback& shader_callback) = 0; | 69 const ShaderCacheCallback& shader_callback) = 0; |
| 64 | 70 |
| 65 virtual void LoadProgram(const std::string& program) = 0; | 71 virtual void LoadProgram(const std::string& program) = 0; |
| 66 | 72 |
| 67 // clears the cache | 73 // clears the cache |
| 68 void Clear(); | 74 void Clear(); |
| 69 | 75 |
| 70 // Only for testing | 76 // Only for testing |
| 71 void LinkedProgramCacheSuccess(const std::string& shader_signature_a, | 77 void LinkedProgramCacheSuccess(const std::string& shader_signature_a, |
| 72 const std::string& shader_signature_b, | 78 const std::string& shader_signature_b, |
| 73 const LocationMap* bind_attrib_location_map); | 79 const LocationMap* bind_attrib_location_map, |
| 80 const std::vector<std::string>& transform_feedback_varyings, |
| 81 GLenum transform_feedback_buffer_mode); |
| 74 | 82 |
| 75 protected: | 83 protected: |
| 76 // called by implementing class after a shader was successfully cached | 84 // called by implementing class after a shader was successfully cached |
| 77 void LinkedProgramCacheSuccess(const std::string& program_hash); | 85 void LinkedProgramCacheSuccess(const std::string& program_hash); |
| 78 | 86 |
| 79 // result is not null terminated | 87 // result is not null terminated |
| 80 void ComputeShaderHash(const std::string& shader, | 88 void ComputeShaderHash(const std::string& shader, |
| 81 char* result) const; | 89 char* result) const; |
| 82 | 90 |
| 83 // result is not null terminated. hashed shaders are expected to be | 91 // result is not null terminated. hashed shaders are expected to be |
| 84 // kHashLength in length | 92 // kHashLength in length |
| 85 void ComputeProgramHash( | 93 void ComputeProgramHash( |
| 86 const char* hashed_shader_0, | 94 const char* hashed_shader_0, |
| 87 const char* hashed_shader_1, | 95 const char* hashed_shader_1, |
| 88 const LocationMap* bind_attrib_location_map, | 96 const LocationMap* bind_attrib_location_map, |
| 97 const std::vector<std::string>& transform_feedback_varyings, |
| 98 GLenum transform_feedback_buffer_mode, |
| 89 char* result) const; | 99 char* result) const; |
| 90 | 100 |
| 91 void Evict(const std::string& program_hash); | 101 void Evict(const std::string& program_hash); |
| 92 | 102 |
| 93 private: | 103 private: |
| 94 typedef base::hash_map<std::string, | 104 typedef base::hash_map<std::string, |
| 95 LinkedProgramStatus> LinkStatusMap; | 105 LinkedProgramStatus> LinkStatusMap; |
| 96 | 106 |
| 97 // called to clear the backend cache | 107 // called to clear the backend cache |
| 98 virtual void ClearBackend() = 0; | 108 virtual void ClearBackend() = 0; |
| 99 | 109 |
| 100 LinkStatusMap link_status_; | 110 LinkStatusMap link_status_; |
| 101 | 111 |
| 102 DISALLOW_COPY_AND_ASSIGN(ProgramCache); | 112 DISALLOW_COPY_AND_ASSIGN(ProgramCache); |
| 103 }; | 113 }; |
| 104 | 114 |
| 105 } // namespace gles2 | 115 } // namespace gles2 |
| 106 } // namespace gpu | 116 } // namespace gpu |
| 107 | 117 |
| 108 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ | 118 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_CACHE_H_ |
| OLD | NEW |