euv_core/platform/linux/struct.rs
1use super::*;
2
3/// Cached `libX11.so.6` function pointer table resolved once per process.
4#[derive(Clone, Copy, Debug, Default)]
5pub(crate) struct LinuxX11Syms {
6 /// Handle returned by `dlopen("libX11.so.6")`.
7 pub(crate) lib: usize,
8 /// `XOpenDisplay` symbol address.
9 pub(crate) open_display: usize,
10 /// `XDefaultScreen` symbol address.
11 pub(crate) default_screen: usize,
12 /// `XRootWindow` symbol address.
13 pub(crate) root_window: usize,
14 /// `XCreateSimpleWindow` symbol address.
15 pub(crate) create_simple_window: usize,
16 /// `XStoreName` symbol address.
17 pub(crate) store_name: usize,
18 /// `XMapWindow` symbol address.
19 pub(crate) map_window: usize,
20 /// `XResizeWindow` symbol address.
21 pub(crate) resize_window: usize,
22 /// `XDestroyWindow` symbol address.
23 pub(crate) destroy_window: usize,
24 /// `XFlush` symbol address.
25 pub(crate) flush: usize,
26 /// `XDefaultGC` symbol address.
27 pub(crate) default_gc: usize,
28 /// `XDefaultVisual` symbol address.
29 pub(crate) default_visual: usize,
30 /// `XDefaultDepth` symbol address.
31 pub(crate) default_depth: usize,
32 /// `XCreateImage` symbol address.
33 pub(crate) create_image: usize,
34 /// `XPutImage` symbol address.
35 pub(crate) put_image: usize,
36 /// `XFree` symbol address.
37 pub(crate) free: usize,
38 /// `XSelectInput` symbol address.
39 pub(crate) select_input: usize,
40 /// `XInternAtom` symbol address.
41 pub(crate) intern_atom: usize,
42 /// `XSetWMProtocols` symbol address.
43 pub(crate) set_wm_protocols: usize,
44 /// `XPending` symbol address.
45 pub(crate) pending: usize,
46 /// `XNextEvent` symbol address.
47 pub(crate) next_event: usize,
48 /// `XLookupString` symbol address.
49 pub(crate) lookup_string: usize,
50 /// `XResourceManagerString` symbol address.
51 pub(crate) resource_manager_string: usize,
52 /// `XConnectionNumber` symbol address returning the display socket fd for `poll()`.
53 pub(crate) connection_number: usize,
54}
55
56/// Cached `libXrandr.so.2` function pointer table resolved once per process.
57#[derive(Clone, Copy, Debug, Default)]
58pub(crate) struct LinuxXRandrSyms {
59 /// `XRRGetScreenInfo` symbol address.
60 pub(crate) get_screen_info: usize,
61 /// `XRRConfigCurrentRate` symbol address.
62 pub(crate) config_current_rate: usize,
63 /// `XRRFreeScreenConfigInfo` symbol address.
64 pub(crate) free_screen_config_info: usize,
65}
66
67/// Cached `libXext.so.6` MIT-SHM function pointer table resolved once per process.
68#[derive(Clone, Copy, Debug, Default)]
69pub(crate) struct LinuxXShmSyms {
70 /// `XShmQueryExtension` symbol address.
71 pub(crate) query_extension: usize,
72 /// `XShmCreateImage` symbol address.
73 pub(crate) create_image: usize,
74 /// `XShmAttach` symbol address.
75 pub(crate) attach: usize,
76 /// `XShmDetach` symbol address.
77 pub(crate) detach: usize,
78 /// `XShmPutImage` symbol address.
79 pub(crate) put_image: usize,
80}
81
82/// Cached `libwayland-client.so.0` + Vulkan WSI symbol table resolved once per process.
83#[derive(Clone, Copy, Debug, Default)]
84pub(crate) struct LinuxWaylandSyms {
85 /// Handle returned by `dlopen("libwayland-client.so.0")`.
86 pub(crate) lib: usize,
87 /// `wl_display_connect` symbol address.
88 pub(crate) display_connect: usize,
89 /// `wl_display_disconnect` symbol address.
90 pub(crate) display_disconnect: usize,
91 /// `wl_display_dispatch_pending` symbol address.
92 pub(crate) display_dispatch_pending: usize,
93 /// `wl_display_dispatch` symbol address.
94 pub(crate) display_dispatch: usize,
95 /// `wl_display_flush` symbol address.
96 pub(crate) display_flush: usize,
97 /// `wl_display_roundtrip` symbol address.
98 pub(crate) display_roundtrip: usize,
99 /// `wl_display_get_error` symbol address.
100 pub(crate) display_get_error: usize,
101 /// `wl_display_get_fd` symbol address for blocking `poll()`.
102 pub(crate) display_get_fd: usize,
103 /// `wl_display_prepare_read` symbol address for race-free Wayland `poll()`.
104 pub(crate) display_prepare_read: usize,
105 /// `wl_display_read_events` symbol address for draining events after `poll()`.
106 pub(crate) display_read_events: usize,
107 /// `wl_display_cancel_read` symbol address canceling a prepared read on wakeup pipe signal.
108 pub(crate) display_cancel_read: usize,
109 /// `wl_proxy_marshal_flags` symbol address.
110 pub(crate) proxy_marshal_flags: usize,
111 /// `wl_proxy_add_listener` symbol address.
112 pub(crate) proxy_add_listener: usize,
113 /// `wl_proxy_destroy` symbol address.
114 pub(crate) proxy_destroy: usize,
115 /// `wl_proxy_get_version` symbol address.
116 pub(crate) proxy_get_version: usize,
117 /// Exported `wl_registry_interface` pointer address.
118 pub(crate) registry_interface: usize,
119 /// Exported `wl_compositor_interface` pointer address.
120 pub(crate) compositor_interface: usize,
121 /// Exported `wl_surface_interface` pointer address.
122 pub(crate) surface_interface: usize,
123 /// Exported `wl_shm_interface` pointer address.
124 pub(crate) shm_interface: usize,
125 /// Exported `wl_shm_pool_interface` pointer address.
126 pub(crate) shm_pool_interface: usize,
127 /// Exported `wl_buffer_interface` pointer address.
128 pub(crate) buffer_interface: usize,
129 /// Exported `wl_callback_interface` pointer address for `wl_surface.frame` VSync pacing.
130 pub(crate) callback_interface: usize,
131 /// True when `vkCreateWaylandSurfaceKHR` is available in `libvulkan.so.1`.
132 pub(crate) vulkan_wsi_available: bool,
133 /// True when `vkCreateXlibSurfaceKHR` is available in `libvulkan.so.1`.
134 pub(crate) xlib_vulkan_wsi_available: bool,
135}
136
137/// POSIX `struct pollfd` ABI layout for blocking `poll(display_fd, wakeup_pipe)`.
138#[repr(C)]
139#[derive(Clone, Copy, Debug, Default)]
140pub(crate) struct LinuxPollFd {
141 /// Target file descriptor.
142 pub(crate) fd: i32,
143 /// Requested event bitmask (`LINUX_POLLIN`).
144 pub(crate) events: i16,
145 /// Returned event bitmask populated by kernel `poll()`.
146 pub(crate) revents: i16,
147}
148
149/// Raw `wl_callback_listener` ABI table tracking `wl_surface.frame` VSync completion.
150#[repr(C)]
151#[derive(Clone, Copy)]
152pub(crate) struct WlCallbackListener {
153 /// Callback invoked on compositor VBlank (`(data, callback, callback_data)`).
154 pub(crate) done: unsafe extern "C" fn(*mut c_void, *mut c_void, u32),
155}
156
157/// Cached `libEGL.so.1`, `libGLESv2.so.2`, and `libwayland-egl.so.1` symbol table resolved once per process.
158#[derive(Clone, Copy, Data, Debug, Default)]
159pub(crate) struct LinuxEglGlesSyms {
160 /// True when core EGL and GLES3 instanced symbols resolved cleanly.
161 #[get(type(copy))]
162 pub(crate) ready: bool,
163 /// True when `libwayland-egl.so.1` resolved cleanly.
164 #[get(type(copy))]
165 pub(crate) wayland_egl_ready: bool,
166 /// `eglGetDisplay` address.
167 #[get(type(copy))]
168 pub(crate) egl_get_display: usize,
169 /// `eglInitialize` address.
170 #[get(type(copy))]
171 pub(crate) egl_initialize: usize,
172 /// `eglBindAPI` address.
173 #[get(type(copy))]
174 pub(crate) egl_bind_api: usize,
175 /// `eglChooseConfig` address.
176 #[get(type(copy))]
177 pub(crate) egl_choose_config: usize,
178 /// `eglCreateContext` address.
179 #[get(type(copy))]
180 pub(crate) egl_create_context: usize,
181 /// `eglCreateWindowSurface` address.
182 #[get(type(copy))]
183 pub(crate) egl_create_window_surface: usize,
184 /// `eglMakeCurrent` address.
185 #[get(type(copy))]
186 pub(crate) egl_make_current: usize,
187 /// `eglSwapInterval` address.
188 #[get(type(copy))]
189 pub(crate) egl_swap_interval: usize,
190 /// `eglSwapBuffers` address.
191 #[get(type(copy))]
192 pub(crate) egl_swap_buffers: usize,
193 /// `eglDestroySurface` address.
194 #[get(type(copy))]
195 pub(crate) egl_destroy_surface: usize,
196 /// `eglDestroyContext` address.
197 #[get(type(copy))]
198 pub(crate) egl_destroy_context: usize,
199 /// `eglTerminate` address.
200 #[get(type(copy))]
201 pub(crate) egl_terminate: usize,
202 /// `wl_egl_window_create` address.
203 #[get(type(copy))]
204 pub(crate) wl_egl_window_create: usize,
205 /// `wl_egl_window_resize` address.
206 #[get(type(copy))]
207 pub(crate) wl_egl_window_resize: usize,
208 /// `wl_egl_window_destroy` address.
209 #[get(type(copy))]
210 pub(crate) wl_egl_window_destroy: usize,
211 /// `glCreateShader` address.
212 #[get(type(copy))]
213 pub(crate) gl_create_shader: usize,
214 /// `glShaderSource` address.
215 #[get(type(copy))]
216 pub(crate) gl_shader_source: usize,
217 /// `glCompileShader` address.
218 #[get(type(copy))]
219 pub(crate) gl_compile_shader: usize,
220 /// `glGetShaderiv` address.
221 #[get(type(copy))]
222 pub(crate) gl_get_shaderiv: usize,
223 /// `glDeleteShader` address.
224 #[get(type(copy))]
225 pub(crate) gl_delete_shader: usize,
226 /// `glCreateProgram` address.
227 #[get(type(copy))]
228 pub(crate) gl_create_program: usize,
229 /// `glAttachShader` address.
230 #[get(type(copy))]
231 pub(crate) gl_attach_shader: usize,
232 /// `glLinkProgram` address.
233 #[get(type(copy))]
234 pub(crate) gl_link_program: usize,
235 /// `glGetProgramiv` address.
236 #[get(type(copy))]
237 pub(crate) gl_get_programiv: usize,
238 /// `glDeleteProgram` address.
239 #[get(type(copy))]
240 pub(crate) gl_delete_program: usize,
241 /// `glUseProgram` address.
242 #[get(type(copy))]
243 pub(crate) gl_use_program: usize,
244 /// `glGetUniformLocation` address.
245 #[get(type(copy))]
246 pub(crate) gl_get_uniform_location: usize,
247 /// `glUniform1i` address.
248 #[get(type(copy))]
249 pub(crate) gl_uniform1i: usize,
250 /// `glUniform1f` address.
251 #[get(type(copy))]
252 pub(crate) gl_uniform1f: usize,
253 /// `glUniform2f` address.
254 #[get(type(copy))]
255 pub(crate) gl_uniform2f: usize,
256 /// `glGenVertexArrays` address.
257 #[get(type(copy))]
258 pub(crate) gl_gen_vertex_arrays: usize,
259 /// `glBindVertexArray` address.
260 #[get(type(copy))]
261 pub(crate) gl_bind_vertex_array: usize,
262 /// `glDeleteVertexArrays` address.
263 #[get(type(copy))]
264 pub(crate) gl_delete_vertex_arrays: usize,
265 /// `glGenBuffers` address.
266 #[get(type(copy))]
267 pub(crate) gl_gen_buffers: usize,
268 /// `glBindBuffer` address.
269 #[get(type(copy))]
270 pub(crate) gl_bind_buffer: usize,
271 /// `glBufferData` address.
272 #[get(type(copy))]
273 pub(crate) gl_buffer_data: usize,
274 /// `glBufferSubData` address.
275 #[get(type(copy))]
276 pub(crate) gl_buffer_sub_data: usize,
277 /// `glDeleteBuffers` address.
278 #[get(type(copy))]
279 pub(crate) gl_delete_buffers: usize,
280 /// `glEnableVertexAttribArray` address.
281 #[get(type(copy))]
282 pub(crate) gl_enable_vertex_attrib_array: usize,
283 /// `glVertexAttribPointer` address.
284 #[get(type(copy))]
285 pub(crate) gl_vertex_attrib_pointer: usize,
286 /// `glVertexAttribIPointer` address.
287 #[get(type(copy))]
288 pub(crate) gl_vertex_attrib_ipointer: usize,
289 /// `glVertexAttribDivisor` address.
290 #[get(type(copy))]
291 pub(crate) gl_vertex_attrib_divisor: usize,
292 /// `glGenTextures` address.
293 #[get(type(copy))]
294 pub(crate) gl_gen_textures: usize,
295 /// `glBindTexture` address.
296 #[get(type(copy))]
297 pub(crate) gl_bind_texture: usize,
298 /// `glTexParameteri` address.
299 #[get(type(copy))]
300 pub(crate) gl_tex_parameteri: usize,
301 /// `glTexStorage2D` address.
302 #[get(type(copy))]
303 pub(crate) gl_tex_storage_2d: usize,
304 /// `glTexImage2D` address.
305 #[get(type(copy))]
306 pub(crate) gl_tex_image_2d: usize,
307 /// `glTexSubImage2D` address.
308 #[get(type(copy))]
309 pub(crate) gl_tex_sub_image_2d: usize,
310 /// `glDeleteTextures` address.
311 #[get(type(copy))]
312 pub(crate) gl_delete_textures: usize,
313 /// `glActiveTexture` address.
314 #[get(type(copy))]
315 pub(crate) gl_active_texture: usize,
316 /// `glPixelStorei` address.
317 #[get(type(copy))]
318 pub(crate) gl_pixel_storei: usize,
319 /// `glViewport` address.
320 #[get(type(copy))]
321 pub(crate) gl_viewport: usize,
322 /// `glEnable` address.
323 #[get(type(copy))]
324 pub(crate) gl_enable: usize,
325 /// `glDisable` address.
326 #[get(type(copy))]
327 pub(crate) gl_disable: usize,
328 /// `glBlendFuncSeparate` address.
329 #[get(type(copy))]
330 pub(crate) gl_blend_func_separate: usize,
331 /// `glScissor` address.
332 #[get(type(copy))]
333 pub(crate) gl_scissor: usize,
334 /// `glClearColor` address.
335 #[get(type(copy))]
336 pub(crate) gl_clear_color: usize,
337 /// `glClear` address.
338 #[get(type(copy))]
339 pub(crate) gl_clear: usize,
340 /// `glDrawArraysInstanced` address.
341 #[get(type(copy))]
342 pub(crate) gl_draw_arrays_instanced: usize,
343 /// `glDrawArrays` address.
344 #[get(type(copy))]
345 pub(crate) gl_draw_arrays: usize,
346 /// `glUniform4f` address.
347 #[get(type(copy))]
348 pub(crate) gl_uniform4f: usize,
349 /// `glUniformMatrix4fv` address.
350 #[get(type(copy))]
351 pub(crate) gl_uniform_matrix4fv: usize,
352 /// `glGetIntegerv` address.
353 #[get(type(copy))]
354 pub(crate) gl_get_integerv: usize,
355 /// `glGenFramebuffers` address.
356 #[get(type(copy))]
357 pub(crate) gl_gen_framebuffers: usize,
358 /// `glBindFramebuffer` address.
359 #[get(type(copy))]
360 pub(crate) gl_bind_framebuffer: usize,
361 /// `glFramebufferTexture2D` address.
362 #[get(type(copy))]
363 pub(crate) gl_framebuffer_texture_2d: usize,
364 /// `glDeleteFramebuffers` address.
365 #[get(type(copy))]
366 pub(crate) gl_delete_framebuffers: usize,
367 /// `glGenRenderbuffers` address.
368 #[get(type(copy))]
369 pub(crate) gl_gen_renderbuffers: usize,
370 /// `glBindRenderbuffer` address.
371 #[get(type(copy))]
372 pub(crate) gl_bind_renderbuffer: usize,
373 /// `glRenderbufferStorage` address.
374 #[get(type(copy))]
375 pub(crate) gl_renderbuffer_storage: usize,
376 /// `glFramebufferRenderbuffer` address.
377 #[get(type(copy))]
378 pub(crate) gl_framebuffer_renderbuffer: usize,
379 /// `glDeleteRenderbuffers` address.
380 #[get(type(copy))]
381 pub(crate) gl_delete_renderbuffers: usize,
382 /// `glDepthMask` address.
383 #[get(type(copy))]
384 pub(crate) gl_depth_mask: usize,
385 /// `glDepthFunc` address.
386 #[get(type(copy))]
387 pub(crate) gl_depth_func: usize,
388 /// `glClearDepthf` address.
389 #[get(type(copy))]
390 pub(crate) gl_clear_depthf: usize,
391 /// `glDrawElementsInstanced` address.
392 #[get(type(copy))]
393 pub(crate) gl_draw_elements_instanced: usize,
394 /// `glUniform4i` address.
395 #[get(type(copy))]
396 pub(crate) gl_uniform4i: usize,
397 /// `glUniform4fv` address.
398 #[get(type(copy))]
399 pub(crate) gl_uniform4fv: usize,
400 /// `glDisableVertexAttribArray` address.
401 #[get(type(copy))]
402 pub(crate) gl_disable_vertex_attrib_array: usize,
403 /// `glVertexAttribI4ui` address.
404 #[get(type(copy))]
405 pub(crate) gl_vertex_attrib_i4ui: usize,
406 /// `glVertexAttrib4f` address.
407 #[get(type(copy))]
408 pub(crate) gl_vertex_attrib_4f: usize,
409 /// `glProgramParameteri` address.
410 #[get(type(copy))]
411 pub(crate) gl_program_parameteri: usize,
412 /// `glGetProgramBinary` address.
413 #[get(type(copy))]
414 pub(crate) gl_get_program_binary: usize,
415 /// `glProgramBinary` address.
416 #[get(type(copy))]
417 pub(crate) gl_program_binary: usize,
418 /// `glGetString` address.
419 #[get(type(copy))]
420 pub(crate) gl_get_string: usize,
421}
422
423/// Retained Linux GLES 3.0 offscreen GPU scene pipeline executing `DirectGpuScenePass` (`OceanFluid` + `World3d`).
424#[derive(Data, Debug, Default)]
425pub(crate) struct LinuxEglScenePipeline {
426 /// Offscreen scene framebuffer handle.
427 #[get(type(copy))]
428 pub(crate) scene_fbo: u32,
429 /// Offscreen RGBA8 scene color texture bound to `GL_TEXTURE3` (`u_external_tex`).
430 #[get(type(copy))]
431 pub(crate) scene_color_tex: u32,
432 /// Offscreen 24-bit depth renderbuffer handle for 3D Z-buffered rendering.
433 #[get(type(copy))]
434 pub(crate) scene_depth_rbo: u32,
435 /// Active offscreen scene width in pixels.
436 #[get(type(copy))]
437 pub(crate) scene_w: u32,
438 /// Active offscreen scene height in pixels.
439 #[get(type(copy))]
440 pub(crate) scene_h: u32,
441 /// Resident PBF interactive wake RGBA8 texture handle.
442 #[get(type(copy))]
443 pub(crate) wake_tex: u32,
444 /// Active wake texture width in texels.
445 #[get(type(copy))]
446 pub(crate) wake_w: u32,
447 /// Active wake texture height in texels.
448 #[get(type(copy))]
449 pub(crate) wake_h: u32,
450 /// Compiled Gerstner ocean + storm sky program ID.
451 #[get(type(copy))]
452 pub(crate) ocean_program: u32,
453 /// Cached ocean uniform `u_time_agit_hor_aspect`.
454 #[get(type(copy))]
455 pub(crate) ocean_time_loc: i32,
456 /// Cached ocean uniform `u_roll_boat_uv`.
457 #[get(type(copy))]
458 pub(crate) ocean_roll_loc: i32,
459 /// Cached ocean uniform `u_sun_dir_wake`.
460 #[get(type(copy))]
461 pub(crate) ocean_sun_loc: i32,
462 /// Compiled origami paper boat overlay program ID.
463 #[get(type(copy))]
464 pub(crate) boat_program: u32,
465 /// Boat vertex array object handle.
466 #[get(type(copy))]
467 pub(crate) boat_vao: u32,
468 /// Streaming boat vertex buffer handle.
469 #[get(type(copy))]
470 pub(crate) boat_vbo: u32,
471 /// Allocated byte capacity of `boat_vbo`.
472 #[get(type(copy))]
473 pub(crate) boat_vbo_cap: usize,
474 /// Compiled 3D atmospheric sky program ID.
475 #[get(type(copy))]
476 pub(crate) sky3d_program: u32,
477 /// Cached 3D sky uniform `u_view_proj`.
478 #[get(type(copy))]
479 pub(crate) sky3d_vp_loc: i32,
480 /// Cached 3D sky uniform `u_camera_pos`.
481 #[get(type(copy))]
482 pub(crate) sky3d_cam_loc: i32,
483 /// Cached 3D sky uniform `u_sun_dir_fog`.
484 #[get(type(copy))]
485 pub(crate) sky3d_sun_dir_loc: i32,
486 /// Cached 3D sky uniform `u_sun_color_ambient`.
487 #[get(type(copy))]
488 pub(crate) sky3d_sun_loc: i32,
489 /// Cached 3D sky uniform `u_sky_horizon_tod`.
490 #[get(type(copy))]
491 pub(crate) sky3d_hor_loc: i32,
492 /// Cached 3D sky uniform `u_sky_zenith_aspect`.
493 #[get(type(copy))]
494 pub(crate) sky3d_zen_loc: i32,
495 /// Compiled instanced 3D PBR open-world program ID.
496 #[get(type(copy))]
497 pub(crate) mesh3d_program: u32,
498 /// Instanced 3D mesh vertex array object handle.
499 #[get(type(copy))]
500 pub(crate) mesh3d_vao: u32,
501 /// Static 3D mesh vertex buffer handle.
502 #[get(type(copy))]
503 pub(crate) mesh3d_vert_vbo: u32,
504 /// Allocated byte capacity of `mesh3d_vert_vbo`.
505 #[get(type(copy))]
506 pub(crate) mesh3d_vert_cap: usize,
507 /// Uploaded mesh vertex buffer revision.
508 #[get(type(copy))]
509 pub(crate) mesh3d_vert_rev: u64,
510 /// Streaming 3D instance buffer handle.
511 #[get(type(copy))]
512 pub(crate) mesh3d_inst_vbo: u32,
513 /// Allocated byte capacity of `mesh3d_inst_vbo`.
514 #[get(type(copy))]
515 pub(crate) mesh3d_inst_cap: usize,
516 /// Cached 3D mesh uniform `u_view_proj`.
517 #[get(type(copy))]
518 pub(crate) mesh3d_vp_loc: i32,
519 /// Cached 3D mesh uniform `u_camera_pos`.
520 #[get(type(copy))]
521 pub(crate) mesh3d_cam_loc: i32,
522 /// Cached 3D mesh uniform `u_sun_dir_fog`.
523 #[get(type(copy))]
524 pub(crate) mesh3d_sun_fog_loc: i32,
525 /// Cached 3D mesh uniform `u_sun_color_ambient`.
526 #[get(type(copy))]
527 pub(crate) mesh3d_sun_col_loc: i32,
528 /// Cached 3D mesh uniform `u_sky_horizon_tod`.
529 #[get(type(copy))]
530 pub(crate) mesh3d_hor_loc: i32,
531 /// Cached 3D mesh uniform `u_sky_zenith_aspect`.
532 #[get(type(copy))]
533 pub(crate) mesh3d_zen_loc: i32,
534 /// Lazily initialized quantized PBR + GPU skinning + mipmap streaming pipeline (`DirectGpuScenePass::PbrScene`).
535 #[get(skip)]
536 #[get_mut(skip)]
537 #[set(skip)]
538 pub(crate) pbr: Option<LinuxEglPbrResources>,
539}
540
541/// Resident Linux GLES3 mipmapped texture slot supporting incremental `glTexSubImage2D` and `GL_TEXTURE_BASE_LEVEL` streaming.
542#[derive(Clone, Copy, Debug, Default)]
543pub(crate) struct LinuxResidentMipTexture {
544 /// GLES3 texture handle.
545 pub(crate) tex_id: u32,
546 /// Base `LOD0` width in texels.
547 pub(crate) base_width: u32,
548 /// Base `LOD0` height in texels.
549 pub(crate) base_height: u32,
550 /// Total allocated mipmap levels.
551 pub(crate) total_mips: u8,
552 /// Active `GL_TEXTURE_BASE_LEVEL` clamp (`0 = FullRes`, higher = mip-tail).
553 pub(crate) min_lod_clamp: u8,
554}
555
556/// Retained Linux EGL/GLES3 `DirectGpuScenePass::PbrScene` programs (backed by persistent `glProgramBinary` disk cache), VAO/VBO/EBO, RGBA32F data textures, and mipmap pool.
557#[derive(Debug, Default)]
558pub(crate) struct LinuxEglPbrResources {
559 /// Compiled/cached sky backdrop GLES3 program ID.
560 pub(crate) sky_program: u32,
561 /// Compiled/cached unified quantized PBR + skinning + morph GLES3 program ID.
562 pub(crate) scene_program: u32,
563 /// `u_camera_pos_exposure` location on `sky_program`.
564 pub(crate) sky_cam_loc: i32,
565 /// `u_sun_dir_fog` location on `sky_program`.
566 pub(crate) sky_sun_fog_loc: i32,
567 /// `u_sun_color_ambient` location on `sky_program`.
568 pub(crate) sky_sun_col_loc: i32,
569 /// `u_sky_horizon_tod` location on `sky_program`.
570 pub(crate) sky_hor_loc: i32,
571 /// `u_sky_zenith_agx` location on `sky_program`.
572 pub(crate) sky_zen_agx_loc: i32,
573 /// `u_view_proj` location on `scene_program`.
574 pub(crate) vp_loc: i32,
575 /// `u_camera_pos_exposure` location on `scene_program`.
576 pub(crate) cam_exp_loc: i32,
577 /// `u_sun_dir_fog` location on `scene_program`.
578 pub(crate) sun_fog_loc: i32,
579 /// `u_sun_color_ambient` location on `scene_program`.
580 pub(crate) sun_col_loc: i32,
581 /// `u_sky_horizon_tod` location on `scene_program`.
582 pub(crate) hor_loc: i32,
583 /// `u_sky_zenith_agx` location on `scene_program`.
584 pub(crate) zen_agx_loc: i32,
585 /// `u_ibl_sh[0]` location on `scene_program`.
586 pub(crate) ibl_sh_loc: i32,
587 /// `u_batch_params` location on `scene_program`.
588 pub(crate) batch_params_loc: i32,
589 /// `u_draw_offsets` location on `scene_program`.
590 pub(crate) draw_offsets_loc: i32,
591 /// `u_morph_weights[0]` location on `scene_program`.
592 pub(crate) morph_weights_loc: i32,
593 /// VAO binding quantized 24B verts, 16B skin verts, `u32` EBO, and 112B instanced transforms.
594 pub(crate) vao: u32,
595 /// Static 24-byte `QuantizedVertex3D` VBO.
596 pub(crate) vert_vbo: u32,
597 /// Allocated byte capacity of `vert_vbo`.
598 pub(crate) vert_cap: usize,
599 /// Static `u32` index EBO.
600 pub(crate) idx_ebo: u32,
601 /// Allocated byte capacity of `idx_ebo`.
602 pub(crate) idx_cap: usize,
603 /// Static 16-byte `QuantizedSkinVertex3D` VBO.
604 pub(crate) skin_vbo: u32,
605 /// Allocated byte capacity of `skin_vbo`.
606 pub(crate) skin_cap: usize,
607 /// Uploaded `GpuPbrMeshBuffer::revision`.
608 pub(crate) mesh_rev: u64,
609 /// Dynamic 112-byte `GpuPbrInstance3D` VBO.
610 pub(crate) inst_vbo: u32,
611 /// Allocated byte capacity of `inst_vbo`.
612 pub(crate) inst_cap: usize,
613 /// `RGBA32F` skeletal bone palette texture (`GL_TEXTURE5`).
614 pub(crate) bone_tex: u32,
615 /// `RGBA32F` Principled BSDF material data texture (`GL_TEXTURE6`).
616 pub(crate) mat_tex: u32,
617 /// `RGBA32F` packed local light data texture (`GL_TEXTURE7`).
618 pub(crate) light_tex: u32,
619 /// `RGBA32F` morph target delta data texture (`GL_TEXTURE8`).
620 pub(crate) morph_tex: u32,
621 /// 1x1 fallback white RGBA8 texture for unbound material texture slots.
622 pub(crate) dummy_white_tex: u32,
623 /// Resident mipmapped PBR texture pool keyed by `texture_slot`.
624 pub(crate) textures: HashMap<u32, LinuxResidentMipTexture>,
625 /// Reusable flat `f32` packing buffer for `RGBA32F` data texture uploads.
626 pub(crate) data_tex_scratch: Vec<f32>,
627}
628
629/// Retained Linux GLES 3.0 offscreen Dual-Kawase `BackdropBlur` pipeline and ping-pong framebuffer targets.
630#[derive(Data, Debug, Default)]
631pub(crate) struct LinuxEglBlurPipeline {
632 /// Compiled `GLSL_ES3_BACKDROP_BLUR_VERTEX_SHADER` + `GLSL_ES3_BACKDROP_BLUR_FRAGMENT_SHADER` program ID.
633 #[get(type(copy))]
634 pub(crate) program: u32,
635 /// Cached `u_texel_size` uniform location.
636 #[get(type(copy))]
637 pub(crate) texel_loc: i32,
638 /// Cached `u_blur_offset` uniform location.
639 #[get(type(copy))]
640 pub(crate) offset_loc: i32,
641 /// Cached `u_blur_pass_mode` uniform location.
642 #[get(type(copy))]
643 pub(crate) mode_loc: i32,
644 /// Cached `u_clip_uv` uniform location.
645 #[get(type(copy))]
646 pub(crate) clip_uv_loc: i32,
647 /// Offscreen scene FBO capturing layers strictly below each `BackdropBlur`.
648 #[get(type(copy))]
649 pub(crate) scene_fbo: u32,
650 /// Offscreen RGBA8 scene color texture bound to `scene_fbo`.
651 #[get(type(copy))]
652 pub(crate) scene_tex: u32,
653 /// Offscreen half-resolution Dual-Kawase downsample FBO.
654 #[get(type(copy))]
655 pub(crate) half_fbo: u32,
656 /// Offscreen half-resolution RGBA8 texture bound to `half_fbo`.
657 #[get(type(copy))]
658 pub(crate) half_tex: u32,
659 /// Offscreen full-resolution Dual-Kawase upsample FBO.
660 #[get(type(copy))]
661 pub(crate) full_fbo: u32,
662 /// Offscreen full-resolution RGBA8 blurred texture bound on `GL_TEXTURE3` during blur draws.
663 #[get(type(copy))]
664 pub(crate) full_tex: u32,
665 /// Active allocated width in physical pixels for `scene_tex` and `full_tex`.
666 #[get(type(copy))]
667 pub(crate) width: u32,
668 /// Active allocated height in physical pixels for `scene_tex` and `full_tex`.
669 #[get(type(copy))]
670 pub(crate) height: u32,
671}
672
673/// Live dynamic EGL + GLES3 instanced uber-shader presentation surface over Wayland (`wl_egl_window`) or X11 (`Window`).
674#[derive(Data, Debug)]
675pub(crate) struct LinuxEglGlesSurface {
676 /// Active `EGLDisplay` handle stored as `usize`.
677 #[get(type(copy))]
678 pub(crate) egl_display: usize,
679 /// Active `EGLContext` handle stored as `usize`.
680 #[get(type(copy))]
681 pub(crate) egl_context: usize,
682 /// Active `EGLSurface` handle stored as `usize`.
683 #[get(type(copy))]
684 pub(crate) egl_surface: usize,
685 /// Active `wl_egl_window*` pointer (`0` on X11).
686 #[get(type(copy))]
687 pub(crate) wl_egl_window: usize,
688 /// Compiled GLES3 instanced UI uber-shader program ID.
689 #[get(type(copy))]
690 pub(crate) program: u32,
691 /// Vertex array object binding quad + instanced attribute descriptors.
692 #[get(type(copy))]
693 pub(crate) vao: u32,
694 /// Static 6-vertex unit quad buffer bound at attribute location `0`.
695 #[get(type(copy))]
696 pub(crate) quad_vbo: u32,
697 /// Streaming 64-byte `GpuPrimitiveInstance` VBO.
698 #[get(type(copy))]
699 pub(crate) instance_vbo: u32,
700 /// Allocated byte capacity of `instance_vbo`.
701 #[get(type(copy))]
702 pub(crate) instance_vbo_cap: usize,
703 /// Persistent `GL_R8` glyph atlas texture ID.
704 #[get(type(copy))]
705 pub(crate) glyph_r8_tex: u32,
706 /// Width of `glyph_r8_tex` in texels.
707 #[get(type(copy))]
708 pub(crate) glyph_r8_w: u32,
709 /// Height of `glyph_r8_tex` in texels.
710 #[get(type(copy))]
711 pub(crate) glyph_r8_h: u32,
712 /// Uploaded revision of `glyph_r8_tex`.
713 #[get(type(copy))]
714 pub(crate) glyph_r8_rev: u64,
715 /// Color `GL_RGBA8` glyph texture ID.
716 #[get(type(copy))]
717 pub(crate) glyph_rgba8_tex: u32,
718 /// Persistent `GL_RGBA8` image atlas texture ID.
719 #[get(type(copy))]
720 pub(crate) image_tex: u32,
721 /// Width of `image_tex` in texels.
722 #[get(type(copy))]
723 pub(crate) image_w: u32,
724 /// Height of `image_tex` in texels.
725 #[get(type(copy))]
726 pub(crate) image_h: u32,
727 /// Uploaded revision of `image_tex`.
728 #[get(type(copy))]
729 pub(crate) image_rev: u64,
730 /// External/video `GL_RGBA8` texture ID.
731 #[get(type(copy))]
732 pub(crate) external_tex: u32,
733 /// Cached uniform location for `u_viewport`.
734 #[get(type(copy))]
735 pub(crate) viewport_loc: i32,
736 /// Cached uniform location for `u_scroll_offset`.
737 #[get(type(copy))]
738 pub(crate) scroll_loc: i32,
739 /// Active surface width in physical pixels.
740 #[get(type(copy))]
741 pub(crate) width: u32,
742 /// Active surface height in physical pixels.
743 #[get(type(copy))]
744 pub(crate) height: u32,
745 /// True when backed by `wl_egl_window`; false when backed by X11 `Window`.
746 #[get(type(copy))]
747 pub(crate) is_wayland: bool,
748 /// Maximum supported GLES3 texture dimension queried via `GL_MAX_TEXTURE_SIZE`.
749 #[get(type(copy))]
750 pub(crate) max_tex_dim: u32,
751 /// Lazily initialized offscreen GLES3 scene pass pipeline (`OceanFluid` + `World3d`).
752 #[get(skip)]
753 #[get_mut(skip)]
754 #[set(skip)]
755 pub(crate) scene: Option<LinuxEglScenePipeline>,
756 /// Lazily initialized offscreen GLES3 Dual-Kawase `BackdropBlur` pipeline enforcing strict Z-order isolation.
757 #[get(skip)]
758 #[get_mut(skip)]
759 #[set(skip)]
760 pub(crate) blur: Option<LinuxEglBlurPipeline>,
761 /// Reusable flat primitive staging buffer avoiding per-frame allocations on direct submission.
762 #[get(skip)]
763 #[get_mut(skip)]
764 #[set(skip)]
765 pub(crate) scratch_prims: Vec<GpuPrimitiveInstance>,
766 /// Reusable draw-range metadata buffer paired with `scratch_prims` (`(base, count, scissor, scroll, has_blur)`).
767 #[get(skip)]
768 #[get_mut(skip)]
769 #[set(skip)]
770 pub(crate) scratch_ranges: Vec<(usize, usize, Rect, [f32; 2], bool)>,
771 /// Heap-stable atomic VSync latch cleared by `wl_surface.frame` callback on Wayland.
772 #[get(skip)]
773 #[get_mut(skip)]
774 #[set(skip)]
775 pub(crate) vsync_pending: Box<AtomicBool>,
776}
777
778/// Raw `wl_registry_listener` ABI table registered during Wayland global discovery.
779#[repr(C)]
780#[derive(Clone, Copy)]
781pub(crate) struct WlRegistryListener {
782 /// Callback invoked for each advertised Wayland global `(data, registry, name, interface, version)`.
783 pub(crate) global: unsafe extern "C" fn(*mut c_void, *mut c_void, u32, *const c_char, u32),
784 /// Callback invoked when a Wayland global is removed `(data, registry, name)`.
785 pub(crate) global_remove: unsafe extern "C" fn(*mut c_void, *mut c_void, u32),
786}
787
788/// Raw `wl_buffer_listener` ABI table tracking compositor buffer release notifications.
789#[repr(C)]
790#[derive(Clone, Copy)]
791pub(crate) struct WlBufferListener {
792 /// Callback invoked when the compositor finishes reading a `wl_buffer` (`(data, buffer)`).
793 pub(crate) release: unsafe extern "C" fn(*mut c_void, *mut c_void),
794}
795
796/// Mutable state populated by `WL_REGISTRY_LISTENER` during initial `wl_display_roundtrip`.
797#[repr(C)]
798#[derive(Clone, Copy, Debug, Default)]
799pub(crate) struct WlRegistryBindState {
800 /// Bound `wl_compositor*` proxy handle.
801 pub(crate) compositor: usize,
802 /// Negotiated `wl_compositor` protocol version.
803 pub(crate) compositor_version: u32,
804 /// Bound `wl_shm*` proxy handle.
805 pub(crate) shm: usize,
806}
807
808/// Descriptor carrying POSIX shared-memory FD, geometry, format, and release flag pointer for `WaylandShmCommitOps`.
809#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
810pub struct WaylandShmBufferDescriptor {
811 /// Open shared-memory file descriptor (`memfd_create` or `/dev/shm`).
812 #[get(type(copy))]
813 pub(crate) fd: i32,
814 /// Total mapped buffer byte size.
815 #[get(type(copy))]
816 pub(crate) size: i32,
817 /// Physical buffer width in pixels.
818 #[get(type(copy))]
819 pub(crate) width: i32,
820 /// Physical buffer height in pixels.
821 #[get(type(copy))]
822 pub(crate) height: i32,
823 /// Row stride in bytes (`width * 4`).
824 #[get(type(copy))]
825 pub(crate) stride: i32,
826 /// Wayland shm pixel format (`WL_SHM_FORMAT_ARGB8888` or `WL_SHM_FORMAT_XRGB8888`).
827 #[get(type(copy))]
828 pub(crate) format: u32,
829 /// Raw pointer to the slot's release `AtomicBool` userdata registered on `wl_buffer.release`.
830 #[get(type(copy))]
831 pub(crate) release_flag_ptr: usize,
832}
833
834/// Single double-buffered Wayland `wl_shm` memory mapping and protocol buffer slot.
835#[derive(Debug)]
836pub struct WaylandShmBufferSlot {
837 /// Open POSIX shared-memory file descriptor (`-1` when unallocated).
838 pub(crate) fd: i32,
839 /// Base pointer returned by `mmap(..., MAP_SHARED, fd, 0)` (`0` when unmapped).
840 pub(crate) mapped_ptr: usize,
841 /// Mapped byte capacity of this shared-memory region.
842 pub(crate) mapped_len: usize,
843 /// Current allocated buffer width in physical pixels.
844 pub(crate) width: u32,
845 /// Current allocated buffer height in physical pixels.
846 pub(crate) height: u32,
847 /// Row stride in bytes (`width * 4`).
848 pub(crate) stride: u32,
849 /// Bound Wayland shm pixel format (`WL_SHM_FORMAT_ARGB8888` or `WL_SHM_FORMAT_XRGB8888`).
850 pub(crate) format: u32,
851 /// Associated `wl_shm_pool*` proxy handle (`0` when detached).
852 pub(crate) wl_pool: usize,
853 /// Associated `wl_buffer*` proxy handle (`0` when detached).
854 pub(crate) wl_buffer: usize,
855 /// Atomic busy flag cleared asynchronously by `wl_buffer.release` (`true` while held by compositor).
856 pub(crate) busy: Box<AtomicBool>,
857 /// True once this slot has received a complete full-frame pixel copy for its current dimensions.
858 pub(crate) has_full_copy: bool,
859}
860
861/// Double-buffered Wayland `wl_shm` software swapchain owning two POSIX shm mappings and dirty-rect tracking.
862#[derive(Debug)]
863pub struct WaylandShmSwapchain {
864 /// Two ping-pong shared-memory slots enabling tear-free double-buffered Wayland commits.
865 pub(crate) slots: [WaylandShmBufferSlot; WL_SHM_SLOT_COUNT],
866 /// Wayland shm pixel format (`WL_SHM_FORMAT_XRGB8888` or `WL_SHM_FORMAT_ARGB8888`).
867 pub(crate) pixel_format: u32,
868 /// Dirty rectangles from the immediately preceding submitted frame so double-buffered back slots stay coherent.
869 pub(crate) previous_dirty_rects: Vec<(u32, u32, u32, u32)>,
870 /// Index (`0` or `1`) of the most recently committed buffer slot.
871 pub(crate) last_committed_slot: u8,
872 /// Cumulative count of successfully committed Wayland shm frames.
873 pub(crate) submitted_frames: u64,
874 /// Cumulative count of unchanged frames skipped without commit.
875 pub(crate) skipped_unchanged_frames: u64,
876 /// Cumulative count of failed presentation attempts.
877 pub(crate) failed_frames: u64,
878}
879
880/// Native `libwayland-client.so.0` transport invoking `wl_shm_pool`, `wl_buffer`, `wl_surface`, and `wl_display_flush`.
881#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
882pub struct NativeWaylandShmTransport {
883 /// Live `wl_display*` connection pointer.
884 #[get(type(copy))]
885 pub(crate) display: usize,
886 /// Live `wl_surface*` proxy pointer.
887 #[get(type(copy))]
888 pub(crate) surface: usize,
889 /// Live `wl_shm*` global proxy pointer.
890 #[get(type(copy))]
891 pub(crate) wl_shm: usize,
892 /// Negotiated `wl_surface` interface version (`>= 4` uses `damage_buffer`, `< 4` uses `damage`).
893 #[get(type(copy))]
894 pub(crate) surface_version: u32,
895 /// Integer `wl_surface.set_buffer_scale` divisor applied prior to commit (`<= 0` defaults to `1`).
896 #[new(skip)]
897 #[get(type(copy))]
898 pub(crate) buffer_scale: i32,
899}
900
901/// Explicit per-frame Linux presentation telemetry separating direct GPU vs Wayland shm vs X11 software blits.
902#[derive(Clone, Copy, Data, Debug, Default, Eq, PartialEq)]
903pub struct LinuxPresentTelemetry {
904 /// Active presentation transport (`GpuDirect`, `WaylandShmSoftware`, or `X11Software`).
905 #[get(type(copy))]
906 pub(crate) mode: LinuxPresentationMode,
907 /// Explicit frame outcome (`Submitted`, `SkippedUnchanged`, or `Failed`).
908 #[get(type(copy))]
909 pub(crate) outcome: LinuxPresentOutcome,
910 /// True whenever a CPU software framebuffer mirror is active (`false` for `GpuDirect`).
911 #[get(type(copy))]
912 pub(crate) cpu_mirror_active: bool,
913 /// Exact pixel bytes copied into Wayland shm or uploaded via X11 `XPutImage` (`0` for `GpuDirect` or skip).
914 #[get(type(copy))]
915 pub(crate) upload_bytes: u64,
916 /// Number of dirty rectangles damaged or uploaded during this frame.
917 #[get(type(copy))]
918 pub(crate) dirty_rect_count: u32,
919 /// Double-buffered Wayland shm slot index (`0` or `1`) committed on this frame.
920 #[get(type(copy))]
921 pub(crate) committed_buffer_slot: u8,
922 /// Cumulative submitted frames recorded on this window.
923 #[get(type(copy))]
924 pub(crate) submitted_frames: u64,
925 /// Cumulative unchanged frames skipped on this window.
926 #[get(type(copy))]
927 pub(crate) skipped_unchanged_frames: u64,
928 /// Cumulative failed frames recorded on this window.
929 #[get(type(copy))]
930 pub(crate) failed_frames: u64,
931}
932
933/// Raw 192-byte X11 `XEvent` union storage aligned for 64-bit Linux LP64 ABI.
934#[repr(C)]
935#[derive(Clone, Copy)]
936pub(crate) struct X11EventRaw {
937 /// Raw union payload words.
938 pub(crate) pad: [isize; 24],
939}
940
941/// X11 `XKeyEvent` / `XButtonEvent` ABI layout on LP64 Linux.
942#[repr(C)]
943#[derive(Clone, Copy)]
944pub(crate) struct X11KeyOrButtonEvent {
945 /// Event discriminant (`KeyPress`, `KeyRelease`, `ButtonPress`, `ButtonRelease`).
946 pub(crate) event_type: i32,
947 /// X server serial number.
948 pub(crate) serial: usize,
949 /// Non-zero when generated by `SendEvent`.
950 pub(crate) send_event: i32,
951 /// Connection `Display*`.
952 pub(crate) display: *mut c_void,
953 /// Target `Window` XID.
954 pub(crate) window: u64,
955 /// Root window XID.
956 pub(crate) root: u64,
957 /// Subwindow XID.
958 pub(crate) subwindow: u64,
959 /// Event timestamp in milliseconds.
960 pub(crate) time: u64,
961 /// Pointer X coordinate relative to window.
962 pub(crate) x: i32,
963 /// Pointer Y coordinate relative to window.
964 pub(crate) y: i32,
965 /// Pointer X relative to root window.
966 pub(crate) x_root: i32,
967 /// Pointer Y relative to root window.
968 pub(crate) y_root: i32,
969 /// Modifier key / button mask.
970 pub(crate) state: u32,
971 /// Hardware keycode or mouse button number.
972 pub(crate) detail: u32,
973 /// Same-screen flag.
974 pub(crate) same_screen: i32,
975}
976
977/// X11 `XMotionEvent` ABI layout on LP64 Linux.
978#[repr(C)]
979#[derive(Clone, Copy)]
980pub(crate) struct X11MotionEvent {
981 /// Event discriminant (`MotionNotify`).
982 pub(crate) event_type: i32,
983 /// X server serial number.
984 pub(crate) serial: usize,
985 /// Send-event flag.
986 pub(crate) send_event: i32,
987 /// Connection `Display*`.
988 pub(crate) display: *mut c_void,
989 /// Target `Window` XID.
990 pub(crate) window: u64,
991 /// Root window XID.
992 pub(crate) root: u64,
993 /// Subwindow XID.
994 pub(crate) subwindow: u64,
995 /// Timestamp in milliseconds.
996 pub(crate) time: u64,
997 /// Pointer X coordinate relative to window.
998 pub(crate) x: i32,
999 /// Pointer Y coordinate relative to window.
1000 pub(crate) y: i32,
1001 /// Pointer X relative to root window.
1002 pub(crate) x_root: i32,
1003 /// Pointer Y relative to root window.
1004 pub(crate) y_root: i32,
1005 /// Active modifier mask.
1006 pub(crate) state: u32,
1007 /// Motion hint byte.
1008 pub(crate) is_hint: c_char,
1009 /// Same-screen flag.
1010 pub(crate) same_screen: i32,
1011}
1012
1013/// X11 `XConfigureEvent` ABI layout on LP64 Linux.
1014#[repr(C)]
1015#[derive(Clone, Copy)]
1016pub(crate) struct X11ConfigureEvent {
1017 /// Event discriminant (`ConfigureNotify`).
1018 pub(crate) event_type: i32,
1019 /// X server serial number.
1020 pub(crate) serial: usize,
1021 /// Send-event flag.
1022 pub(crate) send_event: i32,
1023 /// Connection `Display*`.
1024 pub(crate) display: *mut c_void,
1025 /// Event-delivery window XID.
1026 pub(crate) event_window: u64,
1027 /// Reconfigured target window XID.
1028 pub(crate) window: u64,
1029 /// New window X position.
1030 pub(crate) x: i32,
1031 /// New window Y position.
1032 pub(crate) y: i32,
1033 /// New window client width in physical pixels.
1034 pub(crate) width: i32,
1035 /// New window client height in physical pixels.
1036 pub(crate) height: i32,
1037}
1038
1039/// X11 `XClientMessageEvent` ABI layout on LP64 Linux.
1040#[repr(C)]
1041#[derive(Clone, Copy)]
1042pub(crate) struct X11ClientMessageEvent {
1043 /// Event discriminant (`ClientMessage`).
1044 pub(crate) event_type: i32,
1045 /// X server serial number.
1046 pub(crate) serial: usize,
1047 /// Send-event flag.
1048 pub(crate) send_event: i32,
1049 /// Connection `Display*`.
1050 pub(crate) display: *mut c_void,
1051 /// Target `Window` XID.
1052 pub(crate) window: u64,
1053 /// Message type atom (`WM_PROTOCOLS`).
1054 pub(crate) message_type: u64,
1055 /// Data format (`8`, `16`, or `32`).
1056 pub(crate) format: i32,
1057 /// 32-bit protocol data payload (`l[0]` holds `WM_DELETE_WINDOW`).
1058 pub(crate) data: [u64; 5],
1059}
1060
1061/// Bundle returned when opening a native Linux X11 or Wayland window.
1062#[derive(Clone, Copy, Data, Debug)]
1063pub(crate) struct LinuxNativeWindowHandle {
1064 /// Dynamically loaded `libX11` or `libwayland-client` handle.
1065 #[get(type(copy))]
1066 pub(crate) lib: usize,
1067 /// True when backed by Wayland; false when backed by X11.
1068 #[get(type(copy))]
1069 pub(crate) is_wayland: bool,
1070 /// Raw `Display*` or `wl_display*`.
1071 #[get(type(copy))]
1072 pub(crate) display: usize,
1073 /// Native X11 `Window` XID or Wayland surface pointer.
1074 #[get(type(copy))]
1075 pub(crate) window: u64,
1076 /// Cached X11 `GC` handle for `XPutImage`.
1077 #[get(type(copy))]
1078 pub(crate) gc: usize,
1079 /// Cached X11 `Visual*` pointer for `XCreateImage`.
1080 #[get(type(copy))]
1081 pub(crate) visual: usize,
1082 /// X11 default visual color depth (e.g., `24` or `32`).
1083 #[get(type(copy))]
1084 pub(crate) depth: u32,
1085 /// Interned `WM_DELETE_WINDOW` atom for graceful window closing.
1086 #[get(type(copy))]
1087 pub(crate) wm_delete_atom: u64,
1088 /// Probed display DPI scale factor (`1.0..=4.0`).
1089 #[get(type(copy))]
1090 pub(crate) scale_factor: f32,
1091 /// True when X11 MIT-SHM (`XShmQueryExtension`) is supported on this display.
1092 #[get(type(copy))]
1093 pub(crate) mit_shm_available: bool,
1094 /// True when Wayland Vulkan WSI (`VK_KHR_wayland_surface`) is available.
1095 #[get(type(copy))]
1096 pub(crate) wayland_vulkan_wsi: bool,
1097 /// True when X11 Vulkan WSI (`VK_KHR_xlib_surface`) is available.
1098 #[get(type(copy))]
1099 pub(crate) xlib_vulkan_wsi: bool,
1100 /// Bound Wayland `wl_compositor*` proxy pointer (`0` on X11 or unavailable).
1101 #[get(type(copy))]
1102 pub(crate) wl_compositor: usize,
1103 /// Bound Wayland `wl_shm*` proxy pointer (`0` on X11 or unavailable).
1104 #[get(type(copy))]
1105 pub(crate) wl_shm: usize,
1106 /// Negotiated Wayland `wl_surface` interface version (`0` on X11).
1107 #[get(type(copy))]
1108 pub(crate) wl_surface_version: u32,
1109}
1110
1111/// Native Linux X11 / Wayland window record.
1112#[derive(Clone, Data, Debug)]
1113pub struct LinuxWindowRecord {
1114 /// Window configuration.
1115 pub(crate) config: WindowConfig,
1116 /// Live window state.
1117 #[get(type(copy))]
1118 pub(crate) state: WindowState,
1119 /// True when backed by Wayland; false when backed by X11 Xlib.
1120 #[get(type(copy))]
1121 pub(crate) is_wayland: bool,
1122 /// Raw display handle (`Display*` or `wl_display*`).
1123 #[get(type(copy))]
1124 pub(crate) display: usize,
1125 /// Raw window or surface identifier (`Window` or `wl_surface*`).
1126 #[get(type(copy))]
1127 pub(crate) window: u64,
1128 /// Cached X11 `GC` handle used by `XPutImage`.
1129 #[get(type(copy))]
1130 pub(crate) gc: usize,
1131 /// Cached X11 `Visual*` pointer used by `XCreateImage`.
1132 #[get(type(copy))]
1133 pub(crate) visual: usize,
1134 /// X11 visual depth in bits (`24` or `32`).
1135 #[get(type(copy))]
1136 pub(crate) depth: u32,
1137 /// Interned `WM_DELETE_WINDOW` protocol atom.
1138 #[get(type(copy))]
1139 pub(crate) wm_delete_atom: u64,
1140 /// Whether `XMapWindow` has been issued after Frame 1 presentation (eliminates unmapped flash).
1141 #[get(type(copy))]
1142 pub(crate) revealed: bool,
1143 /// Whether X11 MIT-SHM shared-memory image transport is supported by the X server.
1144 #[get(type(copy))]
1145 pub(crate) mit_shm_available: bool,
1146 /// Whether Wayland Vulkan WSI (`VK_KHR_wayland_surface`) is ready on this display.
1147 #[get(type(copy))]
1148 pub(crate) wayland_vulkan_wsi: bool,
1149 /// Whether X11 Vulkan WSI (`VK_KHR_xlib_surface`) is ready on this display.
1150 #[get(type(copy))]
1151 pub(crate) xlib_vulkan_wsi: bool,
1152 /// Bound Wayland `wl_compositor*` proxy pointer (`0` on X11).
1153 #[get(type(copy))]
1154 pub(crate) wl_compositor: usize,
1155 /// Bound Wayland `wl_shm*` proxy pointer (`0` on X11).
1156 #[get(type(copy))]
1157 pub(crate) wl_shm: usize,
1158 /// Negotiated Wayland `wl_surface` interface version (`>= 4` supports `damage_buffer`).
1159 #[get(type(copy))]
1160 pub(crate) wl_surface_version: u32,
1161 /// Reported `wl_output.mode` refresh rate in millihertz (e.g. `240000` for `240Hz`, `0` if unset).
1162 #[get(type(copy))]
1163 pub(crate) wayland_output_refresh_milli_hz: u32,
1164 /// Latest `wp_presentation` feedback timestamp in nanoseconds (`0` before first presentation).
1165 #[get(type(copy))]
1166 pub(crate) wayland_presentation_time_ns: u64,
1167 /// Whether a `wl_surface::frame` callback is currently armed awaiting compositor VSync.
1168 #[get(type(copy))]
1169 pub(crate) wayland_frame_callback_pending: bool,
1170 /// Active Linux presentation mode (`GpuDirect`, `WaylandShmSoftware`, or `X11Software`).
1171 #[get(type(copy))]
1172 pub(crate) presentation_mode: LinuxPresentationMode,
1173 /// Explicit CPU-mirror telemetry flag (`true` on Wayland shm / X11 software; `false` on direct GPU).
1174 #[get(type(copy))]
1175 pub(crate) cpu_mirror_active: bool,
1176 /// Most recent per-frame Linux presentation telemetry snapshot.
1177 #[get(type(copy))]
1178 pub(crate) last_telemetry: LinuxPresentTelemetry,
1179 /// Double-buffered Wayland `wl_shm` software swapchain attached to this window when Wayland is active.
1180 #[get(skip)]
1181 #[get_mut(skip)]
1182 #[set(skip)]
1183 pub(crate) wayland_shm: Option<Arc<Mutex<WaylandShmSwapchain>>>,
1184 /// Optional dynamically loaded EGL + GLES3 instanced direct-GPU surface over Wayland or X11.
1185 #[get(skip)]
1186 #[get_mut(skip)]
1187 #[set(skip)]
1188 pub(crate) egl_gles: Option<Arc<Mutex<LinuxEglGlesSurface>>>,
1189}
1190
1191/// Direct Linux X11 / Wayland (`dlopen`-loaded) + Vulkan platform backend.
1192#[derive(Clone, Data, Debug)]
1193pub struct LinuxPlatform {
1194 /// Monotonic window handle generator.
1195 #[get(pub(crate), type(copy))]
1196 #[get_mut(pub(crate))]
1197 #[set(pub(crate))]
1198 pub(crate) next_id: u64,
1199 /// Dynamically loaded `libX11` handle if present.
1200 #[get(pub(crate), type(copy))]
1201 #[get_mut(pub(crate))]
1202 #[set(pub(crate))]
1203 pub(crate) x11_lib: usize,
1204 /// Active native Linux windows.
1205 pub(crate) windows: HashMap<WindowId, LinuxWindowRecord>,
1206 /// Queued window and input events.
1207 pub(crate) pending_events: Vec<WindowEvent>,
1208 /// Clipboard text cache.
1209 #[get(skip)]
1210 pub(crate) clipboard_cache: Option<String>,
1211 /// Whether the Linux X11/Wayland frame pump is paused for background freeze.
1212 #[get(pub(crate), type(copy))]
1213 #[set(pub(crate))]
1214 pub(crate) pump_paused: bool,
1215 /// Non-blocking wakeup pipe read end passed to `poll(display_fd, wakeup_pipe)` (`-1` when unavailable).
1216 #[get(pub(crate), type(copy))]
1217 #[set(pub(crate))]
1218 pub(crate) wake_read_fd: i32,
1219 /// Non-blocking wakeup pipe write end signaled by `wake_event_loop()` (`-1` when unavailable).
1220 #[get(pub(crate), type(copy))]
1221 #[set(pub(crate))]
1222 pub(crate) wake_write_fd: i32,
1223}