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 #define STREAM_RENDERER_PARAM_METRICS_CALLBACK_SET_ANNOTATION 1028 58 typedef void (*stream_renderer_param_metrics_callback_set_annotation)(const char* key, 59 const char* value); 60 61 #define STREAM_RENDERER_PARAM_METRICS_CALLBACK_ABORT 1029 62 typedef void (*stream_renderer_param_metrics_callback_abort)(); 63 64 VG_EXPORT void gfxstream_backend_setup_window(void* native_window_handle, int32_t window_x, 65 int32_t window_y, int32_t window_width, 66 int32_t window_height, int32_t fb_width, 67 int32_t fb_height); 68 69 VG_EXPORT void stream_renderer_flush(uint32_t res_handle); 70 71 // Platform resources and contexts support 72 #define STREAM_RENDERER_PLATFORM_RESOURCE_USE_MASK 0xF0 73 #define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_MASK 0x0F 74 75 // types 76 #define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_EGL_NATIVE_PIXMAP 0x01 77 #define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_EGL_IMAGE 0x02 78 #define STREAM_RENDERER_PLATFORM_RESOURCE_TYPE_VK_EXT_MEMORY_HANDLE 0x03 79 80 // uses 81 #define STREAM_RENDERER_PLATFORM_RESOURCE_USE_PRESERVE 0x10 82 83 VG_EXPORT int stream_renderer_platform_import_resource(int res_handle, int res_info, 84 void* resource); 85 VG_EXPORT int stream_renderer_platform_resource_info(int res_handle, int* width, int* height, 86 int* internal_format); 87 VG_EXPORT void* stream_renderer_platform_create_shared_egl_context(void); 88 VG_EXPORT int stream_renderer_platform_destroy_shared_egl_context(void*); 89 90 struct stream_renderer_resource_info { 91 uint32_t handle; 92 uint32_t virgl_format; 93 uint32_t width; 94 uint32_t height; 95 uint32_t depth; 96 uint32_t flags; 97 uint32_t tex_id; 98 uint32_t stride; 99 int drm_fourcc; 100 }; 101 102 VG_EXPORT int stream_renderer_resource_get_info(int res_handle, 103 struct stream_renderer_resource_info* info); 104 105 #ifdef __cplusplus 106 } // extern "C" 107 #endif 108 109 #endif 110