1 #ifndef VIRTGPU_GFXSTREAM_RENDERER_UNSTABLE_H 2 #define VIRTGPU_GFXSTREAM_RENDERER_UNSTABLE_H 3 4 #include "gfxstream/virtio-gpu-gfxstream-renderer.h" 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 // Enables the host to control which memory types the guest will be allowed to map. For types not 11 // in the mask, the bits HOST_VISIBLE and HOST_COHERENT will be removed. 12 #define STREAM_RENDERER_PARAM_HOST_VISIBLE_MEMORY_MASK 8 13 14 // Skip android opengles initiation. Used by aemu to skip android opengles initiation. 15 // aemu does its own initialization in qemu/android/android/android-emu/android/opengles.cpp. 16 // TODO(joshuaduong): Migrate aemu to use stream_renderer_init without this hack. This will 17 // require adding more options to customize the feature flags, etc. 18 #define STREAM_RENDERER_SKIP_OPENGLES_INIT 10 19 20 // Information about one device's memory mask. 21 struct stream_renderer_param_host_visible_memory_mask_entry { 22 // Which device the mask applies to. 23 struct stream_renderer_device_id device_id; 24 // Memory types allowed to be host visible are 1, otherwise 0. 25 uint32_t memory_type_mask; 26 }; 27 28 // Information about the devices in the system with host visible memory type constraints. 29 struct stream_renderer_param_host_visible_memory_mask { 30 // Points to a stream_renderer_param_host_visible_memory_mask_entry array. 31 uint64_t entries; 32 // Length of the entries array. 33 uint64_t num_entries; 34 }; 35 36 // Enables the host to control which GPU is used for rendering. 37 #define STREAM_RENDERER_PARAM_RENDERING_GPU 9 38 39 // External callbacks for tracking metrics. 40 // Separating each function to a parameter allows new functions to be added later. 41 #define STREAM_RENDERER_PARAM_METRICS_CALLBACK_ADD_INSTANT_EVENT 1024 42 typedef void (*stream_renderer_param_metrics_callback_add_instant_event)(int64_t event_code); 43 44 #define STREAM_RENDERER_PARAM_METRICS_CALLBACK_ADD_INSTANT_EVENT_WITH_DESCRIPTOR 1025 45 typedef void (*stream_renderer_param_metrics_callback_add_instant_event_with_descriptor)( 46 int64_t event_code, int64_t descriptor); 47 48 #define STREAM_RENDERER_PARAM_METRICS_CALLBACK_ADD_INSTANT_EVENT_WITH_METRIC 1026 49 typedef void (*stream_renderer_param_metrics_callback_add_instant_event_with_metric)( 50 int64_t event_code, int64_t metric_value); 51 52 #define STREAM_RENDERER_PARAM_METRICS_CALLBACK_ADD_VULKAN_OUT_OF_MEMORY_EVENT 1027 53 typedef void (*stream_renderer_param_metrics_callback_add_vulkan_out_of_memory_event)( 54 int64_t result_code, uint32_t op_code, const char* function, uint32_t line, 55 uint64_t allocation_size, bool is_host_side_result, bool is_allocation); 56 57 // STREAM_RENDERER_PARAM_RENDERER_FEATURES: stream_renderer_param::value is a pointer to a null 58 // terminated string of the form "<feature1 name>:[enabled|disabled],<feature 2 ...>". 59 #define STREAM_RENDERER_PARAM_RENDERER_FEATURES 11 60 61 #define STREAM_RENDERER_PARAM_METRICS_CALLBACK_SET_ANNOTATION 1028 62 typedef void (*stream_renderer_param_metrics_callback_set_annotation)(const char* key, 63 const char* value); 64 65 #define STREAM_RENDERER_PARAM_METRICS_CALLBACK_ABORT 1029 66 typedef void (*stream_renderer_param_metrics_callback_abort)(); 67 68 VG_EXPORT void gfxstream_backend_setup_window(void* native_window_handle, int32_t window_x, 69 int32_t window_y, int32_t window_width, 70 int32_t window_height, int32_t fb_width, 71 int32_t fb_height); 72 73 VG_EXPORT void stream_renderer_flush(uint32_t res_handle); 74 75 // Platform resources and contexts support 76 #define STREAM_RENDERER_PLATFORM_RESOURCE_USE_MASK 0xF0 77 #define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_MASK 0x0F 78 79 // types 80 #define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_EGL_NATIVE_PIXMAP 0x01 81 #define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_EGL_IMAGE 0x02 82 #define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_VK_EXT_MEMORY_HANDLE 0x03 83 84 // uses 85 #define STREAM_RENDERER_PLATFORM_RESOURCE_USE_PRESERVE 0x10 86 87 VG_EXPORT int stream_renderer_platform_import_resource(int res_handle, int res_info, 88 void* resource); 89 VG_EXPORT int stream_renderer_platform_resource_info(int res_handle, int* width, int* height, 90 int* internal_format); 91 VG_EXPORT void* stream_renderer_platform_create_shared_egl_context(void); 92 VG_EXPORT int stream_renderer_platform_destroy_shared_egl_context(void*); 93 94 struct stream_renderer_resource_info { 95 uint32_t handle; 96 uint32_t virgl_format; 97 uint32_t width; 98 uint32_t height; 99 uint32_t depth; 100 uint32_t flags; 101 uint32_t tex_id; 102 uint32_t stride; 103 int drm_fourcc; 104 }; 105 106 VG_EXPORT int stream_renderer_resource_get_info(int res_handle, 107 struct stream_renderer_resource_info* info); 108 109 VG_EXPORT int stream_renderer_snapshot(const char* dir); 110 111 VG_EXPORT int stream_renderer_restore(const char* dir); 112 113 #ifdef __cplusplus 114 } // extern "C" 115 #endif 116 117 #endif 118