radv,driconf: Add radv_force_64k_sparse_alignment config

Needed by DOOM: The Dark Ages.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34944>
This commit is contained in:
Natalie Vock 2025-05-13 09:24:41 +02:00 committed by Marge Bot
parent 720dae85f2
commit e32a90b57c
4 changed files with 12 additions and 1 deletions

View file

@ -167,6 +167,7 @@ radv_get_buffer_memory_requirements(struct radv_device *device, VkDeviceSize siz
VkBufferUsageFlags2 usage, VkMemoryRequirements2 *pMemoryRequirements) VkBufferUsageFlags2 usage, VkMemoryRequirements2 *pMemoryRequirements)
{ {
const struct radv_physical_device *pdev = radv_device_physical(device); const struct radv_physical_device *pdev = radv_device_physical(device);
const struct radv_instance *instance = radv_physical_device_instance(pdev);
pMemoryRequirements->memoryRequirements.memoryTypeBits = pMemoryRequirements->memoryRequirements.memoryTypeBits =
((1u << pdev->memory_properties.memoryTypeCount) - 1u) & ~pdev->memory_types_32bit; ((1u << pdev->memory_properties.memoryTypeCount) - 1u) & ~pdev->memory_types_32bit;
@ -179,7 +180,10 @@ radv_get_buffer_memory_requirements(struct radv_device *device, VkDeviceSize siz
pMemoryRequirements->memoryRequirements.memoryTypeBits = pdev->memory_types_32bit; pMemoryRequirements->memoryRequirements.memoryTypeBits = pdev->memory_types_32bit;
if (flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) { if (flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) {
pMemoryRequirements->memoryRequirements.alignment = 4096; if (instance->drirc.force_64k_sparse_alignment)
pMemoryRequirements->memoryRequirements.alignment = 65536;
else
pMemoryRequirements->memoryRequirements.alignment = 4096;
} else { } else {
if (usage & VK_BUFFER_USAGE_2_PREPROCESS_BUFFER_BIT_EXT) if (usage & VK_BUFFER_USAGE_2_PREPROCESS_BUFFER_BIT_EXT)
pMemoryRequirements->memoryRequirements.alignment = radv_dgc_get_buffer_alignment(device); pMemoryRequirements->memoryRequirements.alignment = radv_dgc_get_buffer_alignment(device);

View file

@ -195,6 +195,7 @@ static const driOptionDescription radv_dri_options[] = {
DRI_CONF_RADV_APP_LAYER() DRI_CONF_RADV_APP_LAYER()
DRI_CONF_RADV_EMULATE_RT(false) DRI_CONF_RADV_EMULATE_RT(false)
DRI_CONF_RADV_ENABLE_FLOAT16_GFX8(false) DRI_CONF_RADV_ENABLE_FLOAT16_GFX8(false)
DRI_CONF_RADV_FORCE_64K_SPARSE_ALIGNMENT(false)
DRI_CONF_SECTION_END DRI_CONF_SECTION_END
}; };
// clang-format on // clang-format on
@ -299,6 +300,8 @@ radv_init_dri_options(struct radv_instance *instance)
instance->drirc.emulate_rt = driQueryOptionb(&instance->drirc.options, "radv_emulate_rt"); instance->drirc.emulate_rt = driQueryOptionb(&instance->drirc.options, "radv_emulate_rt");
instance->drirc.expose_float16_gfx8 = driQueryOptionb(&instance->drirc.options, "radv_enable_float16_gfx8"); instance->drirc.expose_float16_gfx8 = driQueryOptionb(&instance->drirc.options, "radv_enable_float16_gfx8");
instance->drirc.force_64k_sparse_alignment = driQueryOptionb(&instance->drirc.options, "radv_force_64k_sparse_alignment");
} }
static const struct vk_instance_extension_table radv_instance_extensions_supported = { static const struct vk_instance_extension_table radv_instance_extensions_supported = {

View file

@ -74,6 +74,7 @@ struct radv_instance {
bool lower_terminate_to_discard; bool lower_terminate_to_discard;
bool emulate_rt; bool emulate_rt;
bool expose_float16_gfx8; bool expose_float16_gfx8;
bool force_64k_sparse_alignment;
char *app_layer; char *app_layer;
uint8_t override_graphics_shader_version; uint8_t override_graphics_shader_version;
uint8_t override_compute_shader_version; uint8_t override_compute_shader_version;

View file

@ -841,6 +841,9 @@
DRI_CONF_OPT_B(radv_enable_float16_gfx8, def, \ DRI_CONF_OPT_B(radv_enable_float16_gfx8, def, \
"Expose float16 on GFX8, where it's supported but usually not beneficial.") "Expose float16 on GFX8, where it's supported but usually not beneficial.")
#define DRI_CONF_RADV_FORCE_64K_SPARSE_ALIGNMENT(def) \
DRI_CONF_OPT_B(radv_force_64k_sparse_alignment, def, \
"Force the alignment of sparse buffers to 64KiB")
/** /**
* \brief ANV specific configuration options * \brief ANV specific configuration options
*/ */