From: Dave Airlie Date: Wed, 26 Jun 2019 05:42:23 +0000 (+1000) Subject: llvmpipe: add support for ssbo to the fragment shader jit. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e21007f426e70f341909d42bc14f30a18298e963;p=mesa.git llvmpipe: add support for ssbo to the fragment shader jit. This just adds the ssbo ptrs to the jit fragment shader api. Reviewed-by: Roland Scheidegger --- diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index e2309f47157..d5527e30d9b 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -164,7 +164,10 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) PIPE_MAX_SHADER_SAMPLER_VIEWS); elem_types[LP_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type, PIPE_MAX_SAMPLERS); - + elem_types[LP_JIT_CTX_SSBOS] = + LLVMArrayType(LLVMPointerType(LLVMInt32TypeInContext(lc), 0), LP_MAX_TGSI_SHADER_BUFFERS); + elem_types[LP_JIT_CTX_NUM_SSBOS] = + LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_SHADER_BUFFERS); context_type = LLVMStructTypeInContext(lc, elem_types, ARRAY_SIZE(elem_types), 0); @@ -198,6 +201,12 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, samplers, gallivm->target, context_type, LP_JIT_CTX_SAMPLERS); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, ssbos, + gallivm->target, context_type, + LP_JIT_CTX_SSBOS); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, num_ssbos, + gallivm->target, context_type, + LP_JIT_CTX_NUM_SSBOS); LP_CHECK_STRUCT_SIZE(struct lp_jit_context, gallivm->target, context_type); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 312d1a1281d..6dc3147df2a 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -135,6 +135,9 @@ struct lp_jit_context struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS]; struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS]; + + const uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS]; + int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS]; }; @@ -153,6 +156,8 @@ enum { LP_JIT_CTX_VIEWPORTS, LP_JIT_CTX_TEXTURES, LP_JIT_CTX_SAMPLERS, + LP_JIT_CTX_SSBOS, + LP_JIT_CTX_NUM_SSBOS, LP_JIT_CTX_COUNT }; @@ -187,6 +192,11 @@ enum { #define lp_jit_context_samplers(_gallivm, _ptr) \ lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLERS, "samplers") +#define lp_jit_context_ssbos(_gallivm, _ptr) \ + lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SSBOS, "ssbos") + +#define lp_jit_context_num_ssbos(_gallivm, _ptr) \ + lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_NUM_SSBOS, "num_ssbos") struct lp_jit_thread_data { diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 2203779d55f..cf54d034fa5 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -313,6 +313,7 @@ generate_fs_loop(struct gallivm_state *gallivm, LLVMTypeRef vec_type, int_vec_type; LLVMValueRef mask_ptr, mask_val; LLVMValueRef consts_ptr, num_consts_ptr; + LLVMValueRef ssbo_ptr, num_ssbo_ptr; LLVMValueRef z; LLVMValueRef z_value, s_value; LLVMValueRef z_fb, s_fb; @@ -392,6 +393,9 @@ generate_fs_loop(struct gallivm_state *gallivm, consts_ptr = lp_jit_context_constants(gallivm, context_ptr); num_consts_ptr = lp_jit_context_num_constants(gallivm, context_ptr); + ssbo_ptr = lp_jit_context_ssbos(gallivm, context_ptr); + num_ssbo_ptr = lp_jit_context_num_ssbos(gallivm, context_ptr); + lp_build_for_loop_begin(&loop_state, gallivm, lp_build_const_int32(gallivm, 0), LLVMIntULT, @@ -479,7 +483,7 @@ generate_fs_loop(struct gallivm_state *gallivm, consts_ptr, num_consts_ptr, &system_values, interp->inputs, outputs, context_ptr, thread_data_ptr, - sampler, &shader->info.base, NULL, NULL, NULL); + sampler, &shader->info.base, NULL, ssbo_ptr, num_ssbo_ptr); /* Alpha test */ if (key->alpha.enabled) {