From 5e96edf2162711cee42ad29bc3be79351b0d3320 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 30 Jun 2020 13:09:29 -0700 Subject: [PATCH] virgl: add enum virgl_capsets to virgl_hw.h Capset ids belong to virgl_hw.h. Mesa uses magic numbers right now and can be fixed with this change. Capset ids are also leaked in virtio_gpu.h, for use with virgl_renderer_get_cap_set by qemu. We should replace virgl_renderer_get_cap_set by something that enumerates all capsets to stop the leaking, but that is another story. Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh --- src/virgl_hw.h | 7 +++++++ src/virglrenderer.c | 20 ++++++++++++++++++-- src/vrend_renderer.c | 4 ++-- src/vrend_renderer.h | 3 --- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/virgl_hw.h b/src/virgl_hw.h index 58dafd9..69730ad 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.h @@ -370,6 +370,13 @@ enum virgl_formats { VIRGL_FORMAT_MAX_EXTENDED }; +#ifdef VIRGL_RENDERER_UNSTABLE_APIS +enum virgl_capsets { + VIRGL_CAPSET_VIRGL = 1, + VIRGL_CAPSET_VIRGL2 = 2, +}; +#endif + /* These are used by the capability_bits field in virgl_caps_v2. */ #define VIRGL_CAP_NONE 0 #define VIRGL_CAP_TGSI_INVARIANT (1 << 0) diff --git a/src/virglrenderer.c b/src/virglrenderer.c index d334465..c43d901 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -155,7 +155,14 @@ void virgl_renderer_resource_unref(uint32_t res_handle) void virgl_renderer_fill_caps(uint32_t set, uint32_t version, void *caps) { - vrend_renderer_fill_caps(set, version, (union virgl_caps *)caps); + switch (set) { + case VIRGL_CAPSET_VIRGL: + case VIRGL_CAPSET_VIRGL2: + vrend_renderer_fill_caps(set, version, (union virgl_caps *)caps); + break; + default: + break; + } } int virgl_renderer_context_create(uint32_t handle, uint32_t nlen, const char *name) @@ -354,7 +361,16 @@ int virgl_renderer_resource_get_info(int res_handle, void virgl_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver, uint32_t *max_size) { - vrend_renderer_get_cap_set(cap_set, max_ver, max_size); + switch (cap_set) { + case VIRGL_CAPSET_VIRGL: + case VIRGL_CAPSET_VIRGL2: + vrend_renderer_get_cap_set(cap_set, max_ver, max_size); + break; + default: + *max_ver = 0; + *max_size = 0; + break; + } } void virgl_renderer_get_rect(int resource_id, struct iovec *iov, unsigned int num_iovs, diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index bafa428..ff2c0e7 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -10264,11 +10264,11 @@ void vrend_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver, uint32_t *max_size) { switch (cap_set) { - case VREND_CAP_SET: + case VIRGL_CAPSET_VIRGL: *max_ver = 1; *max_size = sizeof(struct virgl_caps_v1); break; - case VREND_CAP_SET2: + case VIRGL_CAPSET_VIRGL2: /* we should never need to increase this - it should be possible to just grow virgl_caps */ *max_ver = 2; *max_size = sizeof(struct virgl_caps_v2); diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 424d750..26ec08e 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -434,9 +434,6 @@ struct vrend_renderer_resource_info { int vrend_renderer_resource_get_info(struct pipe_resource *pres, struct vrend_renderer_resource_info *info); -#define VREND_CAP_SET 1 -#define VREND_CAP_SET2 2 - void vrend_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver, uint32_t *max_size);