mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 08:58:02 +02:00
freedreno/a6xx: Add a way to assert valid format
Layout transitions caused by access as a various format must happen at state bind time, before batch_draw_tracking(). Add a helper to assert this fact. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21408>
This commit is contained in:
parent
ea9d1cfb20
commit
b6778995d7
3 changed files with 42 additions and 26 deletions
|
|
@ -410,7 +410,8 @@ fd6_set_shader_images(struct pipe_context *pctx, enum pipe_shader_type shader,
|
|||
* due to the extra caching (CCU) involved:
|
||||
*/
|
||||
if (rsc->layout.ubwc) {
|
||||
bool linear = fd6_valid_tiling(rsc, buf->format);
|
||||
bool linear =
|
||||
fd6_check_valid_format(rsc, buf->format) == DEMOTE_TO_LINEAR;
|
||||
|
||||
perf_debug_ctx(ctx,
|
||||
"%" PRSC_FMT ": demoted to %suncompressed due to coherent/volatile use as %s",
|
||||
|
|
|
|||
|
|
@ -161,21 +161,28 @@ is_r8g8(enum pipe_format format)
|
|||
}
|
||||
|
||||
/**
|
||||
* Can a rsc be accessed tiled with the specified format, or does it need to
|
||||
* be linearized?
|
||||
* Can a rsc as it is currently laid out be accessed as the specified format.
|
||||
* Returns whether the access is ok or whether the rsc needs to be demoted
|
||||
* to uncompressed tiled or linear.
|
||||
*/
|
||||
bool
|
||||
fd6_valid_tiling(struct fd_resource *rsc, enum pipe_format format)
|
||||
enum fd6_format_status
|
||||
fd6_check_valid_format(struct fd_resource *rsc, enum pipe_format format)
|
||||
{
|
||||
enum pipe_format orig_format = rsc->b.b.format;
|
||||
|
||||
if (orig_format == format)
|
||||
return true;
|
||||
return FORMAT_OK;
|
||||
|
||||
if (rsc->layout.tile_mode && (is_r8g8(orig_format) != is_r8g8(format)))
|
||||
return false;
|
||||
return DEMOTE_TO_LINEAR;
|
||||
|
||||
return true;
|
||||
if (!rsc->layout.ubwc)
|
||||
return FORMAT_OK;
|
||||
|
||||
if (ok_ubwc_format(rsc->b.b.screen, format) && valid_format_cast(rsc, format))
|
||||
return FORMAT_OK;
|
||||
|
||||
return DEMOTE_TO_TILED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -187,33 +194,26 @@ void
|
|||
fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc,
|
||||
enum pipe_format format)
|
||||
{
|
||||
enum pipe_format orig_format = rsc->b.b.format;
|
||||
|
||||
tc_assert_driver_thread(ctx->tc);
|
||||
|
||||
if (orig_format == format)
|
||||
switch (fd6_check_valid_format(rsc, format)) {
|
||||
case FORMAT_OK:
|
||||
return;
|
||||
|
||||
if (!fd6_valid_tiling(rsc, format)) {
|
||||
case DEMOTE_TO_LINEAR:
|
||||
perf_debug_ctx(ctx,
|
||||
"%" PRSC_FMT ": demoted to linear+uncompressed due to use as %s",
|
||||
PRSC_ARGS(&rsc->b.b), util_format_short_name(format));
|
||||
|
||||
fd_resource_uncompress(ctx, rsc, true);
|
||||
return;
|
||||
case DEMOTE_TO_TILED:
|
||||
perf_debug_ctx(ctx,
|
||||
"%" PRSC_FMT ": demoted to uncompressed due to use as %s",
|
||||
PRSC_ARGS(&rsc->b.b), util_format_short_name(format));
|
||||
|
||||
fd_resource_uncompress(ctx, rsc, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rsc->layout.ubwc)
|
||||
return;
|
||||
|
||||
if (ok_ubwc_format(rsc->b.b.screen, format) && valid_format_cast(rsc, format))
|
||||
return;
|
||||
|
||||
perf_debug_ctx(ctx,
|
||||
"%" PRSC_FMT ": demoted to uncompressed due to use as %s",
|
||||
PRSC_ARGS(&rsc->b.b), util_format_short_name(format));
|
||||
|
||||
fd_resource_uncompress(ctx, rsc, false);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -30,9 +30,24 @@
|
|||
|
||||
#include "freedreno_resource.h"
|
||||
|
||||
bool fd6_valid_tiling(struct fd_resource *rsc, enum pipe_format format);
|
||||
|
||||
enum fd6_format_status {
|
||||
FORMAT_OK,
|
||||
DEMOTE_TO_LINEAR,
|
||||
DEMOTE_TO_TILED,
|
||||
};
|
||||
|
||||
enum fd6_format_status fd6_check_valid_format(struct fd_resource *rsc,
|
||||
enum pipe_format format);
|
||||
void fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc,
|
||||
enum pipe_format format) assert_dt;
|
||||
|
||||
static inline void
|
||||
fd6_assert_valid_format(struct fd_resource *rsc, enum pipe_format format)
|
||||
{
|
||||
assert(fd6_check_valid_format(rsc, format) == FORMAT_OK);
|
||||
}
|
||||
|
||||
void fd6_emit_flag_reference(struct fd_ringbuffer *ring,
|
||||
struct fd_resource *rsc, int level, int layer);
|
||||
void fd6_resource_screen_init(struct pipe_screen *pscreen);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue