From 483c40a21d5f74db075439056bea27a656df0d24 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Thu, 5 Dec 2024 13:03:33 -0500 Subject: [PATCH] anv: Allow compressed memtypes with default buffer types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Source 2 games segfault if certain buffers are not able to use the same memory types as images. CS2 specifically expects this to be the case for vertex and index buffers (VK_BUFFER_USAGE_2_INDEX_BUFFER_BIT, VK_BUFFER_USAGE_2_VERTEX_BUFFER_BIT). I have not tested other Source 2 games to see how much the requirement differs for the usage (if at all). Up until now, we've disabled CCS for the Source 2 engine with the anv_disable_xe2_ccs driconf option. However, this option is not great for performance. So, replace this with a new option to allow the same memory types we use for images on buffers - anv_enable_buffer_comp. Compression of buffers is generally not good for performance. I collected the result of unconditionally enabling the feature in the performance CI on BMG. I used the default configuration to average the result of two runs of each trace. The CI reports that 4 game traces would regress between 0.44-1.01% FPS with buffer compression. However, the CI actually shows it to be beneficial in three of our game traces: * Cyberpunk-trace-dx12-1080p-high 106.51% * Hitman3-trace-dx12-1080p-med 101.59% * Blackops3-trace-dx11-1080p-high 100.44% So, enable the option for the two games we already have driconf entries for, Cyberpunk and Hitman3. Of course, also enable the option for Source 2 games. Casey Bowman reports that on BMG, some frame times drop from ~15ms to ~7ms in CS2. This is in large part due to the removal of HiZ resolves, which is a consequence of the game now using of HIZ_CCS_WT instead of plain HIZ. Ref: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11520 Acked-by: Paulo Zanoni Reviewed-by: José Roberto de Souza Part-of: --- src/intel/vulkan/anv_buffer.c | 3 +++ src/intel/vulkan/anv_instance.c | 6 +++--- src/intel/vulkan/anv_physical_device.c | 3 --- src/intel/vulkan/anv_private.h | 7 +++++-- src/util/00-mesa-defaults.conf | 15 ++++++++++++--- src/util/driconf.h | 6 +++--- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/intel/vulkan/anv_buffer.c b/src/intel/vulkan/anv_buffer.c index 89e14d947ef..e2a101be8cf 100644 --- a/src/intel/vulkan/anv_buffer.c +++ b/src/intel/vulkan/anv_buffer.c @@ -72,6 +72,9 @@ anv_get_buffer_memory_requirements(struct anv_device *device, else if (usage & (VK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT | VK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT)) memory_types = device->physical->memory.dynamic_visible_mem_types; + else if (device->physical->instance->enable_buffer_comp) + memory_types = device->physical->memory.default_buffer_mem_types | + device->physical->memory.compressed_mem_types; else memory_types = device->physical->memory.default_buffer_mem_types; diff --git a/src/intel/vulkan/anv_instance.c b/src/intel/vulkan/anv_instance.c index e63aa9e873f..99dcad7db19 100644 --- a/src/intel/vulkan/anv_instance.c +++ b/src/intel/vulkan/anv_instance.c @@ -17,7 +17,7 @@ static const driOptionDescription anv_dri_options[] = { DRI_CONF_ANV_ASSUME_FULL_SUBGROUPS(0) DRI_CONF_ANV_ASSUME_FULL_SUBGROUPS_WITH_BARRIER(false) DRI_CONF_ANV_DISABLE_FCV(false) - DRI_CONF_ANV_DISABLE_XE2_CCS(false) + DRI_CONF_ANV_ENABLE_BUFFER_COMP(false) DRI_CONF_ANV_EXTERNAL_MEMORY_IMPLICIT_SYNC(true) DRI_CONF_ANV_FORCE_GUC_LOW_LATENCY(false) DRI_CONF_ANV_SAMPLE_MASK_OUT_OPENGL_BEHAVIOUR(false) @@ -171,8 +171,8 @@ anv_init_dri_options(struct anv_instance *instance) instance->enable_tbimr = driQueryOptionb(&instance->dri_options, "intel_tbimr"); instance->disable_fcv = driQueryOptionb(&instance->dri_options, "anv_disable_fcv"); - instance->disable_xe2_ccs = - driQueryOptionb(&instance->dri_options, "anv_disable_xe2_ccs"); + instance->enable_buffer_comp = + driQueryOptionb(&instance->dri_options, "anv_enable_buffer_comp"); instance->external_memory_implicit_sync = driQueryOptionb(&instance->dri_options, "anv_external_memory_implicit_sync"); instance->compression_control_enabled = diff --git a/src/intel/vulkan/anv_physical_device.c b/src/intel/vulkan/anv_physical_device.c index fa2f7f78100..82a128fc587 100644 --- a/src/intel/vulkan/anv_physical_device.c +++ b/src/intel/vulkan/anv_physical_device.c @@ -2440,9 +2440,6 @@ anv_physical_device_try_create(struct vk_instance *vk_instance, goto fail_fd; } - if (devinfo.ver == 20 && instance->disable_xe2_ccs) - intel_debug |= DEBUG_NO_CCS; - /* Disable Wa_16013994831 on Gfx12.0 because we found other cases where we * need to always disable preemption : * - https://gitlab.freedesktop.org/mesa/mesa/-/issues/5963 diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index db68a67675c..5142443a186 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1137,7 +1137,10 @@ struct anv_physical_device { uint32_t dynamic_visible_mem_types; /** Mask of memory types of protected buffers/images */ uint32_t protected_mem_types; - /** Mask of memory types of compressed buffers/images */ + /** + * Mask of memory types of compressed buffers/images. This is generally + * a win for images, but a loss for buffers. + */ uint32_t compressed_mem_types; } memory; @@ -1304,7 +1307,7 @@ struct anv_instance { unsigned force_vk_vendor; bool has_fake_sparse; bool disable_fcv; - bool disable_xe2_ccs; + bool enable_buffer_comp; bool compression_control_enabled; bool anv_fake_nonlocal_memory; bool anv_upper_bound_descriptor_pool_sampler; diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index 635b2193bc1..4a3daf49663 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -1201,6 +1201,10 @@ TODO: document the other workarounds. +