aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2020-05-13 09:30:44 +1000
committerDave Airlie <[email protected]>2020-06-11 06:05:40 +1000
commit7b7c02d161df2f09fa06b8b0b42caf869a326dc9 (patch)
tree47b19cb7ebce915a0a0580bd32da4507ad0b876f /src/gallium/auxiliary
parent333ee94285ac453b9d75ce93b01bc26e48bf96d7 (diff)
gallivm: add support for a cache object
This plumbs the cache object into the gallivm API, nothing uses it yet. Reviewed-by: Roland Scheidegger <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5049>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c8
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_init.c14
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_init.h5
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_misc.cpp1
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_misc.h12
5 files changed, 31 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index db8e24f4306..445f2e11130 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -850,7 +850,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
snprintf(module_name, sizeof(module_name), "draw_llvm_vs_variant%u",
variant->shader->variants_cached);
- variant->gallivm = gallivm_create(module_name, llvm->context);
+ variant->gallivm = gallivm_create(module_name, llvm->context, NULL);
create_jit_types(variant);
@@ -2848,7 +2848,7 @@ draw_gs_llvm_create_variant(struct draw_llvm *llvm,
snprintf(module_name, sizeof(module_name), "draw_llvm_gs_variant%u",
variant->shader->variants_cached);
- variant->gallivm = gallivm_create(module_name, llvm->context);
+ variant->gallivm = gallivm_create(module_name, llvm->context, NULL);
create_gs_jit_types(variant);
@@ -3453,7 +3453,7 @@ draw_tcs_llvm_create_variant(struct draw_llvm *llvm,
snprintf(module_name, sizeof(module_name), "draw_llvm_tcs_variant%u",
variant->shader->variants_cached);
- variant->gallivm = gallivm_create(module_name, llvm->context);
+ variant->gallivm = gallivm_create(module_name, llvm->context, NULL);
create_tcs_jit_types(variant);
@@ -3928,7 +3928,7 @@ draw_tes_llvm_create_variant(struct draw_llvm *llvm,
snprintf(module_name, sizeof(module_name), "draw_llvm_tes_variant%u",
variant->shader->variants_cached);
- variant->gallivm = gallivm_create(module_name, llvm->context);
+ variant->gallivm = gallivm_create(module_name, llvm->context, NULL);
create_tes_jit_types(variant);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c
index ce522806669..06214014290 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -211,6 +211,9 @@ gallivm_free_ir(struct gallivm_state *gallivm)
LLVMDisposeModule(gallivm->module);
}
+ if (gallivm->cache) {
+ free(gallivm->cache->data);
+ }
FREE(gallivm->module_name);
if (gallivm->target) {
@@ -230,6 +233,7 @@ gallivm_free_ir(struct gallivm_state *gallivm)
gallivm->passmgr = NULL;
gallivm->context = NULL;
gallivm->builder = NULL;
+ gallivm->cache = NULL;
}
@@ -265,6 +269,7 @@ init_gallivm_engine(struct gallivm_state *gallivm)
ret = lp_build_create_jit_compiler_for_module(&gallivm->engine,
&gallivm->code,
+ gallivm->cache,
gallivm->module,
gallivm->memorymgr,
(unsigned) optlevel,
@@ -310,7 +315,7 @@ fail:
*/
static boolean
init_gallivm_state(struct gallivm_state *gallivm, const char *name,
- LLVMContextRef context)
+ LLVMContextRef context, struct lp_cached_code *cache)
{
assert(!gallivm->context);
assert(!gallivm->module);
@@ -319,7 +324,7 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name,
return FALSE;
gallivm->context = context;
-
+ gallivm->cache = cache;
if (!gallivm->context)
goto fail;
@@ -496,13 +501,14 @@ lp_build_init(void)
* Create a new gallivm_state object.
*/
struct gallivm_state *
-gallivm_create(const char *name, LLVMContextRef context)
+gallivm_create(const char *name, LLVMContextRef context,
+ struct lp_cached_code *cache)
{
struct gallivm_state *gallivm;
gallivm = CALLOC_STRUCT(gallivm_state);
if (gallivm) {
- if (!init_gallivm_state(gallivm, name, context)) {
+ if (!init_gallivm_state(gallivm, name, context, cache)) {
FREE(gallivm);
gallivm = NULL;
}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h
index cebf6a793d5..4b00cebaef5 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_init.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h
@@ -39,6 +39,7 @@
extern "C" {
#endif
+struct lp_cached_code;
struct gallivm_state
{
char *module_name;
@@ -51,6 +52,7 @@ struct gallivm_state
LLVMBuilderRef builder;
LLVMMCJITMemoryManagerRef memorymgr;
struct lp_generated_code *code;
+ struct lp_cached_code *cache;
unsigned compiled;
LLVMValueRef coro_malloc_hook;
LLVMValueRef coro_free_hook;
@@ -63,7 +65,8 @@ lp_build_init(void);
struct gallivm_state *
-gallivm_create(const char *name, LLVMContextRef context);
+gallivm_create(const char *name, LLVMContextRef context,
+ struct lp_cached_code *cache);
void
gallivm_destroy(struct gallivm_state *gallivm);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index b079b96b6de..186965f32bb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -304,6 +304,7 @@ extern "C"
LLVMBool
lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
lp_generated_code **OutCode,
+ struct lp_cached_code *cache_out,
LLVMModuleRef M,
LLVMMCJITMemoryManagerRef CMM,
unsigned OptLevel,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/src/gallium/auxiliary/gallivm/lp_bld_misc.h
index 363fbded728..f3be195554b 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.h
@@ -40,6 +40,17 @@
extern "C" {
#endif
+/*
+ * some shaders use function pointers incorrectly so can't be relinked
+ * properly. (mostly the fallback fetch shaders).
+ * We should fix them, but the dont_cache flag can be set for now,
+ * so they don't end up getting cached at all.
+ */
+struct lp_cached_code {
+ void *data;
+ size_t data_size;
+ bool dont_cache;
+};
struct lp_generated_code;
@@ -56,6 +67,7 @@ lp_set_target_options(void);
extern int
lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
struct lp_generated_code **OutCode,
+ struct lp_cached_code *cache_out,
LLVMModuleRef M,
LLVMMCJITMemoryManagerRef MM,
unsigned OptLevel,