From a8bd993809a13959b9da9b4c8c55b1849c20d479 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 26 Sep 2022 12:56:23 +1000 Subject: [PATCH] llvmpipe/fs: convert linear context to opaque pointers friendly 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 | 24 +++++++++---------- src/gallium/drivers/llvmpipe/lp_state_fs.h | 1 + .../llvmpipe/lp_state_fs_linear_llvm.c | 24 ++++++++++++++----- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index c55cf1f253b..4e67a30e978 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -374,6 +374,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) LP_CHECK_STRUCT_SIZE(struct lp_jit_linear_context, gallivm->target, linear_context_type); + lp->jit_linear_context_type = linear_context_type; lp->jit_linear_context_ptr_type = LLVMPointerType(linear_context_type, 0); } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 7e476055ee9..25b09981245 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -366,23 +366,23 @@ enum { }; -#define lp_jit_linear_context_constants(_gallivm, _ptr) \ - lp_build_struct_get(_gallivm, _ptr, LP_JIT_LINEAR_CTX_CONSTANTS, "constants") +#define lp_jit_linear_context_constants(_gallivm, _type, _ptr) \ + lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_LINEAR_CTX_CONSTANTS, "constants") -#define lp_jit_linear_context_tex(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_LINEAR_CTX_TEX, "tex") +#define lp_jit_linear_context_tex(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_LINEAR_CTX_TEX, "tex") -#define lp_jit_linear_context_inputs(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_LINEAR_CTX_INPUTS, "inputs") +#define lp_jit_linear_context_inputs(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_LINEAR_CTX_INPUTS, "inputs") -#define lp_jit_linear_context_color0(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_LINEAR_CTX_COLOR0, "color0") +#define lp_jit_linear_context_color0(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_LINEAR_CTX_COLOR0, "color0") -#define lp_jit_linear_context_blend_color(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_LINEAR_CTX_BLEND_COLOR, "blend_color") +#define lp_jit_linear_context_blend_color(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_LINEAR_CTX_BLEND_COLOR, "blend_color") -#define lp_jit_linear_context_alpha_ref(_gallivm, _ptr) \ - lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_LINEAR_CTX_ALPHA_REF, "alpha_ref_value") +#define lp_jit_linear_context_alpha_ref(_gallivm, _type, _ptr) \ + lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_LINEAR_CTX_ALPHA_REF, "alpha_ref_value") typedef const uint8_t * diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.h b/src/gallium/drivers/llvmpipe/lp_state_fs.h index ef86a2a81a9..d6211df5e5e 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.h +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.h @@ -177,6 +177,7 @@ struct lp_fragment_shader_variant LLVMTypeRef jit_context_ptr_type; LLVMTypeRef jit_thread_data_type; LLVMTypeRef jit_thread_data_ptr_type; + LLVMTypeRef jit_linear_context_type; LLVMTypeRef jit_linear_context_ptr_type; LLVMValueRef function[2]; // [RAST_WHOLE], [RAST_EDGE_TEST] diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs_linear_llvm.c b/src/gallium/drivers/llvmpipe/lp_state_fs_linear_llvm.c index 3f794759408..21e0c63ec58 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs_linear_llvm.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs_linear_llvm.c @@ -336,20 +336,30 @@ llvmpipe_fs_variant_linear_llvm(struct llvmpipe_context *lp, * Get context data */ LLVMValueRef consts_ptr = - lp_jit_linear_context_constants(gallivm, context_ptr); + lp_jit_linear_context_constants(gallivm, + variant->jit_linear_context_type, + context_ptr); LLVMValueRef interpolators_ptr = - lp_jit_linear_context_inputs(gallivm, context_ptr); + lp_jit_linear_context_inputs(gallivm, + variant->jit_linear_context_type, + context_ptr); LLVMValueRef samplers_ptr = - lp_jit_linear_context_tex(gallivm, context_ptr); + lp_jit_linear_context_tex(gallivm, + variant->jit_linear_context_type, + context_ptr); LLVMValueRef color0_ptr = - lp_jit_linear_context_color0(gallivm, context_ptr); + lp_jit_linear_context_color0(gallivm, + variant->jit_linear_context_type, + context_ptr); color0_ptr = LLVMBuildLoad(builder, color0_ptr, ""); color0_ptr = LLVMBuildBitCast(builder, color0_ptr, LLVMPointerType(bld.vec_type, 0), ""); LLVMValueRef blend_color = - lp_jit_linear_context_blend_color(gallivm, context_ptr); + lp_jit_linear_context_blend_color(gallivm, + variant->jit_linear_context_type, + context_ptr); blend_color = LLVMBuildLoad(builder, blend_color, ""); blend_color = lp_build_broadcast(gallivm, LLVMVectorType(int32t, 4), blend_color); @@ -357,7 +367,9 @@ llvmpipe_fs_variant_linear_llvm(struct llvmpipe_context *lp, LLVMVectorType(int8t, 16), ""); LLVMValueRef alpha_ref = - lp_jit_linear_context_alpha_ref(gallivm, context_ptr); + lp_jit_linear_context_alpha_ref(gallivm, + variant->jit_linear_context_type, + context_ptr); alpha_ref = LLVMBuildLoad(builder, alpha_ref, ""); /*