zink: track the "real" buffer range from replacement buffers

when tc replaces a buffer in subdata, it may subsequently perform subdata calls
on the replacement if it is forced to sync during map, e.g.,
* bind_vbo(dst)
* draw
* subdata(src)
  * buffer replacement
  * map
  * tc sync
  * replace_buffer(dst, src)
  * memcpy <- broken
* draw

in this scenario, src may not have data at the time of replacement,
but it will get data soon after, and this buffer range is the real one

cc: mesa-stable

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30107>
(cherry picked from commit 76da22bfc2)
This commit is contained in:
Mike Blumenkrantz 2024-06-25 11:50:13 -04:00 committed by Eric Engestrom
parent 722a7f589d
commit fe4312235f
3 changed files with 3 additions and 1 deletions

View file

@ -234,7 +234,7 @@
"description": "zink: track the \"real\" buffer range from replacement buffers",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -5003,6 +5003,7 @@ zink_context_replace_buffer_storage(struct pipe_context *pctx, struct pipe_resou
/* don't be too creative */
zink_resource_object_reference(screen, &d->obj, s->obj);
d->valid_buffer_range = s->valid_buffer_range;
s->real_buffer_range = &d->valid_buffer_range;
zink_resource_copies_reset(d);
/* force counter buffer reset */
d->so_valid = false;

View file

@ -1315,6 +1315,7 @@ struct zink_resource {
union {
struct {
struct util_range valid_buffer_range;
struct util_range *real_buffer_range; //only set on tc replace_buffer src
uint32_t vbo_bind_mask : PIPE_MAX_ATTRIBS;
uint8_t ubo_bind_count[2];
uint8_t ssbo_bind_count[2];