llvmpipe: reogranise jit pointer ordering
authorDave Airlie <airlied@redhat.com>
Wed, 26 Jun 2019 00:12:28 +0000 (10:12 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 4 Sep 2019 05:22:20 +0000 (15:22 +1000)
In order to share the texture/image/sampler code with compute
shaders we need to reorg them to be at the front of context
same as draw does for vs/gs sharing.

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

index 035cc28..36062ac 100644 (file)
@@ -202,18 +202,18 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
          LLVMArrayType(LLVMPointerType(LLVMFloatTypeInContext(lc), 0), LP_MAX_TGSI_CONST_BUFFERS);
       elem_types[LP_JIT_CTX_NUM_CONSTANTS] =
             LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_CONST_BUFFERS);
-      elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatTypeInContext(lc);
-      elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] =
-      elem_types[LP_JIT_CTX_STENCIL_REF_BACK] = LLVMInt32TypeInContext(lc);
-      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_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_ALPHA_REF] = LLVMFloatTypeInContext(lc);
+      elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] =
+      elem_types[LP_JIT_CTX_STENCIL_REF_BACK] = LLVMInt32TypeInContext(lc);
+      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_SSBOS] =
          LLVMArrayType(LLVMPointerType(LLVMInt32TypeInContext(lc), 0), LP_MAX_TGSI_SHADER_BUFFERS);
       elem_types[LP_JIT_CTX_NUM_SSBOS] =
@@ -227,6 +227,15 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, num_constants,
                              gallivm->target, context_type,
                              LP_JIT_CTX_NUM_CONSTANTS);
+      LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures,
+                             gallivm->target, context_type,
+                             LP_JIT_CTX_TEXTURES);
+      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, images,
+                             gallivm->target, context_type,
+                             LP_JIT_CTX_IMAGES);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
                              gallivm->target, context_type,
                              LP_JIT_CTX_ALPHA_REF);
@@ -245,15 +254,6 @@ 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, textures,
-                             gallivm->target, context_type,
-                             LP_JIT_CTX_TEXTURES);
-      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, images,
-                             gallivm->target, context_type,
-                             LP_JIT_CTX_IMAGES);
       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, ssbos,
                              gallivm->target, context_type,
                              LP_JIT_CTX_SSBOS);
index 81e0019..f8d350e 100644 (file)
@@ -142,6 +142,10 @@ struct lp_jit_context
    const float *constants[LP_MAX_TGSI_CONST_BUFFERS];
    int num_constants[LP_MAX_TGSI_CONST_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];
+
    float alpha_ref_value;
 
    uint32_t stencil_ref_front, stencil_ref_back;
@@ -151,10 +155,6 @@ struct lp_jit_context
 
    struct lp_jit_viewport *viewports;
 
-   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 uint32_t *ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
    int num_ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
 };
@@ -167,15 +167,15 @@ struct lp_jit_context
 enum {
    LP_JIT_CTX_CONSTANTS = 0,
    LP_JIT_CTX_NUM_CONSTANTS,
+   LP_JIT_CTX_TEXTURES,
+   LP_JIT_CTX_SAMPLERS,
+   LP_JIT_CTX_IMAGES,
    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_TEXTURES,
-   LP_JIT_CTX_SAMPLERS,
-   LP_JIT_CTX_IMAGES,
    LP_JIT_CTX_SSBOS,
    LP_JIT_CTX_NUM_SSBOS,
    LP_JIT_CTX_COUNT
@@ -188,6 +188,15 @@ enum {
 #define lp_jit_context_num_constants(_gallivm, _ptr) \
    lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_NUM_CONSTANTS, "num_constants")
 
+#define lp_jit_context_textures(_gallivm, _ptr) \
+   lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_TEXTURES, "textures")
+
+#define lp_jit_context_samplers(_gallivm, _ptr) \
+   lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLERS, "samplers")
+
+#define lp_jit_context_images(_gallivm, _ptr) \
+   lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_IMAGES, "images")
+
 #define lp_jit_context_alpha_ref_value(_gallivm, _ptr) \
    lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
 
@@ -206,15 +215,6 @@ enum {
 #define lp_jit_context_viewports(_gallivm, _ptr) \
    lp_build_struct_get(_gallivm, _ptr, LP_JIT_CTX_VIEWPORTS, "viewports")
 
-#define lp_jit_context_textures(_gallivm, _ptr) \
-   lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_TEXTURES, "textures")
-
-#define lp_jit_context_samplers(_gallivm, _ptr) \
-   lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLERS, "samplers")
-
-#define lp_jit_context_images(_gallivm, _ptr) \
-   lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_IMAGES, "images")
-
 #define lp_jit_context_ssbos(_gallivm, _ptr) \
    lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SSBOS, "ssbos")