v3dv: directly use v3d_has_feature instead of caps struct

v3d_has_feature() function was also moved to the top of the file
so get_device_extensions() and get_features() could use it

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42177>
This commit is contained in:
Sid Pranjale 2026-06-11 14:31:17 +02:00 committed by Sid
parent 4fded54fd0
commit 5abc4e3e1a
2 changed files with 16 additions and 27 deletions

View file

@ -108,6 +108,17 @@ v3dv_EnumerateInstanceVersion(uint32_t *pApiVersion)
#include "wsi_common.h"
#endif
static bool v3d_has_feature(const struct v3dv_physical_device *device,
enum drm_v3d_param feature)
{
struct drm_v3d_get_param p = {
.param = feature,
};
if (v3d_ioctl(device->render_fd, DRM_IOCTL_V3D_GET_PARAM, &p) != 0)
return false;
return p.value;
}
static const struct vk_instance_extension_table instance_extensions = {
.KHR_device_group_creation = true,
#ifdef VK_USE_PLATFORM_DISPLAY_KHR
@ -177,7 +188,7 @@ get_device_extensions(const struct v3dv_physical_device *device,
.KHR_index_type_uint8 = true,
.KHR_line_rasterization = true,
.KHR_load_store_op_none = true,
.KHR_performance_query = device->caps.perfmon,
.KHR_performance_query = v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_PERFMON),
.KHR_relaxed_block_layout = true,
.KHR_robustness2 = true,
.KHR_maintenance1 = true,
@ -502,7 +513,7 @@ get_features(const struct v3dv_physical_device *physical_device,
.vertexAttributeInstanceRateZeroDivisor = false,
/* VK_KHR_performance_query */
.performanceCounterQueryPools = physical_device->caps.perfmon,
.performanceCounterQueryPools = v3d_has_feature(physical_device, DRM_V3D_PARAM_SUPPORTS_PERFMON),
.performanceCounterMultipleQueryPools = false,
/* VK_EXT_texel_buffer_alignment */
@ -818,25 +829,14 @@ compute_memory_budget(struct v3dv_physical_device *device)
#endif
}
static bool
v3d_has_feature(struct v3dv_physical_device *device, enum drm_v3d_param feature)
{
struct drm_v3d_get_param p = {
.param = feature,
};
if (v3d_ioctl(device->render_fd, DRM_IOCTL_V3D_GET_PARAM, &p) != 0)
return false;
return p.value;
}
static bool
device_has_expected_features(struct v3dv_physical_device *device)
{
return v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_TFU) &&
v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_CSD) &&
v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_CACHE_FLUSH) &&
v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_CPU_QUEUE) &&
device->caps.multisync;
v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT) &&
v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_CPU_QUEUE);
}
@ -1444,12 +1444,6 @@ create_physical_device(struct v3dv_instance *instance,
goto fail;
}
device->caps.multisync =
v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT);
device->caps.perfmon =
v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_PERFMON);
/* Always mention only the newest kernel version we require */
if (!device_has_expected_features(device)) {
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
@ -1458,7 +1452,7 @@ create_physical_device(struct v3dv_instance *instance,
goto fail;
}
if (device->caps.perfmon) {
if (v3d_has_feature(device, DRM_V3D_PARAM_SUPPORTS_PERFMON)) {
device->perfcntr = v3d_perfcntrs_init(&device->devinfo, device->render_fd);
if (!device->perfcntr) {

View file

@ -116,11 +116,6 @@ struct v3dv_physical_device {
*/
struct util_sparse_array bo_map;
struct {
bool multisync;
bool perfmon;
} caps;
bool merge_jobs;
bool is_shim;
};