radv: Use get_first_non_void_channel more often
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Fri, 16 Sep 2022 13:41:26 +0000 (15:41 +0200)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Dec 2022 22:06:11 +0000 (22:06 +0000)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18634>

src/amd/vulkan/radv_formats.c
src/amd/vulkan/radv_sdma_copy_image.c

index 5251916a488e389b941ab4b81613d96b1af09343..ab3413fd35ddb5811be3289be06c3aeb034f5089 100644 (file)
@@ -2056,13 +2056,8 @@ static void
 radv_get_dcc_channel_type(const struct util_format_description *desc, enum dcc_channel_type *type,
                           unsigned *size)
 {
-   int i;
-
-   /* Find the first non-void channel. */
-   for (i = 0; i < desc->nr_channels; i++)
-      if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
-         break;
-   if (i == desc->nr_channels) {
+   int i = util_format_get_first_non_void_channel(desc->format);
+   if (i == -1) {
       *type = dcc_channel_incompatible;
       return;
    }
index 93044c6e6754e92579c9136f57da1eeb430f411c..5a7b1713ddf6fbc98f7b2fc1af6a196b8180fd24 100644 (file)
@@ -34,13 +34,8 @@ radv_translate_format_to_hw(struct radeon_info *info, VkFormat format, unsigned
    const struct util_format_description *desc = vk_format_description(format);
    *hw_fmt = radv_translate_colorformat(format);
 
-   int firstchan;
-   for (firstchan = 0; firstchan < 4; firstchan++) {
-      if (desc->channel[firstchan].type != UTIL_FORMAT_TYPE_VOID) {
-         break;
-      }
-   }
-   if (firstchan == 4 || desc->channel[firstchan].type == UTIL_FORMAT_TYPE_FLOAT) {
+   int firstchan = vk_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;