Mesa (staging/22.0): gallium/tc: zero alloc transfers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Apr 14 19:50:46 UTC 2022
Module: Mesa
Branch: staging/22.0
Commit: 6b372769123356401c13a8b5e280146972149133
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b372769123356401c13a8b5e280146972149133
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date: Tue Mar 8 11:44:26 2022 +0100
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 at gmail.com>
Reviewed-by: Rob Clark <robdclark at chromium.org>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15298>
(cherry picked from commit 3c3a8f853dd8b43bfd51794f2a7d632feda396c4)
---
src/gallium/auxiliary/util/u_threaded_context.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
index 3045af7e4c8..c3007b93ab6 100644
--- a/src/gallium/auxiliary/util/u_threaded_context.c
+++ b/src/gallium/auxiliary/util/u_threaded_context.c
@@ -2181,15 +2181,10 @@ tc_buffer_map(struct pipe_context *_pipe,
tres->cpu_storage = align_malloc(resource->width0, tc->map_buffer_alignment);
if (tres->cpu_storage) {
- struct threaded_transfer *ttrans = slab_alloc(&tc->pool_transfers);
+ struct threaded_transfer *ttrans = slab_zalloc(&tc->pool_transfers);
ttrans->b.resource = resource;
- ttrans->b.level = 0;
ttrans->b.usage = usage;
ttrans->b.box = *box;
- ttrans->b.stride = 0;
- ttrans->b.layer_stride = 0;
- ttrans->b.offset = 0;
- ttrans->staging = NULL;
ttrans->valid_buffer_range = &tres->valid_buffer_range;
ttrans->cpu_storage_mapped = true;
*transfer = &ttrans->b;
@@ -2204,11 +2199,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,
More information about the mesa-commit
mailing list