From 597f13b24421f4308ac9d513d9774f2b8673c120 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sat, 29 Mar 2025 14:36:09 +0100 Subject: [PATCH] radv: Add radv_format_description to remap 10/12bit formats to 16bit Remapping was missing for format description which made these formats effectively unsupported as zero format features were reported. Fixes: 0098f8ef35a ("radv: Remap 10 and 12 bit formats to 16 bit formats") Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/meta/radv_meta_clear.c | 4 ++-- src/amd/vulkan/meta/radv_meta_copy.c | 4 ++-- src/amd/vulkan/radv_buffer_view.c | 2 +- src/amd/vulkan/radv_formats.c | 25 +++++++++++++------------ src/amd/vulkan/radv_formats.h | 6 ++++++ src/amd/vulkan/radv_image.c | 6 +++--- src/amd/vulkan/radv_pipeline_graphics.c | 8 ++++---- src/amd/vulkan/radv_sdma.c | 2 +- 8 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/amd/vulkan/meta/radv_meta_clear.c b/src/amd/vulkan/meta/radv_meta_clear.c index 50bfa2210b7..58406633273 100644 --- a/src/amd/vulkan/meta/radv_meta_clear.c +++ b/src/amd/vulkan/meta/radv_meta_clear.c @@ -1169,7 +1169,7 @@ gfx8_get_fast_clear_parameters(struct radv_device *device, const struct radv_ima *can_avoid_fast_clear_elim = false; } - const struct util_format_description *desc = vk_format_description(iview->vk.format); + const struct util_format_description *desc = radv_format_description(iview->vk.format); if (iview->vk.format == VK_FORMAT_B10G11R11_UFLOAT_PACK32 || iview->vk.format == VK_FORMAT_R5G6B5_UNORM_PACK16 || iview->vk.format == VK_FORMAT_B5G6R5_UNORM_PACK16) extra_channel = -1; @@ -1249,7 +1249,7 @@ static bool gfx11_get_fast_clear_parameters(struct radv_device *device, const struct radv_image_view *iview, const VkClearColorValue *clear_value, uint32_t *reset_value) { - const struct util_format_description *desc = vk_format_description(iview->vk.format); + const struct util_format_description *desc = radv_format_description(iview->vk.format); unsigned start_bit = UINT_MAX; unsigned end_bit = 0; diff --git a/src/amd/vulkan/meta/radv_meta_copy.c b/src/amd/vulkan/meta/radv_meta_copy.c index 23a75d462e6..c4ea6976a94 100644 --- a/src/amd/vulkan/meta/radv_meta_copy.c +++ b/src/amd/vulkan/meta/radv_meta_copy.c @@ -242,7 +242,7 @@ radv_CmdCopyBufferToImage2(VkCommandBuffer commandBuffer, const VkCopyBufferToIm radv_dst_access_flush(cmd_buffer, VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_READ_BIT, 0, dst_image, NULL); - const enum util_format_layout format_layout = vk_format_description(dst_image->vk.format)->layout; + const enum util_format_layout format_layout = radv_format_description(dst_image->vk.format)->layout; for (unsigned r = 0; r < pCopyBufferToImageInfo->regionCount; r++) { if (format_layout == UTIL_FORMAT_LAYOUT_ASTC) { radv_meta_decode_astc(cmd_buffer, dst_image, pCopyBufferToImageInfo->dstImageLayout, @@ -671,7 +671,7 @@ radv_CmdCopyImage2(VkCommandBuffer commandBuffer, const VkCopyImageInfo2 *pCopyI radv_dst_access_flush(cmd_buffer, VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_READ_BIT, 0, dst_image, NULL); - const enum util_format_layout format_layout = vk_format_description(dst_image->vk.format)->layout; + const enum util_format_layout format_layout = radv_format_description(dst_image->vk.format)->layout; for (unsigned r = 0; r < pCopyImageInfo->regionCount; r++) { VkExtent3D dst_extent = pCopyImageInfo->pRegions[r].extent; if (src_image->vk.format != dst_image->vk.format) { diff --git a/src/amd/vulkan/radv_buffer_view.c b/src/amd/vulkan/radv_buffer_view.c index acc2cc213bc..947337d70dc 100644 --- a/src/amd/vulkan/radv_buffer_view.c +++ b/src/amd/vulkan/radv_buffer_view.c @@ -28,7 +28,7 @@ radv_make_texel_buffer_descriptor(struct radv_device *device, uint64_t va, VkFor unsigned stride; enum pipe_swizzle swizzle[4]; - desc = vk_format_description(vk_format); + desc = radv_format_description(vk_format); stride = desc->block.bits / 8; radv_compose_swizzle(desc, NULL, swizzle); diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c index b446d83b97f..5023694773f 100644 --- a/src/amd/vulkan/radv_formats.c +++ b/src/amd/vulkan/radv_formats.c @@ -48,7 +48,7 @@ radv_is_vertex_buffer_format_supported(VkFormat format) if (first_non_void < 0) return false; - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); return ac_translate_buffer_dataformat(desc, first_non_void) != V_008F0C_BUF_DATA_FORMAT_INVALID; } @@ -81,7 +81,7 @@ radv_translate_tex_numformat(const struct util_format_description *desc, int fir static bool radv_is_sampler_format_supported(const struct radv_physical_device *pdev, VkFormat format, bool *linear_sampling) { - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); uint32_t num_format; if (format == VK_FORMAT_UNDEFINED || format == VK_FORMAT_R64_UINT || format == VK_FORMAT_R64_SINT) return false; @@ -95,7 +95,8 @@ radv_is_sampler_format_supported(const struct radv_physical_device *pdev, VkForm *linear_sampling = true; else *linear_sampling = false; - return radv_translate_tex_dataformat(pdev, vk_format_description(format), + + return radv_translate_tex_dataformat(pdev, radv_format_description(format), vk_format_get_first_non_void_channel(format)) != ~0U; } @@ -110,7 +111,7 @@ bool radv_is_storage_image_format_supported(const struct radv_physical_device *pdev, VkFormat format) { const struct radv_instance *instance = radv_physical_device_instance(pdev); - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); unsigned data_format, num_format; if (format == VK_FORMAT_UNDEFINED) return false; @@ -200,7 +201,7 @@ radv_is_buffer_dataformat_supported(const struct util_format_description *desc, bool radv_is_buffer_format_supported(VkFormat format, bool *scaled) { - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); unsigned num_format; if (format == VK_FORMAT_UNDEFINED) @@ -223,7 +224,7 @@ radv_is_buffer_format_supported(VkFormat format, bool *scaled) static bool radv_is_colorbuffer_format_blendable(const struct radv_physical_device *pdev, VkFormat format) { - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); const uint32_t color_format = ac_get_cb_format(pdev->info.gfx_level, desc->format); const uint32_t color_num_format = ac_get_cb_number_type(desc->format); @@ -239,7 +240,7 @@ radv_is_colorbuffer_format_blendable(const struct radv_physical_device *pdev, Vk bool radv_is_colorbuffer_format_supported(const struct radv_physical_device *pdev, VkFormat format) { - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); return ac_is_colorbuffer_format_supported(pdev->info.gfx_level, desc->format); } @@ -275,7 +276,7 @@ radv_physical_device_get_format_properties(struct radv_physical_device *pdev, Vk VkFormatProperties3 *out_properties) { VkFormatFeatureFlags2 linear = 0, tiled = 0, buffer = 0; - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); bool scaled = false; /* TODO: implement some software emulation of SUBSAMPLED formats. */ if (desc->format == PIPE_FORMAT_NONE || desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) { @@ -502,7 +503,7 @@ radv_physical_device_get_format_properties(struct radv_physical_device *pdev, Vk bool radv_format_pack_clear_color(VkFormat format, uint32_t clear_vals[2], VkClearColorValue *value) { - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); if (format == VK_FORMAT_B10G11R11_UFLOAT_PACK32) { clear_vals[0] = float3_to_r11g11b10f(value->float32); @@ -865,7 +866,7 @@ radv_get_image_format_properties(struct radv_physical_device *pdev, const VkPhys uint32_t maxMipLevels; uint32_t maxArraySize; VkSampleCountFlags sampleCounts = VK_SAMPLE_COUNT_1_BIT; - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); enum amd_gfx_level gfx_level = pdev->info.gfx_level; VkImageTiling tiling = info->tiling; const VkPhysicalDeviceImageDrmFormatModifierInfoEXT *mod_info = @@ -1507,8 +1508,8 @@ radv_dcc_formats_compatible(enum amd_gfx_level gfx_level, VkFormat format1, VkFo if (format1 == format2) return true; - desc1 = vk_format_description(format1); - desc2 = vk_format_description(format2); + desc1 = radv_format_description(format1); + desc2 = radv_format_description(format2); if (desc1->nr_channels != desc2->nr_channels) return false; diff --git a/src/amd/vulkan/radv_formats.h b/src/amd/vulkan/radv_formats.h index b9d53b16155..834bd1b076d 100644 --- a/src/amd/vulkan/radv_formats.h +++ b/src/amd/vulkan/radv_formats.h @@ -34,6 +34,12 @@ radv_format_to_pipe_format(VkFormat vkformat) } } +static inline const struct util_format_description * +radv_format_description(VkFormat format) +{ + return util_format_description(radv_format_to_pipe_format(format)); +} + /** * Return the index of the first non-void channel * -1 if no non-void channels diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index b24500fd4fd..f3832aa008b 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -606,7 +606,7 @@ radv_image_get_plane_format(const struct radv_physical_device *pdev, const struc if (radv_is_format_emulated(pdev, image->vk.format)) { if (plane == 0) return image->vk.format; - if (vk_format_description(image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ASTC) + if (radv_format_description(image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ASTC) return vk_texcompress_astc_emulation_format(image->vk.format); else return vk_texcompress_etc2_emulation_format(image->vk.format); @@ -624,7 +624,7 @@ radv_get_surface_flags(struct radv_device *device, struct radv_image *image, uns uint64_t flags; unsigned array_mode = radv_choose_tiling(device, pCreateInfo, image_format); VkFormat format = radv_image_get_plane_format(pdev, image, plane_id); - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); const VkImageAlignmentControlCreateInfoMESA *alignment = vk_find_struct_const(pCreateInfo->pNext, IMAGE_ALIGNMENT_CONTROL_CREATE_INFO_MESA); bool is_depth, is_stencil; @@ -1322,7 +1322,7 @@ radv_image_print_info(struct radv_device *device, struct radv_image *image) for (unsigned i = 0; i < image->plane_count; ++i) { const struct radv_image_plane *plane = &image->planes[i]; const struct radeon_surf *surf = &plane->surface; - const struct util_format_description *desc = vk_format_description(plane->format); + const struct util_format_description *desc = radv_format_description(plane->format); uint64_t offset = ac_surface_get_plane_offset(pdev->info.gfx_level, &plane->surface, 0, 0); fprintf(stderr, " Plane[%u]: vkformat=%s, offset=%" PRIu64 "\n", i, desc->name, offset); diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index b6172c55d6b..7dc2227728b 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -101,7 +101,7 @@ radv_choose_spi_color_format(const struct radv_device *device, VkFormat vk_forma bool blend_need_alpha) { const struct radv_physical_device *pdev = radv_device_physical(device); - const struct util_format_description *desc = vk_format_description(vk_format); + const struct util_format_description *desc = radv_format_description(vk_format); bool use_rbplus = pdev->info.rbplus_allowed; struct ac_spi_color_formats formats = {0}; unsigned format, ntype, swap; @@ -125,7 +125,7 @@ radv_choose_spi_color_format(const struct radv_device *device, VkFormat vk_forma static bool format_is_int8(VkFormat format) { - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); int channel = vk_format_get_first_non_void_channel(format); return channel >= 0 && desc->channel[channel].pure_integer && desc->channel[channel].size == 8; @@ -134,7 +134,7 @@ format_is_int8(VkFormat format) static bool format_is_int10(VkFormat format) { - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); if (desc->nr_channels != 4) return false; @@ -148,7 +148,7 @@ format_is_int10(VkFormat format) static bool format_is_float32(VkFormat format) { - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); int channel = vk_format_get_first_non_void_channel(format); return channel >= 0 && desc->channel[channel].type == UTIL_FORMAT_TYPE_FLOAT && desc->channel[channel].size == 32; diff --git a/src/amd/vulkan/radv_sdma.c b/src/amd/vulkan/radv_sdma.c index fe660f8f891..2b6e3262ad3 100644 --- a/src/amd/vulkan/radv_sdma.c +++ b/src/amd/vulkan/radv_sdma.c @@ -201,7 +201,7 @@ radv_sdma_get_metadata_config(const struct radv_device *const device, const stru } const VkFormat format = vk_format_get_aspect_format(image->vk.format, subresource.aspectMask); - const struct util_format_description *desc = vk_format_description(format); + const struct util_format_description *desc = radv_format_description(format); const uint32_t data_format = ac_get_cb_format(pdev->info.gfx_level, radv_format_to_pipe_format(format)); const uint32_t alpha_is_on_msb = ac_alpha_is_on_msb(&pdev->info, radv_format_to_pipe_format(format));