diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 85d1f913bbe..0169bf188c4 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -691,6 +691,8 @@ radv_physical_device_try_create(struct radv_instance *instance, drmDevicePtr drm } #endif + device->emulate_etc2 = false; + snprintf(device->name, sizeof(device->name), "AMD RADV %s%s", device->rad_info.name, radv_get_compiler_string(device)); @@ -1169,7 +1171,7 @@ radv_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDevice .alphaToOne = false, .multiViewport = true, .samplerAnisotropy = true, - .textureCompressionETC2 = radv_device_supports_etc(pdevice), + .textureCompressionETC2 = radv_device_supports_etc(pdevice) || pdevice->emulate_etc2, .textureCompressionASTC_LDR = false, .textureCompressionBC = true, .occlusionQueryPrecise = true, diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c index 7a3508fc4c0..be62ef1d001 100644 --- a/src/amd/vulkan/radv_formats.c +++ b/src/amd/vulkan/radv_formats.c @@ -708,7 +708,8 @@ radv_physical_device_get_format_properties(struct radv_physical_device *physical return; } - if (desc->layout == UTIL_FORMAT_LAYOUT_ETC && !radv_device_supports_etc(physical_device)) { + if (desc->layout == UTIL_FORMAT_LAYOUT_ETC && !radv_device_supports_etc(physical_device) && + !physical_device->emulate_etc2) { out_properties->linearTilingFeatures = linear; out_properties->optimalTilingFeatures = tiled; out_properties->bufferFeatures = buffer; @@ -1349,11 +1350,15 @@ 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 || (desc->layout == UTIL_FORMAT_LAYOUT_ETC && dev->emulate_etc2)) + return VK_ERROR_FORMAT_NOT_SUPPORTED; + /* We did not add modifiers for sparse textures. */ if (info->flags & (VK_IMAGE_CREATE_SPARSE_BINDING_BIT | VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) @@ -1617,6 +1622,12 @@ radv_get_image_format_properties(struct radv_physical_device *physical_device, goto unsupported; } + 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)) { + goto unsupported; + } + *pImageFormatProperties = (VkImageFormatProperties){ .maxExtent = maxExtent, .maxMipLevels = maxMipLevels, @@ -1659,6 +1670,10 @@ 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 || (desc->layout == UTIL_FORMAT_LAYOUT_ETC && physical_device->emulate_etc2)) + return; if (pImageFormatInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) return; diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 98c573d4f53..7378fc81995 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -291,6 +291,9 @@ struct radv_physical_device { /* Whether to use the LLVM compiler backend */ bool use_llvm; + /* Whether to emulate ETC2 image support on HW without support. */ + bool emulate_etc2; + /* This is the drivers on-disk cache used as a fallback as opposed to * the pipeline cache defined by apps. */