diff --git a/config.h.meson b/config.h.meson index ce1c9a6..6f556de 100644 --- a/config.h.meson +++ b/config.h.meson @@ -7,3 +7,4 @@ #mesondefine HAVE_FUNC_ATTRIBUTE_VISIBILITY #mesondefine HAVE_EVENTFD_H #mesondefine HAVE_DLFCN_H +#mesondefine VIRGL_RENDERER_UNSTABLE_APIS diff --git a/meson.build b/meson.build index 6e253e5..373095f 100644 --- a/meson.build +++ b/meson.build @@ -147,6 +147,11 @@ if with_glx endif endif +with_unstable_apis = get_option('unstable_apis') +if with_unstable_apis + conf_data.set('VIRGL_RENDERER_UNSTABLE_APIS', 1) +endif + if cc.compiles('void __attribute__((hidden)) func() {}') conf_data.set('HAVE_FUNC_ATTRIBUTE_VISIBILITY', 1) endif @@ -198,6 +203,7 @@ lines += 'minigbm_alloc: ' + (with_minigbm_allocation ? 'yes' : 'no' ) lines += '' lines += 'tests: ' + (with_tests ? 'yes' : 'no' ) lines += 'fuzzer: ' + (with_fuzzer ? 'yes' : 'no' ) +lines += 'unstable apis: ' + (with_unstable_apis ? 'yes' : 'no' ) indent = ' ' summary = indent + ('\n' + indent).join(lines) diff --git a/meson_options.txt b/meson_options.txt index 9d7e5b5..96e6196 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -58,3 +58,10 @@ option( value : 'false', description : 'enable running unit tests with valgrind' ) + +option( + 'unstable_apis', + type : 'boolean', + value : 'false', + description : 'enable unstable apis' +) diff --git a/src/virglrenderer.c b/src/virglrenderer.c index 5223d16..1260a23 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -538,8 +538,10 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks if (flags & VIRGL_RENDERER_THREAD_SYNC) renderer_flags |= VREND_USE_THREAD_SYNC; +#ifdef VIRGL_RENDERER_UNSTABLE_APIS if (flags & VIRGL_RENDERER_USE_EXTERNAL_BLOB) renderer_flags |= VREND_USE_EXTERNAL_BLOB; +#endif /* VIRGL_RENDERER_UNSTABLE_APIS */ return vrend_renderer_init(&virgl_cbs, renderer_flags); } @@ -636,8 +638,11 @@ int virgl_renderer_execute(void *execute_args, uint32_t execute_size) } } +#ifdef VIRGL_RENDERER_UNSTABLE_APIS + int virgl_renderer_resource_create_blob(const struct virgl_renderer_resource_create_blob_args *args) { + int ret; uint32_t blob_mem = args->blob_mem; uint64_t blob_id = args->blob_id; @@ -705,3 +710,5 @@ int virgl_renderer_resource_get_map_info(uint32_t res_handle, uint32_t *map_info return vrend_renderer_resource_get_map_info(res->pipe_resource, map_info); } + +#endif /* VIRGL_RENDERER_UNSTABLE_APIS */ diff --git a/src/virglrenderer.h b/src/virglrenderer.h index 0061025..f8f99fb 100644 --- a/src/virglrenderer.h +++ b/src/virglrenderer.h @@ -69,6 +69,8 @@ struct virgl_renderer_callbacks { #define VIRGL_RENDERER_USE_GLX (1 << 2) #define VIRGL_RENDERER_USE_SURFACELESS (1 << 3) #define VIRGL_RENDERER_USE_GLES (1 << 4) + +#ifdef VIRGL_RENDERER_UNSTABLE_APIS /* * Blob resources used with the 3D driver must be able to be represented as file descriptors. * The typical use case is the virtual machine manager (or vtest) is running in a multiprocess @@ -80,6 +82,8 @@ struct virgl_renderer_callbacks { */ #define VIRGL_RENDERER_USE_EXTERNAL_BLOB (1 << 5) +#endif /* VIRGL_RENDERER_UNSTABLE_APIS */ + VIRGL_EXPORT int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cb); VIRGL_EXPORT void virgl_renderer_poll(void); /* force fences */ @@ -246,6 +250,12 @@ VIRGL_EXPORT int virgl_renderer_get_poll_fd(void); VIRGL_EXPORT int virgl_renderer_execute(void *execute_args, uint32_t execute_size); +/* + * These are unstable APIs for development only. Use these for development/testing purposes + * only, not in production + */ +#ifdef VIRGL_RENDERER_UNSTABLE_APIS + #define VIRGL_RENDERER_BLOB_MEM_GUEST 0x0001 #define VIRGL_RENDERER_BLOB_MEM_HOST3D 0x0002 #define VIRGL_RENDERER_BLOB_MEM_HOST3D_GUEST 0x0003 @@ -281,4 +291,6 @@ VIRGL_EXPORT int virgl_renderer_resource_unmap(uint32_t res_handle); VIRGL_EXPORT int virgl_renderer_resource_get_map_info(uint32_t res_handle, uint32_t *map_info); +#endif /* VIRGL_RENDERER_UNSTABLE_APIS */ + #endif