llvmpipe/cs: migrate cs image handle to common jit code.
authorDave Airlie <airlied@redhat.com>
Wed, 27 Sep 2023 05:30:05 +0000 (15:30 +1000)
committerMarge Bot <emma+marge@anholt.net>
Thu, 28 Sep 2023 00:41:04 +0000 (00:41 +0000)
This moves some of the code over, and uses the generic paths.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25416>

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

index 7dcea53..77be06f 100644 (file)
@@ -587,9 +587,29 @@ lp_jit_image_from_pipe(struct lp_jit_image *jit, const struct pipe_image_view *v
          jit->sample_stride = lp_res->sample_stride;
          jit->base = (uint8_t *)jit->base + mip_offset;
       } else {
-         unsigned view_blocksize = util_format_get_blocksize(view->format);
-         jit->width = view->u.buf.size / view_blocksize;
-         jit->base = (uint8_t *)jit->base + view->u.buf.offset;
+         unsigned image_blocksize = util_format_get_blocksize(view->format);
+
+         jit->img_stride = 0;
+
+         /* If it's not a 2D image view of a buffer, adjust using size. */
+         if (!(view->access & PIPE_IMAGE_ACCESS_TEX2D_FROM_BUFFER)) {
+            /* everything specified in number of elements here. */
+            jit->width = view->u.buf.size / image_blocksize;
+            jit->row_stride = 0;
+
+            /* Adjust base pointer with offset. */
+            jit->base = (uint8_t *)jit->base + view->u.buf.offset;
+
+            /* XXX Unsure if we need to sanitize parameters? */
+            assert(view->u.buf.offset + view->u.buf.size <= res->width0);
+         } else {
+            jit->width = view->u.tex2d_from_buf.width;
+            jit->height = view->u.tex2d_from_buf.height;
+            jit->row_stride = view->u.tex2d_from_buf.row_stride * image_blocksize;
+
+            jit->base = (uint8_t *)jit->base +
+               view->u.tex2d_from_buf.offset * image_blocksize;
+         }
       }
    }
 }
index 413ab80..1a8d26e 100644 (file)
@@ -1566,70 +1566,8 @@ lp_csctx_set_cs_images(struct lp_cs_context *csctx,
       jit_image = &csctx->cs.current.jit_resources.images[i];
       if (!lp_res)
          continue;
-      if (!lp_res->dt) {
-         /* regular texture - csctx array of mipmap level offsets */
-         if (llvmpipe_resource_is_texture(res)) {
-            jit_image->base = lp_res->tex_data;
-         } else
-            jit_image->base = lp_res->data;
-
-         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];
-
-            jit_image->width = u_minify(jit_image->width, image->u.tex.level);
-            jit_image->height = u_minify(jit_image->height, image->u.tex.level);
-
-            if (res->target == PIPE_TEXTURE_1D_ARRAY ||
-                res->target == PIPE_TEXTURE_2D_ARRAY ||
-                res->target == PIPE_TEXTURE_3D ||
-                res->target == PIPE_TEXTURE_CUBE ||
-                res->target == PIPE_TEXTURE_CUBE_ARRAY) {
-               /*
-                * For array textures, we don't have first_layer, instead
-                * adjust last_layer (stored as depth) plus the mip level
-                * offsets (as we have mip-first layout can't just adjust base
-                * ptr).  XXX For mip levels, could do something similar.
-                */
-               jit_image->depth = image->u.tex.last_layer - image->u.tex.first_layer + 1;
-               mip_offset += image->u.tex.first_layer * lp_res->img_stride[image->u.tex.level];
-            } else
-               jit_image->depth = u_minify(jit_image->depth, image->u.tex.level);
-
-            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 = lp_res->sample_stride;
-            jit_image->base = (uint8_t *)jit_image->base + mip_offset;
-         } else {
-            unsigned image_blocksize = util_format_get_blocksize(image->format);
-
-            jit_image->img_stride = 0;
-
-            /* If it's not a 2D image view of a buffer, adjust using size. */
-            if (!(image->access & PIPE_IMAGE_ACCESS_TEX2D_FROM_BUFFER)) {
-               /* everything specified in number of elements here. */
-               jit_image->width = image->u.buf.size / image_blocksize;
-               jit_image->row_stride = 0;
-
-               /* Adjust base pointer with offset. */
-               jit_image->base = (uint8_t *)jit_image->base + image->u.buf.offset;
-
-               /* XXX Unsure if we need to sanitize parameters? */
-               assert(image->u.buf.offset + image->u.buf.size <= res->width0);
-            } else {
-               jit_image->width = image->u.tex2d_from_buf.width;
-               jit_image->height = image->u.tex2d_from_buf.height;
-               jit_image->row_stride = image->u.tex2d_from_buf.row_stride * image_blocksize;
-
-               jit_image->base = (uint8_t *)jit_image->base +
-                  image->u.tex2d_from_buf.offset * image_blocksize;
-            }
-         }
-      }
+
+      lp_jit_image_from_pipe(jit_image, image);
    }
    for (; i < ARRAY_SIZE(csctx->images); i++) {
       util_copy_image_view(&csctx->images[i].current, NULL);