llvmpipe: add multisample support to texture allocator.
authorDave Airlie <airlied@redhat.com>
Tue, 10 Mar 2020 00:30:13 +0000 (10:30 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
This adds a sample stride field and allocates enough memory for
each sample storage. Hook up the sample_stride field to draw
and jit textures and images

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

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_texture.c
src/gallium/drivers/llvmpipe/lp_texture.h

index a52f6bbb9c5df9cd98b6cc6eb27af82336aea6bb..eaa759bdab95b4eecab828aca6c2d24d0fa275a3 100644 (file)
@@ -726,7 +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->sample_stride = lp_res->sample_stride;
             jit_image->base = (uint8_t *)jit_image->base + mip_offset;
          }
          else {
@@ -943,6 +943,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
                      jit_tex->img_stride[j] = lp_tex->img_stride[j];
                   }
 
+                  jit_tex->sample_stride = lp_tex->sample_stride;
+
                   if (res->target == PIPE_TEXTURE_1D_ARRAY ||
                       res->target == PIPE_TEXTURE_2D_ARRAY ||
                       res->target == PIPE_TEXTURE_CUBE ||
index 1d33d5314d672ef977f526828bdb48fc7bb48fe6..38210d444f55013671969a2a843227608a1518bd 100644 (file)
@@ -880,6 +880,7 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
                      jit_tex->row_stride[j] = lp_tex->row_stride[j];
                      jit_tex->img_stride[j] = lp_tex->img_stride[j];
                   }
+                  jit_tex->sample_stride = lp_tex->sample_stride;
 
                   if (res->target == PIPE_TEXTURE_1D_ARRAY ||
                       res->target == PIPE_TEXTURE_2D_ARRAY ||
@@ -1076,7 +1077,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->sample_stride = lp_res->sample_stride;
             jit_image->base = (uint8_t *)jit_image->base + mip_offset;
          } else {
             unsigned view_blocksize = util_format_get_blocksize(image->format);
index 9ddfc37864f9ef21b92d6a34e459c0c5c87fd69d..0851213a798fac5b7b2222374e97c50c52dba834 100644 (file)
@@ -283,6 +283,8 @@ prepare_shader_sampling(
                assert(last_level <= res->last_level);
                addr = lp_tex->tex_data;
 
+               sample_stride = lp_tex->sample_stride;
+
                for (j = first_level; j <= last_level; j++) {
                   mip_offsets[j] = lp_tex->mip_offsets[j];
                   row_stride[j] = lp_tex->row_stride[j];
@@ -443,7 +445,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;
+               sample_stride = lp_img->sample_stride;
                addr = (uint8_t *)addr + mip_offset;
             }
             else {
index 0d5c4ac544d112aa54bcfa711d2fcd1508894f73..47491ac46041a1cc6c7cee90ad3b9284ddf3a5d8 100644 (file)
@@ -76,6 +76,8 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
    unsigned depth = pt->depth0;
    uint64_t total_size = 0;
    unsigned layers = pt->array_size;
+   unsigned num_samples = util_res_sample_count(pt);
+
    /* XXX:
     * This alignment here (same for displaytarget) was added for the purpose of
     * ARB_map_buffer_alignment. I am not convinced it's needed for non-buffer
@@ -166,6 +168,9 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
       depth = u_minify(depth, 1);
    }
 
+   lpr->sample_stride = total_size;
+   total_size *= num_samples;
+
    if (allocate) {
       lpr->tex_data = align_malloc(total_size, mip_align);
       if (!lpr->tex_data) {
index 3d315bb9a73ed802d3cf67e56485f5103a927a39..03cf5a749d5194f2fff36bbc5b7b1b99d97ea49a 100644 (file)
@@ -90,6 +90,7 @@ struct llvmpipe_resource
 
    unsigned id;  /**< temporary, for debugging */
 
+   unsigned sample_stride;
 #ifdef DEBUG
    /** for linked list */
    struct llvmpipe_resource *prev, *next;