diff options
author | Dylan Baker <[email protected]> | 2018-12-20 15:54:06 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-05-21 15:05:38 -0700 |
commit | 4756864cdc5fee9602ab63a9fa2c4b459667a6c2 (patch) | |
tree | 808a9fc15d411a67890f01b40e1e9ba5404867a0 /src/gallium/drivers/iris | |
parent | 6ae2caf20103d7a09d3e2f38537c997eb171311d (diff) |
iris: Start wiring up on-disk shader cache
This creates the on-disk shader cache data structure, and handles the
build-id keying aspects. The next commits will fill it out so it's
actually used.
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/gallium/drivers/iris')
-rw-r--r-- | src/gallium/drivers/iris/iris_disk_cache.c | 72 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_screen.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_screen.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/iris/meson.build | 1 |
4 files changed, 81 insertions, 0 deletions
diff --git a/src/gallium/drivers/iris/iris_disk_cache.c b/src/gallium/drivers/iris/iris_disk_cache.c new file mode 100644 index 00000000000..c0dc46e7e25 --- /dev/null +++ b/src/gallium/drivers/iris/iris_disk_cache.c @@ -0,0 +1,72 @@ +/* + * Copyright © 2018 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * @file iris_disk_cache.c + * + * Functions for interacting with the on-disk shader cache. + */ + +#include <stdio.h> +#include <stdint.h> +#include <assert.h> +#include <string.h> + +#include "compiler/blob.h" +#include "compiler/nir/nir.h" +#include "util/build_id.h" +#include "util/disk_cache.h" +#include "util/mesa-sha1.h" + +#include "iris_context.h" + +/** + * Initialize the on-disk shader cache. + */ +void +iris_disk_cache_init(struct iris_screen *screen) +{ +#ifdef ENABLE_SHADER_CACHE + if (INTEL_DEBUG & DEBUG_DISK_CACHE_DISABLE_MASK) + return; + + /* array length = print length + nul char + 1 extra to verify it's unused */ + char renderer[11]; + UNUSED int len = + snprintf(renderer, sizeof(renderer), "iris_%04x", screen->pci_id); + assert(len == sizeof(renderer) - 2); + + const struct build_id_note *note = + build_id_find_nhdr_for_addr(iris_disk_cache_init); + assert(note && build_id_length(note) == 20); /* sha1 */ + + const uint8_t *id_sha1 = build_id_data(note); + assert(id_sha1); + + char timestamp[41]; + _mesa_sha1_format(timestamp, id_sha1); + + const uint64_t driver_flags = + brw_get_compiler_config_value(screen->compiler); + screen->disk_cache = disk_cache_create(renderer, timestamp, driver_flags); +#endif +} diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 84fd39bb23b..fcd1bf72d73 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -510,6 +510,7 @@ iris_destroy_screen(struct pipe_screen *pscreen) iris_bo_unreference(screen->workaround_bo); u_transfer_helper_destroy(pscreen->transfer_helper); iris_bufmgr_destroy(screen->bufmgr); + disk_cache_destroy(screen->disk_cache); ralloc_free(screen); } @@ -637,6 +638,8 @@ iris_screen_create(int fd, const struct pipe_screen_config *config) screen->compiler->shader_perf_log = iris_shader_perf_log; screen->compiler->supports_pull_constants = false; + iris_disk_cache_init(screen); + slab_create_parent(&screen->transfer_pool, sizeof(struct iris_transfer), 64); diff --git a/src/gallium/drivers/iris/iris_screen.h b/src/gallium/drivers/iris/iris_screen.h index 270597a46d0..66e18ae2353 100644 --- a/src/gallium/drivers/iris/iris_screen.h +++ b/src/gallium/drivers/iris/iris_screen.h @@ -25,6 +25,7 @@ #include "pipe/p_screen.h" #include "state_tracker/drm_driver.h" +#include "util/disk_cache.h" #include "util/slab.h" #include "util/u_screen.h" #include "intel/dev/gen_device_info.h" @@ -80,6 +81,8 @@ struct iris_screen { * require scratch writes or reads from some unimportant memory. */ struct iris_bo *workaround_bo; + + struct disk_cache *disk_cache; }; struct pipe_screen * @@ -93,4 +96,6 @@ iris_is_format_supported(struct pipe_screen *pscreen, unsigned storage_sample_count, unsigned usage); +void iris_disk_cache_init(struct iris_screen *screen); + #endif diff --git a/src/gallium/drivers/iris/meson.build b/src/gallium/drivers/iris/meson.build index 673b2170e1a..7d8948c9d40 100644 --- a/src/gallium/drivers/iris/meson.build +++ b/src/gallium/drivers/iris/meson.build @@ -45,6 +45,7 @@ files_libiris = files( 'iris_resource.h', 'iris_screen.c', 'iris_screen.h', + 'iris_disk_cache.c', ) iris_driinfo_h = custom_target( |