llvmpipe/fs: start passing explicit context pointer type.
In order to support opaque pointers in the future, we need to be more explicit with the pointer types here. Reviewed-by: Roland Scheidegger <sroland@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Mihai Preda <mhpreda@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18837>
This commit is contained in:
@@ -285,6 +285,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
|
|||||||
LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
|
LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
|
||||||
gallivm->target, context_type);
|
gallivm->target, context_type);
|
||||||
|
|
||||||
|
lp->jit_context_type = context_type;
|
||||||
lp->jit_context_ptr_type = LLVMPointerType(context_type, 0);
|
lp->jit_context_ptr_type = LLVMPointerType(context_type, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -199,44 +199,44 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define lp_jit_context_constants(_gallivm, _ptr) \
|
#define lp_jit_context_constants(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_CONSTANTS, "constants")
|
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_CONSTANTS, "constants")
|
||||||
|
|
||||||
#define lp_jit_context_textures(_gallivm, _ptr) \
|
#define lp_jit_context_textures(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_TEXTURES, "textures")
|
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_TEXTURES, "textures")
|
||||||
|
|
||||||
#define lp_jit_context_samplers(_gallivm, _ptr) \
|
#define lp_jit_context_samplers(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLERS, "samplers")
|
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_SAMPLERS, "samplers")
|
||||||
|
|
||||||
#define lp_jit_context_images(_gallivm, _ptr) \
|
#define lp_jit_context_images(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_IMAGES, "images")
|
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_IMAGES, "images")
|
||||||
|
|
||||||
#define lp_jit_context_alpha_ref_value(_gallivm, _ptr) \
|
#define lp_jit_context_alpha_ref_value(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
|
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
|
||||||
|
|
||||||
#define lp_jit_context_stencil_ref_front_value(_gallivm, _ptr) \
|
#define lp_jit_context_stencil_ref_front_value(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_STENCIL_REF_FRONT, "stencil_ref_front")
|
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_STENCIL_REF_FRONT, "stencil_ref_front")
|
||||||
|
|
||||||
#define lp_jit_context_stencil_ref_back_value(_gallivm, _ptr) \
|
#define lp_jit_context_stencil_ref_back_value(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_STENCIL_REF_BACK, "stencil_ref_back")
|
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_STENCIL_REF_BACK, "stencil_ref_back")
|
||||||
|
|
||||||
#define lp_jit_context_u8_blend_color(_gallivm, _ptr) \
|
#define lp_jit_context_u8_blend_color(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_U8_BLEND_COLOR, "u8_blend_color")
|
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_U8_BLEND_COLOR, "u8_blend_color")
|
||||||
|
|
||||||
#define lp_jit_context_f_blend_color(_gallivm, _ptr) \
|
#define lp_jit_context_f_blend_color(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_F_BLEND_COLOR, "f_blend_color")
|
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_F_BLEND_COLOR, "f_blend_color")
|
||||||
|
|
||||||
#define lp_jit_context_viewports(_gallivm, _ptr) \
|
#define lp_jit_context_viewports(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_VIEWPORTS, "viewports")
|
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_VIEWPORTS, "viewports")
|
||||||
|
|
||||||
#define lp_jit_context_ssbos(_gallivm, _ptr) \
|
#define lp_jit_context_ssbos(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SSBOS, "ssbos")
|
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_SSBOS, "ssbos")
|
||||||
|
|
||||||
#define lp_jit_context_sample_mask(_gallivm, _ptr) \
|
#define lp_jit_context_sample_mask(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLE_MASK, "sample_mask")
|
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_SAMPLE_MASK, "sample_mask")
|
||||||
|
|
||||||
#define lp_jit_context_aniso_filter_table(_gallivm, _ptr) \
|
#define lp_jit_context_aniso_filter_table(_gallivm, _type, _ptr) \
|
||||||
lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
|
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
|
||||||
|
|
||||||
|
|
||||||
struct lp_jit_thread_data
|
struct lp_jit_thread_data
|
||||||
|
@@ -322,7 +322,8 @@ find_output_by_semantic(const struct tgsi_shader_info *info,
|
|||||||
* Fetch the specified lp_jit_viewport structure for a given viewport_index.
|
* Fetch the specified lp_jit_viewport structure for a given viewport_index.
|
||||||
*/
|
*/
|
||||||
static LLVMValueRef
|
static LLVMValueRef
|
||||||
lp_llvm_viewport(LLVMValueRef context_ptr,
|
lp_llvm_viewport(LLVMTypeRef context_type,
|
||||||
|
LLVMValueRef context_ptr,
|
||||||
struct gallivm_state *gallivm,
|
struct gallivm_state *gallivm,
|
||||||
LLVMValueRef viewport_index)
|
LLVMValueRef viewport_index)
|
||||||
{
|
{
|
||||||
@@ -332,7 +333,7 @@ lp_llvm_viewport(LLVMValueRef context_ptr,
|
|||||||
struct lp_type viewport_type =
|
struct lp_type viewport_type =
|
||||||
lp_type_float_vec(32, 32 * LP_JIT_VIEWPORT_NUM_FIELDS);
|
lp_type_float_vec(32, 32 * LP_JIT_VIEWPORT_NUM_FIELDS);
|
||||||
|
|
||||||
ptr = lp_jit_context_viewports(gallivm, context_ptr);
|
ptr = lp_jit_context_viewports(gallivm, context_type, context_ptr);
|
||||||
ptr = LLVMBuildPointerCast(builder, ptr,
|
ptr = LLVMBuildPointerCast(builder, ptr,
|
||||||
LLVMPointerType(lp_build_vec_type(gallivm, viewport_type), 0), "");
|
LLVMPointerType(lp_build_vec_type(gallivm, viewport_type), 0), "");
|
||||||
|
|
||||||
@@ -348,6 +349,7 @@ lp_build_depth_clamp(struct gallivm_state *gallivm,
|
|||||||
bool depth_clamp,
|
bool depth_clamp,
|
||||||
bool restrict_depth,
|
bool restrict_depth,
|
||||||
struct lp_type type,
|
struct lp_type type,
|
||||||
|
LLVMTypeRef context_type,
|
||||||
LLVMValueRef context_ptr,
|
LLVMValueRef context_ptr,
|
||||||
LLVMValueRef thread_data_ptr,
|
LLVMValueRef thread_data_ptr,
|
||||||
LLVMValueRef z)
|
LLVMValueRef z)
|
||||||
@@ -379,7 +381,7 @@ lp_build_depth_clamp(struct gallivm_state *gallivm,
|
|||||||
* Load the min and max depth from the lp_jit_context.viewports
|
* Load the min and max depth from the lp_jit_context.viewports
|
||||||
* array of lp_jit_viewport structures.
|
* array of lp_jit_viewport structures.
|
||||||
*/
|
*/
|
||||||
viewport = lp_llvm_viewport(context_ptr, gallivm, viewport_index);
|
viewport = lp_llvm_viewport(context_type, context_ptr, gallivm, viewport_index);
|
||||||
|
|
||||||
/* viewports[viewport_index].min_depth */
|
/* viewports[viewport_index].min_depth */
|
||||||
min_depth = LLVMBuildExtractElement(builder, viewport,
|
min_depth = LLVMBuildExtractElement(builder, viewport,
|
||||||
@@ -622,6 +624,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
|
|||||||
const struct lp_fragment_shader_variant_key *key,
|
const struct lp_fragment_shader_variant_key *key,
|
||||||
LLVMBuilderRef builder,
|
LLVMBuilderRef builder,
|
||||||
struct lp_type type,
|
struct lp_type type,
|
||||||
|
LLVMTypeRef context_type,
|
||||||
LLVMValueRef context_ptr,
|
LLVMValueRef context_ptr,
|
||||||
LLVMValueRef sample_pos_array,
|
LLVMValueRef sample_pos_array,
|
||||||
LLVMValueRef num_loop,
|
LLVMValueRef num_loop,
|
||||||
@@ -721,15 +724,15 @@ generate_fs_loop(struct gallivm_state *gallivm,
|
|||||||
LLVMTypeRef int_vec_type = lp_build_vec_type(gallivm, int_type);
|
LLVMTypeRef int_vec_type = lp_build_vec_type(gallivm, int_type);
|
||||||
|
|
||||||
LLVMValueRef stencil_refs[2];
|
LLVMValueRef stencil_refs[2];
|
||||||
stencil_refs[0] = lp_jit_context_stencil_ref_front_value(gallivm, context_ptr);
|
stencil_refs[0] = lp_jit_context_stencil_ref_front_value(gallivm, context_type, context_ptr);
|
||||||
stencil_refs[1] = lp_jit_context_stencil_ref_back_value(gallivm, context_ptr);
|
stencil_refs[1] = lp_jit_context_stencil_ref_back_value(gallivm, context_type, context_ptr);
|
||||||
/* convert scalar stencil refs into vectors */
|
/* convert scalar stencil refs into vectors */
|
||||||
stencil_refs[0] = lp_build_broadcast(gallivm, int_vec_type, stencil_refs[0]);
|
stencil_refs[0] = lp_build_broadcast(gallivm, int_vec_type, stencil_refs[0]);
|
||||||
stencil_refs[1] = lp_build_broadcast(gallivm, int_vec_type, stencil_refs[1]);
|
stencil_refs[1] = lp_build_broadcast(gallivm, int_vec_type, stencil_refs[1]);
|
||||||
|
|
||||||
LLVMValueRef consts_ptr = lp_jit_context_constants(gallivm, context_ptr);
|
LLVMValueRef consts_ptr = lp_jit_context_constants(gallivm, context_type, context_ptr);
|
||||||
|
|
||||||
LLVMValueRef ssbo_ptr = lp_jit_context_ssbos(gallivm, context_ptr);
|
LLVMValueRef ssbo_ptr = lp_jit_context_ssbos(gallivm, context_type, context_ptr);
|
||||||
|
|
||||||
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][TGSI_NUM_CHANNELS];
|
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][TGSI_NUM_CHANNELS];
|
||||||
memset(outputs, 0, sizeof outputs);
|
memset(outputs, 0, sizeof outputs);
|
||||||
@@ -875,7 +878,8 @@ generate_fs_loop(struct gallivm_state *gallivm,
|
|||||||
|
|
||||||
if (depth_mode & EARLY_DEPTH_TEST) {
|
if (depth_mode & EARLY_DEPTH_TEST) {
|
||||||
z = lp_build_depth_clamp(gallivm, builder, key->depth_clamp,
|
z = lp_build_depth_clamp(gallivm, builder, key->depth_clamp,
|
||||||
key->restrict_depth_values, type, context_ptr,
|
key->restrict_depth_values, type,
|
||||||
|
context_type, context_ptr,
|
||||||
thread_data_ptr, z);
|
thread_data_ptr, z);
|
||||||
|
|
||||||
lp_build_depth_stencil_load_swizzled(gallivm, type,
|
lp_build_depth_stencil_load_swizzled(gallivm, type,
|
||||||
@@ -1028,7 +1032,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
|
|||||||
params.info = &shader->info.base;
|
params.info = &shader->info.base;
|
||||||
params.ssbo_ptr = ssbo_ptr;
|
params.ssbo_ptr = ssbo_ptr;
|
||||||
params.image = image;
|
params.image = image;
|
||||||
params.aniso_filter_table = lp_jit_context_aniso_filter_table(gallivm, context_ptr);
|
params.aniso_filter_table = lp_jit_context_aniso_filter_table(gallivm, context_type, context_ptr);
|
||||||
|
|
||||||
/* Build the actual shader */
|
/* Build the actual shader */
|
||||||
if (shader->base.type == PIPE_SHADER_IR_TGSI)
|
if (shader->base.type == PIPE_SHADER_IR_TGSI)
|
||||||
@@ -1049,7 +1053,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
|
|||||||
LLVMValueRef alpha = LLVMBuildLoad(builder, outputs[color0][3], "alpha");
|
LLVMValueRef alpha = LLVMBuildLoad(builder, outputs[color0][3], "alpha");
|
||||||
LLVMValueRef alpha_ref_value;
|
LLVMValueRef alpha_ref_value;
|
||||||
|
|
||||||
alpha_ref_value = lp_jit_context_alpha_ref_value(gallivm, context_ptr);
|
alpha_ref_value = lp_jit_context_alpha_ref_value(gallivm, context_type, context_ptr);
|
||||||
alpha_ref_value = lp_build_broadcast(gallivm, vec_type, alpha_ref_value);
|
alpha_ref_value = lp_build_broadcast(gallivm, vec_type, alpha_ref_value);
|
||||||
|
|
||||||
cbuf_format_desc = util_format_description(key->cbuf_format[0]);
|
cbuf_format_desc = util_format_description(key->cbuf_format[0]);
|
||||||
@@ -1255,7 +1259,8 @@ generate_fs_loop(struct gallivm_state *gallivm,
|
|||||||
* Clamp according to ARB_depth_clamp semantics.
|
* Clamp according to ARB_depth_clamp semantics.
|
||||||
*/
|
*/
|
||||||
z = lp_build_depth_clamp(gallivm, builder, key->depth_clamp,
|
z = lp_build_depth_clamp(gallivm, builder, key->depth_clamp,
|
||||||
key->restrict_depth_values, type, context_ptr,
|
key->restrict_depth_values, type,
|
||||||
|
context_type, context_ptr,
|
||||||
thread_data_ptr, z);
|
thread_data_ptr, z);
|
||||||
|
|
||||||
if (shader->info.base.writes_stencil) {
|
if (shader->info.base.writes_stencil) {
|
||||||
@@ -2358,6 +2363,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
|
|||||||
struct lp_type fs_type,
|
struct lp_type fs_type,
|
||||||
LLVMValueRef* fs_mask,
|
LLVMValueRef* fs_mask,
|
||||||
LLVMValueRef fs_out_color[PIPE_MAX_COLOR_BUFS][TGSI_NUM_CHANNELS][4],
|
LLVMValueRef fs_out_color[PIPE_MAX_COLOR_BUFS][TGSI_NUM_CHANNELS][4],
|
||||||
|
LLVMTypeRef context_type,
|
||||||
LLVMValueRef context_ptr,
|
LLVMValueRef context_ptr,
|
||||||
LLVMValueRef color_ptr,
|
LLVMValueRef color_ptr,
|
||||||
LLVMValueRef stride,
|
LLVMValueRef stride,
|
||||||
@@ -2720,7 +2726,7 @@ generate_unswizzled_blend(struct gallivm_state *gallivm,
|
|||||||
/*
|
/*
|
||||||
* Blend Colour conversion
|
* Blend Colour conversion
|
||||||
*/
|
*/
|
||||||
blend_color = lp_jit_context_f_blend_color(gallivm, context_ptr);
|
blend_color = lp_jit_context_f_blend_color(gallivm, context_type, context_ptr);
|
||||||
blend_color = LLVMBuildPointerCast(builder, blend_color,
|
blend_color = LLVMBuildPointerCast(builder, blend_color,
|
||||||
LLVMPointerType(lp_build_vec_type(gallivm, fs_type), 0),
|
LLVMPointerType(lp_build_vec_type(gallivm, fs_type), 0),
|
||||||
"");
|
"");
|
||||||
@@ -3313,7 +3319,7 @@ generate_fragment(struct llvmpipe_context *lp,
|
|||||||
if (key->multisample) {
|
if (key->multisample) {
|
||||||
LLVMValueRef smask_val =
|
LLVMValueRef smask_val =
|
||||||
LLVMBuildLoad(builder,
|
LLVMBuildLoad(builder,
|
||||||
lp_jit_context_sample_mask(gallivm, context_ptr),
|
lp_jit_context_sample_mask(gallivm, variant->jit_context_type, context_ptr),
|
||||||
"");
|
"");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3364,6 +3370,7 @@ generate_fragment(struct llvmpipe_context *lp,
|
|||||||
shader, key,
|
shader, key,
|
||||||
builder,
|
builder,
|
||||||
fs_type,
|
fs_type,
|
||||||
|
variant->jit_context_type,
|
||||||
context_ptr,
|
context_ptr,
|
||||||
glob_sample_pos,
|
glob_sample_pos,
|
||||||
num_loop,
|
num_loop,
|
||||||
@@ -3470,6 +3477,7 @@ generate_fragment(struct llvmpipe_context *lp,
|
|||||||
key->cbuf_format[cbuf],
|
key->cbuf_format[cbuf],
|
||||||
num_fs, fs_type, &fs_mask[mask_idx],
|
num_fs, fs_type, &fs_mask[mask_idx],
|
||||||
fs_out_color[out_idx],
|
fs_out_color[out_idx],
|
||||||
|
variant->jit_context_type,
|
||||||
context_ptr, out_ptr, stride,
|
context_ptr, out_ptr, stride,
|
||||||
partial_mask, do_branch);
|
partial_mask, do_branch);
|
||||||
}
|
}
|
||||||
|
@@ -173,6 +173,7 @@ struct lp_fragment_shader_variant
|
|||||||
|
|
||||||
struct gallivm_state *gallivm;
|
struct gallivm_state *gallivm;
|
||||||
|
|
||||||
|
LLVMTypeRef jit_context_type;
|
||||||
LLVMTypeRef jit_context_ptr_type;
|
LLVMTypeRef jit_context_ptr_type;
|
||||||
LLVMTypeRef jit_thread_data_ptr_type;
|
LLVMTypeRef jit_thread_data_ptr_type;
|
||||||
LLVMTypeRef jit_linear_context_ptr_type;
|
LLVMTypeRef jit_linear_context_ptr_type;
|
||||||
|
Reference in New Issue
Block a user