radv: Set up ETC2 emulation wiring.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14071>
This commit is contained in:
Bas Nieuwenhuizen 2021-11-03 12:55:28 +01:00 committed by Marge Bot
parent ef3b31c967
commit 7c5fe66f8a
3 changed files with 22 additions and 2 deletions

View file

@ -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,

View file

@ -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;

View file

@ -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.
*/