mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 04:58:05 +02:00
freedreno: Pass layout type to backend
Pass the layout type to setup_slices, renamed to layout_resource, to move some of the partial layout initialization to the gen specific backend. Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36075>
This commit is contained in:
parent
34153d92b5
commit
4d4745764c
15 changed files with 55 additions and 41 deletions
|
|
@ -7,9 +7,10 @@
|
|||
*/
|
||||
|
||||
#include "fd2_resource.h"
|
||||
#include "freedreno_screen.h"
|
||||
|
||||
uint32_t
|
||||
fd2_setup_slices(struct fd_resource *rsc)
|
||||
fd2_layout_resource(struct fd_resource *rsc, enum fd_layout_type type)
|
||||
{
|
||||
struct pipe_resource *prsc = &rsc->b.b;
|
||||
enum pipe_format format = prsc->format;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "freedreno_resource.h"
|
||||
|
||||
uint32_t fd2_setup_slices(struct fd_resource *rsc);
|
||||
uint32_t fd2_layout_resource(struct fd_resource *rsc, enum fd_layout_type type);
|
||||
unsigned fd2_tile_mode(const struct pipe_resource *tmpl);
|
||||
|
||||
#endif /* FD2_RESOURCE_H_ */
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ fd2_screen_init(struct pipe_screen *pscreen)
|
|||
pscreen->context_create = fd2_context_create;
|
||||
pscreen->is_format_supported = fd2_screen_is_format_supported;
|
||||
|
||||
screen->setup_slices = fd2_setup_slices;
|
||||
screen->layout_resource = fd2_layout_resource;
|
||||
if (FD_DBG(TTILE))
|
||||
screen->tile_mode = fd2_tile_mode;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,10 +52,15 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment,
|
|||
}
|
||||
|
||||
uint32_t
|
||||
fd3_setup_slices(struct fd_resource *rsc)
|
||||
fd3_layout_resource(struct fd_resource *rsc, enum fd_layout_type type)
|
||||
{
|
||||
uint32_t alignment;
|
||||
|
||||
if (type >= FD_LAYOUT_TILED)
|
||||
rsc->layout.tile_mode = fd3_tile_mode(&rsc->b.b);
|
||||
if (type == FD_LAYOUT_UBWC)
|
||||
rsc->layout.ubwc = true;
|
||||
|
||||
switch (rsc->b.b.target) {
|
||||
case PIPE_TEXTURE_3D:
|
||||
case PIPE_TEXTURE_1D_ARRAY:
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "freedreno_resource.h"
|
||||
|
||||
uint32_t fd3_setup_slices(struct fd_resource *rsc);
|
||||
uint32_t fd3_layout_resource(struct fd_resource *rsc, enum fd_layout_type type);
|
||||
unsigned fd3_tile_mode(const struct pipe_resource *tmpl);
|
||||
|
||||
#endif /* FD3_RESOURCE_H_ */
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ fd3_screen_init(struct pipe_screen *pscreen)
|
|||
fd3_emit_init_screen(pscreen);
|
||||
ir3_screen_init(pscreen);
|
||||
|
||||
screen->setup_slices = fd3_setup_slices;
|
||||
screen->layout_resource = fd3_layout_resource;
|
||||
if (FD_DBG(TTILE))
|
||||
screen->tile_mode = fd3_tile_mode;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@
|
|||
*/
|
||||
|
||||
#include "fd4_resource.h"
|
||||
#include "freedreno_screen.h"
|
||||
|
||||
uint32_t
|
||||
fd4_setup_slices(struct fd_resource *rsc)
|
||||
fd4_layout_resource(struct fd_resource *rsc, enum fd_layout_type type)
|
||||
{
|
||||
struct pipe_resource *prsc = &rsc->b.b;
|
||||
enum pipe_format format = prsc->format;
|
||||
|
|
@ -23,6 +24,8 @@ fd4_setup_slices(struct fd_resource *rsc)
|
|||
*/
|
||||
uint32_t layers_in_level, alignment;
|
||||
|
||||
assert(type == FD_LAYOUT_LINEAR);
|
||||
|
||||
if (prsc->target == PIPE_TEXTURE_3D) {
|
||||
rsc->layout.layer_first = false;
|
||||
layers_in_level = prsc->array_size;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "freedreno_resource.h"
|
||||
|
||||
uint32_t fd4_setup_slices(struct fd_resource *rsc);
|
||||
unsigned fd4_tile_mode(const struct pipe_resource *tmpl);
|
||||
uint32_t fd4_layout_resource(struct fd_resource *rsc, enum fd_layout_type type);
|
||||
|
||||
#endif /* FD4_RESOURCE_H_ */
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ fd4_screen_init(struct pipe_screen *pscreen)
|
|||
{
|
||||
struct fd_screen *screen = fd_screen(pscreen);
|
||||
screen->max_rts = A4XX_MAX_RENDER_TARGETS;
|
||||
screen->setup_slices = fd4_setup_slices;
|
||||
screen->layout_resource = fd4_layout_resource;
|
||||
pscreen->context_create = fd4_context_create;
|
||||
pscreen->is_format_supported = fd4_screen_is_format_supported;
|
||||
fd4_emit_init_screen(pscreen);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
#include "fd5_resource.h"
|
||||
#include "fd5_blitter.h"
|
||||
|
||||
static void
|
||||
setup_lrz(struct fd_resource *rsc)
|
||||
|
|
@ -19,13 +20,18 @@ setup_lrz(struct fd_resource *rsc)
|
|||
}
|
||||
|
||||
uint32_t
|
||||
fd5_setup_slices(struct fd_resource *rsc)
|
||||
fd5_layout_resource(struct fd_resource *rsc, enum fd_layout_type type)
|
||||
{
|
||||
struct pipe_resource *prsc = &rsc->b.b;
|
||||
|
||||
if (FD_DBG(LRZ) && has_depth(prsc->format) && !is_z32(prsc->format))
|
||||
setup_lrz(rsc);
|
||||
|
||||
if (type >= FD_LAYOUT_TILED)
|
||||
rsc->layout.tile_mode = fd5_tile_mode(prsc);
|
||||
if (type == FD_LAYOUT_UBWC)
|
||||
rsc->layout.ubwc = true;
|
||||
|
||||
fdl5_layout(&rsc->layout, prsc->format, fd_resource_nr_samples(prsc),
|
||||
prsc->width0, prsc->height0, prsc->depth0, prsc->last_level + 1,
|
||||
prsc->array_size, prsc->target == PIPE_TEXTURE_3D);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
#include "freedreno_resource.h"
|
||||
|
||||
uint32_t fd5_setup_slices(struct fd_resource *rsc);
|
||||
uint32_t fd5_layout_resource(struct fd_resource *rsc, enum fd_layout_type type);
|
||||
|
||||
#endif /* FD5_RESOURCE_H_ */
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ fd5_screen_init(struct pipe_screen *pscreen)
|
|||
pscreen->context_create = fd5_context_create;
|
||||
pscreen->is_format_supported = fd5_screen_is_format_supported;
|
||||
|
||||
screen->setup_slices = fd5_setup_slices;
|
||||
screen->layout_resource = fd5_layout_resource;
|
||||
if (FD_DBG(TTILE))
|
||||
screen->tile_mode = fd5_tile_mode;
|
||||
|
||||
|
|
|
|||
|
|
@ -252,11 +252,16 @@ setup_lrz(struct fd_resource *rsc)
|
|||
|
||||
template <chip CHIP>
|
||||
static uint32_t
|
||||
fd6_setup_slices(struct fd_resource *rsc)
|
||||
fd6_layout_resource(struct fd_resource *rsc, enum fd_layout_type type)
|
||||
{
|
||||
struct pipe_resource *prsc = &rsc->b.b;
|
||||
struct fd_screen *screen = fd_screen(prsc->screen);
|
||||
|
||||
if (type >= FD_LAYOUT_TILED)
|
||||
rsc->layout.tile_mode = fd6_tile_mode(prsc);
|
||||
if (type == FD_LAYOUT_UBWC)
|
||||
rsc->layout.ubwc = true;
|
||||
|
||||
if (rsc->layout.ubwc && !ok_ubwc_format(prsc->screen, prsc->format, prsc->nr_samples))
|
||||
rsc->layout.ubwc = false;
|
||||
|
||||
|
|
@ -354,7 +359,7 @@ fd6_resource_screen_init(struct pipe_screen *pscreen)
|
|||
{
|
||||
struct fd_screen *screen = fd_screen(pscreen);
|
||||
|
||||
screen->setup_slices = fd6_setup_slices<CHIP>;
|
||||
screen->layout_resource = fd6_layout_resource<CHIP>;
|
||||
screen->layout_resource_for_modifier = fd6_layout_resource_for_modifier;
|
||||
screen->is_format_supported = fd6_is_format_supported;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1235,13 +1235,6 @@ alloc_resource_struct(struct pipe_screen *pscreen,
|
|||
return rsc;
|
||||
}
|
||||
|
||||
enum fd_layout_type {
|
||||
ERROR,
|
||||
LINEAR,
|
||||
TILED,
|
||||
UBWC,
|
||||
};
|
||||
|
||||
static bool
|
||||
has_implicit_modifier(const uint64_t *modifiers, int count)
|
||||
{
|
||||
|
|
@ -1269,34 +1262,34 @@ get_best_layout(struct fd_screen *screen,
|
|||
|
||||
/* First, find all the conditions which would force us to linear */
|
||||
if (!screen->tile_mode)
|
||||
return LINEAR;
|
||||
return FD_LAYOUT_LINEAR;
|
||||
|
||||
if (!screen->tile_mode(tmpl))
|
||||
return LINEAR;
|
||||
return FD_LAYOUT_LINEAR;
|
||||
|
||||
if (tmpl->target == PIPE_BUFFER)
|
||||
return LINEAR;
|
||||
return FD_LAYOUT_LINEAR;
|
||||
|
||||
if ((tmpl->usage == PIPE_USAGE_STAGING) &&
|
||||
!util_format_is_depth_or_stencil(tmpl->format))
|
||||
return LINEAR;
|
||||
return FD_LAYOUT_LINEAR;
|
||||
|
||||
if (tmpl->bind & PIPE_BIND_LINEAR) {
|
||||
if (tmpl->usage != PIPE_USAGE_STAGING)
|
||||
perf_debug("%" PRSC_FMT ": forcing linear: bind flags",
|
||||
PRSC_ARGS(tmpl));
|
||||
return LINEAR;
|
||||
return FD_LAYOUT_LINEAR;
|
||||
}
|
||||
|
||||
if (FD_DBG(NOTILE))
|
||||
return LINEAR;
|
||||
return FD_LAYOUT_LINEAR;
|
||||
|
||||
/* Shared resources without explicit modifiers must always be linear */
|
||||
if (!can_explicit && (tmpl->bind & PIPE_BIND_SHARED)) {
|
||||
perf_debug("%" PRSC_FMT
|
||||
": forcing linear: shared resource + implicit modifiers",
|
||||
PRSC_ARGS(tmpl));
|
||||
return LINEAR;
|
||||
return FD_LAYOUT_LINEAR;
|
||||
}
|
||||
|
||||
bool ubwc_ok = is_a6xx(screen) && !screen->info->a6xx.is_a702;
|
||||
|
|
@ -1324,21 +1317,21 @@ get_best_layout(struct fd_screen *screen,
|
|||
}
|
||||
|
||||
if (ubwc_ok)
|
||||
return UBWC;
|
||||
return FD_LAYOUT_UBWC;
|
||||
|
||||
if (can_implicit ||
|
||||
drm_find_modifier(DRM_FORMAT_MOD_QCOM_TILED3, modifiers, count))
|
||||
return TILED;
|
||||
return FD_LAYOUT_TILED;
|
||||
|
||||
if (!drm_find_modifier(DRM_FORMAT_MOD_LINEAR, modifiers, count)) {
|
||||
perf_debug("%" PRSC_FMT ": need linear but not in modifier set",
|
||||
PRSC_ARGS(tmpl));
|
||||
return ERROR;
|
||||
return FD_LAYOUT_ERROR;
|
||||
}
|
||||
|
||||
perf_debug("%" PRSC_FMT ": not using tiling: explicit modifiers and no UBWC",
|
||||
PRSC_ARGS(tmpl));
|
||||
return LINEAR;
|
||||
return FD_LAYOUT_LINEAR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1379,16 +1372,11 @@ fd_resource_allocate_and_resolve(struct pipe_screen *pscreen,
|
|||
|
||||
enum fd_layout_type layout =
|
||||
get_best_layout(screen, tmpl, modifiers, count);
|
||||
if (layout == ERROR) {
|
||||
if (layout == FD_LAYOUT_ERROR) {
|
||||
free(prsc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (layout >= TILED)
|
||||
rsc->layout.tile_mode = screen->tile_mode(prsc);
|
||||
if (layout == UBWC)
|
||||
rsc->layout.ubwc = true;
|
||||
|
||||
rsc->internal_format = format;
|
||||
|
||||
if (prsc->target == PIPE_BUFFER) {
|
||||
|
|
@ -1396,7 +1384,7 @@ fd_resource_allocate_and_resolve(struct pipe_screen *pscreen,
|
|||
size = prsc->width0;
|
||||
fdl_layout_buffer(&rsc->layout, size);
|
||||
} else {
|
||||
size = screen->setup_slices(rsc);
|
||||
size = screen->layout_resource(rsc, layout);
|
||||
}
|
||||
|
||||
/* special case for hw-query buffer, which we need to allocate before we
|
||||
|
|
|
|||
|
|
@ -29,6 +29,13 @@
|
|||
|
||||
struct fd_bo;
|
||||
|
||||
enum fd_layout_type {
|
||||
FD_LAYOUT_ERROR,
|
||||
FD_LAYOUT_LINEAR,
|
||||
FD_LAYOUT_TILED,
|
||||
FD_LAYOUT_UBWC,
|
||||
};
|
||||
|
||||
/* Potential reasons for needing to skip bypass path and use GMEM, the
|
||||
* generation backend can override this with screen->gmem_reason_mask
|
||||
*/
|
||||
|
|
@ -127,7 +134,7 @@ struct fd_screen {
|
|||
*/
|
||||
struct fd_pipe *pipe;
|
||||
|
||||
uint32_t (*setup_slices)(struct fd_resource *rsc);
|
||||
uint32_t (*layout_resource)(struct fd_resource *rsc, enum fd_layout_type type);
|
||||
unsigned (*tile_mode)(const struct pipe_resource *prsc);
|
||||
int (*layout_resource_for_modifier)(struct fd_resource *rsc,
|
||||
uint64_t modifier);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue