[Mesa-dev] [PATCH 8/8] radeonsi: use a thread queue to write to shader cache
Timothy Arceri
tarceri at itsqueeze.com
Fri Mar 10 02:28:55 UTC 2017
---
src/gallium/drivers/radeonsi/si_state_shaders.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 343cb83..8c00967 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -202,26 +202,36 @@ static bool si_shader_cache_insert_shader(struct si_screen *sscreen,
if (_mesa_hash_table_insert(sscreen->shader_cache, tgsi_binary,
hw_binary) == NULL) {
FREE(hw_binary);
return false;
}
if (sscreen->b.disk_shader_cache && insert_into_disk_cache) {
_mesa_sha1_compute(tgsi_binary, *((uint32_t *)tgsi_binary), key);
+ size_t hw_binary_size = *((uint32_t *) hw_binary);
+
+ /* The binary could be freed before we write it to disk so
+ * make a copy.
+ */
+ void *hw_binary_cp = malloc(hw_binary_size);
+ memcpy(hw_binary_cp, hw_binary, hw_binary_size);
+
struct disk_cache_put_job *dc_job =
disk_cache_create_put_job(sscreen->b.disk_shader_cache,
- key, hw_binary,
- *((uint32_t *) hw_binary),
- NULL);
- disk_cache_put(dc_job, 0);
+ key, hw_binary_cp,
+ hw_binary_size, hw_binary_cp);
+ util_queue_fence_init(&dc_job->fence);
+ util_queue_add_job(&sscreen->b.disk_shader_cache->cache_queue,
+ dc_job, &dc_job->fence, disk_cache_put,
+ disk_cache_destroy_put_job);
}
return true;
}
static bool si_shader_cache_load_shader(struct si_screen *sscreen,
void *tgsi_binary,
struct si_shader *shader)
{
struct hash_entry *entry =
--
2.9.3
More information about the mesa-dev
mailing list