Mesa (main): llvmpipe: add filter table shader accessor

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 21 00:40:08 UTC 2021


Module: Mesa
Branch: main
Commit: a672f9ebf02645e66797357cd4b7db3b415359dc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a672f9ebf02645e66797357cd4b7db3b415359dc

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Feb  8 12:21:32 2021 +1000

llvmpipe: add filter table shader accessor

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8804>

---

 src/gallium/drivers/llvmpipe/lp_jit.c      |  9 +++++++++
 src/gallium/drivers/llvmpipe/lp_jit.h      | 12 ++++++++++++
 src/gallium/drivers/llvmpipe/lp_setup.c    |  1 +
 src/gallium/drivers/llvmpipe/lp_state_cs.c |  4 +++-
 src/gallium/drivers/llvmpipe/lp_state_fs.c |  1 +
 5 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c
index 80d8d9e5c67..eaeba9419fc 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.c
+++ b/src/gallium/drivers/llvmpipe/lp_jit.c
@@ -232,6 +232,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
       elem_types[LP_JIT_CTX_U8_BLEND_COLOR] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
       elem_types[LP_JIT_CTX_F_BLEND_COLOR] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
       elem_types[LP_JIT_CTX_VIEWPORTS] = LLVMPointerType(viewport_type, 0);
+      elem_types[LP_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
       elem_types[LP_JIT_CTX_SSBOS] =
          LLVMArrayType(LLVMPointerType(LLVMInt32TypeInContext(lc), 0), LP_MAX_TGSI_SHADER_BUFFERS);
       elem_types[LP_JIT_CTX_NUM_SSBOS] =
@@ -281,6 +282,9 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, sample_mask,
                              gallivm->target, context_type,
                              LP_JIT_CTX_SAMPLE_MASK);
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, aniso_filter_table,
+                             gallivm->target, context_type,
+                             LP_JIT_CTX_ANISO_FILTER_TABLE);
       LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
                            gallivm->target, context_type);
 
@@ -385,6 +389,8 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
 
       elem_types[LP_JIT_CS_CTX_KERNEL_ARGS] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
 
+      elem_types[LP_JIT_CS_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
+
       cs_context_type = LLVMStructTypeInContext(lc, elem_types,
                                              ARRAY_SIZE(elem_types), 0);
 
@@ -415,6 +421,9 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, kernel_args,
                              gallivm->target, cs_context_type,
                              LP_JIT_CS_CTX_KERNEL_ARGS);
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, aniso_filter_table,
+                             gallivm->target, cs_context_type,
+                             LP_JIT_CS_CTX_ANISO_FILTER_TABLE);
       LP_CHECK_STRUCT_SIZE(struct lp_jit_cs_context,
                            gallivm->target, cs_context_type);
 
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h
index ce08b90dcdc..b9a4173022d 100644
--- a/src/gallium/drivers/llvmpipe/lp_jit.h
+++ b/src/gallium/drivers/llvmpipe/lp_jit.h
@@ -168,6 +168,8 @@ struct lp_jit_context
    int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
 
    uint32_t sample_mask;
+
+   const float *aniso_filter_table;
 };
 
 
@@ -190,6 +192,7 @@ enum {
    LP_JIT_CTX_SSBOS,
    LP_JIT_CTX_NUM_SSBOS,
    LP_JIT_CTX_SAMPLE_MASK,
+   LP_JIT_CTX_ANISO_FILTER_TABLE,
    LP_JIT_CTX_COUNT
 };
 
@@ -236,6 +239,9 @@ enum {
 #define lp_jit_context_sample_mask(_gallivm, _ptr) \
    lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLE_MASK, "sample_mask")
 
+#define lp_jit_context_aniso_filter_table(_gallivm, _ptr) \
+   lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
+
 struct lp_jit_thread_data
 {
    struct lp_build_format_cache *cache;
@@ -350,6 +356,8 @@ struct lp_jit_cs_context
    void *kernel_args;
 
    uint32_t shared_size;
+
+   const float *aniso_filter_table;
 };
 
 /**
@@ -366,6 +374,7 @@ enum {
    LP_JIT_CS_CTX_NUM_SSBOS,
    LP_JIT_CS_CTX_KERNEL_ARGS,
    LP_JIT_CS_CTX_SHARED_SIZE,
+   LP_JIT_CS_CTX_ANISO_FILTER_TABLE,
    LP_JIT_CS_CTX_COUNT
 };
 
@@ -396,6 +405,9 @@ enum {
 #define lp_jit_cs_context_kernel_args(_gallivm, _ptr) \
    lp_build_struct_get(_gallivm, _ptr, LP_JIT_CS_CTX_KERNEL_ARGS, "kernel_args")
 
+#define lp_jit_cs_context_aniso_filter_table(_gallivm, _ptr) \
+   lp_build_struct_get(_gallivm, _ptr, LP_JIT_CS_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
+
 
 typedef void
 (*lp_jit_cs_func)(const struct lp_jit_cs_context *context,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index f4d20bc313b..d9ac8ed2385 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -1293,6 +1293,7 @@ try_update_scene_state( struct lp_setup_context *setup )
          memcpy(&stored->jit_context,
                 &setup->fs.current.jit_context,
                 sizeof setup->fs.current.jit_context);
+         stored->jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
          stored->variant = setup->fs.current.variant;
 
          if (!lp_scene_add_frag_shader_reference(scene,
diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c
index 93e5d0cca6f..392cdf938f0 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_cs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c
@@ -404,6 +404,7 @@ generate_compute(struct llvmpipe_context *lp,
       params.shared_ptr = shared_ptr;
       params.coro = &coro_info;
       params.kernel_args = kernel_args_ptr;
+      params.aniso_filter_table = lp_jit_cs_context_aniso_filter_table(gallivm, context_ptr);
 
       if (shader->base.type == PIPE_SHADER_IR_TGSI)
          lp_build_tgsi_soa(gallivm, shader->base.tokens, &params, NULL);
@@ -1252,8 +1253,9 @@ llvmpipe_cs_update_derived(struct llvmpipe_context *llvmpipe, void *input)
                               ARRAY_SIZE(llvmpipe->images[PIPE_SHADER_COMPUTE]),
                               llvmpipe->images[PIPE_SHADER_COMPUTE]);
 
+   struct lp_cs_context *csctx = llvmpipe->csctx;
+   csctx->cs.current.jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
    if (input) {
-      struct lp_cs_context *csctx = llvmpipe->csctx;
       csctx->input = input;
       csctx->cs.current.jit_context.kernel_args = input;
    }
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 563408ac8e0..69e2ea562e4 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -959,6 +959,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
    params.ssbo_ptr = ssbo_ptr;
    params.ssbo_sizes_ptr = num_ssbo_ptr;
    params.image = image;
+   params.aniso_filter_table = lp_jit_context_aniso_filter_table(gallivm, context_ptr);
 
    /* Build the actual shader */
    if (shader->base.type == PIPE_SHADER_IR_TGSI)



More information about the mesa-commit mailing list