freedreno/a6xx: Support PIPE_FORMAT_R8_G8B8_420_UNORM for texturing

This makes freedreno advertise support for
PIPE_FORMAT_R8_G8B8_420_UNORM on a6xx, which enables lowering NV12 to
this format.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6693>
This commit is contained in:
Kristian H. Kristensen 2020-09-28 20:21:49 +00:00 committed by Marge Bot
parent 11563da8fa
commit 981464356c
3 changed files with 35 additions and 4 deletions

View File

@ -332,6 +332,8 @@ static struct fd6_format formats[PIPE_FORMAT_COUNT] = {
_T_(ASTC_10x10_SRGB, ASTC_10x10, WZYX),
_T_(ASTC_12x10_SRGB, ASTC_12x10, WZYX),
_T_(ASTC_12x12_SRGB, ASTC_12x12, WZYX),
_T_(R8_G8B8_420_UNORM, R8_G8B8_2PLANE_420_UNORM, WZYX),
};
/* convert pipe format to vertex buffer format: */

View File

@ -58,6 +58,9 @@ ok_ubwc_format(struct fd_resource *rsc, enum pipe_format pfmt)
pfmt == PIPE_FORMAT_Z24_UNORM_S8_UINT)
return false;
if (pfmt == PIPE_FORMAT_R8_G8B8_420_UNORM)
return true;
switch (fd6_pipe2color(pfmt)) {
case FMT6_10_10_10_2_UINT:
case FMT6_10_10_10_2_UNORM_DEST:

View File

@ -267,11 +267,37 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
so->texconst2 =
A6XX_TEX_CONST_2_PITCHALIGN(rsc->layout.pitchalign - 6) |
A6XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl));
so->offset1 = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer);
ubwc_enabled = fd_resource_ubwc_enabled(rsc, lvl);
if (ubwc_enabled) {
so->ptr2 = rsc;
so->offset2 = fd_resource_ubwc_offset(rsc, lvl, cso->u.tex.first_layer);
if (rsc->base.format == PIPE_FORMAT_R8_G8B8_420_UNORM) {
struct fd_resource *next = fd_resource(rsc->base.next);
/* In case of biplanar R8_G8B8, the UBWC metadata address in
* dwords 7 and 8, is instead the pointer to the second plane.
*/
so->ptr2 = next;
so->texconst6 =
A6XX_TEX_CONST_6_PLANE_PITCH(fd_resource_pitch(next, lvl));
if (ubwc_enabled) {
/* Further, if using UBWC with R8_G8B8, we only point to the
* UBWC header and the color data is expected to follow immediately.
*/
so->offset1 =
fd_resource_ubwc_offset(rsc, lvl, cso->u.tex.first_layer);
so->offset2 =
fd_resource_ubwc_offset(next, lvl, cso->u.tex.first_layer);
} else {
so->offset1 = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer);
so->offset2 = fd_resource_offset(next, lvl, cso->u.tex.first_layer);
}
} else {
so->offset1 = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer);
if (ubwc_enabled) {
so->ptr2 = rsc;
so->offset2 = fd_resource_ubwc_offset(rsc, lvl, cso->u.tex.first_layer);
}
}
}