llvmpipe: add support for ssbo to the fragment shader jit.
authorDave Airlie <airlied@redhat.com>
Wed, 26 Jun 2019 05:42:23 +0000 (15:42 +1000)
committerDave Airlie <airlied@redhat.com>
Sun, 7 Jul 2019 06:23:51 +0000 (16:23 +1000)
This just adds the ssbo ptrs to the jit fragment shader api.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_state_fs.c

index e2309f471573defbea7b9471852e7dbb2afb5385..d5527e30d9b8faa1a8c5205d9f5eda48a88fa7b2 100644 (file)
@@ -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);
 
index 312d1a1281db3cc527f0e4314761cd01a6f973ba..6dc3147df2a4c55c0bd2d5d873359a3900d6edb6 100644 (file)
@@ -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
 {
index 2203779d55f53e3dbc2d3b68bf3b476e58bf8951..cf54d034fa57bd98b4467d87d4d295a912c88230 100644 (file)
@@ -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) {