radv: set ac_surf_info::num_channels correctly
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 25 Apr 2018 09:22:17 +0000 (11:22 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 26 Apr 2018 13:34:14 +0000 (15:34 +0200)
num_channels has been introduced since "ac/surface: don't set
the display flag for obviously unsupported cases".

Based on RadeonSI.

Fixes: e29facff315 ("ac/surface: don't set the display flag for obviously unsupported cases (v2)")
Cc: 18.1 <mesa-stable@lists.freedesktop.org>
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_image.c
src/amd/vulkan/vk_format.h

index 793f861f4f6c46e25501e8413d0e305d1e7de750..a6f3628c8f87d7d2f83877672202c5906fad67b5 100644 (file)
@@ -968,7 +968,7 @@ radv_image_create(VkDevice _device,
        image->info.samples = pCreateInfo->samples;
        image->info.array_size = pCreateInfo->arrayLayers;
        image->info.levels = pCreateInfo->mipLevels;
-       image->info.num_channels = 4; /* TODO: set this correctly */
+       image->info.num_channels = vk_format_get_nr_components(pCreateInfo->format);
 
        image->vk_format = pCreateInfo->format;
        image->tiling = pCreateInfo->tiling;
index 43265ed3d979aa9a85faabc5a1534753f5b09343..b8cb4f4ed37a79700be507f08688b6f82987440d 100644 (file)
@@ -488,4 +488,11 @@ vk_to_non_srgb_format(VkFormat format)
        }
 }
 
+static inline unsigned
+vk_format_get_nr_components(VkFormat format)
+{
+       const struct vk_format_description *desc = vk_format_description(format);
+       return desc->nr_channels;
+}
+
 #endif /* VK_FORMAT_H */