diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index de9d36edd87..c55cf1f253b 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -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); } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 49a2b54671e..7e476055ee9 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -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 diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index e500c867ccf..217349a1a86 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -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++) { diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.h b/src/gallium/drivers/llvmpipe/lp_state_fs.h index 95534288db0..ef86a2a81a9 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.h +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.h @@ -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; diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index 4df42d785b0..0812bc72cd0 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -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