llvmpipe/fs: convert thread data ptr to opaque ptr friendly apis

this converts the thread data code.

The cache code still isn't fixed but needs future API changes
to sampling code.

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:
Dave Airlie
2022-09-26 12:51:30 +10:00
parent 1a7250ad96
commit f0e9d3e497
5 changed files with 29 additions and 21 deletions
+1
View File
@@ -305,6 +305,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
thread_data_type = LLVMStructTypeInContext(lc, elem_types,
ARRAY_SIZE(elem_types), 0);
lp->jit_thread_data_type = thread_data_type;
lp->jit_thread_data_ptr_type = LLVMPointerType(thread_data_type, 0);
}
+14 -14
View File
@@ -265,24 +265,24 @@ enum {
};
#define lp_jit_thread_data_cache(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, LP_JIT_THREAD_DATA_CACHE, "cache")
#define lp_jit_thread_data_cache(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_THREAD_DATA_CACHE, "cache")
#define lp_jit_thread_data_counter(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_THREAD_DATA_COUNTER, "counter")
#define lp_jit_thread_data_counter(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_THREAD_DATA_COUNTER, "counter")
#define lp_jit_thread_data_invocations(_gallivm, _ptr) \
lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_THREAD_DATA_INVOCATIONS, "invocs")
#define lp_jit_thread_data_invocations(_gallivm, _type, _ptr) \
lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_THREAD_DATA_INVOCATIONS, "invocs")
#define lp_jit_thread_data_raster_state_viewport_index(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, \
LP_JIT_THREAD_DATA_RASTER_STATE_VIEWPORT_INDEX, \
"raster_state.viewport_index")
#define lp_jit_thread_data_raster_state_viewport_index(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, \
LP_JIT_THREAD_DATA_RASTER_STATE_VIEWPORT_INDEX, \
"raster_state.viewport_index")
#define lp_jit_thread_data_raster_state_view_index(_gallivm, _ptr) \
lp_build_struct_get(_gallivm, _ptr, \
LP_JIT_THREAD_DATA_RASTER_STATE_VIEW_INDEX, \
"raster_state.view_index")
#define lp_jit_thread_data_raster_state_view_index(_gallivm, _type, _ptr) \
lp_build_struct_get2(_gallivm, _type, _ptr, \
LP_JIT_THREAD_DATA_RASTER_STATE_VIEW_INDEX, \
"raster_state.view_index")
/**
* typedef for fragment shader function
+12 -6
View File
@@ -351,6 +351,7 @@ lp_build_depth_clamp(struct gallivm_state *gallivm,
struct lp_type type,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
LLVMTypeRef thread_data_type,
LLVMValueRef thread_data_ptr,
LLVMValueRef z)
{
@@ -375,7 +376,8 @@ lp_build_depth_clamp(struct gallivm_state *gallivm,
* semantics.
*/
viewport_index = lp_jit_thread_data_raster_state_viewport_index(gallivm,
thread_data_ptr);
thread_data_type,
thread_data_ptr);
/*
* Load the min and max depth from the lp_jit_context.viewports
@@ -640,6 +642,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
LLVMValueRef color_stride_ptr,
LLVMValueRef color_sample_stride_ptr,
LLVMValueRef facing,
LLVMTypeRef thread_data_type,
LLVMValueRef thread_data_ptr)
{
const struct tgsi_token *tokens = shader->base.tokens;
@@ -676,7 +679,9 @@ generate_fs_loop(struct gallivm_state *gallivm,
LLVMBuildSExt(gallivm->builder, system_values.front_facing,
LLVMInt32TypeInContext(gallivm->context), "");
system_values.view_index =
lp_jit_thread_data_raster_state_view_index(gallivm, thread_data_ptr);
lp_jit_thread_data_raster_state_view_index(gallivm,
thread_data_type,
thread_data_ptr);
unsigned depth_mode;
const struct util_format_description *zs_format_desc = NULL;
@@ -880,7 +885,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
z = lp_build_depth_clamp(gallivm, builder, key->depth_clamp,
key->restrict_depth_values, type,
context_type, context_ptr,
thread_data_ptr, z);
thread_data_type, thread_data_ptr, z);
lp_build_depth_stencil_load_swizzled(gallivm, type,
zs_format_desc, key->resource_1d,
@@ -1261,7 +1266,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
z = lp_build_depth_clamp(gallivm, builder, key->depth_clamp,
key->restrict_depth_values, type,
context_type, context_ptr,
thread_data_ptr, z);
thread_data_type, thread_data_ptr, z);
if (shader->info.base.writes_stencil) {
LLVMValueRef idx = loop_state.counter;
@@ -1323,7 +1328,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
}
if (key->occlusion_count) {
LLVMValueRef counter = lp_jit_thread_data_counter(gallivm, thread_data_ptr);
LLVMValueRef counter = lp_jit_thread_data_counter(gallivm, thread_data_type, thread_data_ptr);
lp_build_name(counter, "counter");
lp_build_occlusion_count(gallivm, type,
@@ -3238,7 +3243,7 @@ generate_fragment(struct llvmpipe_context *lp,
*/
if (shader->info.base.num_instructions > 1) {
LLVMValueRef invocs, val;
invocs = lp_jit_thread_data_invocations(gallivm, thread_data_ptr);
invocs = lp_jit_thread_data_invocations(gallivm, variant->jit_thread_data_type, thread_data_ptr);
val = LLVMBuildLoad(builder, invocs, "");
val = LLVMBuildAdd(builder, val,
LLVMConstInt(LLVMInt64TypeInContext(gallivm->context),
@@ -3386,6 +3391,7 @@ generate_fragment(struct llvmpipe_context *lp,
stride_ptr,
color_sample_stride_ptr,
facing,
variant->jit_thread_data_type,
thread_data_ptr);
for (unsigned i = 0; i < num_fs; i++) {
@@ -175,6 +175,7 @@ struct lp_fragment_shader_variant
LLVMTypeRef jit_context_type;
LLVMTypeRef jit_context_ptr_type;
LLVMTypeRef jit_thread_data_type;
LLVMTypeRef jit_thread_data_ptr_type;
LLVMTypeRef jit_linear_context_ptr_type;
+1 -1
View File
@@ -335,7 +335,7 @@ lp_llvm_texture_cache_ptr(struct gallivm_state *gallivm,
/* We use the same cache for all units */
(void)unit;
return lp_jit_thread_data_cache(gallivm, thread_data_ptr);
return lp_jit_thread_data_cache(gallivm, LLVMGetElementType(LLVMTypeOf(thread_data_ptr)), thread_data_ptr);
}
#endif