Module: Mesa Branch: main Commit: 29e2e9290b3d5a567b7c76a1fa52e22c9fb71293 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=29e2e9290b3d5a567b7c76a1fa52e22c9fb71293
Author: Chia-I Wu <[email protected]> Date: Thu Sep 28 10:38:01 2023 -0700 anv: add support for vk_require_astc driconf 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 <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25467> --- src/intel/vulkan/anv_device.c | 22 ++++++++++++++-------- src/intel/vulkan/anv_private.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 7c3968180c6..f68ee8290e8 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -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) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index eb21036de22..e780295fc0c 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -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;
