pvr: add support for driconf for the Vulkan driver

Bringing force_vk_vendor as the first option, force_vk_devicename
will be added later

Signed-off-by: hmtheboy154 <buingoc67@gmail.com>
Reviewed-by: Simon Perretta <simon.perretta@imgtec.com>
[Icenowy: rebased on top of main]

Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41197>
This commit is contained in:
hmtheboy154 2026-01-27 01:12:28 +07:00 committed by Marge Bot
parent 109af1b077
commit 88f5e5986b
4 changed files with 41 additions and 2 deletions

View file

@ -22,6 +22,7 @@
#include "wsi_common.h"
#include "util/build_id.h"
#include "util/driconf.h"
#include "pvr_debug.h"
#include "pvr_device.h"
@ -320,6 +321,32 @@ pvr_get_driver_build_sha(struct pvr_instance *instance)
return true;
}
static const driOptionDescription pvr_dri_options[] = {
DRI_CONF_SECTION_DEBUG
DRI_CONF_FORCE_VK_VENDOR()
DRI_CONF_SECTION_END
};
static void pvr_init_dri_options(struct pvr_instance *instance)
{
driParseOptionInfo(&instance->available_dri_options,
pvr_dri_options,
ARRAY_SIZE(pvr_dri_options));
driParseConfigFiles(&instance->dri_options,
&instance->available_dri_options,
0,
"pvr",
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");
}
VkResult pvr_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance)
@ -357,6 +384,7 @@ VkResult pvr_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
goto err_free_instance;
pvr_process_debug_variable();
pvr_init_dri_options(instance);
instance->active_device_count = 0;
@ -377,6 +405,8 @@ VkResult pvr_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
return VK_SUCCESS;
err_free_instance:
driDestroyOptionCache(&instance->dri_options);
driDestroyOptionInfo(&instance->available_dri_options);
vk_free(pAllocator, instance);
return result;
}
@ -391,6 +421,9 @@ void pvr_DestroyInstance(VkInstance _instance,
VG(VALGRIND_DESTROY_MEMPOOL(instance));
driDestroyOptionCache(&instance->dri_options);
driDestroyOptionInfo(&instance->available_dri_options);
vk_instance_finish(&instance->vk);
vk_free(&instance->vk.alloc, instance);
}

View file

@ -15,6 +15,7 @@
#define PVR_INSTANCE_H
#include "vk_instance.h"
#include "util/xmlconfig.h"
#include <stdint.h>
@ -25,7 +26,11 @@ struct pvr_instance {
uint32_t active_device_count;
struct driOptionCache dri_options;
struct driOptionCache available_dri_options;
uint8_t driver_build_sha[BLAKE3_KEY_LEN];
uint32_t force_vk_vendor;
};
VK_DEFINE_HANDLE_CASTS(pvr_instance,

View file

@ -559,7 +559,8 @@ static bool pvr_physical_device_get_properties(
/* Vulkan 1.0 */
.apiVersion = get_api_version(),
.driverVersion = vk_get_driver_version(),
.vendorID = VK_VENDOR_ID_IMAGINATION,
.vendorID = pdevice->instance->force_vk_vendor ?
pdevice->instance->force_vk_vendor : VK_VENDOR_ID_IMAGINATION,
.deviceID = dev_info->ident.device_id,
.deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
/* deviceName and pipelineCacheUUID are filled below .*/

View file

@ -74,7 +74,7 @@ VkResult pvr_wsi_init(struct pvr_physical_device *pdevice)
pvr_wsi_proc_addr,
&pdevice->vk.instance->alloc,
pdevice->ws->display_fd,
NULL,
&pdevice->instance->dri_options,
&(struct wsi_device_options){ .sw_device = false });
if (result != VK_SUCCESS)
return result;