From dd60813657bc7cb753afb62ab45d3dfc68e632da Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 26 Sep 2022 12:59:05 +1000 Subject: [PATCH] llvmpipe/cs: convert cs context to opaque friendly api Reviewed-by: Roland Scheidegger Reviewed-by: Brian Paul Reviewed-by: Mihai Preda Part-of: --- src/gallium/drivers/llvmpipe/lp_jit.c | 1 + src/gallium/drivers/llvmpipe/lp_jit.h | 32 +++++++++++----------- src/gallium/drivers/llvmpipe/lp_state_cs.c | 16 ++++++++--- src/gallium/drivers/llvmpipe/lp_state_cs.h | 1 + 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 4e67a30e978..e0c6f75b111 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -486,6 +486,7 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp) LP_CHECK_STRUCT_SIZE(struct lp_jit_cs_context, gallivm->target, cs_context_type); + lp->jit_cs_context_type = cs_context_type; lp->jit_cs_context_ptr_type = LLVMPointerType(cs_context_type, 0); } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 25b09981245..876b9bf198b 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -461,29 +461,29 @@ enum { LP_JIT_CS_CTX_COUNT }; -#define lp_jit_cs_context_constants(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_CONSTANTS, "constants") +#define lp_jit_cs_context_constants(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_CONSTANTS, "constants") -#define lp_jit_cs_context_textures(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_TEXTURES, "textures") +#define lp_jit_cs_context_textures(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_TEXTURES, "textures") -#define lp_jit_cs_context_samplers(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_SAMPLERS, "samplers") +#define lp_jit_cs_context_samplers(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_SAMPLERS, "samplers") -#define lp_jit_cs_context_images(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_IMAGES, "images") +#define lp_jit_cs_context_images(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_IMAGES, "images") -#define lp_jit_cs_context_ssbos(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_SSBOS, "ssbos") +#define lp_jit_cs_context_ssbos(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_SSBOS, "ssbos") -#define lp_jit_cs_context_shared_size(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CS_CTX_SHARED_SIZE, "shared_size") +#define lp_jit_cs_context_shared_size(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_SHARED_SIZE, "shared_size") -#define lp_jit_cs_context_kernel_args(_gallivm, _ptr) \ - lp_build_struct_get(_gallivm, _ptr, LP_JIT_CS_CTX_KERNEL_ARGS, "kernel_args") +#define lp_jit_cs_context_kernel_args(_gallivm, _type, _ptr) \ + lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_KERNEL_ARGS, "kernel_args") -#define lp_jit_cs_context_aniso_filter_table(_gallivm, _ptr) \ - lp_build_struct_get(_gallivm, _ptr, LP_JIT_CS_CTX_ANISO_FILTER_TABLE, "aniso_filter_table") +#define lp_jit_cs_context_aniso_filter_table(_gallivm, _type, _ptr) \ + lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_ANISO_FILTER_TABLE, "aniso_filter_table") typedef void diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index f32bd539b93..d959dc01879 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -327,9 +327,15 @@ generate_compute(struct llvmpipe_context *lp, struct lp_bld_tgsi_system_values system_values; memset(&system_values, 0, sizeof(system_values)); - consts_ptr = lp_jit_cs_context_constants(gallivm, context_ptr); - ssbo_ptr = lp_jit_cs_context_ssbos(gallivm, context_ptr); - kernel_args_ptr = lp_jit_cs_context_kernel_args(gallivm, context_ptr); + consts_ptr = lp_jit_cs_context_constants(gallivm, + variant->jit_cs_context_type, + context_ptr); + ssbo_ptr = lp_jit_cs_context_ssbos(gallivm, + variant->jit_cs_context_type, + context_ptr); + kernel_args_ptr = lp_jit_cs_context_kernel_args(gallivm, + variant->jit_cs_context_type, + context_ptr); shared_ptr = lp_jit_cs_thread_data_shared(gallivm, thread_data_ptr); @@ -444,7 +450,9 @@ generate_compute(struct llvmpipe_context *lp, params.shared_ptr = shared_ptr; params.coro = &coro_info; params.kernel_args = kernel_args_ptr; - params.aniso_filter_table = lp_jit_cs_context_aniso_filter_table(gallivm, context_ptr); + params.aniso_filter_table = lp_jit_cs_context_aniso_filter_table(gallivm, + variant->jit_cs_context_type, + context_ptr); if (shader->base.type == PIPE_SHADER_IR_TGSI) lp_build_tgsi_soa(gallivm, shader->base.tokens, ¶ms, NULL); diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.h b/src/gallium/drivers/llvmpipe/lp_state_cs.h index c461b614599..7fb2127a1cd 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.h +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.h @@ -80,6 +80,7 @@ struct lp_compute_shader_variant { struct gallivm_state *gallivm; + LLVMTypeRef jit_cs_context_type; LLVMTypeRef jit_cs_context_ptr_type; LLVMTypeRef jit_cs_thread_data_ptr_type;