draw: fix vsplit code when the (post-bias) index value is -1
[mesa.git] / src / gallium / auxiliary / draw / draw_pt_vsplit.c
index a68d5bf971cf2bcb87b9216d1303aeec5bffaef7..3ff077b76026eedb281cc4af8469c7a29754a02e 100644 (file)
@@ -133,7 +133,7 @@ vsplit_add_cache_ubyte(struct vsplit_frontend *vsplit, const ubyte *elts,
    VSPLIT_CREATE_IDX(elts, start, fetch, elt_bias);
    /* unlike the uint case this can only happen with elt_bias */
    if (elt_bias && elt_idx == DRAW_MAX_FETCH_IDX && !vsplit->cache.has_max_fetch) {
-      unsigned hash = fetch % MAP_SIZE;
+      unsigned hash = elt_idx % MAP_SIZE;
       vsplit->cache.fetches[hash] = 0;
       vsplit->cache.has_max_fetch = TRUE;
    }
@@ -148,7 +148,7 @@ vsplit_add_cache_ushort(struct vsplit_frontend *vsplit, const ushort *elts,
    VSPLIT_CREATE_IDX(elts, start, fetch, elt_bias);
    /* unlike the uint case this can only happen with elt_bias */
    if (elt_bias && elt_idx == DRAW_MAX_FETCH_IDX && !vsplit->cache.has_max_fetch) {
-      unsigned hash = fetch % MAP_SIZE;
+      unsigned hash = elt_idx % MAP_SIZE;
       vsplit->cache.fetches[hash] = 0;
       vsplit->cache.has_max_fetch = TRUE;
    }
@@ -168,7 +168,7 @@ vsplit_add_cache_uint(struct vsplit_frontend *vsplit, const uint *elts,
    VSPLIT_CREATE_IDX(elts, start, fetch, elt_bias);
    /* Take care for DRAW_MAX_FETCH_IDX (since cache is initialized to -1). */
    if (elt_idx == DRAW_MAX_FETCH_IDX && !vsplit->cache.has_max_fetch) {
-      unsigned hash = fetch % MAP_SIZE;
+      unsigned hash = elt_idx % MAP_SIZE;
       /* force update - any value will do except DRAW_MAX_FETCH_IDX */
       vsplit->cache.fetches[hash] = 0;
       vsplit->cache.has_max_fetch = TRUE;