Mesa (main): radv: Set up ETC2 emulation wiring.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Dec 14 12:10:38 UTC 2021
Module: Mesa
Branch: main
Commit: 7c5fe66f8af4a8b3dde940f656eb4d149e9580d2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c5fe66f8af4a8b3dde940f656eb4d149e9580d2
Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date: Wed Nov 3 12:55:28 2021 +0100
radv: Set up ETC2 emulation wiring.
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14071>
---
src/amd/vulkan/radv_device.c | 4 +++-
src/amd/vulkan/radv_formats.c | 17 ++++++++++++++++-
src/amd/vulkan/radv_private.h | 3 +++
3 files changed, 22 insertions(+), 2 deletions(-)
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.
*/
More information about the mesa-commit
mailing list