From: Chia-I Wu Date: Wed, 13 Sep 2023 22:54:00 +0000 (-0700) Subject: radv: add radv_is_format_emulated X-Git-Tag: upstream/23.3.3~1244 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55b7d6e5a338ab959ce1c03f46134a77b837b306;p=platform%2Fupstream%2Fmesa.git radv: add radv_is_format_emulated This is a cleanup with no functional change. Part-of: --- diff --git a/src/amd/vulkan/meta/radv_meta_copy.c b/src/amd/vulkan/meta/radv_meta_copy.c index 4867b8f..c4c4da9 100644 --- a/src/amd/vulkan/meta/radv_meta_copy.c +++ b/src/amd/vulkan/meta/radv_meta_copy.c @@ -207,12 +207,13 @@ radv_CmdCopyBufferToImage2(VkCommandBuffer commandBuffer, const VkCopyBufferToIm &pCopyBufferToImageInfo->pRegions[r]); } - if (cmd_buffer->device->physical_device->emulate_etc2 && - vk_format_description(dst_image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ETC) { + if (radv_is_format_emulated(cmd_buffer->device->physical_device, dst_image->vk.format)) { cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_CS_PARTIAL_FLUSH | RADV_CMD_FLAG_PS_PARTIAL_FLUSH | radv_src_access_flush(cmd_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, dst_image) | radv_dst_access_flush(cmd_buffer, VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, dst_image); + + assert(vk_format_description(dst_image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ETC); for (unsigned r = 0; r < pCopyBufferToImageInfo->regionCount; r++) { radv_meta_decode_etc(cmd_buffer, dst_image, pCopyBufferToImageInfo->dstImageLayout, &pCopyBufferToImageInfo->pRegions[r].imageSubresource, @@ -552,12 +553,13 @@ radv_CmdCopyImage2(VkCommandBuffer commandBuffer, const VkCopyImageInfo2 *pCopyI &pCopyImageInfo->pRegions[r]); } - if (cmd_buffer->device->physical_device->emulate_etc2 && - vk_format_description(dst_image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ETC) { + if (radv_is_format_emulated(cmd_buffer->device->physical_device, dst_image->vk.format)) { cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_CS_PARTIAL_FLUSH | RADV_CMD_FLAG_PS_PARTIAL_FLUSH | radv_src_access_flush(cmd_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, dst_image) | radv_dst_access_flush(cmd_buffer, VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT, dst_image); + + assert(vk_format_description(dst_image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ETC); for (unsigned r = 0; r < pCopyImageInfo->regionCount; r++) { radv_meta_decode_etc(cmd_buffer, dst_image, pCopyImageInfo->dstImageLayout, &pCopyImageInfo->pRegions[r].dstSubresource, pCopyImageInfo->pRegions[r].dstOffset, diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c index a7b1d7a..148acab 100644 --- a/src/amd/vulkan/radv_formats.c +++ b/src/amd/vulkan/radv_formats.c @@ -618,6 +618,15 @@ radv_is_filter_minmax_format_supported(VkFormat format) } bool +radv_is_format_emulated(const struct radv_physical_device *physical_device, VkFormat format) +{ + if (physical_device->emulate_etc2 && vk_texcompress_etc2_emulation_format(format) != VK_FORMAT_UNDEFINED) + return true; + + return false; +} + +bool radv_device_supports_etc(const struct radv_physical_device *physical_device) { return physical_device->rad_info.family == CHIP_VEGA10 || physical_device->rad_info.family == CHIP_RAVEN || @@ -1201,13 +1210,12 @@ static VkResult radv_check_modifier_support(struct radv_physical_device *dev, const VkPhysicalDeviceImageFormatInfo2 *info, VkImageFormatProperties *props, VkFormat format, uint64_t modifier) { - const struct util_format_description *desc = vk_format_description(format); uint32_t max_width, max_height; if (info->type != VK_IMAGE_TYPE_2D) return VK_ERROR_FORMAT_NOT_SUPPORTED; - if (desc->layout == UTIL_FORMAT_LAYOUT_ETC && dev->emulate_etc2) + if (radv_is_format_emulated(dev, format)) return VK_ERROR_FORMAT_NOT_SUPPORTED; /* We did not add modifiers for sparse textures. */ @@ -1335,7 +1343,7 @@ radv_get_image_format_properties(struct radv_physical_device *physical_device, if (format_feature_flags == 0) goto unsupported; - if (info->type == VK_IMAGE_TYPE_1D && (desc->layout == UTIL_FORMAT_LAYOUT_ETC && physical_device->emulate_etc2)) + if (info->type == VK_IMAGE_TYPE_1D && radv_is_format_emulated(physical_device, format)) goto unsupported; if (info->type != VK_IMAGE_TYPE_2D && vk_format_is_depth_or_stencil(format)) goto unsupported; @@ -1485,7 +1493,7 @@ radv_get_image_format_properties(struct radv_physical_device *physical_device, } if ((info->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT)) && - (desc->layout == UTIL_FORMAT_LAYOUT_ETC && physical_device->emulate_etc2)) { + radv_is_format_emulated(physical_device, format)) { goto unsupported; } @@ -1531,9 +1539,8 @@ get_external_image_format_properties(struct radv_physical_device *physical_devic VkExternalMemoryFeatureFlagBits flags = 0; VkExternalMemoryHandleTypeFlags export_flags = 0; VkExternalMemoryHandleTypeFlags compat_flags = 0; - const struct util_format_description *desc = vk_format_description(pImageFormatInfo->format); - if (desc->layout == UTIL_FORMAT_LAYOUT_ETC && physical_device->emulate_etc2) + if (radv_is_format_emulated(physical_device, pImageFormatInfo->format)) return; if (pImageFormatInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index 8723a36..88aa4c0 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -534,7 +534,8 @@ radv_patch_image_from_extra_info(struct radv_device *device, struct radv_image * static VkFormat radv_image_get_plane_format(const struct radv_physical_device *pdev, const struct radv_image *image, unsigned plane) { - if (pdev->emulate_etc2 && vk_format_description(image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ETC) { + if (radv_is_format_emulated(pdev, image->vk.format)) { + assert(vk_format_description(image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ETC); if (plane == 0) return image->vk.format; return vk_texcompress_etc2_emulation_format(image->vk.format); @@ -1610,7 +1611,7 @@ radv_image_use_comp_to_single(const struct radv_device *device, const struct rad static unsigned radv_get_internal_plane_count(const struct radv_physical_device *pdev, VkFormat fmt) { - if (pdev->emulate_etc2 && vk_format_description(fmt)->layout == UTIL_FORMAT_LAYOUT_ETC) + if (radv_is_format_emulated(pdev, fmt)) return 2; return vk_format_get_plane_count(fmt); } @@ -2167,8 +2168,7 @@ radv_image_view_init(struct radv_image_view *iview, struct radv_device *device, plane_count = vk_format_get_plane_count(iview->vk.format); } - if (device->physical_device->emulate_etc2 && - vk_format_description(image->vk.format)->layout == UTIL_FORMAT_LAYOUT_ETC) { + if (radv_is_format_emulated(device->physical_device, image->vk.format)) { const struct util_format_description *desc = vk_format_description(iview->vk.format); if (desc->layout == UTIL_FORMAT_LAYOUT_ETC) { iview->plane_id = 1; diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 3573289..c060782 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -2570,6 +2570,7 @@ bool radv_dcc_formats_compatible(enum amd_gfx_level gfx_level, VkFormat format1, bool *sign_reinterpret); bool radv_is_atomic_format_supported(VkFormat format); bool radv_device_supports_etc(const struct radv_physical_device *physical_device); +bool radv_is_format_emulated(const struct radv_physical_device *physical_device, VkFormat format); static const VkImageUsageFlags RADV_IMAGE_USAGE_WRITE_BITS = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |