llvmpipe: refactor fs/cs jit structure members.
authorDave Airlie <airlied@redhat.com>
Fri, 26 Aug 2022 07:17:34 +0000 (17:17 +1000)
committerMarge Bot <emma+marge@anholt.net>
Wed, 17 May 2023 01:19:24 +0000 (01:19 +0000)
This lines them up just like the draw ones.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22788>

src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h

index 0ed8725..4b42dc1 100644 (file)
@@ -82,12 +82,15 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
 
       elem_types[LP_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type,
                                                        LP_MAX_TGSI_CONST_BUFFERS);
+      elem_types[LP_JIT_CTX_SSBOS] =
+         LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
       elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
                                                       PIPE_MAX_SHADER_SAMPLER_VIEWS);
       elem_types[LP_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
                                                       PIPE_MAX_SAMPLERS);
       elem_types[LP_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
                                                     PIPE_MAX_SHADER_IMAGES);
+      elem_types[LP_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
       elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatTypeInContext(lc);
       elem_types[LP_JIT_CTX_SAMPLE_MASK] =
       elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] =
@@ -95,15 +98,16 @@ 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(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
+
       context_type = LLVMStructTypeInContext(lc, elem_types,
                                              ARRAY_SIZE(elem_types), 0);
 
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
                              gallivm->target, context_type,
                              LP_JIT_CTX_CONSTANTS);
+      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, textures,
                              gallivm->target, context_type,
                              LP_JIT_CTX_TEXTURES);
@@ -113,6 +117,9 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, images,
                              gallivm->target, context_type,
                              LP_JIT_CTX_IMAGES);
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, aniso_filter_table,
+                             gallivm->target, context_type,
+                             LP_JIT_CTX_ANISO_FILTER_TABLE);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
                              gallivm->target, context_type,
                              LP_JIT_CTX_ALPHA_REF);
@@ -131,15 +138,9 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, viewports,
                              gallivm->target, context_type,
                              LP_JIT_CTX_VIEWPORTS);
-      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, 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);
 
@@ -304,20 +305,17 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
 
       elem_types[LP_JIT_CS_CTX_CONSTANTS] =
          LLVMArrayType(buffer_type, LP_MAX_TGSI_CONST_BUFFERS);
+      elem_types[LP_JIT_CS_CTX_SSBOS] =
+         LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
       elem_types[LP_JIT_CS_CTX_TEXTURES] = LLVMArrayType(texture_type,
                                                       PIPE_MAX_SHADER_SAMPLER_VIEWS);
       elem_types[LP_JIT_CS_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
                                                       PIPE_MAX_SAMPLERS);
       elem_types[LP_JIT_CS_CTX_IMAGES] = LLVMArrayType(image_type,
                                                        PIPE_MAX_SHADER_IMAGES);
-      elem_types[LP_JIT_CS_CTX_SSBOS] =
-         LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
-
-      elem_types[LP_JIT_CS_CTX_SHARED_SIZE] = LLVMInt32TypeInContext(lc);
-
-      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);
+      elem_types[LP_JIT_CS_CTX_KERNEL_ARGS] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
+      elem_types[LP_JIT_CS_CTX_SHARED_SIZE] = LLVMInt32TypeInContext(lc);
 
       cs_context_type = LLVMStructTypeInContext(lc, elem_types,
                                              ARRAY_SIZE(elem_types), 0);
@@ -325,6 +323,9 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, constants,
                              gallivm->target, cs_context_type,
                              LP_JIT_CS_CTX_CONSTANTS);
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, ssbos,
+                             gallivm->target, cs_context_type,
+                             LP_JIT_CS_CTX_SSBOS);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, textures,
                              gallivm->target, cs_context_type,
                              LP_JIT_CS_CTX_TEXTURES);
@@ -334,18 +335,15 @@ lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, images,
                              gallivm->target, cs_context_type,
                              LP_JIT_CS_CTX_IMAGES);
-      LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, ssbos,
-                             gallivm->target, cs_context_type,
-                             LP_JIT_CS_CTX_SSBOS);
-      LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, shared_size,
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, aniso_filter_table,
                              gallivm->target, cs_context_type,
-                             LP_JIT_CS_CTX_SHARED_SIZE);
+                             LP_JIT_CS_CTX_ANISO_FILTER_TABLE);
       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,
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, shared_size,
                              gallivm->target, cs_context_type,
-                             LP_JIT_CS_CTX_ANISO_FILTER_TABLE);
+                             LP_JIT_CS_CTX_SHARED_SIZE);
       LP_CHECK_STRUCT_SIZE(struct lp_jit_cs_context,
                            gallivm->target, cs_context_type);
 
index 12336ff..19b79c9 100644 (file)
@@ -76,10 +76,11 @@ enum {
 struct lp_jit_context
 {
    struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
-
+   struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
    struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
    struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS];
    struct lp_jit_image images[PIPE_MAX_SHADER_IMAGES];
+   const float *aniso_filter_table;
 
    float alpha_ref_value;
 
@@ -90,11 +91,7 @@ struct lp_jit_context
 
    struct lp_jit_viewport *viewports;
 
-   struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
-
    uint32_t sample_mask;
-
-   const float *aniso_filter_table;
 };
 
 
@@ -104,18 +101,18 @@ struct lp_jit_context
  */
 enum {
    LP_JIT_CTX_CONSTANTS = 0,
+   LP_JIT_CTX_SSBOS,
    LP_JIT_CTX_TEXTURES,
    LP_JIT_CTX_SAMPLERS,
    LP_JIT_CTX_IMAGES,
+   LP_JIT_CTX_ANISO_FILTER_TABLE,
    LP_JIT_CTX_ALPHA_REF,
    LP_JIT_CTX_STENCIL_REF_FRONT,
    LP_JIT_CTX_STENCIL_REF_BACK,
    LP_JIT_CTX_U8_BLEND_COLOR,
    LP_JIT_CTX_F_BLEND_COLOR,
    LP_JIT_CTX_VIEWPORTS,
-   LP_JIT_CTX_SSBOS,
    LP_JIT_CTX_SAMPLE_MASK,
-   LP_JIT_CTX_ANISO_FILTER_TABLE,
    LP_JIT_CTX_COUNT
 };
 
@@ -123,6 +120,9 @@ enum {
 #define lp_jit_context_constants(_gallivm, _type, _ptr) \
    lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_CONSTANTS, "constants")
 
+#define lp_jit_context_ssbos(_gallivm, _type, _ptr)                    \
+   lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_SSBOS, "ssbos")
+
 #define lp_jit_context_textures(_gallivm, _type, _ptr) \
    lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_TEXTURES, "textures")
 
@@ -132,6 +132,9 @@ enum {
 #define lp_jit_context_images(_gallivm, _type, _ptr) \
    lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_IMAGES, "images")
 
+#define lp_jit_context_aniso_filter_table(_gallivm, _type, _ptr)         \
+   lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
+
 #define lp_jit_context_alpha_ref_value(_gallivm, _type, _ptr) \
    lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
 
@@ -150,15 +153,9 @@ enum {
 #define lp_jit_context_viewports(_gallivm, _type, _ptr) \
    lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_VIEWPORTS, "viewports")
 
-#define lp_jit_context_ssbos(_gallivm, _type, _ptr) \
-   lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_SSBOS, "ssbos")
-
-#define lp_jit_context_sample_mask(_gallivm, _type, _ptr) \
+#define lp_jit_context_sample_mask(_gallivm, _type, _ptr)                \
    lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CTX_SAMPLE_MASK, "sample_mask")
 
-#define lp_jit_context_aniso_filter_table(_gallivm, _type, _ptr) \
-   lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
-
 
 struct lp_jit_thread_data
 {
@@ -352,18 +349,15 @@ enum {
 struct lp_jit_cs_context
 {
    struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
-
+   struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
    struct lp_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
    struct lp_jit_sampler samplers[PIPE_MAX_SAMPLERS];
    struct lp_jit_image images[PIPE_MAX_SHADER_IMAGES];
-
-   struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
+   const float *aniso_filter_table;
 
    const void *kernel_args;
 
    uint32_t shared_size;
-
-   const float *aniso_filter_table;
 };
 
 /**
@@ -372,19 +366,22 @@ struct lp_jit_cs_context
  */
 enum {
    LP_JIT_CS_CTX_CONSTANTS = 0,
+   LP_JIT_CS_CTX_SSBOS,
    LP_JIT_CS_CTX_TEXTURES, /* must match the LP_JIT_CTX_TEXTURES */
    LP_JIT_CS_CTX_SAMPLERS,
    LP_JIT_CS_CTX_IMAGES,
-   LP_JIT_CS_CTX_SSBOS,
+   LP_JIT_CS_CTX_ANISO_FILTER_TABLE,
    LP_JIT_CS_CTX_KERNEL_ARGS,
    LP_JIT_CS_CTX_SHARED_SIZE,
-   LP_JIT_CS_CTX_ANISO_FILTER_TABLE,
    LP_JIT_CS_CTX_COUNT
 };
 
 #define lp_jit_cs_context_constants(_gallivm, _type, _ptr) \
    lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_CONSTANTS, "constants")
 
+#define lp_jit_cs_context_ssbos(_gallivm, _type, _ptr) \
+   lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_SSBOS, "ssbos")
+
 #define lp_jit_cs_context_textures(_gallivm, _type, _ptr) \
    lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_TEXTURES, "textures")
 
@@ -394,8 +391,8 @@ enum {
 #define lp_jit_cs_context_images(_gallivm, _type, _ptr) \
    lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_IMAGES, "images")
 
-#define lp_jit_cs_context_ssbos(_gallivm, _type, _ptr) \
-   lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_SSBOS, "ssbos")
+#define lp_jit_cs_context_aniso_filter_table(_gallivm, _type, _ptr) \
+   lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
 
 #define lp_jit_cs_context_shared_size(_gallivm, _type, _ptr) \
    lp_build_struct_get_ptr2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_SHARED_SIZE, "shared_size")
@@ -403,10 +400,6 @@ enum {
 #define lp_jit_cs_context_kernel_args(_gallivm, _type, _ptr) \
    lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_KERNEL_ARGS, "kernel_args")
 
-#define lp_jit_cs_context_aniso_filter_table(_gallivm, _type, _ptr) \
-   lp_build_struct_get2(_gallivm, _type, _ptr, LP_JIT_CS_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
-
-
 typedef void
 (*lp_jit_cs_func)(const struct lp_jit_cs_context *context,
                   uint32_t x,