nvk: support driconf option force_vk_vendor

Some games match on the vendor ID and then check if the driver version
is at least a specific version. Some games just warn about the "old" driver
version. Others refuse to start.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27784>
This commit is contained in:
Thomas H.P. Andersen 2024-02-25 21:00:19 +01:00 committed by Marge Bot
parent 951aa2fa82
commit 03d72c4ef1
3 changed files with 7 additions and 1 deletions

View file

@ -85,6 +85,7 @@ static const driOptionDescription nvk_dri_options[] = {
DRI_CONF_SECTION_END
DRI_CONF_SECTION_DEBUG
DRI_CONF_FORCE_VK_VENDOR(0)
DRI_CONF_VK_WSI_FORCE_SWAPCHAIN_TO_CURRENT_EXTENT(false)
DRI_CONF_VK_X11_IGNORE_SUBOPTIMAL(false)
DRI_CONF_SECTION_END
@ -97,6 +98,9 @@ nvk_init_dri_options(struct nvk_instance *instance)
driParseConfigFiles(&instance->dri_options, &instance->available_dri_options, 0, "nvk", NULL, NULL,
instance->vk.app_info.app_name, instance->vk.app_info.app_version,
instance->vk.app_info.engine_name, instance->vk.app_info.engine_version);
instance->force_vk_vendor =
driQueryOptioni(&instance->dri_options, "force_vk_vendor");
}
VKAPI_ATTR VkResult VKAPI_CALL

View file

@ -17,6 +17,7 @@ struct nvk_instance {
struct driOptionCache available_dri_options;
uint8_t driver_build_sha[20];
uint32_t force_vk_vendor;
};
VK_DEFINE_HANDLE_CASTS(nvk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE)

View file

@ -609,7 +609,8 @@ nvk_get_device_properties(const struct nvk_instance *instance,
*properties = (struct vk_properties) {
.apiVersion = nvk_get_vk_version(info),
.driverVersion = vk_get_driver_version(),
.vendorID = NVIDIA_VENDOR_ID,
.vendorID = instance->force_vk_vendor != 0 ?
instance->force_vk_vendor : NVIDIA_VENDOR_ID,
.deviceID = info->device_id,
.deviceType = info->type == NV_DEVICE_TYPE_DIS ?
VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU :