There were a couple paths where we weren't getting valid seqno's, which
are supposed to be updated whenever the backing bo is set/changed. So
wrap that up in a helper to make it harder to mess up.
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6575>
fd_screen_unlock(screen);
}
fd_screen_unlock(screen);
}
+static inline void
+fd_resource_set_bo(struct fd_resource *rsc, struct fd_bo *bo)
+{
+ struct fd_screen *screen = fd_screen(rsc->base.screen);
+
+ rsc->bo = bo;
+ rsc->seqno = p_atomic_inc_return(&screen->rsc_seqno);
+}
+
static void
realloc_bo(struct fd_resource *rsc, uint32_t size)
{
static void
realloc_bo(struct fd_resource *rsc, uint32_t size)
{
if (rsc->bo)
fd_bo_del(rsc->bo);
if (rsc->bo)
fd_bo_del(rsc->bo);
- rsc->bo = fd_bo_new(screen->dev, size, flags, "%ux%ux%u@%u:%x",
+ struct fd_bo *bo = fd_bo_new(screen->dev, size, flags, "%ux%ux%u@%u:%x",
prsc->width0, prsc->height0, prsc->depth0, rsc->layout.cpp, prsc->bind);
prsc->width0, prsc->height0, prsc->depth0, rsc->layout.cpp, prsc->bind);
+ fd_resource_set_bo(rsc, bo);
/* Zero out the UBWC area on allocation. This fixes intermittent failures
* with UBWC, which I suspect are due to the HW having a hard time
/* Zero out the UBWC area on allocation. This fixes intermittent failures
* with UBWC, which I suspect are due to the HW having a hard time
rsc->needs_ubwc_clear = true;
}
rsc->needs_ubwc_clear = true;
}
- rsc->seqno = p_atomic_inc_return(&screen->rsc_seqno);
util_range_set_empty(&rsc->valid_buffer_range);
fd_bc_invalidate_resource(rsc, true);
}
util_range_set_empty(&rsc->valid_buffer_range);
fd_bc_invalidate_resource(rsc, true);
}
simple_mtx_init(&rsc->lock, mtx_plain);
simple_mtx_init(&rsc->lock, mtx_plain);
- rsc->bo = fd_screen_bo_from_handle(pscreen, handle);
- if (!rsc->bo)
+ struct fd_bo *bo = fd_screen_bo_from_handle(pscreen, handle);
+ if (!bo)
+ fd_resource_set_bo(rsc, bo);
+
rsc->internal_format = tmpl->format;
rsc->layout.pitch0 = handle->stride;
slice->offset = handle->offset;
rsc->internal_format = tmpl->format;
rsc->layout.pitch0 = handle->stride;
slice->offset = handle->offset;
}
/* Share the bo with the memory object. */
}
/* Share the bo with the memory object. */
- rsc->bo = fd_bo_ref(memobj->bo);
+ fd_resource_set_bo(rsc, fd_bo_ref(memobj->bo));
struct fd_resource {
struct pipe_resource base;
struct fd_resource {
struct pipe_resource base;
+ struct fd_bo *bo; /* use fd_resource_set_bo() to write */
enum pipe_format internal_format;
struct fdl_layout layout;
enum pipe_format internal_format;
struct fdl_layout layout;