2 * Copyright © 2014 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #ifdef ENABLE_SHADER_CACHE
32 #include <sys/types.h>
42 #include "util/crc32.h"
43 #include "util/u_atomic.h"
44 #include "util/u_queue.h"
45 #include "util/mesa-sha1.h"
46 #include "util/ralloc.h"
47 #include "main/errors.h"
49 #include "disk_cache.h"
51 /* Number of bits to mask off from a cache key to get an index. */
52 #define CACHE_INDEX_KEY_BITS 16
54 /* Mask for computing an index from a key. */
55 #define CACHE_INDEX_KEY_MASK ((1 << CACHE_INDEX_KEY_BITS) - 1)
57 /* The number of keys that can be stored in the index. */
58 #define CACHE_INDEX_MAX_KEYS (1 << CACHE_INDEX_KEY_BITS)
61 /* The path to the cache directory. */
64 /* Thread queue for compressing and writing cache entries to disk */
65 struct util_queue cache_queue
;
67 /* A pointer to the mmapped index file within the cache directory. */
69 size_t index_mmap_size
;
71 /* Pointer to total size of all objects in cache (within index_mmap) */
74 /* Pointer to stored keys, (within index_mmap). */
77 /* Maximum size of all cached objects (in bytes). */
81 struct disk_cache_put_job
{
82 struct util_queue_fence fence
;
84 struct disk_cache
*cache
;
88 /* Copy of cache data to be compressed and written. */
91 /* Size of data to be compressed and written. */
95 /* Create a directory named 'path' if it does not already exist.
97 * Returns: 0 if path already exists as a directory or if created.
98 * -1 in all other cases.
101 mkdir_if_needed(const char *path
)
105 /* If the path exists already, then our work is done if it's a
106 * directory, but it's an error if it is not.
108 if (stat(path
, &sb
) == 0) {
109 if (S_ISDIR(sb
.st_mode
)) {
112 fprintf(stderr
, "Cannot use %s for shader cache (not a directory)"
113 "---disabling.\n", path
);
118 int ret
= mkdir(path
, 0755);
119 if (ret
== 0 || (ret
== -1 && errno
== EEXIST
))
122 fprintf(stderr
, "Failed to create %s for shader cache (%s)---disabling.\n",
123 path
, strerror(errno
));
128 /* Concatenate an existing path and a new name to form a new path. If the new
129 * path does not exist as a directory, create it then return the resulting
130 * name of the new path (ralloc'ed off of 'ctx').
132 * Returns NULL on any error, such as:
134 * <path> does not exist or is not a directory
135 * <path>/<name> exists but is not a directory
136 * <path>/<name> cannot be created as a directory
139 concatenate_and_mkdir(void *ctx
, const char *path
, const char *name
)
144 if (stat(path
, &sb
) != 0 || ! S_ISDIR(sb
.st_mode
))
147 new_path
= ralloc_asprintf(ctx
, "%s/%s", path
, name
);
149 if (mkdir_if_needed(new_path
) == 0)
156 remove_dir(const char *fpath
, const struct stat
*sb
,
157 int typeflag
, struct FTW
*ftwbuf
)
159 if (S_ISREG(sb
->st_mode
))
161 else if (S_ISDIR(sb
->st_mode
))
168 remove_old_cache_directories(void *mem_ctx
, const char *path
,
169 const char *timestamp
)
171 DIR *dir
= opendir(path
);
173 struct dirent
* d_entry
;
174 while((d_entry
= readdir(dir
)) != NULL
)
177 ralloc_asprintf(mem_ctx
, "%s/%s", path
, d_entry
->d_name
);
180 if (stat(full_path
, &sb
) == 0 && S_ISDIR(sb
.st_mode
) &&
181 strcmp(d_entry
->d_name
, timestamp
) != 0 &&
182 strcmp(d_entry
->d_name
, "..") != 0 &&
183 strcmp(d_entry
->d_name
, ".") != 0) {
184 nftw(full_path
, remove_dir
, 20, FTW_DEPTH
);
192 create_mesa_cache_dir(void *mem_ctx
, const char *path
, const char *timestamp
,
193 const char *gpu_name
)
195 char *new_path
= concatenate_and_mkdir(mem_ctx
, path
, "mesa");
196 if (new_path
== NULL
)
199 /* Create a parent architecture directory so that we don't remove cache
200 * files for other architectures. In theory we could share the cache
201 * between architectures but we have no way of knowing if they were created
202 * by a compatible Mesa version.
204 new_path
= concatenate_and_mkdir(mem_ctx
, new_path
, get_arch_bitness_str());
205 if (new_path
== NULL
)
208 /* Remove cache directories for old Mesa versions */
209 remove_old_cache_directories(mem_ctx
, new_path
, timestamp
);
211 new_path
= concatenate_and_mkdir(mem_ctx
, new_path
, timestamp
);
212 if (new_path
== NULL
)
215 new_path
= concatenate_and_mkdir(mem_ctx
, new_path
, gpu_name
);
216 if (new_path
== NULL
)
223 disk_cache_create(const char *gpu_name
, const char *timestamp
)
226 struct disk_cache
*cache
= NULL
;
227 char *path
, *max_size_str
;
233 /* If running as a users other than the real user disable cache */
234 if (geteuid() != getuid())
237 /* A ralloc context for transient data during this invocation. */
238 local
= ralloc_context(NULL
);
242 /* At user request, disable shader cache entirely. */
243 if (getenv("MESA_GLSL_CACHE_DISABLE"))
246 /* Determine path for cache based on the first defined name as follows:
248 * $MESA_GLSL_CACHE_DIR
249 * $XDG_CACHE_HOME/mesa
250 * <pwd.pw_dir>/.cache/mesa
252 path
= getenv("MESA_GLSL_CACHE_DIR");
254 if (mkdir_if_needed(path
) == -1)
257 path
= create_mesa_cache_dir(local
, path
, timestamp
,
264 char *xdg_cache_home
= getenv("XDG_CACHE_HOME");
266 if (xdg_cache_home
) {
267 if (mkdir_if_needed(xdg_cache_home
) == -1)
270 path
= create_mesa_cache_dir(local
, xdg_cache_home
, timestamp
,
280 struct passwd pwd
, *result
;
282 buf_size
= sysconf(_SC_GETPW_R_SIZE_MAX
);
286 /* Loop until buf_size is large enough to query the directory */
288 buf
= ralloc_size(local
, buf_size
);
290 getpwuid_r(getuid(), &pwd
, buf
, buf_size
, &result
);
294 if (errno
== ERANGE
) {
303 path
= concatenate_and_mkdir(local
, pwd
.pw_dir
, ".cache");
307 path
= create_mesa_cache_dir(local
, path
, timestamp
, gpu_name
);
312 cache
= ralloc(NULL
, struct disk_cache
);
316 cache
->path
= ralloc_strdup(cache
, path
);
317 if (cache
->path
== NULL
)
320 path
= ralloc_asprintf(local
, "%s/index", cache
->path
);
324 fd
= open(path
, O_RDWR
| O_CREAT
| O_CLOEXEC
, 0644);
328 if (fstat(fd
, &sb
) == -1)
331 /* Force the index file to be the expected size. */
332 size
= sizeof(*cache
->size
) + CACHE_INDEX_MAX_KEYS
* CACHE_KEY_SIZE
;
333 if (sb
.st_size
!= size
) {
334 if (ftruncate(fd
, size
) == -1)
338 /* We map this shared so that other processes see updates that we
341 * Note: We do use atomic addition to ensure that multiple
342 * processes don't scramble the cache size recorded in the
343 * index. But we don't use any locking to prevent multiple
344 * processes from updating the same entry simultaneously. The idea
345 * is that if either result lands entirely in the index, then
346 * that's equivalent to a well-ordered write followed by an
347 * eviction and a write. On the other hand, if the simultaneous
348 * writes result in a corrupt entry, that's not really any
349 * different than both entries being evicted, (since within the
350 * guarantees of the cryptographic hash, a corrupt entry is
351 * unlikely to ever match a real cache key).
353 cache
->index_mmap
= mmap(NULL
, size
, PROT_READ
| PROT_WRITE
,
355 if (cache
->index_mmap
== MAP_FAILED
)
357 cache
->index_mmap_size
= size
;
361 cache
->size
= (uint64_t *) cache
->index_mmap
;
362 cache
->stored_keys
= cache
->index_mmap
+ sizeof(uint64_t);
366 max_size_str
= getenv("MESA_GLSL_CACHE_MAX_SIZE");
369 max_size
= strtoul(max_size_str
, &end
, 10);
370 if (end
== max_size_str
) {
380 max_size
*= 1024*1024;
386 max_size
*= 1024*1024*1024;
392 /* Default to 1GB for maximum cache size. */
394 max_size
= 1024*1024*1024;
396 cache
->max_size
= max_size
;
398 /* A limit of 32 jobs was choosen as observations of Deus Ex start-up times
399 * showed that we reached at most 11 jobs on an Intel i5-6400 CPU@2.70GHz
400 * (a fairly modest desktop CPU). 1 thread was chosen because we don't
401 * really care about getting things to disk quickly just that it's not
402 * blocking other tasks.
404 util_queue_init(&cache
->cache_queue
, "disk_cache", 32, 1);
421 disk_cache_destroy(struct disk_cache
*cache
)
424 util_queue_destroy(&cache
->cache_queue
);
425 munmap(cache
->index_mmap
, cache
->index_mmap_size
);
431 /* Return a filename within the cache's directory corresponding to 'key'. The
432 * returned filename is ralloced with 'cache' as the parent context.
434 * Returns NULL if out of memory.
437 get_cache_file(struct disk_cache
*cache
, const cache_key key
)
442 _mesa_sha1_format(buf
, key
);
443 if (asprintf(&filename
, "%s/%c%c/%s", cache
->path
, buf
[0],
444 buf
[1], buf
+ 2) == -1)
450 /* Create the directory that will be needed for the cache file for \key.
452 * Obviously, the implementation here must closely match
453 * _get_cache_file above.
456 make_cache_file_directory(struct disk_cache
*cache
, const cache_key key
)
461 _mesa_sha1_format(buf
, key
);
462 if (asprintf(&dir
, "%s/%c%c", cache
->path
, buf
[0], buf
[1]) == -1)
465 mkdir_if_needed(dir
);
469 /* Given a directory path and predicate function, count all entries in
470 * that directory for which the predicate returns true. Then choose a
471 * random entry from among those counted.
473 * Returns: A malloc'ed string for the path to the chosen file, (or
474 * NULL on any error). The caller should free the string when
478 choose_random_file_matching(const char *dir_path
,
479 bool (*predicate
)(const struct dirent
*,
480 const char *dir_path
))
483 struct dirent
*entry
;
484 unsigned int count
, victim
;
487 dir
= opendir(dir_path
);
494 entry
= readdir(dir
);
497 if (!predicate(entry
, dir_path
))
508 victim
= rand() % count
;
514 entry
= readdir(dir
);
517 if (!predicate(entry
, dir_path
))
530 if (asprintf(&filename
, "%s/%s", dir_path
, entry
->d_name
) < 0)
538 /* Is entry a regular file, and not having a name with a trailing
542 is_regular_non_tmp_file(const struct dirent
*entry
, const char *path
)
545 if (asprintf(&filename
, "%s/%s", path
, entry
->d_name
) == -1)
549 int res
= stat(filename
, &sb
);
552 if (res
== -1 || !S_ISREG(sb
.st_mode
))
555 size_t len
= strlen (entry
->d_name
);
556 if (len
>= 4 && strcmp(&entry
->d_name
[len
-4], ".tmp") == 0)
562 /* Returns the size of the deleted file, (or 0 on any error). */
564 unlink_random_file_from_directory(const char *path
)
569 filename
= choose_random_file_matching(path
, is_regular_non_tmp_file
);
570 if (filename
== NULL
)
573 if (stat(filename
, &sb
) == -1) {
585 /* Is entry a directory with a two-character name, (and not the
586 * special name of "..")
589 is_two_character_sub_directory(const struct dirent
*entry
, const char *path
)
592 if (asprintf(&subdir
, "%s/%s", path
, entry
->d_name
) == -1)
596 int res
= stat(subdir
, &sb
);
599 if (res
== -1 || !S_ISDIR(sb
.st_mode
))
602 if (strlen(entry
->d_name
) != 2)
605 if (strcmp(entry
->d_name
, "..") == 0)
612 evict_random_item(struct disk_cache
*cache
)
614 const char hex
[] = "0123456789abcde";
619 /* With a reasonably-sized, full cache, (and with keys generated
620 * from a cryptographic hash), we can choose two random hex digits
621 * and reasonably expect the directory to exist with a file in it.
626 if (asprintf(&dir_path
, "%s/%c%c", cache
->path
, hex
[a
], hex
[b
]) < 0)
629 size
= unlink_random_file_from_directory(dir_path
);
634 p_atomic_add(cache
->size
, - (uint64_t)size
);
638 /* In the case where the random choice of directory didn't find
639 * something, we choose randomly from the existing directories.
641 * Really, the only reason this code exists is to allow the unit
642 * tests to work, (which use an artificially-small cache to be able
643 * to force a single cached item to be evicted).
645 dir_path
= choose_random_file_matching(cache
->path
,
646 is_two_character_sub_directory
);
647 if (dir_path
== NULL
)
650 size
= unlink_random_file_from_directory(dir_path
);
655 p_atomic_add(cache
->size
, - (uint64_t)size
);
659 disk_cache_remove(struct disk_cache
*cache
, const cache_key key
)
663 char *filename
= get_cache_file(cache
, key
);
664 if (filename
== NULL
) {
668 if (stat(filename
, &sb
) == -1) {
677 p_atomic_add(cache
->size
, - (uint64_t)sb
.st_size
);
680 /* From the zlib docs:
681 * "If the memory is available, buffers sizes on the order of 128K or 256K
682 * bytes should be used."
684 #define BUFSIZE 256 * 1024
687 * Compresses cache entry in memory and writes it to disk. Returns the size
688 * of the data written to disk.
691 deflate_and_write_to_disk(const void *in_data
, size_t in_data_size
, int dest
,
692 const char *filename
)
694 unsigned char out
[BUFSIZE
];
696 /* allocate deflate state */
698 strm
.zalloc
= Z_NULL
;
700 strm
.opaque
= Z_NULL
;
701 strm
.next_in
= (uint8_t *) in_data
;
702 strm
.avail_in
= in_data_size
;
704 int ret
= deflateInit(&strm
, Z_BEST_COMPRESSION
);
708 /* compress until end of in_data */
709 size_t compressed_size
= 0;
712 int remaining
= in_data_size
- BUFSIZE
;
713 flush
= remaining
> 0 ? Z_NO_FLUSH
: Z_FINISH
;
714 in_data_size
-= BUFSIZE
;
716 /* Run deflate() on input until the output buffer is not full (which
717 * means there is no more data to deflate).
720 strm
.avail_out
= BUFSIZE
;
723 ret
= deflate(&strm
, flush
); /* no bad return value */
724 assert(ret
!= Z_STREAM_ERROR
); /* state not clobbered */
726 size_t have
= BUFSIZE
- strm
.avail_out
;
727 compressed_size
+= have
;
730 for (size_t len
= 0; len
< have
; len
+= written
) {
731 written
= write(dest
, out
+ len
, have
- len
);
733 (void)deflateEnd(&strm
);
737 } while (strm
.avail_out
== 0);
739 /* all input should be used */
740 assert(strm
.avail_in
== 0);
742 } while (flush
!= Z_FINISH
);
744 /* stream should be complete */
745 assert(ret
== Z_STREAM_END
);
747 /* clean up and return */
748 (void)deflateEnd(&strm
);
749 return compressed_size
;
752 static struct disk_cache_put_job
*
753 create_put_job(struct disk_cache
*cache
, const cache_key key
,
754 const void *data
, size_t size
)
756 struct disk_cache_put_job
*dc_job
= (struct disk_cache_put_job
*)
757 malloc(sizeof(struct disk_cache_put_job
) + size
);
760 dc_job
->cache
= cache
;
761 memcpy(dc_job
->key
, key
, sizeof(cache_key
));
762 dc_job
->data
= dc_job
+ 1;
763 memcpy(dc_job
->data
, data
, size
);
771 destroy_put_job(void *job
, int thread_index
)
778 struct cache_entry_file_data
{
780 uint32_t uncompressed_size
;
784 cache_put(void *job
, int thread_index
)
788 int fd
= -1, fd_final
= -1, err
, ret
;
790 char *filename
= NULL
, *filename_tmp
= NULL
;
791 struct disk_cache_put_job
*dc_job
= (struct disk_cache_put_job
*) job
;
793 filename
= get_cache_file(dc_job
->cache
, dc_job
->key
);
794 if (filename
== NULL
)
797 /* Write to a temporary file to allow for an atomic rename to the
798 * final destination filename, (to prevent any readers from seeing
799 * a partially written file).
801 if (asprintf(&filename_tmp
, "%s.tmp", filename
) == -1)
804 fd
= open(filename_tmp
, O_WRONLY
| O_CLOEXEC
| O_CREAT
, 0644);
806 /* Make the two-character subdirectory within the cache as needed. */
811 make_cache_file_directory(dc_job
->cache
, dc_job
->key
);
813 fd
= open(filename_tmp
, O_WRONLY
| O_CLOEXEC
| O_CREAT
, 0644);
818 /* With the temporary file open, we take an exclusive flock on
819 * it. If the flock fails, then another process still has the file
820 * open with the flock held. So just let that file be responsible
821 * for writing the file.
823 err
= flock(fd
, LOCK_EX
| LOCK_NB
);
827 /* Now that we have the lock on the open temporary file, we can
828 * check to see if the destination file already exists. If so,
829 * another process won the race between when we saw that the file
830 * didn't exist and now. In this case, we don't do anything more,
831 * (to ensure the size accounting of the cache doesn't get off).
833 fd_final
= open(filename
, O_RDONLY
| O_CLOEXEC
);
837 /* OK, we're now on the hook to write out a file that we know is
838 * not in the cache, and is also not being written out to the cache
839 * by some other process.
841 * Before we do that, if the cache is too large, evict something
844 if (*dc_job
->cache
->size
+ dc_job
->size
> dc_job
->cache
->max_size
)
845 evict_random_item(dc_job
->cache
);
847 /* Create CRC of the data and store at the start of the file. We will
848 * read this when restoring the cache and use it to check for corruption.
850 struct cache_entry_file_data cf_data
;
851 cf_data
.crc32
= util_hash_crc32(dc_job
->data
, dc_job
->size
);
852 cf_data
.uncompressed_size
= dc_job
->size
;
854 size_t cf_data_size
= sizeof(cf_data
);
855 for (len
= 0; len
< cf_data_size
; len
+= ret
) {
856 ret
= write(fd
, ((uint8_t *) &cf_data
) + len
, cf_data_size
- len
);
858 unlink(filename_tmp
);
863 /* Now, finally, write out the contents to the temporary file, then
864 * rename them atomically to the destination filename, and also
865 * perform an atomic increment of the total cache size.
867 size_t file_size
= deflate_and_write_to_disk(dc_job
->data
, dc_job
->size
,
869 if (file_size
== 0) {
870 unlink(filename_tmp
);
873 rename(filename_tmp
, filename
);
875 file_size
+= cf_data_size
;
876 p_atomic_add(dc_job
->cache
->size
, file_size
);
881 /* This close finally releases the flock, (now that the final dile
882 * has been renamed into place and the size has been added).
893 disk_cache_put(struct disk_cache
*cache
, const cache_key key
,
894 const void *data
, size_t size
)
896 struct disk_cache_put_job
*dc_job
=
897 create_put_job(cache
, key
, data
, size
);
900 util_queue_fence_init(&dc_job
->fence
);
901 util_queue_add_job(&cache
->cache_queue
, dc_job
, &dc_job
->fence
,
902 cache_put
, destroy_put_job
);
907 * Decompresses cache entry, returns true if successful.
910 inflate_cache_data(uint8_t *in_data
, size_t in_data_size
,
911 uint8_t *out_data
, size_t out_data_size
)
915 /* allocate inflate state */
916 strm
.zalloc
= Z_NULL
;
918 strm
.opaque
= Z_NULL
;
919 strm
.next_in
= in_data
;
920 strm
.avail_in
= in_data_size
;
921 strm
.next_out
= out_data
;
922 strm
.avail_out
= out_data_size
;
924 int ret
= inflateInit(&strm
);
928 ret
= inflate(&strm
, Z_NO_FLUSH
);
929 assert(ret
!= Z_STREAM_ERROR
); /* state not clobbered */
931 /* Unless there was an error we should have decompressed everything in one
932 * go as we know the uncompressed file size.
934 if (ret
!= Z_STREAM_END
) {
935 (void)inflateEnd(&strm
);
938 assert(strm
.avail_out
== 0);
940 /* clean up and return */
941 (void)inflateEnd(&strm
);
946 disk_cache_get(struct disk_cache
*cache
, const cache_key key
, size_t *size
)
948 int fd
= -1, ret
, len
;
950 char *filename
= NULL
;
951 uint8_t *data
= NULL
;
952 uint8_t *uncompressed_data
= NULL
;
957 filename
= get_cache_file(cache
, key
);
958 if (filename
== NULL
)
961 fd
= open(filename
, O_RDONLY
| O_CLOEXEC
);
965 if (fstat(fd
, &sb
) == -1)
968 data
= malloc(sb
.st_size
);
972 /* Load the CRC that was created when the file was written. */
973 struct cache_entry_file_data cf_data
;
974 size_t cf_data_size
= sizeof(cf_data
);
975 assert(sb
.st_size
> cf_data_size
);
976 for (len
= 0; len
< cf_data_size
; len
+= ret
) {
977 ret
= read(fd
, ((uint8_t *) &cf_data
) + len
, cf_data_size
- len
);
982 /* Load the actual cache data. */
983 size_t cache_data_size
= sb
.st_size
- cf_data_size
;
984 for (len
= 0; len
< cache_data_size
; len
+= ret
) {
985 ret
= read(fd
, data
+ len
, cache_data_size
- len
);
990 /* Uncompress the cache data */
991 uncompressed_data
= malloc(cf_data
.uncompressed_size
);
992 if (!inflate_cache_data(data
, cache_data_size
, uncompressed_data
,
993 cf_data
.uncompressed_size
))
996 /* Check the data for corruption */
997 if (cf_data
.crc32
!= util_hash_crc32(uncompressed_data
,
998 cf_data
.uncompressed_size
))
1006 *size
= cf_data
.uncompressed_size
;
1008 return uncompressed_data
;
1013 if (uncompressed_data
)
1014 free(uncompressed_data
);
1024 disk_cache_put_key(struct disk_cache
*cache
, const cache_key key
)
1026 const uint32_t *key_chunk
= (const uint32_t *) key
;
1027 int i
= *key_chunk
& CACHE_INDEX_KEY_MASK
;
1028 unsigned char *entry
;
1030 entry
= &cache
->stored_keys
[i
+ CACHE_KEY_SIZE
];
1032 memcpy(entry
, key
, CACHE_KEY_SIZE
);
1035 /* This function lets us test whether a given key was previously
1036 * stored in the cache with disk_cache_put_key(). The implement is
1037 * efficient by not using syscalls or hitting the disk. It's not
1038 * race-free, but the races are benign. If we race with someone else
1039 * calling disk_cache_put_key, then that's just an extra cache miss and an
1043 disk_cache_has_key(struct disk_cache
*cache
, const cache_key key
)
1045 const uint32_t *key_chunk
= (const uint32_t *) key
;
1046 int i
= *key_chunk
& CACHE_INDEX_KEY_MASK
;
1047 unsigned char *entry
;
1049 entry
= &cache
->stored_keys
[i
+ CACHE_KEY_SIZE
];
1051 return memcmp(entry
, key
, CACHE_KEY_SIZE
) == 0;
1054 #endif /* ENABLE_SHADER_CACHE */