llvmpipe: change mask input to fragment shader to 64-bit.
authorDave Airlie <airlied@redhat.com>
Tue, 10 Mar 2020 22:23:10 +0000 (08:23 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
In order to handle a 4xMSAA mask (16-bits per sample) increase
the fragment shader API to be 64-bit.

v2: drop pointless if (Roland)

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

src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_rast_priv.h
src/gallium/drivers/llvmpipe/lp_state_fs.c

index 61f4b9b650b1e9c9f78d59cdb42b581086cc6f61..dcfe274b6f4240cc8396db856ba91db696b6265f 100644 (file)
@@ -286,7 +286,7 @@ enum {
  * @param dady          shader input dady
  * @param color         color buffer
  * @param depth         depth buffer
- * @param mask          mask of visible pixels in block
+ * @param mask          mask of visible pixels in block (16-bits per sample)
  * @param thread_data   task thread data
  * @param stride        color buffer row stride in bytes
  * @param depth_stride  depth buffer row stride in bytes
@@ -301,7 +301,7 @@ typedef void
                     const void *dady,
                     uint8_t **color,
                     uint8_t *depth,
-                    uint32_t mask,
+                    uint64_t mask,
                     struct lp_jit_thread_data *thread_data,
                     unsigned *stride,
                     unsigned depth_stride,
index 5a6abd8de4db7f8ff5ee1679d1d9a5e31a9153d6..c4c5053be78d4183f9aab47bd3886a97c5bd6041 100644 (file)
@@ -374,7 +374,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
                                             GET_DADY(inputs),
                                             color,
                                             depth,
-                                            0xffff,
+                                            (uint64_t)0xffff,
                                             &task->thread_data,
                                             stride,
                                             depth_stride,
@@ -482,7 +482,7 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
                                             GET_DADY(inputs),
                                             color,
                                             depth,
-                                            mask,
+                                            (uint64_t)mask,
                                             &task->thread_data,
                                             stride,
                                             depth_stride,
index d4a3e48eff4991c8c9806322c554684b2f1e0e57..6c962ffdc52b669098a0ba2a61be2f74cc907b0a 100644 (file)
@@ -275,7 +275,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
                                          GET_DADY(inputs),
                                          color,
                                          depth,
-                                         0xffff,
+                                         (uint64_t)0xffff,
                                          &task->thread_data,
                                          stride,
                                          depth_stride,
index b6bc8c3a7c05ad833ffa7a12ac12df480be74593..7014f6ddeb4d03e393c2f34cc4a60402976819c1 100644 (file)
@@ -123,7 +123,8 @@ static LLVMValueRef
 generate_quad_mask(struct gallivm_state *gallivm,
                    struct lp_type fs_type,
                    unsigned first_quad,
-                   LLVMValueRef mask_input) /* int32 */
+                   unsigned sample,
+                   LLVMValueRef mask_input) /* int64 */
 {
    LLVMBuilderRef builder = gallivm->builder;
    struct lp_type mask_type;
@@ -162,6 +163,11 @@ generate_quad_mask(struct gallivm_state *gallivm,
       shift = 0;
    }
 
+   mask_input = LLVMBuildLShr(builder, mask_input, lp_build_const_int64(gallivm, 16 * sample), "");
+   mask_input = LLVMBuildTrunc(builder, mask_input,
+                               i32t, "");
+   mask_input = LLVMBuildAnd(builder, mask_input, lp_build_const_int32(gallivm, 0xffff), "");
+
    mask_input = LLVMBuildLShr(builder,
                               mask_input,
                               LLVMConstInt(i32t, shift, 0),
@@ -2538,7 +2544,7 @@ generate_fragment(struct llvmpipe_context *lp,
    arg_types[6] = LLVMPointerType(fs_elem_type, 0);    /* dady */
    arg_types[7] = LLVMPointerType(LLVMPointerType(blend_vec_type, 0), 0);  /* color */
    arg_types[8] = LLVMPointerType(int8_type, 0);       /* depth */
-   arg_types[9] = int32_type;                          /* mask_input */
+   arg_types[9] = LLVMInt64TypeInContext(gallivm->context);  /* mask_input */
    arg_types[10] = variant->jit_thread_data_ptr_type;  /* per thread data */
    arg_types[11] = LLVMPointerType(int32_type, 0);     /* stride */
    arg_types[12] = int32_type;                         /* depth_stride */
@@ -2660,7 +2666,7 @@ generate_fragment(struct llvmpipe_context *lp,
 
          if (partial_mask) {
             mask = generate_quad_mask(gallivm, fs_type,
-                                      i*fs_type.length/4, mask_input);
+                                      i*fs_type.length/4, 0, mask_input);
          }
          else {
             mask = lp_build_const_int_vec(gallivm, fs_type, ~0);