diff --git a/src/virglrenderer.h b/src/virglrenderer.h index a57cc03..bd96aa5 100644 --- a/src/virglrenderer.h +++ b/src/virglrenderer.h @@ -99,8 +99,9 @@ VIRGL_EXPORT int virgl_renderer_get_fd_for_texture2(uint32_t tex_id, int *fd, in #define VIRGL_RES_BIND_SHARED (1 << 20) enum virgl_renderer_structure_type_v0 { - VIRGL_RENDERER_STRUCTURE_TYPE_NONE = 0x00000000, - VIRGL_RENDERER_STRUCTURE_TYPE_EXPORT_QUERY = 0x00000001, + VIRGL_RENDERER_STRUCTURE_TYPE_NONE = 0, + VIRGL_RENDERER_STRUCTURE_TYPE_EXPORT_QUERY = (1 << 0), + VIRGL_RENDERER_STRUCTURE_TYPE_SUPPORTED_STRUCTURES = (1 << 1), }; struct virgl_renderer_resource_create_args { @@ -144,6 +145,17 @@ struct virgl_renderer_export_query { uint64_t out_modifier; }; +/* + * "out_supported_structures_mask" is a bitmask representing the structures that + * virglrenderer knows how to handle for a given "in_stype_version". + */ + +struct virgl_renderer_supported_structures { + struct virgl_renderer_hdr hdr; + uint32_t in_stype_version; + uint32_t out_supported_structures_mask; +}; + /* new API */ /* This typedef must be kept in sync with vrend_debug.h */ typedef void (*virgl_debug_callback_type)(const char *fmt, va_list ap); diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 4653147..dbfa9d8 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -9937,19 +9937,14 @@ int vrend_renderer_get_poll_fd(void) return vrend_state.eventfd; } -int vrend_renderer_execute(void *execute_args, uint32_t execute_size) +static int vrend_renderer_export_query(void *execute_args, uint32_t execute_size) { - /* - * This function only supports VIRGL_RENDERER_STRUCTURE_TYPE_RESOURCE_QUERY currently. - */ struct vrend_resource *res; struct virgl_renderer_export_query *export_query = execute_args; if (execute_size != sizeof(struct virgl_renderer_export_query)) return -EINVAL; - if (export_query->hdr.stype != VIRGL_RENDERER_STRUCTURE_TYPE_EXPORT_QUERY || - export_query->hdr.stype_version != 0 || - export_query->hdr.size != sizeof(struct virgl_renderer_export_query)) + if (export_query->hdr.size != sizeof(struct virgl_renderer_export_query)) return -EINVAL; res = vrend_resource_lookup(export_query->in_resource_id, 0); @@ -9972,3 +9967,39 @@ int vrend_renderer_execute(void *execute_args, uint32_t execute_size) return 0; } + +static int vrend_renderer_supported_structures(void *execute_args, uint32_t execute_size) +{ + struct virgl_renderer_supported_structures *supported_structures = execute_args; + if (execute_size != sizeof(struct virgl_renderer_supported_structures)) + return -EINVAL; + + if (supported_structures->hdr.size != sizeof(struct virgl_renderer_supported_structures)) + return -EINVAL; + + if (supported_structures->in_stype_version == 0) { + supported_structures->out_supported_structures_mask = + VIRGL_RENDERER_STRUCTURE_TYPE_EXPORT_QUERY | + VIRGL_RENDERER_STRUCTURE_TYPE_SUPPORTED_STRUCTURES; + } else { + supported_structures->out_supported_structures_mask = 0; + } + + return 0; +} + +int vrend_renderer_execute(void *execute_args, uint32_t execute_size) +{ + struct virgl_renderer_hdr *hdr = execute_args; + if (hdr->stype_version != 0) + return -EINVAL; + + switch (hdr->stype) { + case VIRGL_RENDERER_STRUCTURE_TYPE_SUPPORTED_STRUCTURES: + return vrend_renderer_supported_structures(execute_args, execute_size); + case VIRGL_RENDERER_STRUCTURE_TYPE_EXPORT_QUERY: + return vrend_renderer_export_query(execute_args, execute_size); + default: + return -EINVAL; + } +}