gallium/tc: zero alloc transfers

Otherwise this causes trouble with unitialized memory, eg with:
   struct si_transfer {
      struct threaded_transfer b;
      struct si_resource *staging;
   };
'staging' will not be initialized and this causes #6109.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6109

Cc: mesa-stable
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15298>
(cherry picked from commit 3c3a8f853d)
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2022-03-08 11:44:26 +01:00 committed by Eric Engestrom
parent eb7534abc8
commit 0bef7767b2
2 changed files with 2 additions and 4 deletions

View file

@ -769,7 +769,7 @@
"description": "gallium/tc: zero alloc transfers",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -2148,11 +2148,9 @@ tc_buffer_map(struct pipe_context *_pipe,
* only get resource_copy_region.
*/
if (usage & PIPE_MAP_DISCARD_RANGE) {
struct threaded_transfer *ttrans = slab_alloc(&tc->pool_transfers);
struct threaded_transfer *ttrans = slab_zalloc(&tc->pool_transfers);
uint8_t *map;
ttrans->staging = NULL;
u_upload_alloc(tc->base.stream_uploader, 0,
box->width + (box->x % tc->map_buffer_alignment),
tc->map_buffer_alignment, &ttrans->b.offset,