| 225 | } |
| 226 | |
| 227 | GLShaderCache::CacheIndexKey GLShaderCache::GetCacheKey( |
| 228 | const std::string_view vertex_shader, const std::string_view fragment_shader) |
| 229 | { |
| 230 | union ShaderHash |
| 231 | { |
| 232 | struct |
| 233 | { |
| 234 | u64 low; |
| 235 | u64 high; |
| 236 | }; |
| 237 | u8 bytes[16]; |
| 238 | }; |
| 239 | |
| 240 | ShaderHash vertex_hash = {}; |
| 241 | ShaderHash fragment_hash = {}; |
| 242 | |
| 243 | MD5Digest digest; |
| 244 | if (!vertex_shader.empty()) |
| 245 | { |
| 246 | digest.Update(vertex_shader.data(), static_cast<u32>(vertex_shader.length())); |
| 247 | digest.Final(vertex_hash.bytes); |
| 248 | } |
| 249 | |
| 250 | if (!fragment_shader.empty()) |
| 251 | { |
| 252 | digest.Reset(); |
| 253 | digest.Update(fragment_shader.data(), static_cast<u32>(fragment_shader.length())); |
| 254 | digest.Final(fragment_hash.bytes); |
| 255 | } |
| 256 | |
| 257 | return CacheIndexKey{vertex_hash.low, vertex_hash.high, static_cast<u32>(vertex_shader.length()), fragment_hash.low, |
| 258 | fragment_hash.high, static_cast<u32>(fragment_shader.length())}; |
| 259 | } |
| 260 | |
| 261 | std::string GLShaderCache::GetIndexFileName() const |
| 262 | { |