lima: move reload flags from surface to resource

This is in preparation to remove lima_surface.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35749>
This commit is contained in:
Erico Nunes
2025-06-18 15:10:22 +02:00
committed by Marge Bot
parent 87e990ec56
commit 972da604dc
5 changed files with 33 additions and 26 deletions
+7 -8
View File
@@ -44,10 +44,10 @@ lima_pack_blit_cmd(struct lima_job *job,
#define lima_blit_buffer_size 0x0140
struct lima_context *ctx = job->ctx;
struct lima_surface *surf = lima_surface(psurf);
int level = psurf->level;
unsigned first_layer = psurf->first_layer;
float fb_width = dst->width, fb_height = dst->height;
struct lima_resource *res = lima_resource(psurf->texture);
uint32_t va;
void *cpu = lima_job_create_stream_bo(
@@ -88,9 +88,9 @@ lima_pack_blit_cmd(struct lima_job *job,
reload_render_state.alpha_blend &= 0x0fffffff;
if (psurf->format != PIPE_FORMAT_Z16_UNORM)
reload_render_state.depth_test |= 0x400;
if (surf->reload & PIPE_CLEAR_DEPTH)
if (res->reload & PIPE_CLEAR_DEPTH)
reload_render_state.depth_test |= 0x801;
if (surf->reload & PIPE_CLEAR_STENCIL) {
if (res->reload & PIPE_CLEAR_STENCIL) {
reload_render_state.depth_test |= 0x1000;
reload_render_state.stencil_front = 0x0000024f;
reload_render_state.stencil_back = 0x0000024f;
@@ -259,7 +259,6 @@ lima_do_blit(struct pipe_context *pctx,
struct pipe_surface *dst_surf =
lima_get_blit_surface(pctx, info->dst.resource, info->dst.level);
struct lima_surface *lima_dst_surf = lima_surface(dst_surf);
struct pipe_surface *src_surf =
lima_get_blit_surface(pctx, info->src.resource, info->src.level);
@@ -297,8 +296,8 @@ lima_do_blit(struct pipe_context *pctx,
bool tile_aligned = false;
if (info->dst.box.x == 0 && info->dst.box.y == 0 &&
info->dst.box.width == pipe_surface_width(&lima_dst_surf->base) &&
info->dst.box.height == pipe_surface_height(&lima_dst_surf->base))
info->dst.box.width == pipe_surface_width(dst_surf) &&
info->dst.box.height == pipe_surface_height(dst_surf))
tile_aligned = true;
if (info->dst.box.x % 16 == 0 && info->dst.box.y % 16 == 0 &&
@@ -307,9 +306,9 @@ lima_do_blit(struct pipe_context *pctx,
/* Reload if dest is not aligned to tile boundaries */
if (!tile_aligned)
lima_dst_surf->reload = reload_flags;
dst_res->reload = reload_flags;
else
lima_dst_surf->reload = 0;
dst_res->reload = 0;
job->resolve = reload_flags;
+10 -5
View File
@@ -165,7 +165,8 @@ lima_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scisso
/* no need to reload if cleared */
if (ctx->framebuffer.base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0)) {
struct lima_surface *surf = lima_surface(ctx->framebuffer.fb_cbufs[0]);
surf->reload &= ~PIPE_CLEAR_COLOR0;
struct lima_resource *res = lima_resource(surf->base.texture);
res->reload &= ~PIPE_CLEAR_COLOR0;
}
struct lima_job_clear *clear = &job->clear;
@@ -182,15 +183,19 @@ lima_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scisso
if (buffers & PIPE_CLEAR_DEPTH) {
clear->depth = util_pack_z(PIPE_FORMAT_Z24X8_UNORM, depth);
if (zsbuf)
zsbuf->reload &= ~PIPE_CLEAR_DEPTH;
if (zsbuf) {
struct lima_resource *res = lima_resource(zsbuf->base.texture);
res->reload &= ~PIPE_CLEAR_DEPTH;
}
}
if (buffers & PIPE_CLEAR_STENCIL) {
// the provided stencil value seems to be 16 bit, truncate
clear->stencil = stencil & 0xFF;
if (zsbuf)
zsbuf->reload &= ~PIPE_CLEAR_STENCIL;
if (zsbuf) {
struct lima_resource *res = lima_resource(zsbuf->base.texture);
res->reload &= ~PIPE_CLEAR_STENCIL;
}
}
ctx->dirty |= LIMA_CONTEXT_DIRTY_CLEAR;
+7 -4
View File
@@ -341,7 +341,7 @@ lima_fb_cbuf_needs_reload(struct lima_job *job)
// return true;
return true;
}
else if (surf->reload & PIPE_CLEAR_COLOR0)
else if (res->reload & PIPE_CLEAR_COLOR0)
return true;
return false;
@@ -354,7 +354,8 @@ lima_fb_zsbuf_needs_reload(struct lima_job *job)
return false;
struct lima_surface *surf = lima_surface(job->key.zsbuf);
if (surf->reload & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))
struct lima_resource *res = lima_resource(surf->base.texture);
if (res->reload & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))
return true;
return false;
@@ -1011,12 +1012,14 @@ lima_do_job(struct lima_job *job)
/* Set reload flags for next draw. It'll be unset if buffer is cleared */
if (job->key.cbuf && (job->resolve & PIPE_CLEAR_COLOR0)) {
struct lima_surface *surf = lima_surface(job->key.cbuf);
surf->reload |= PIPE_CLEAR_COLOR0;
struct lima_resource *res = lima_resource(surf->base.texture);
res->reload |= PIPE_CLEAR_COLOR0;
}
if (job->key.zsbuf && (job->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
struct lima_surface *surf = lima_surface(job->key.zsbuf);
surf->reload |= (job->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL));
struct lima_resource *res = lima_resource(surf->base.texture);
res->reload |= (job->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL));
}
if (ctx->job == job)
+8 -8
View File
@@ -245,6 +245,14 @@ _lima_resource_create_with_modifiers(struct pipe_screen *pscreen,
struct lima_resource *res = lima_resource(pres);
res->tiled = should_tile;
res->reload = 0;
if (util_format_has_stencil(util_format_description(pres->format)))
res->reload |= PIPE_CLEAR_STENCIL;
if (util_format_has_depth(util_format_description(pres->format)))
res->reload |= PIPE_CLEAR_DEPTH;
if (!util_format_is_depth_or_stencil(pres->format))
res->reload |= PIPE_CLEAR_COLOR0;
if (templat->bind & PIPE_BIND_INDEX_BUFFER)
res->index_cache = CALLOC_STRUCT(pan_minmax_cache);
@@ -585,14 +593,6 @@ lima_surface_create(struct pipe_context *pctx,
psurf->first_layer = surf_tmpl->first_layer;
psurf->last_layer = surf_tmpl->last_layer;
surf->reload = 0;
if (util_format_has_stencil(util_format_description(psurf->format)))
surf->reload |= PIPE_CLEAR_STENCIL;
if (util_format_has_depth(util_format_description(psurf->format)))
surf->reload |= PIPE_CLEAR_DEPTH;
if (!util_format_is_depth_or_stencil(psurf->format))
surf->reload |= PIPE_CLEAR_COLOR0;
return &surf->base;
}
+1 -1
View File
@@ -58,13 +58,13 @@ struct lima_resource {
bool tiled;
bool modifier_constant;
unsigned full_updates;
unsigned reload;
struct lima_resource_level levels[LIMA_MAX_MIP_LEVELS];
};
struct lima_surface {
struct pipe_surface base;
unsigned reload;
};
struct lima_transfer {