panfrost: Make panfrost_format_to_bifrost_blend() a per-gen helper

Make panfrost_format_to_bifrost_blend() a per-gen helper so we don't
have to pass a panfrost_device object around.

While at it, pick a better name for this helper and move it to
pan_format.h.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Constantine Shablya <constantine.shablya@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26698>
This commit is contained in:
Boris Brezillon
2023-12-05 15:08:29 +01:00
committed by Marge Bot
parent b87de3a2e0
commit e0fe9c369a
9 changed files with 22 additions and 28 deletions

View File

@@ -339,7 +339,6 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
}
#if PAN_ARCH >= 6
const struct panfrost_device *dev = pan_device(ctx->base.screen);
struct panfrost_compiled_shader *fs = ctx->prog[PIPE_SHADER_FRAGMENT];
/* Words 2 and 3: Internal blend */
@@ -371,8 +370,8 @@ panfrost_emit_blend(struct panfrost_batch *batch, void *rts,
* num_comps must be set to 4
*/
cfg.fixed_function.num_comps = 4;
cfg.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(dev, format, dithered);
cfg.fixed_function.conversion.memory_format = GENX(
panfrost_dithered_format_from_pipe_format)(format, dithered);
cfg.fixed_function.rt = i;
#if PAN_ARCH <= 7

View File

@@ -775,7 +775,7 @@ GENX(pan_blend_get_internal_desc)(const struct panfrost_device *dev,
}
cfg.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(dev, fmt, dithered);
GENX(panfrost_dithered_format_from_pipe_format)(fmt, dithered);
}
return res;

View File

@@ -151,8 +151,8 @@ pan_blitter_emit_blend(const struct panfrost_device *dev, unsigned rt,
nir_alu_type type = blit_shader->key.surfaces[rt].type;
cfg.internal.fixed_function.num_comps = 4;
cfg.internal.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(dev, iview->format, false);
cfg.internal.fixed_function.conversion.memory_format = GENX(
panfrost_dithered_format_from_pipe_format)(iview->format, false);
cfg.internal.fixed_function.conversion.register_format =
blit_type_to_reg_fmt(type);

View File

@@ -165,6 +165,20 @@ GENX(panfrost_blendable_format_from_pipe_format)(enum pipe_format f)
{
return &GENX(panfrost_blendable_formats)[f];
}
#if PAN_ARCH >= 6
static inline unsigned
GENX(panfrost_dithered_format_from_pipe_format)(enum pipe_format f, bool dithered)
{
mali_pixel_format pixfmt =
GENX(panfrost_blendable_formats)[f].bifrost[dithered];
/* Formats requiring blend shaders are stored raw in the tilebuffer and will
* have 0 as their pixel format. Assumes dithering is set, I don't know of a
* case when it makes sense to turn off dithering. */
return pixfmt ?: GENX(panfrost_format_from_pipe_format)(f)->hw;
}
#endif
#endif
#endif

View File

@@ -65,16 +65,3 @@ panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
out[idx] = PIPE_SWIZZLE_X + c;
}
}
/* Formats requiring blend shaders are stored raw in the tilebuffer and will
* have 0 as their pixel format. Assumes dithering is set, I don't know of a
* case when it makes sense to turn off dithering. */
unsigned
panfrost_format_to_bifrost_blend(const struct panfrost_device *dev,
enum pipe_format format, bool dithered)
{
mali_pixel_format pixfmt = dev->blendable_formats[format].bifrost[dithered];
return pixfmt ?: dev->formats[format].hw;
}

View File

@@ -55,17 +55,12 @@
#define PAN_DBG_YUV 0x20000
#define PAN_DBG_FORCE_PACK 0x40000
struct panfrost_device;
struct pan_blendable_format;
unsigned panfrost_translate_swizzle_4(const unsigned char swizzle[4]);
void panfrost_invert_swizzle(const unsigned char *in, unsigned char *out);
unsigned panfrost_format_to_bifrost_blend(const struct panfrost_device *dev,
enum pipe_format format,
bool dithered);
void pan_pack_color(const struct pan_blendable_format *blendable_formats,
uint32_t *packed, const union pipe_color_union *color,
enum pipe_format format, bool dithered);

View File

@@ -627,7 +627,6 @@ panvk_per_arch(emit_blend)(const struct panvk_device *dev,
cfg.load_destination = pan_blend_reads_dest(blend->rts[rt].equation);
cfg.round_to_fb_precision = !dithered;
const struct panfrost_device *pdev = &dev->physical_device->pdev;
const struct util_format_description *format_desc =
util_format_description(rts->format);
unsigned chan_size = 0;
@@ -660,7 +659,7 @@ panvk_per_arch(emit_blend)(const struct panvk_device *dev,
*/
cfg.internal.fixed_function.num_comps = 4;
cfg.internal.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(pdev, rts->format, dithered);
GENX(panfrost_dithered_format_from_pipe_format)(rts->format, dithered);
cfg.internal.fixed_function.conversion.register_format =
bifrost_blend_type_from_nir(pipeline->fs.info.bifrost.blend[rt].type);
cfg.internal.fixed_function.rt = rt;

View File

@@ -111,7 +111,7 @@ panvk_meta_clear_color_attachment_emit_rsd(struct panfrost_device *pdev,
cfg.internal.fixed_function.num_comps = 4;
cfg.internal.fixed_function.rt = rt;
cfg.internal.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(pdev, format, false);
GENX(panfrost_dithered_format_from_pipe_format)(format, false);
cfg.internal.fixed_function.conversion.register_format =
shader_info->bifrost.blend[0].format;
}

View File

@@ -248,7 +248,7 @@ panvk_meta_copy_to_img_emit_rsd(struct panfrost_device *pdev,
cfg.internal.fixed_function.num_comps = 4;
if (!raw) {
cfg.internal.fixed_function.conversion.memory_format =
panfrost_format_to_bifrost_blend(pdev, fmt, false);
GENX(panfrost_dithered_format_from_pipe_format)(fmt, false);
cfg.internal.fixed_function.conversion.register_format =
MALI_REGISTER_FILE_FORMAT_F32;
} else {