gallium/swr: Fix array stride problem.
authorKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>
Wed, 1 Apr 2020 14:57:20 +0000 (16:57 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 1 Apr 2020 19:43:50 +0000 (19:43 +0000)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4405>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4405>

src/gallium/drivers/swr/swr_state.cpp

index 625f0050ad59b0951a8c4337686c94fdaf2e3778..07ff9b46ad2bf0f77a9f334b52c0cd8cfedd509b 100644 (file)
@@ -1106,16 +1106,17 @@ swr_user_vbuf_range(const struct pipe_draw_info *info,
 {
    /* FIXME: The size is too large - we don't access the full extra stride. */
    unsigned elems;
+   unsigned elem_pitch = vb->stride + velems->stream_pitch[i];
    if (velems->instanced_bufs & (1U << i)) {
       elems = info->instance_count / velems->min_instance_div[i] + 1;
       *totelems = info->start_instance + elems;
       *base = info->start_instance * vb->stride;
-      *size = elems * vb->stride;
+      *size = elems * elem_pitch;
    } else if (vb->stride) {
       elems = info->max_index - info->min_index + 1;
       *totelems = (info->max_index + info->index_bias) + 1;
       *base = (info->min_index + info->index_bias) * vb->stride;
-      *size = elems * vb->stride;
+      *size = elems * elem_pitch;
    } else {
       *totelems = 1;
       *base = 0;