llvmpipe: add samples support to image jit
authorDave Airlie <airlied@redhat.com>
Mon, 23 Mar 2020 05:11:37 +0000 (15:11 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>

src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_state_cs.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/llvmpipe/lp_tex_sample.c

index 39910c66837ed2e839f06bc28d824436b70699c2..4ec83480c05921946732f2dca5dadc041d8c30ef 100644 (file)
@@ -146,7 +146,9 @@ create_jit_image_type(struct gallivm_state *gallivm)
    elem_types[LP_JIT_IMAGE_DEPTH] = LLVMInt32TypeInContext(lc);
    elem_types[LP_JIT_IMAGE_BASE] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
    elem_types[LP_JIT_IMAGE_ROW_STRIDE] =
-   elem_types[LP_JIT_IMAGE_IMG_STRIDE] = LLVMInt32TypeInContext(lc);
+   elem_types[LP_JIT_IMAGE_IMG_STRIDE] =
+   elem_types[LP_JIT_IMAGE_NUM_SAMPLES] =
+   elem_types[LP_JIT_IMAGE_SAMPLE_STRIDE] = LLVMInt32TypeInContext(lc);
 
    image_type = LLVMStructTypeInContext(lc, elem_types,
                                         ARRAY_SIZE(elem_types), 0);
@@ -168,6 +170,12 @@ create_jit_image_type(struct gallivm_state *gallivm)
    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, img_stride,
                           gallivm->target, image_type,
                           LP_JIT_IMAGE_IMG_STRIDE);
+   LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, num_samples,
+                          gallivm->target, image_type,
+                          LP_JIT_IMAGE_NUM_SAMPLES);
+   LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, sample_stride,
+                          gallivm->target, image_type,
+                          LP_JIT_IMAGE_SAMPLE_STRIDE);
    return image_type;
 }
 
index b89f25b8dba14eebe4714baeae5bb11324c9a668..d7960e21d30fde9dd12961e4834366ced5149a56 100644 (file)
@@ -89,6 +89,8 @@ struct lp_jit_image
    const void *base;
    uint32_t row_stride;
    uint32_t img_stride;
+   uint32_t num_samples;
+   uint32_t sample_stride;
 };
 
 enum {
@@ -129,6 +131,8 @@ enum {
    LP_JIT_IMAGE_BASE,
    LP_JIT_IMAGE_ROW_STRIDE,
    LP_JIT_IMAGE_IMG_STRIDE,
+   LP_JIT_IMAGE_NUM_SAMPLES,
+   LP_JIT_IMAGE_SAMPLE_STRIDE,
    LP_JIT_IMAGE_NUM_FIELDS  /* number of fields above */
 };
 /**
index e67392059a3819b869366f1a694d85721fdaf44a..a52f6bbb9c5df9cd98b6cc6eb27af82336aea6bb 100644 (file)
@@ -700,6 +700,7 @@ lp_setup_set_fs_images(struct lp_setup_context *setup,
          jit_image->width = res->width0;
          jit_image->height = res->height0;
          jit_image->depth = res->depth0;
+         jit_image->num_samples = res->nr_samples;
 
          if (llvmpipe_resource_is_texture(res)) {
             uint32_t mip_offset = lp_res->mip_offsets[image->u.tex.level];
@@ -725,6 +726,7 @@ lp_setup_set_fs_images(struct lp_setup_context *setup,
 
             jit_image->row_stride = lp_res->row_stride[image->u.tex.level];
             jit_image->img_stride = lp_res->img_stride[image->u.tex.level];
+            jit_image->sample_stride = 0;
             jit_image->base = (uint8_t *)jit_image->base + mip_offset;
          }
          else {
index da5eed7abd3895d799c28045e93fcee5d34a0378..1d33d5314d672ef977f526828bdb48fc7bb48fe6 100644 (file)
@@ -1050,6 +1050,7 @@ lp_csctx_set_cs_images(struct lp_cs_context *csctx,
          jit_image->width = res->width0;
          jit_image->height = res->height0;
          jit_image->depth = res->depth0;
+         jit_image->num_samples = res->nr_samples;
 
          if (llvmpipe_resource_is_texture(res)) {
             uint32_t mip_offset = lp_res->mip_offsets[image->u.tex.level];
@@ -1075,6 +1076,7 @@ lp_csctx_set_cs_images(struct lp_cs_context *csctx,
 
             jit_image->row_stride = lp_res->row_stride[image->u.tex.level];
             jit_image->img_stride = lp_res->img_stride[image->u.tex.level];
+            jit_image->sample_stride = 0;
             jit_image->base = (uint8_t *)jit_image->base + mip_offset;
          } else {
             unsigned view_blocksize = util_format_get_blocksize(image->format);
index 723e472720ede98fdffd7f7ada51adafe8db492d..9ddfc37864f9ef21b92d6a34e459c0c5c87fd69d 100644 (file)
@@ -402,6 +402,7 @@ prepare_shader_images(
    unsigned i;
    uint32_t row_stride;
    uint32_t img_stride;
+   uint32_t sample_stride;
    const void *addr;
 
    assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
@@ -420,6 +421,7 @@ prepare_shader_images(
          unsigned width = u_minify(img->width0, view->u.tex.level);
          unsigned height = u_minify(img->height0, view->u.tex.level);
          unsigned num_layers = img->depth0;
+         unsigned num_samples = img->nr_samples;
 
          if (!lp_img->dt) {
             /* regular texture - setup array of mipmap level offsets */
@@ -441,6 +443,7 @@ prepare_shader_images(
 
                row_stride = lp_img->row_stride[view->u.tex.level];
                img_stride = lp_img->img_stride[view->u.tex.level];
+               sample_stride = 0;
                addr = (uint8_t *)addr + mip_offset;
             }
             else {
@@ -449,6 +452,7 @@ prepare_shader_images(
                /* probably don't really need to fill that out */
                row_stride = 0;
                img_stride = 0;
+               sample_stride = 0;
 
                /* everything specified in number of elements here. */
                width = view->u.buf.size / view_blocksize;
@@ -467,6 +471,7 @@ prepare_shader_images(
                                                 PIPE_TRANSFER_READ);
             row_stride = lp_img->row_stride[0];
             img_stride = lp_img->img_stride[0];
+            sample_stride = 0;
             assert(addr);
          }
          draw_set_mapped_image(lp->draw,
@@ -474,7 +479,8 @@ prepare_shader_images(
                                i,
                                width, height, num_layers,
                                addr,
-                               row_stride, img_stride, 0, 0);
+                               row_stride, img_stride,
+                               num_samples, sample_stride);
       }
    }
 }
index 326fde79f942ee109b1dace7715c984ac94b8f20..e0285c70e5b8d730f9d1843ad702211aab702380 100644 (file)
@@ -313,6 +313,8 @@ LP_LLVM_IMAGE_MEMBER(depth,      LP_JIT_IMAGE_DEPTH, TRUE)
 LP_LLVM_IMAGE_MEMBER(base_ptr,   LP_JIT_IMAGE_BASE, TRUE)
 LP_LLVM_IMAGE_MEMBER(row_stride, LP_JIT_IMAGE_ROW_STRIDE, TRUE)
 LP_LLVM_IMAGE_MEMBER(img_stride, LP_JIT_IMAGE_IMG_STRIDE, TRUE)
+LP_LLVM_IMAGE_MEMBER(num_samples, LP_JIT_IMAGE_NUM_SAMPLES, TRUE)
+LP_LLVM_IMAGE_MEMBER(sample_stride, LP_JIT_IMAGE_SAMPLE_STRIDE, TRUE)
 
 #if LP_USE_TEXTURE_CACHE
 static LLVMValueRef
@@ -477,6 +479,8 @@ lp_llvm_image_soa_create(const struct lp_image_static_state *static_state)
    image->dynamic_state.base.base_ptr = lp_llvm_image_base_ptr;
    image->dynamic_state.base.row_stride = lp_llvm_image_row_stride;
    image->dynamic_state.base.img_stride = lp_llvm_image_img_stride;
+   image->dynamic_state.base.num_samples = lp_llvm_image_num_samples;
+   image->dynamic_state.base.sample_stride = lp_llvm_image_sample_stride;
 
    image->dynamic_state.static_state = static_state;