anv: add support for vk_require_astc driconf
authorChia-I Wu <olvaffe@gmail.com>
Thu, 28 Sep 2023 17:38:01 +0000 (10:38 -0700)
committerMarge Bot <emma+marge@anholt.net>
Sat, 14 Oct 2023 02:36:40 +0000 (02:36 +0000)
When vk_require_astc is true and there is no native ASTC LDR support,
enable ASTC LDR emulation.

vk_require_astc defaults to true on Android 14+.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25467>

src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_private.h

index 7c3968180c6c8261e40e4b2b9f8e1df396e09ece..f68ee8290e841eecc0b00179cee98e02e14d8a1e 100644 (file)
@@ -97,6 +97,11 @@ static const driOptionDescription anv_dri_options[] = {
       DRI_CONF_ANV_MESH_CONV_PRIM_ATTRS_TO_VERT_ATTRS(-2)
       DRI_CONF_FORCE_VK_VENDOR(0)
       DRI_CONF_FAKE_SPARSE(false)
+#if defined(ANDROID) && ANDROID_API_LEVEL >= 34
+      DRI_CONF_VK_REQUIRE_ASTC(true)
+#else
+      DRI_CONF_VK_REQUIRE_ASTC(false)
+#endif
    DRI_CONF_SECTION_END
 
    DRI_CONF_SECTION_QUALITY
@@ -403,11 +408,6 @@ get_features(const struct anv_physical_device *pdevice,
 {
    struct vk_app_info *app_info = &pdevice->instance->vk.app_info;
 
-   /* Just pick one; they're all the same */
-   const bool has_astc_ldr =
-      isl_format_supports_sampling(&pdevice->info,
-                                   ISL_FORMAT_ASTC_LDR_2D_4X4_FLT16);
-
    const bool rt_enabled = ANV_SUPPORT_RT && pdevice->info.has_ray_tracing;
 
    const bool mesh_shader =
@@ -439,7 +439,8 @@ get_features(const struct anv_physical_device *pdevice,
       .multiViewport                            = true,
       .samplerAnisotropy                        = true,
       .textureCompressionETC2                   = true,
-      .textureCompressionASTC_LDR               = has_astc_ldr,
+      .textureCompressionASTC_LDR               = pdevice->has_astc_ldr ||
+                                                  pdevice->emu_astc_ldr,
       .textureCompressionBC                     = true,
       .occlusionQueryPrecise                    = true,
       .pipelineStatisticsQuery                  = true,
@@ -1351,8 +1352,13 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
    device->has_protected_contexts = device->info.ver >= 12 &&
       intel_gem_supports_protected_context(fd, device->info.kmd_type);
 
-   /* always false for now */
-   device->emu_astc_ldr = false;
+   /* Just pick one; they're all the same */
+   device->has_astc_ldr =
+      isl_format_supports_sampling(&device->info,
+                                   ISL_FORMAT_ASTC_LDR_2D_4X4_FLT16);
+   if (!device->has_astc_ldr &&
+       driQueryOptionb(&device->instance->dri_options, "vk_require_astc"))
+      device->emu_astc_ldr = true;
 
    result = anv_physical_device_init_heaps(device, fd);
    if (result != VK_SUCCESS)
index eb21036de222fa3061bb3d038e332d0f5cac294a..e780295fc0c33723ef8787f61ca1285c32916aac 100644 (file)
@@ -922,6 +922,8 @@ struct anv_physical_device {
      */
     bool                                        has_sparse;
 
+    /** True if HW supports ASTC LDR */
+    bool                                        has_astc_ldr;
     /** True if ASTC LDR is supported via emulation */
     bool                                        emu_astc_ldr;