1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
/* automatically generated by rust-bindgen 0.68.1 */

#[cfg(feature = "virgl_renderer")]
#[link(name = "virglrenderer")]
extern "C" {}

pub const VIRGL_RENDERER_CALLBACKS_VERSION: u32 = 4;
pub const VIRGL_RENDERER_USE_EGL: u32 = 1;
pub const VIRGL_RENDERER_THREAD_SYNC: u32 = 2;
pub const VIRGL_RENDERER_USE_GLX: u32 = 4;
pub const VIRGL_RENDERER_USE_SURFACELESS: u32 = 8;
pub const VIRGL_RENDERER_USE_GLES: u32 = 16;
pub const VIRGL_RENDERER_USE_EXTERNAL_BLOB: u32 = 32;
pub const VIRGL_RENDERER_VENUS: u32 = 64;
pub const VIRGL_RENDERER_NO_VIRGL: u32 = 128;
pub const VIRGL_RENDERER_ASYNC_FENCE_CB: u32 = 256;
pub const VIRGL_RENDERER_RENDER_SERVER: u32 = 512;
pub const VIRGL_RENDERER_DRM: u32 = 1024;
pub const VIRGL_RENDERER_USE_VIDEO: u32 = 2048;
pub const VIRGL_RENDERER_D3D11_SHARE_TEXTURE: u32 = 4096;
pub const VIRGL_RENDERER_COMPAT_PROFILE: u32 = 8192;
pub const VIRGL_RES_BIND_DEPTH_STENCIL: u32 = 1;
pub const VIRGL_RES_BIND_RENDER_TARGET: u32 = 2;
pub const VIRGL_RES_BIND_SAMPLER_VIEW: u32 = 8;
pub const VIRGL_RES_BIND_VERTEX_BUFFER: u32 = 16;
pub const VIRGL_RES_BIND_INDEX_BUFFER: u32 = 32;
pub const VIRGL_RES_BIND_CONSTANT_BUFFER: u32 = 64;
pub const VIRGL_RES_BIND_STREAM_OUTPUT: u32 = 2048;
pub const VIRGL_RES_BIND_CURSOR: u32 = 65536;
pub const VIRGL_RES_BIND_CUSTOM: u32 = 131072;
pub const VIRGL_RES_BIND_SCANOUT: u32 = 262144;
pub const VIRGL_RES_BIND_SHARED: u32 = 1048576;
pub const VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION: u32 = 0;
pub const VIRGL_RENDERER_CONTEXT_FLAG_CAPSET_ID_MASK: u32 = 255;
pub const VIRGL_RENDERER_BLOB_MEM_GUEST: u32 = 1;
pub const VIRGL_RENDERER_BLOB_MEM_HOST3D: u32 = 2;
pub const VIRGL_RENDERER_BLOB_MEM_HOST3D_GUEST: u32 = 3;
pub const VIRGL_RENDERER_BLOB_MEM_GUEST_VRAM: u32 = 4;
pub const VIRGL_RENDERER_BLOB_FLAG_USE_MAPPABLE: u32 = 1;
pub const VIRGL_RENDERER_BLOB_FLAG_USE_SHAREABLE: u32 = 2;
pub const VIRGL_RENDERER_BLOB_FLAG_USE_CROSS_DEVICE: u32 = 4;
pub const VIRGL_RENDERER_BLOB_FLAG_USE_DUMB_BUFFER: u32 = 8;
pub const VIRGL_RENDERER_MAP_CACHE_MASK: u32 = 15;
pub const VIRGL_RENDERER_MAP_CACHE_NONE: u32 = 0;
pub const VIRGL_RENDERER_MAP_CACHE_CACHED: u32 = 1;
pub const VIRGL_RENDERER_MAP_CACHE_UNCACHED: u32 = 2;
pub const VIRGL_RENDERER_MAP_CACHE_WC: u32 = 3;
pub const VIRGL_RENDERER_BLOB_FD_TYPE_DMABUF: u32 = 1;
pub const VIRGL_RENDERER_BLOB_FD_TYPE_OPAQUE: u32 = 2;
pub const VIRGL_RENDERER_BLOB_FD_TYPE_SHM: u32 = 3;
pub const VIRGL_RENDERER_FENCE_FLAG_MERGEABLE: u32 = 1;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct virgl_box {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct iovec {
    _unused: [u8; 0],
}
pub type virgl_renderer_gl_context = *mut ::std::os::raw::c_void;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct virgl_renderer_gl_ctx_param {
    pub version: ::std::os::raw::c_int,
    pub shared: bool,
    pub major_ver: ::std::os::raw::c_int,
    pub minor_ver: ::std::os::raw::c_int,
    pub compat_ctx: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct virgl_renderer_callbacks {
    pub version: ::std::os::raw::c_int,
    pub write_fence: ::std::option::Option<
        unsafe extern "C" fn(cookie: *mut ::std::os::raw::c_void, fence: u32),
    >,
    pub create_gl_context: ::std::option::Option<
        unsafe extern "C" fn(
            cookie: *mut ::std::os::raw::c_void,
            scanout_idx: ::std::os::raw::c_int,
            param: *mut virgl_renderer_gl_ctx_param,
        ) -> virgl_renderer_gl_context,
    >,
    pub destroy_gl_context: ::std::option::Option<
        unsafe extern "C" fn(cookie: *mut ::std::os::raw::c_void, ctx: virgl_renderer_gl_context),
    >,
    pub make_current: ::std::option::Option<
        unsafe extern "C" fn(
            cookie: *mut ::std::os::raw::c_void,
            scanout_idx: ::std::os::raw::c_int,
            ctx: virgl_renderer_gl_context,
        ) -> ::std::os::raw::c_int,
    >,
    pub get_drm_fd: ::std::option::Option<
        unsafe extern "C" fn(cookie: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
    >,
    pub write_context_fence: ::std::option::Option<
        unsafe extern "C" fn(
            cookie: *mut ::std::os::raw::c_void,
            ctx_id: u32,
            ring_idx: u32,
            fence_id: u64,
        ),
    >,
    pub get_server_fd: ::std::option::Option<
        unsafe extern "C" fn(
            cookie: *mut ::std::os::raw::c_void,
            version: u32,
        ) -> ::std::os::raw::c_int,
    >,
    pub get_egl_display: ::std::option::Option<
        unsafe extern "C" fn(cookie: *mut ::std::os::raw::c_void) -> *mut ::std::os::raw::c_void,
    >,
}
extern "C" {
    pub fn virgl_renderer_init(
        cookie: *mut ::std::os::raw::c_void,
        flags: ::std::os::raw::c_int,
        cb: *mut virgl_renderer_callbacks,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_poll();
}
extern "C" {
    pub fn virgl_renderer_get_cursor_data(
        resource_id: u32,
        width: *mut u32,
        height: *mut u32,
    ) -> *mut ::std::os::raw::c_void;
}
extern "C" {
    pub fn virgl_renderer_get_rect(
        resource_id: ::std::os::raw::c_int,
        iov: *mut iovec,
        num_iovs: ::std::os::raw::c_uint,
        offset: u32,
        x: ::std::os::raw::c_int,
        y: ::std::os::raw::c_int,
        width: ::std::os::raw::c_int,
        height: ::std::os::raw::c_int,
    );
}
extern "C" {
    pub fn virgl_renderer_get_fd_for_texture(
        tex_id: u32,
        fd: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_get_fd_for_texture2(
        tex_id: u32,
        fd: *mut ::std::os::raw::c_int,
        stride: *mut ::std::os::raw::c_int,
        offset: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
pub const VIRGL_RENDERER_STRUCTURE_TYPE_NONE: virgl_renderer_structure_type_v0 = 0;
pub const VIRGL_RENDERER_STRUCTURE_TYPE_EXPORT_QUERY: virgl_renderer_structure_type_v0 = 1;
pub const VIRGL_RENDERER_STRUCTURE_TYPE_SUPPORTED_STRUCTURES: virgl_renderer_structure_type_v0 = 2;
pub type virgl_renderer_structure_type_v0 = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct virgl_renderer_resource_create_args {
    pub handle: u32,
    pub target: u32,
    pub format: u32,
    pub bind: u32,
    pub width: u32,
    pub height: u32,
    pub depth: u32,
    pub array_size: u32,
    pub last_level: u32,
    pub nr_samples: u32,
    pub flags: u32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct virgl_renderer_hdr {
    pub stype: u32,
    pub stype_version: u32,
    pub size: u32,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct virgl_renderer_export_query {
    pub hdr: virgl_renderer_hdr,
    pub in_resource_id: u32,
    pub out_num_fds: u32,
    pub in_export_fds: u32,
    pub out_fourcc: u32,
    pub pad: u32,
    pub out_fds: [i32; 4usize],
    pub out_strides: [u32; 4usize],
    pub out_offsets: [u32; 4usize],
    pub out_modifier: u64,
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct virgl_renderer_supported_structures {
    pub hdr: virgl_renderer_hdr,
    pub in_stype_version: u32,
    pub out_supported_structures_mask: u32,
}
pub const VIRGL_LOG_LEVEL_DEBUG: virgl_log_level_flags = 0;
pub const VIRGL_LOG_LEVEL_INFO: virgl_log_level_flags = 1;
pub const VIRGL_LOG_LEVEL_WARNING: virgl_log_level_flags = 2;
pub const VIRGL_LOG_LEVEL_ERROR: virgl_log_level_flags = 3;
pub const VIRGL_LOG_LEVEL_SILENT: virgl_log_level_flags = 4;
pub type virgl_log_level_flags = ::std::os::raw::c_uint;
pub type virgl_free_data_callback_type =
    ::std::option::Option<unsafe extern "C" fn(user_data: *mut ::std::os::raw::c_void)>;
pub type virgl_log_callback_type = ::std::option::Option<
    unsafe extern "C" fn(
        log_level: virgl_log_level_flags,
        message: *const ::std::os::raw::c_char,
        user_data: *mut ::std::os::raw::c_void,
    ),
>;
extern "C" {
    pub fn virgl_renderer_resource_create(
        args: *mut virgl_renderer_resource_create_args,
        iov: *mut iovec,
        num_iovs: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_resource_import_eglimage(
        args: *mut virgl_renderer_resource_create_args,
        image: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_resource_unref(res_handle: u32);
}
extern "C" {
    pub fn virgl_renderer_resource_set_priv(res_handle: u32, priv_: *mut ::std::os::raw::c_void);
}
extern "C" {
    pub fn virgl_renderer_resource_get_priv(res_handle: u32) -> *mut ::std::os::raw::c_void;
}
extern "C" {
    pub fn virgl_renderer_context_create(
        handle: u32,
        nlen: u32,
        name: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_context_destroy(handle: u32);
}
extern "C" {
    pub fn virgl_renderer_submit_cmd(
        buffer: *mut ::std::os::raw::c_void,
        ctx_id: ::std::os::raw::c_int,
        ndw: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_transfer_read_iov(
        handle: u32,
        ctx_id: u32,
        level: u32,
        stride: u32,
        layer_stride: u32,
        box_: *mut virgl_box,
        offset: u64,
        iov: *mut iovec,
        iovec_cnt: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_transfer_write_iov(
        handle: u32,
        ctx_id: u32,
        level: ::std::os::raw::c_int,
        stride: u32,
        layer_stride: u32,
        box_: *mut virgl_box,
        offset: u64,
        iovec: *mut iovec,
        iovec_cnt: ::std::os::raw::c_uint,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_get_cap_set(set: u32, max_ver: *mut u32, max_size: *mut u32);
}
extern "C" {
    pub fn virgl_renderer_fill_caps(set: u32, version: u32, caps: *mut ::std::os::raw::c_void);
}
extern "C" {
    pub fn virgl_renderer_resource_attach_iov(
        res_handle: ::std::os::raw::c_int,
        iov: *mut iovec,
        num_iovs: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_resource_detach_iov(
        res_handle: ::std::os::raw::c_int,
        iov: *mut *mut iovec,
        num_iovs: *mut ::std::os::raw::c_int,
    );
}
extern "C" {
    pub fn virgl_renderer_create_fence(
        client_fence_id: ::std::os::raw::c_int,
        ctx_id: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_force_ctx_0();
}
extern "C" {
    pub fn virgl_renderer_ctx_attach_resource(
        ctx_id: ::std::os::raw::c_int,
        res_handle: ::std::os::raw::c_int,
    );
}
extern "C" {
    pub fn virgl_renderer_ctx_detach_resource(
        ctx_id: ::std::os::raw::c_int,
        res_handle: ::std::os::raw::c_int,
    );
}
extern "C" {
    pub fn virgl_set_log_callback(
        cb: virgl_log_callback_type,
        user_data: *mut ::std::os::raw::c_void,
        free_user_data_cb: virgl_free_data_callback_type,
    );
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct virgl_renderer_resource_info {
    pub handle: u32,
    pub virgl_format: u32,
    pub width: u32,
    pub height: u32,
    pub depth: u32,
    pub flags: u32,
    pub tex_id: u32,
    pub stride: u32,
    pub drm_fourcc: ::std::os::raw::c_int,
    pub fd: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct virgl_renderer_resource_info_ext {
    pub version: ::std::os::raw::c_int,
    pub base: virgl_renderer_resource_info,
    pub has_dmabuf_export: bool,
    pub planes: ::std::os::raw::c_int,
    pub modifiers: u64,
    pub d3d_tex2d: *mut ::std::os::raw::c_void,
}
impl Default for virgl_renderer_resource_info_ext {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        // TODO(b/315870313): Add safety comment
        #[allow(clippy::undocumented_unsafe_blocks)]
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn virgl_renderer_resource_get_info(
        res_handle: ::std::os::raw::c_int,
        info: *mut virgl_renderer_resource_info,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_resource_get_info_ext(
        res_handle: ::std::os::raw::c_int,
        info: *mut virgl_renderer_resource_info_ext,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_cleanup(cookie: *mut ::std::os::raw::c_void);
}
extern "C" {
    pub fn virgl_renderer_reset();
}
extern "C" {
    pub fn virgl_renderer_get_poll_fd() -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_execute(
        execute_args: *mut ::std::os::raw::c_void,
        execute_size: u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_context_create_with_flags(
        ctx_id: u32,
        ctx_flags: u32,
        nlen: u32,
        name: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct virgl_renderer_resource_create_blob_args {
    pub res_handle: u32,
    pub ctx_id: u32,
    pub blob_mem: u32,
    pub blob_flags: u32,
    pub blob_id: u64,
    pub size: u64,
    pub iovecs: *const iovec,
    pub num_iovs: u32,
}
impl Default for virgl_renderer_resource_create_blob_args {
    fn default() -> Self {
        let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
        // TODO(b/315870313): Add safety comment
        #[allow(clippy::undocumented_unsafe_blocks)]
        unsafe {
            ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
            s.assume_init()
        }
    }
}
extern "C" {
    pub fn virgl_renderer_resource_create_blob(
        args: *const virgl_renderer_resource_create_blob_args,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_resource_map(
        res_handle: u32,
        map: *mut *mut ::std::os::raw::c_void,
        out_size: *mut u64,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_resource_unmap(res_handle: u32) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_resource_get_map_info(
        res_handle: u32,
        map_info: *mut u32,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_resource_export_blob(
        res_id: u32,
        fd_type: *mut u32,
        fd: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct virgl_renderer_resource_import_blob_args {
    pub res_handle: u32,
    pub blob_mem: u32,
    pub fd_type: u32,
    pub fd: ::std::os::raw::c_int,
    pub size: u64,
}
extern "C" {
    pub fn virgl_renderer_resource_import_blob(
        args: *const virgl_renderer_resource_import_blob_args,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_context_create_fence(
        ctx_id: u32,
        flags: u32,
        ring_idx: u32,
        fence_id: u64,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_export_fence(
        client_fence_id: u64,
        fd: *mut ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_export_signalled_fence() -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_context_poll(ctx_id: u32);
}
extern "C" {
    pub fn virgl_renderer_context_get_poll_fd(ctx_id: u32) -> ::std::os::raw::c_int;
}
extern "C" {
    pub fn virgl_renderer_submit_cmd2(
        buffer: *mut ::std::os::raw::c_void,
        ctx_id: ::std::os::raw::c_int,
        ndw: ::std::os::raw::c_int,
        in_fence_ids: *mut u64,
        num_in_fences: u32,
    ) -> ::std::os::raw::c_int;
}