pco: add support for sscaled8* formats

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36412>
This commit is contained in:
Simon Perretta 2025-03-20 12:16:21 +00:00 committed by Marge Bot
parent c3987eb5fc
commit b50f0b47d2
5 changed files with 69 additions and 0 deletions

View file

@ -284,6 +284,15 @@ unpack_unorm_1x16(uint16_t u)
return (float) u / 65535.0f;
}
/**
* Evaluate one component of unpackSscaled4x8.
*/
static float
unpack_sscaled_1x8(uint8_t u)
{
return CLAMP((int8_t) u, -128.0f, +127.0f);
}
/**
* Evaluate one component of packHalf2x16.
*/

View file

@ -279,9 +279,12 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data)
return NULL;
case nir_op_unpack_snorm_8_8:
case nir_op_unpack_sscaled_8_8:
case nir_op_unpack_unorm_8_8:
case nir_op_unpack_snorm_8_8_8:
case nir_op_unpack_sscaled_8_8_8:
case nir_op_unpack_unorm_8_8_8:
case nir_op_unpack_sscaled_8_8_8_8:
case nir_op_unpack_unorm_10_10_10_2:
case nir_op_unpack_float_11_11_10:
return NULL;

View file

@ -1883,14 +1883,19 @@ dst.w = unpack_{fmt}_1x{a}((src0.x >> {r + g + b}) & ((1u << {a}) - 1));
""")
unpack_r("snorm", 8)
unpack_r("sscaled", 8)
unpack_r("unorm", 8)
unpack_rg("snorm", 8, 8)
unpack_rg("sscaled", 8, 8)
unpack_rg("unorm", 8, 8)
unpack_rgb("snorm", 8, 8, 8)
unpack_rgb("sscaled", 8, 8, 8)
unpack_rgb("unorm", 8, 8, 8)
unpack_rgba("sscaled", 8, 8, 8, 8)
unpack_r("snorm", 16)
unpack_r("unorm", 16)

View file

@ -401,6 +401,26 @@ static nir_def *unpack_from_format(nir_builder *b,
unpacked = nir_unpack_snorm_4x8(b, input);
break;
case PIPE_FORMAT_R8_SSCALED:
assert(dest_type == nir_type_float);
unpacked = nir_unpack_sscaled_8(b, input);
break;
case PIPE_FORMAT_R8G8_SSCALED:
assert(dest_type == nir_type_float);
unpacked = nir_unpack_sscaled_8_8(b, input);
break;
case PIPE_FORMAT_R8G8B8_SSCALED:
assert(dest_type == nir_type_float);
unpacked = nir_unpack_sscaled_8_8_8(b, input);
break;
case PIPE_FORMAT_R8G8B8A8_SSCALED:
assert(dest_type == nir_type_float);
unpacked = nir_unpack_sscaled_8_8_8_8(b, input);
break;
case PIPE_FORMAT_R8G8B8A8_UINT:
unpacked = nir_vector_insert_imm(
b,

View file

@ -2249,6 +2249,38 @@ static pco_instr *trans_alu(trans_ctx *tctx, nir_alu_instr *alu)
.scale = true);
break;
case nir_op_unpack_sscaled_8:
instr = pco_unpck(&tctx->b,
dest,
pco_ref_elem(src[0], 0),
.rpt = 1,
.pck_fmt = PCO_PCK_FMT_S8888);
break;
case nir_op_unpack_sscaled_8_8:
instr = pco_unpck(&tctx->b,
dest,
pco_ref_elem(src[0], 0),
.rpt = 2,
.pck_fmt = PCO_PCK_FMT_S8888);
break;
case nir_op_unpack_sscaled_8_8_8:
instr = pco_unpck(&tctx->b,
dest,
pco_ref_elem(src[0], 0),
.rpt = 3,
.pck_fmt = PCO_PCK_FMT_S8888);
break;
case nir_op_unpack_sscaled_8_8_8_8:
instr = pco_unpck(&tctx->b,
dest,
pco_ref_elem(src[0], 0),
.rpt = 4,
.pck_fmt = PCO_PCK_FMT_S8888);
break;
case nir_op_pack_unorm_8:
instr = pco_pck(&tctx->b,
dest,