Commit 4756864c authored by Dylan Baker's avatar Dylan Baker Committed by Kenneth Graunke

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's avatarKenneth Graunke <kenneth@whitecape.org>
parent 6ae2caf2
/*
* 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
}
......@@ -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);
......
......@@ -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
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment