From d2e6c4d255b66eb26833f3ccbbbaca146c0564da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 12 May 2023 21:41:07 -0400 Subject: [PATCH] radeonsi: unduplicate si_translate_format_to_hw Reviewed-by: Qiang Yu Part-of: --- .../drivers/radeonsi/si_sdma_copy_image.c | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_sdma_copy_image.c b/src/gallium/drivers/radeonsi/si_sdma_copy_image.c index 9cda3370f17..ec020ceef9d 100644 --- a/src/gallium/drivers/radeonsi/si_sdma_copy_image.c +++ b/src/gallium/drivers/radeonsi/si_sdma_copy_image.c @@ -52,40 +52,6 @@ static unsigned encode_legacy_tile_info(struct si_context *sctx, struct si_textu (G_009910_PIPE_CONFIG(tile_mode) << 26); } -static -bool si_translate_format_to_hw(struct si_context *sctx, enum pipe_format format, unsigned *hw_fmt, unsigned *hw_type) -{ - const struct util_format_description *desc = util_format_description(format); - *hw_fmt = ac_get_cb_format(sctx->gfx_level, format); - - int firstchan = util_format_get_first_non_void_channel(format); - if (firstchan == -1 || desc->channel[firstchan].type == UTIL_FORMAT_TYPE_FLOAT) { - *hw_type = V_028C70_NUMBER_FLOAT; - } else { - *hw_type = V_028C70_NUMBER_UNORM; - if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) - *hw_type = V_028C70_NUMBER_SRGB; - else if (desc->channel[firstchan].type == UTIL_FORMAT_TYPE_SIGNED) { - if (desc->channel[firstchan].pure_integer) { - *hw_type = V_028C70_NUMBER_SINT; - } else { - assert(desc->channel[firstchan].normalized); - *hw_type = V_028C70_NUMBER_SNORM; - } - } else if (desc->channel[firstchan].type == UTIL_FORMAT_TYPE_UNSIGNED) { - if (desc->channel[firstchan].pure_integer) { - *hw_type = V_028C70_NUMBER_UINT; - } else { - assert(desc->channel[firstchan].normalized); - *hw_type = V_028C70_NUMBER_UNORM; - } - } else { - return false; - } - } - return true; -} - static bool si_sdma_v4_v5_copy_texture(struct si_context *sctx, struct si_texture *sdst, struct si_texture *ssrc, bool is_v5) { @@ -175,11 +141,10 @@ bool si_sdma_v4_v5_copy_texture(struct si_context *sctx, struct si_texture *sdst radeon_emit(0); if (dcc) { - unsigned hw_fmt, hw_type; + unsigned hw_fmt = ac_get_cb_format(sctx->gfx_level, tiled->buffer.b.b.format); + unsigned hw_type = ac_get_cb_number_type(tiled->buffer.b.b.format); uint64_t md_address = tiled_address + tiled->surface.meta_offset; - si_translate_format_to_hw(sctx, tiled->buffer.b.b.format, &hw_fmt, &hw_type); - /* Add metadata */ radeon_emit((uint32_t)md_address); radeon_emit((uint32_t)(md_address >> 32));