<div dir="ltr"><div>Pushed, thanks!</div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 7, 2019 at 7:19 AM <<a href="mailto:rsalvaterra@gmail.com">rsalvaterra@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Rui Salvaterra <<a href="mailto:rsalvaterra@gmail.com" target="_blank">rsalvaterra@gmail.com</a>><br>
<br>
This implements GLSL disk shader caching for the R300-R500 series of AMD GPUs.<br>
<br>
Signed-off-by: Rui Salvaterra <<a href="mailto:rsalvaterra@gmail.com" target="_blank">rsalvaterra@gmail.com</a>><br>
---<br>
src/gallium/drivers/r300/r300_screen.c | 38 +++++++++++++++++++++++++-<br>
src/gallium/drivers/r300/r300_screen.h | 3 ++<br>
2 files changed, 40 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c<br>
index d26cf901a7b..b9df321de86 100644<br>
--- a/src/gallium/drivers/r300/r300_screen.c<br>
+++ b/src/gallium/drivers/r300/r300_screen.c<br>
@@ -80,11 +80,42 @@ static const char* chip_families[] = {<br>
"ATI RV570"<br>
};<br>
<br>
+static const char* r300_get_family_name(struct r300_screen* r300screen)<br>
+{<br>
+ return chip_families[r300screen->caps.family];<br>
+}<br>
+<br>
static const char* r300_get_name(struct pipe_screen* pscreen)<br>
{<br>
struct r300_screen* r300screen = r300_screen(pscreen);<br>
<br>
- return chip_families[r300screen->caps.family];<br>
+ return r300_get_family_name(r300screen);<br>
+}<br>
+<br>
+static void r300_disk_cache_create(struct r300_screen* r300screen)<br>
+{<br>
+ struct mesa_sha1 ctx;<br>
+ unsigned char sha1[20];<br>
+ char cache_id[20 * 2 + 1];<br>
+<br>
+ _mesa_sha1_init(&ctx);<br>
+ if (!disk_cache_get_function_identifier(r300_disk_cache_create,<br>
+ &ctx))<br>
+ return;<br>
+<br>
+ _mesa_sha1_final(&ctx, sha1);<br>
+ disk_cache_format_hex_id(cache_id, sha1, 20 * 2);<br>
+<br>
+ r300screen->disk_shader_cache =<br>
+ disk_cache_create(r300_get_family_name(r300screen),<br>
+ cache_id,<br>
+ r300screen->debug);<br>
+}<br>
+<br>
+static struct disk_cache* r300_get_disk_shader_cache(struct pipe_screen* pscreen)<br>
+{<br>
+ struct r300_screen* r300screen = r300_screen(pscreen);<br>
+ return r300screen->disk_shader_cache;<br>
}<br>
<br>
static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)<br>
@@ -745,6 +776,8 @@ static void r300_destroy_screen(struct pipe_screen* pscreen)<br>
mtx_destroy(&r300screen->cmask_mutex);<br>
slab_destroy_parent(&r300screen->pool_transfers);<br>
<br>
+ disk_cache_destroy(r300screen->disk_shader_cache);<br>
+<br>
if (rws)<br>
rws->destroy(rws);<br>
<br>
@@ -795,6 +828,7 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws,<br>
r300screen->screen.get_name = r300_get_name;<br>
r300screen->screen.get_vendor = r300_get_vendor;<br>
r300screen->screen.get_device_vendor = r300_get_device_vendor;<br>
+ r300screen->screen.get_disk_shader_cache = r300_get_disk_shader_cache;<br>
r300screen->screen.get_param = r300_get_param;<br>
r300screen->screen.get_shader_param = r300_get_shader_param;<br>
r300screen->screen.get_paramf = r300_get_paramf;<br>
@@ -807,6 +841,8 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws,<br>
<br>
r300_init_screen_resource_functions(r300screen);<br>
<br>
+ r300_disk_cache_create(r300screen);<br>
+<br>
slab_create_parent(&r300screen->pool_transfers, sizeof(struct pipe_transfer), 64);<br>
<br>
(void) mtx_init(&r300screen->cmask_mutex, mtx_plain);<br>
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h<br>
index 952dc341ab7..b28de008304 100644<br>
--- a/src/gallium/drivers/r300/r300_screen.h<br>
+++ b/src/gallium/drivers/r300/r300_screen.h<br>
@@ -27,6 +27,7 @@<br>
#include "r300_chipset.h"<br>
#include "radeon/radeon_winsys.h"<br>
#include "pipe/p_screen.h"<br>
+#include "util/disk_cache.h"<br>
#include "util/slab.h"<br>
#include "os/os_thread.h"<br>
#include <stdio.h><br>
@@ -44,6 +45,8 @@ struct r300_screen {<br>
/** Combination of DBG_xxx flags */<br>
unsigned debug;<br>
<br>
+ struct disk_cache *disk_shader_cache;<br>
+<br>
struct slab_parent_pool pool_transfers;<br>
<br>
/* The MSAA texture with CMASK access; */<br>
-- <br>
2.21.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div>