panfrost/shared: avoid use gallium helper in pan_minmax_cache.*

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24439>
This commit is contained in:
Yonggang Luo 2023-06-05 04:22:34 +08:00 committed by Marge Bot
parent 20df1d2b1f
commit 13ce0358b0
4 changed files with 18 additions and 12 deletions

View file

@ -708,7 +708,7 @@ lima_transfer_map(struct pipe_context *pctx,
ptrans->layer_stride = res->levels[level].layer_stride;
if ((usage & PIPE_MAP_WRITE) && (usage & PIPE_MAP_DIRECTLY))
panfrost_minmax_cache_invalidate(res->index_cache, ptrans);
panfrost_minmax_cache_invalidate(res->index_cache, ptrans->box.x, ptrans->box.width);
return bo->map + res->levels[level].offset +
box->z * res->levels[level].layer_stride +
@ -816,7 +816,9 @@ lima_transfer_unmap(struct pipe_context *pctx,
lima_transfer_flush_region(pctx, ptrans, &box);
if (trans->staging)
free(trans->staging);
panfrost_minmax_cache_invalidate(res->index_cache, ptrans);
if (ptrans->usage & PIPE_MAP_WRITE) {
panfrost_minmax_cache_invalidate(res->index_cache, ptrans->box.x, ptrans->box.width);
}
pipe_resource_reference(&ptrans->resource, NULL);
slab_free(&ctx->transfer_pool, trans);

View file

@ -1308,7 +1308,8 @@ panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
if (usage & PIPE_MAP_WRITE) {
BITSET_SET(rsrc->valid.data, level);
panfrost_minmax_cache_invalidate(rsrc->index_cache, &transfer->base);
panfrost_minmax_cache_invalidate(
rsrc->index_cache, transfer->base.box.x, transfer->base.box.width);
}
return bo->ptr.cpu + rsrc->image.layout.slices[level].offset +
@ -1664,7 +1665,10 @@ panfrost_ptr_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer)
util_range_add(&prsrc->base, &prsrc->valid_buffer_range, transfer->box.x,
transfer->box.x + transfer->box.width);
panfrost_minmax_cache_invalidate(prsrc->index_cache, transfer);
if (transfer->usage & PIPE_MAP_WRITE) {
panfrost_minmax_cache_invalidate(prsrc->index_cache, transfer->box.x,
transfer->box.width);
}
/* Derefence the resource */
pipe_resource_reference(&transfer->resource, NULL);

View file

@ -39,6 +39,7 @@
*/
#include "pan_minmax_cache.h"
#include "util/macros.h"
bool
panfrost_minmax_cache_get(struct panfrost_minmax_cache *cache, unsigned start,
@ -94,15 +95,12 @@ panfrost_minmax_cache_add(struct panfrost_minmax_cache *cache, unsigned start,
void
panfrost_minmax_cache_invalidate(struct panfrost_minmax_cache *cache,
struct pipe_transfer *transfer)
size_t offset, size_t size)
{
/* Ensure there is a cache to invalidate and a write */
if (!cache)
return;
if (!(transfer->usage & PIPE_MAP_WRITE))
return;
unsigned valid_count = 0;
for (unsigned i = 0; i < cache->size; ++i) {
@ -112,8 +110,8 @@ panfrost_minmax_cache_invalidate(struct panfrost_minmax_cache *cache,
uint32_t count = key >> 32;
/* 1D range intersection */
bool invalid = MAX2(transfer->box.x, start) <
MIN2(transfer->box.x + transfer->box.width, start + count);
bool invalid = MAX2(offset, start) <
MIN2(offset + size, start + count);
if (!invalid) {
cache->keys[valid_count] = key;
cache->values[valid_count] = cache->values[i];

View file

@ -27,7 +27,9 @@
#ifndef H_PAN_MINMAX_CACHE
#define H_PAN_MINMAX_CACHE
#include "util/u_transfer.h"
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#define PANFROST_MINMAX_SIZE 64
@ -47,6 +49,6 @@ void panfrost_minmax_cache_add(struct panfrost_minmax_cache *cache,
unsigned min_index, unsigned max_index);
void panfrost_minmax_cache_invalidate(struct panfrost_minmax_cache *cache,
struct pipe_transfer *transfer);
size_t offset, size_t size);
#endif