Skip to main content

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    /// `glUniform2f` address.
251    #[get(type(copy))]
252    pub(crate) gl_uniform2f: usize,
253    /// `glGenVertexArrays` address.
254    #[get(type(copy))]
255    pub(crate) gl_gen_vertex_arrays: usize,
256    /// `glBindVertexArray` address.
257    #[get(type(copy))]
258    pub(crate) gl_bind_vertex_array: usize,
259    /// `glDeleteVertexArrays` address.
260    #[get(type(copy))]
261    pub(crate) gl_delete_vertex_arrays: usize,
262    /// `glGenBuffers` address.
263    #[get(type(copy))]
264    pub(crate) gl_gen_buffers: usize,
265    /// `glBindBuffer` address.
266    #[get(type(copy))]
267    pub(crate) gl_bind_buffer: usize,
268    /// `glBufferData` address.
269    #[get(type(copy))]
270    pub(crate) gl_buffer_data: usize,
271    /// `glBufferSubData` address.
272    #[get(type(copy))]
273    pub(crate) gl_buffer_sub_data: usize,
274    /// `glDeleteBuffers` address.
275    #[get(type(copy))]
276    pub(crate) gl_delete_buffers: usize,
277    /// `glEnableVertexAttribArray` address.
278    #[get(type(copy))]
279    pub(crate) gl_enable_vertex_attrib_array: usize,
280    /// `glVertexAttribPointer` address.
281    #[get(type(copy))]
282    pub(crate) gl_vertex_attrib_pointer: usize,
283    /// `glVertexAttribIPointer` address.
284    #[get(type(copy))]
285    pub(crate) gl_vertex_attrib_ipointer: usize,
286    /// `glVertexAttribDivisor` address.
287    #[get(type(copy))]
288    pub(crate) gl_vertex_attrib_divisor: usize,
289    /// `glGenTextures` address.
290    #[get(type(copy))]
291    pub(crate) gl_gen_textures: usize,
292    /// `glBindTexture` address.
293    #[get(type(copy))]
294    pub(crate) gl_bind_texture: usize,
295    /// `glTexParameteri` address.
296    #[get(type(copy))]
297    pub(crate) gl_tex_parameteri: usize,
298    /// `glTexStorage2D` address.
299    #[get(type(copy))]
300    pub(crate) gl_tex_storage_2d: usize,
301    /// `glTexImage2D` address.
302    #[get(type(copy))]
303    pub(crate) gl_tex_image_2d: usize,
304    /// `glTexSubImage2D` address.
305    #[get(type(copy))]
306    pub(crate) gl_tex_sub_image_2d: usize,
307    /// `glDeleteTextures` address.
308    #[get(type(copy))]
309    pub(crate) gl_delete_textures: usize,
310    /// `glActiveTexture` address.
311    #[get(type(copy))]
312    pub(crate) gl_active_texture: usize,
313    /// `glPixelStorei` address.
314    #[get(type(copy))]
315    pub(crate) gl_pixel_storei: usize,
316    /// `glViewport` address.
317    #[get(type(copy))]
318    pub(crate) gl_viewport: usize,
319    /// `glEnable` address.
320    #[get(type(copy))]
321    pub(crate) gl_enable: usize,
322    /// `glDisable` address.
323    #[get(type(copy))]
324    pub(crate) gl_disable: usize,
325    /// `glBlendFuncSeparate` address.
326    #[get(type(copy))]
327    pub(crate) gl_blend_func_separate: usize,
328    /// `glScissor` address.
329    #[get(type(copy))]
330    pub(crate) gl_scissor: usize,
331    /// `glClearColor` address.
332    #[get(type(copy))]
333    pub(crate) gl_clear_color: usize,
334    /// `glClear` address.
335    #[get(type(copy))]
336    pub(crate) gl_clear: usize,
337    /// `glDrawArraysInstanced` address.
338    #[get(type(copy))]
339    pub(crate) gl_draw_arrays_instanced: usize,
340    /// `glDrawArrays` address.
341    #[get(type(copy))]
342    pub(crate) gl_draw_arrays: usize,
343    /// `glUniform4f` address.
344    #[get(type(copy))]
345    pub(crate) gl_uniform4f: usize,
346    /// `glUniformMatrix4fv` address.
347    #[get(type(copy))]
348    pub(crate) gl_uniform_matrix4fv: usize,
349    /// `glGetIntegerv` address.
350    #[get(type(copy))]
351    pub(crate) gl_get_integerv: usize,
352    /// `glGenFramebuffers` address.
353    #[get(type(copy))]
354    pub(crate) gl_gen_framebuffers: usize,
355    /// `glBindFramebuffer` address.
356    #[get(type(copy))]
357    pub(crate) gl_bind_framebuffer: usize,
358    /// `glFramebufferTexture2D` address.
359    #[get(type(copy))]
360    pub(crate) gl_framebuffer_texture_2d: usize,
361    /// `glDeleteFramebuffers` address.
362    #[get(type(copy))]
363    pub(crate) gl_delete_framebuffers: usize,
364    /// `glGenRenderbuffers` address.
365    #[get(type(copy))]
366    pub(crate) gl_gen_renderbuffers: usize,
367    /// `glBindRenderbuffer` address.
368    #[get(type(copy))]
369    pub(crate) gl_bind_renderbuffer: usize,
370    /// `glRenderbufferStorage` address.
371    #[get(type(copy))]
372    pub(crate) gl_renderbuffer_storage: usize,
373    /// `glFramebufferRenderbuffer` address.
374    #[get(type(copy))]
375    pub(crate) gl_framebuffer_renderbuffer: usize,
376    /// `glDeleteRenderbuffers` address.
377    #[get(type(copy))]
378    pub(crate) gl_delete_renderbuffers: usize,
379    /// `glDepthMask` address.
380    #[get(type(copy))]
381    pub(crate) gl_depth_mask: usize,
382    /// `glDepthFunc` address.
383    #[get(type(copy))]
384    pub(crate) gl_depth_func: usize,
385    /// `glClearDepthf` address.
386    #[get(type(copy))]
387    pub(crate) gl_clear_depthf: usize,
388    /// `glDrawElementsInstanced` address.
389    #[get(type(copy))]
390    pub(crate) gl_draw_elements_instanced: usize,
391    /// `glUniform4i` address.
392    #[get(type(copy))]
393    pub(crate) gl_uniform4i: usize,
394    /// `glUniform4fv` address.
395    #[get(type(copy))]
396    pub(crate) gl_uniform4fv: usize,
397    /// `glDisableVertexAttribArray` address.
398    #[get(type(copy))]
399    pub(crate) gl_disable_vertex_attrib_array: usize,
400    /// `glVertexAttribI4ui` address.
401    #[get(type(copy))]
402    pub(crate) gl_vertex_attrib_i4ui: usize,
403    /// `glVertexAttrib4f` address.
404    #[get(type(copy))]
405    pub(crate) gl_vertex_attrib_4f: usize,
406    /// `glProgramParameteri` address.
407    #[get(type(copy))]
408    pub(crate) gl_program_parameteri: usize,
409    /// `glGetProgramBinary` address.
410    #[get(type(copy))]
411    pub(crate) gl_get_program_binary: usize,
412    /// `glProgramBinary` address.
413    #[get(type(copy))]
414    pub(crate) gl_program_binary: usize,
415    /// `glGetString` address.
416    #[get(type(copy))]
417    pub(crate) gl_get_string: usize,
418}
419
420/// Retained Linux GLES 3.0 offscreen GPU scene pipeline executing `DirectGpuScenePass` (`OceanFluid` + `World3d`).
421#[derive(Data, Debug, Default)]
422pub(crate) struct LinuxEglScenePipeline {
423    /// Offscreen scene framebuffer handle.
424    #[get(type(copy))]
425    pub(crate) scene_fbo: u32,
426    /// Offscreen RGBA8 scene color texture bound to `GL_TEXTURE3` (`u_external_tex`).
427    #[get(type(copy))]
428    pub(crate) scene_color_tex: u32,
429    /// Offscreen 24-bit depth renderbuffer handle for 3D Z-buffered rendering.
430    #[get(type(copy))]
431    pub(crate) scene_depth_rbo: u32,
432    /// Active offscreen scene width in pixels.
433    #[get(type(copy))]
434    pub(crate) scene_w: u32,
435    /// Active offscreen scene height in pixels.
436    #[get(type(copy))]
437    pub(crate) scene_h: u32,
438    /// Resident PBF interactive wake RGBA8 texture handle.
439    #[get(type(copy))]
440    pub(crate) wake_tex: u32,
441    /// Active wake texture width in texels.
442    #[get(type(copy))]
443    pub(crate) wake_w: u32,
444    /// Active wake texture height in texels.
445    #[get(type(copy))]
446    pub(crate) wake_h: u32,
447    /// Compiled Gerstner ocean + storm sky program ID.
448    #[get(type(copy))]
449    pub(crate) ocean_program: u32,
450    /// Cached ocean uniform `u_time_agit_hor_aspect`.
451    #[get(type(copy))]
452    pub(crate) ocean_time_loc: i32,
453    /// Cached ocean uniform `u_roll_boat_uv`.
454    #[get(type(copy))]
455    pub(crate) ocean_roll_loc: i32,
456    /// Cached ocean uniform `u_sun_dir_wake`.
457    #[get(type(copy))]
458    pub(crate) ocean_sun_loc: i32,
459    /// Compiled origami paper boat overlay program ID.
460    #[get(type(copy))]
461    pub(crate) boat_program: u32,
462    /// Boat vertex array object handle.
463    #[get(type(copy))]
464    pub(crate) boat_vao: u32,
465    /// Streaming boat vertex buffer handle.
466    #[get(type(copy))]
467    pub(crate) boat_vbo: u32,
468    /// Allocated byte capacity of `boat_vbo`.
469    #[get(type(copy))]
470    pub(crate) boat_vbo_cap: usize,
471    /// Compiled 3D atmospheric sky program ID.
472    #[get(type(copy))]
473    pub(crate) sky3d_program: u32,
474    /// Cached 3D sky uniform `u_view_proj`.
475    #[get(type(copy))]
476    pub(crate) sky3d_vp_loc: i32,
477    /// Cached 3D sky uniform `u_camera_pos`.
478    #[get(type(copy))]
479    pub(crate) sky3d_cam_loc: i32,
480    /// Cached 3D sky uniform `u_sun_dir_fog`.
481    #[get(type(copy))]
482    pub(crate) sky3d_sun_dir_loc: i32,
483    /// Cached 3D sky uniform `u_sun_color_ambient`.
484    #[get(type(copy))]
485    pub(crate) sky3d_sun_loc: i32,
486    /// Cached 3D sky uniform `u_sky_horizon_tod`.
487    #[get(type(copy))]
488    pub(crate) sky3d_hor_loc: i32,
489    /// Cached 3D sky uniform `u_sky_zenith_aspect`.
490    #[get(type(copy))]
491    pub(crate) sky3d_zen_loc: i32,
492    /// Compiled instanced 3D PBR open-world program ID.
493    #[get(type(copy))]
494    pub(crate) mesh3d_program: u32,
495    /// Instanced 3D mesh vertex array object handle.
496    #[get(type(copy))]
497    pub(crate) mesh3d_vao: u32,
498    /// Static 3D mesh vertex buffer handle.
499    #[get(type(copy))]
500    pub(crate) mesh3d_vert_vbo: u32,
501    /// Allocated byte capacity of `mesh3d_vert_vbo`.
502    #[get(type(copy))]
503    pub(crate) mesh3d_vert_cap: usize,
504    /// Uploaded mesh vertex buffer revision.
505    #[get(type(copy))]
506    pub(crate) mesh3d_vert_rev: u64,
507    /// Streaming 3D instance buffer handle.
508    #[get(type(copy))]
509    pub(crate) mesh3d_inst_vbo: u32,
510    /// Allocated byte capacity of `mesh3d_inst_vbo`.
511    #[get(type(copy))]
512    pub(crate) mesh3d_inst_cap: usize,
513    /// Cached 3D mesh uniform `u_view_proj`.
514    #[get(type(copy))]
515    pub(crate) mesh3d_vp_loc: i32,
516    /// Cached 3D mesh uniform `u_camera_pos`.
517    #[get(type(copy))]
518    pub(crate) mesh3d_cam_loc: i32,
519    /// Cached 3D mesh uniform `u_sun_dir_fog`.
520    #[get(type(copy))]
521    pub(crate) mesh3d_sun_fog_loc: i32,
522    /// Cached 3D mesh uniform `u_sun_color_ambient`.
523    #[get(type(copy))]
524    pub(crate) mesh3d_sun_col_loc: i32,
525    /// Cached 3D mesh uniform `u_sky_horizon_tod`.
526    #[get(type(copy))]
527    pub(crate) mesh3d_hor_loc: i32,
528    /// Cached 3D mesh uniform `u_sky_zenith_aspect`.
529    #[get(type(copy))]
530    pub(crate) mesh3d_zen_loc: i32,
531    /// Lazily initialized quantized PBR + GPU skinning + mipmap streaming pipeline (`DirectGpuScenePass::PbrScene`).
532    #[get(skip)]
533    #[get_mut(skip)]
534    #[set(skip)]
535    pub(crate) pbr: Option<LinuxEglPbrResources>,
536}
537
538/// Resident Linux GLES3 mipmapped texture slot supporting incremental `glTexSubImage2D` and `GL_TEXTURE_BASE_LEVEL` streaming.
539#[derive(Clone, Copy, Debug, Default)]
540pub(crate) struct LinuxResidentMipTexture {
541    /// GLES3 texture handle.
542    pub(crate) tex_id: u32,
543    /// Base `LOD0` width in texels.
544    pub(crate) base_width: u32,
545    /// Base `LOD0` height in texels.
546    pub(crate) base_height: u32,
547    /// Total allocated mipmap levels.
548    pub(crate) total_mips: u8,
549    /// Active `GL_TEXTURE_BASE_LEVEL` clamp (`0 = FullRes`, higher = mip-tail).
550    pub(crate) min_lod_clamp: u8,
551}
552
553/// Retained Linux EGL/GLES3 `DirectGpuScenePass::PbrScene` programs (backed by persistent `glProgramBinary` disk cache), VAO/VBO/EBO, RGBA32F data textures, and mipmap pool.
554#[derive(Debug, Default)]
555pub(crate) struct LinuxEglPbrResources {
556    /// Compiled/cached sky backdrop GLES3 program ID.
557    pub(crate) sky_program: u32,
558    /// Compiled/cached unified quantized PBR + skinning + morph GLES3 program ID.
559    pub(crate) scene_program: u32,
560    /// `u_camera_pos_exposure` location on `sky_program`.
561    pub(crate) sky_cam_loc: i32,
562    /// `u_sun_dir_fog` location on `sky_program`.
563    pub(crate) sky_sun_fog_loc: i32,
564    /// `u_sun_color_ambient` location on `sky_program`.
565    pub(crate) sky_sun_col_loc: i32,
566    /// `u_sky_horizon_tod` location on `sky_program`.
567    pub(crate) sky_hor_loc: i32,
568    /// `u_sky_zenith_agx` location on `sky_program`.
569    pub(crate) sky_zen_agx_loc: i32,
570    /// `u_view_proj` location on `scene_program`.
571    pub(crate) vp_loc: i32,
572    /// `u_camera_pos_exposure` location on `scene_program`.
573    pub(crate) cam_exp_loc: i32,
574    /// `u_sun_dir_fog` location on `scene_program`.
575    pub(crate) sun_fog_loc: i32,
576    /// `u_sun_color_ambient` location on `scene_program`.
577    pub(crate) sun_col_loc: i32,
578    /// `u_sky_horizon_tod` location on `scene_program`.
579    pub(crate) hor_loc: i32,
580    /// `u_sky_zenith_agx` location on `scene_program`.
581    pub(crate) zen_agx_loc: i32,
582    /// `u_ibl_sh[0]` location on `scene_program`.
583    pub(crate) ibl_sh_loc: i32,
584    /// `u_batch_params` location on `scene_program`.
585    pub(crate) batch_params_loc: i32,
586    /// `u_draw_offsets` location on `scene_program`.
587    pub(crate) draw_offsets_loc: i32,
588    /// `u_morph_weights[0]` location on `scene_program`.
589    pub(crate) morph_weights_loc: i32,
590    /// VAO binding quantized 24B verts, 16B skin verts, `u32` EBO, and 112B instanced transforms.
591    pub(crate) vao: u32,
592    /// Static 24-byte `QuantizedVertex3D` VBO.
593    pub(crate) vert_vbo: u32,
594    /// Allocated byte capacity of `vert_vbo`.
595    pub(crate) vert_cap: usize,
596    /// Static `u32` index EBO.
597    pub(crate) idx_ebo: u32,
598    /// Allocated byte capacity of `idx_ebo`.
599    pub(crate) idx_cap: usize,
600    /// Static 16-byte `QuantizedSkinVertex3D` VBO.
601    pub(crate) skin_vbo: u32,
602    /// Allocated byte capacity of `skin_vbo`.
603    pub(crate) skin_cap: usize,
604    /// Uploaded `GpuPbrMeshBuffer::revision`.
605    pub(crate) mesh_rev: u64,
606    /// Dynamic 112-byte `GpuPbrInstance3D` VBO.
607    pub(crate) inst_vbo: u32,
608    /// Allocated byte capacity of `inst_vbo`.
609    pub(crate) inst_cap: usize,
610    /// `RGBA32F` skeletal bone palette texture (`GL_TEXTURE5`).
611    pub(crate) bone_tex: u32,
612    /// `RGBA32F` Principled BSDF material data texture (`GL_TEXTURE6`).
613    pub(crate) mat_tex: u32,
614    /// `RGBA32F` packed local light data texture (`GL_TEXTURE7`).
615    pub(crate) light_tex: u32,
616    /// `RGBA32F` morph target delta data texture (`GL_TEXTURE8`).
617    pub(crate) morph_tex: u32,
618    /// 1x1 fallback white RGBA8 texture for unbound material texture slots.
619    pub(crate) dummy_white_tex: u32,
620    /// Resident mipmapped PBR texture pool keyed by `texture_slot`.
621    pub(crate) textures: HashMap<u32, LinuxResidentMipTexture>,
622    /// Reusable flat `f32` packing buffer for `RGBA32F` data texture uploads.
623    pub(crate) data_tex_scratch: Vec<f32>,
624}
625
626/// Live dynamic EGL + GLES3 instanced uber-shader presentation surface over Wayland (`wl_egl_window`) or X11 (`Window`).
627#[derive(Data, Debug)]
628pub(crate) struct LinuxEglGlesSurface {
629    /// Active `EGLDisplay` handle stored as `usize`.
630    #[get(type(copy))]
631    pub(crate) egl_display: usize,
632    /// Active `EGLContext` handle stored as `usize`.
633    #[get(type(copy))]
634    pub(crate) egl_context: usize,
635    /// Active `EGLSurface` handle stored as `usize`.
636    #[get(type(copy))]
637    pub(crate) egl_surface: usize,
638    /// Active `wl_egl_window*` pointer (`0` on X11).
639    #[get(type(copy))]
640    pub(crate) wl_egl_window: usize,
641    /// Compiled GLES3 instanced UI uber-shader program ID.
642    #[get(type(copy))]
643    pub(crate) program: u32,
644    /// Vertex array object binding quad + instanced attribute descriptors.
645    #[get(type(copy))]
646    pub(crate) vao: u32,
647    /// Static 6-vertex unit quad buffer bound at attribute location `0`.
648    #[get(type(copy))]
649    pub(crate) quad_vbo: u32,
650    /// Streaming 64-byte `GpuPrimitiveInstance` VBO.
651    #[get(type(copy))]
652    pub(crate) instance_vbo: u32,
653    /// Allocated byte capacity of `instance_vbo`.
654    #[get(type(copy))]
655    pub(crate) instance_vbo_cap: usize,
656    /// Persistent `GL_R8` glyph atlas texture ID.
657    #[get(type(copy))]
658    pub(crate) glyph_r8_tex: u32,
659    /// Width of `glyph_r8_tex` in texels.
660    #[get(type(copy))]
661    pub(crate) glyph_r8_w: u32,
662    /// Height of `glyph_r8_tex` in texels.
663    #[get(type(copy))]
664    pub(crate) glyph_r8_h: u32,
665    /// Uploaded revision of `glyph_r8_tex`.
666    #[get(type(copy))]
667    pub(crate) glyph_r8_rev: u64,
668    /// Color `GL_RGBA8` glyph texture ID.
669    #[get(type(copy))]
670    pub(crate) glyph_rgba8_tex: u32,
671    /// Persistent `GL_RGBA8` image atlas texture ID.
672    #[get(type(copy))]
673    pub(crate) image_tex: u32,
674    /// Width of `image_tex` in texels.
675    #[get(type(copy))]
676    pub(crate) image_w: u32,
677    /// Height of `image_tex` in texels.
678    #[get(type(copy))]
679    pub(crate) image_h: u32,
680    /// Uploaded revision of `image_tex`.
681    #[get(type(copy))]
682    pub(crate) image_rev: u64,
683    /// External/video `GL_RGBA8` texture ID.
684    #[get(type(copy))]
685    pub(crate) external_tex: u32,
686    /// Cached uniform location for `u_viewport`.
687    #[get(type(copy))]
688    pub(crate) viewport_loc: i32,
689    /// Cached uniform location for `u_scroll_offset`.
690    #[get(type(copy))]
691    pub(crate) scroll_loc: i32,
692    /// Active surface width in physical pixels.
693    #[get(type(copy))]
694    pub(crate) width: u32,
695    /// Active surface height in physical pixels.
696    #[get(type(copy))]
697    pub(crate) height: u32,
698    /// True when backed by `wl_egl_window`; false when backed by X11 `Window`.
699    #[get(type(copy))]
700    pub(crate) is_wayland: bool,
701    /// Maximum supported GLES3 texture dimension queried via `GL_MAX_TEXTURE_SIZE`.
702    #[get(type(copy))]
703    pub(crate) max_tex_dim: u32,
704    /// Lazily initialized offscreen GLES3 scene pass pipeline (`OceanFluid` + `World3d`).
705    #[get(skip)]
706    #[get_mut(skip)]
707    #[set(skip)]
708    pub(crate) scene: Option<LinuxEglScenePipeline>,
709    /// Reusable flat primitive staging buffer avoiding per-frame allocations on direct submission.
710    #[get(skip)]
711    #[get_mut(skip)]
712    #[set(skip)]
713    pub(crate) scratch_prims: Vec<GpuPrimitiveInstance>,
714    /// Reusable draw-range metadata buffer paired with `scratch_prims`.
715    #[get(skip)]
716    #[get_mut(skip)]
717    #[set(skip)]
718    pub(crate) scratch_ranges: Vec<(usize, usize, Rect, [f32; 2])>,
719    /// Heap-stable atomic VSync latch cleared by `wl_surface.frame` callback on Wayland.
720    #[get(skip)]
721    #[get_mut(skip)]
722    #[set(skip)]
723    pub(crate) vsync_pending: Box<AtomicBool>,
724}
725
726/// Raw `wl_registry_listener` ABI table registered during Wayland global discovery.
727#[repr(C)]
728#[derive(Clone, Copy)]
729pub(crate) struct WlRegistryListener {
730    /// Callback invoked for each advertised Wayland global `(data, registry, name, interface, version)`.
731    pub(crate) global: unsafe extern "C" fn(*mut c_void, *mut c_void, u32, *const c_char, u32),
732    /// Callback invoked when a Wayland global is removed `(data, registry, name)`.
733    pub(crate) global_remove: unsafe extern "C" fn(*mut c_void, *mut c_void, u32),
734}
735
736/// Raw `wl_buffer_listener` ABI table tracking compositor buffer release notifications.
737#[repr(C)]
738#[derive(Clone, Copy)]
739pub(crate) struct WlBufferListener {
740    /// Callback invoked when the compositor finishes reading a `wl_buffer` (`(data, buffer)`).
741    pub(crate) release: unsafe extern "C" fn(*mut c_void, *mut c_void),
742}
743
744/// Mutable state populated by `WL_REGISTRY_LISTENER` during initial `wl_display_roundtrip`.
745#[repr(C)]
746#[derive(Clone, Copy, Debug, Default)]
747pub(crate) struct WlRegistryBindState {
748    /// Bound `wl_compositor*` proxy handle.
749    pub(crate) compositor: usize,
750    /// Negotiated `wl_compositor` protocol version.
751    pub(crate) compositor_version: u32,
752    /// Bound `wl_shm*` proxy handle.
753    pub(crate) shm: usize,
754}
755
756/// Descriptor carrying POSIX shared-memory FD, geometry, format, and release flag pointer for `WaylandShmCommitOps`.
757#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
758pub struct WaylandShmBufferDescriptor {
759    /// Open shared-memory file descriptor (`memfd_create` or `/dev/shm`).
760    #[get(type(copy))]
761    pub(crate) fd: i32,
762    /// Total mapped buffer byte size.
763    #[get(type(copy))]
764    pub(crate) size: i32,
765    /// Physical buffer width in pixels.
766    #[get(type(copy))]
767    pub(crate) width: i32,
768    /// Physical buffer height in pixels.
769    #[get(type(copy))]
770    pub(crate) height: i32,
771    /// Row stride in bytes (`width * 4`).
772    #[get(type(copy))]
773    pub(crate) stride: i32,
774    /// Wayland shm pixel format (`WL_SHM_FORMAT_ARGB8888` or `WL_SHM_FORMAT_XRGB8888`).
775    #[get(type(copy))]
776    pub(crate) format: u32,
777    /// Raw pointer to the slot's release `AtomicBool` userdata registered on `wl_buffer.release`.
778    #[get(type(copy))]
779    pub(crate) release_flag_ptr: usize,
780}
781
782/// Single double-buffered Wayland `wl_shm` memory mapping and protocol buffer slot.
783#[derive(Debug)]
784pub struct WaylandShmBufferSlot {
785    /// Open POSIX shared-memory file descriptor (`-1` when unallocated).
786    pub(crate) fd: i32,
787    /// Base pointer returned by `mmap(..., MAP_SHARED, fd, 0)` (`0` when unmapped).
788    pub(crate) mapped_ptr: usize,
789    /// Mapped byte capacity of this shared-memory region.
790    pub(crate) mapped_len: usize,
791    /// Current allocated buffer width in physical pixels.
792    pub(crate) width: u32,
793    /// Current allocated buffer height in physical pixels.
794    pub(crate) height: u32,
795    /// Row stride in bytes (`width * 4`).
796    pub(crate) stride: u32,
797    /// Bound Wayland shm pixel format (`WL_SHM_FORMAT_ARGB8888` or `WL_SHM_FORMAT_XRGB8888`).
798    pub(crate) format: u32,
799    /// Associated `wl_shm_pool*` proxy handle (`0` when detached).
800    pub(crate) wl_pool: usize,
801    /// Associated `wl_buffer*` proxy handle (`0` when detached).
802    pub(crate) wl_buffer: usize,
803    /// Atomic busy flag cleared asynchronously by `wl_buffer.release` (`true` while held by compositor).
804    pub(crate) busy: Box<AtomicBool>,
805    /// True once this slot has received a complete full-frame pixel copy for its current dimensions.
806    pub(crate) has_full_copy: bool,
807}
808
809/// Double-buffered Wayland `wl_shm` software swapchain owning two POSIX shm mappings and dirty-rect tracking.
810#[derive(Debug)]
811pub struct WaylandShmSwapchain {
812    /// Two ping-pong shared-memory slots enabling tear-free double-buffered Wayland commits.
813    pub(crate) slots: [WaylandShmBufferSlot; WL_SHM_SLOT_COUNT],
814    /// Wayland shm pixel format (`WL_SHM_FORMAT_XRGB8888` or `WL_SHM_FORMAT_ARGB8888`).
815    pub(crate) pixel_format: u32,
816    /// Dirty rectangles from the immediately preceding submitted frame so double-buffered back slots stay coherent.
817    pub(crate) previous_dirty_rects: Vec<(u32, u32, u32, u32)>,
818    /// Index (`0` or `1`) of the most recently committed buffer slot.
819    pub(crate) last_committed_slot: u8,
820    /// Cumulative count of successfully committed Wayland shm frames.
821    pub(crate) submitted_frames: u64,
822    /// Cumulative count of unchanged frames skipped without commit.
823    pub(crate) skipped_unchanged_frames: u64,
824    /// Cumulative count of failed presentation attempts.
825    pub(crate) failed_frames: u64,
826}
827
828/// Native `libwayland-client.so.0` transport invoking `wl_shm_pool`, `wl_buffer`, `wl_surface`, and `wl_display_flush`.
829#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
830pub struct NativeWaylandShmTransport {
831    /// Live `wl_display*` connection pointer.
832    #[get(type(copy))]
833    pub(crate) display: usize,
834    /// Live `wl_surface*` proxy pointer.
835    #[get(type(copy))]
836    pub(crate) surface: usize,
837    /// Live `wl_shm*` global proxy pointer.
838    #[get(type(copy))]
839    pub(crate) wl_shm: usize,
840    /// Negotiated `wl_surface` interface version (`>= 4` uses `damage_buffer`, `< 4` uses `damage`).
841    #[get(type(copy))]
842    pub(crate) surface_version: u32,
843    /// Integer `wl_surface.set_buffer_scale` divisor applied prior to commit (`<= 0` defaults to `1`).
844    #[new(skip)]
845    #[get(type(copy))]
846    pub(crate) buffer_scale: i32,
847}
848
849/// Explicit per-frame Linux presentation telemetry separating direct GPU vs Wayland shm vs X11 software blits.
850#[derive(Clone, Copy, Data, Debug, Default, Eq, PartialEq)]
851pub struct LinuxPresentTelemetry {
852    /// Active presentation transport (`GpuDirect`, `WaylandShmSoftware`, or `X11Software`).
853    #[get(type(copy))]
854    pub(crate) mode: LinuxPresentationMode,
855    /// Explicit frame outcome (`Submitted`, `SkippedUnchanged`, or `Failed`).
856    #[get(type(copy))]
857    pub(crate) outcome: LinuxPresentOutcome,
858    /// True whenever a CPU software framebuffer mirror is active (`false` for `GpuDirect`).
859    #[get(type(copy))]
860    pub(crate) cpu_mirror_active: bool,
861    /// Exact pixel bytes copied into Wayland shm or uploaded via X11 `XPutImage` (`0` for `GpuDirect` or skip).
862    #[get(type(copy))]
863    pub(crate) upload_bytes: u64,
864    /// Number of dirty rectangles damaged or uploaded during this frame.
865    #[get(type(copy))]
866    pub(crate) dirty_rect_count: u32,
867    /// Double-buffered Wayland shm slot index (`0` or `1`) committed on this frame.
868    #[get(type(copy))]
869    pub(crate) committed_buffer_slot: u8,
870    /// Cumulative submitted frames recorded on this window.
871    #[get(type(copy))]
872    pub(crate) submitted_frames: u64,
873    /// Cumulative unchanged frames skipped on this window.
874    #[get(type(copy))]
875    pub(crate) skipped_unchanged_frames: u64,
876    /// Cumulative failed frames recorded on this window.
877    #[get(type(copy))]
878    pub(crate) failed_frames: u64,
879}
880
881/// Raw 192-byte X11 `XEvent` union storage aligned for 64-bit Linux LP64 ABI.
882#[repr(C)]
883#[derive(Clone, Copy)]
884pub(crate) struct X11EventRaw {
885    /// Raw union payload words.
886    pub(crate) pad: [isize; 24],
887}
888
889/// X11 `XKeyEvent` / `XButtonEvent` ABI layout on LP64 Linux.
890#[repr(C)]
891#[derive(Clone, Copy)]
892pub(crate) struct X11KeyOrButtonEvent {
893    /// Event discriminant (`KeyPress`, `KeyRelease`, `ButtonPress`, `ButtonRelease`).
894    pub(crate) event_type: i32,
895    /// X server serial number.
896    pub(crate) serial: usize,
897    /// Non-zero when generated by `SendEvent`.
898    pub(crate) send_event: i32,
899    /// Connection `Display*`.
900    pub(crate) display: *mut c_void,
901    /// Target `Window` XID.
902    pub(crate) window: u64,
903    /// Root window XID.
904    pub(crate) root: u64,
905    /// Subwindow XID.
906    pub(crate) subwindow: u64,
907    /// Event timestamp in milliseconds.
908    pub(crate) time: u64,
909    /// Pointer X coordinate relative to window.
910    pub(crate) x: i32,
911    /// Pointer Y coordinate relative to window.
912    pub(crate) y: i32,
913    /// Pointer X relative to root window.
914    pub(crate) x_root: i32,
915    /// Pointer Y relative to root window.
916    pub(crate) y_root: i32,
917    /// Modifier key / button mask.
918    pub(crate) state: u32,
919    /// Hardware keycode or mouse button number.
920    pub(crate) detail: u32,
921    /// Same-screen flag.
922    pub(crate) same_screen: i32,
923}
924
925/// X11 `XMotionEvent` ABI layout on LP64 Linux.
926#[repr(C)]
927#[derive(Clone, Copy)]
928pub(crate) struct X11MotionEvent {
929    /// Event discriminant (`MotionNotify`).
930    pub(crate) event_type: i32,
931    /// X server serial number.
932    pub(crate) serial: usize,
933    /// Send-event flag.
934    pub(crate) send_event: i32,
935    /// Connection `Display*`.
936    pub(crate) display: *mut c_void,
937    /// Target `Window` XID.
938    pub(crate) window: u64,
939    /// Root window XID.
940    pub(crate) root: u64,
941    /// Subwindow XID.
942    pub(crate) subwindow: u64,
943    /// Timestamp in milliseconds.
944    pub(crate) time: u64,
945    /// Pointer X coordinate relative to window.
946    pub(crate) x: i32,
947    /// Pointer Y coordinate relative to window.
948    pub(crate) y: i32,
949    /// Pointer X relative to root window.
950    pub(crate) x_root: i32,
951    /// Pointer Y relative to root window.
952    pub(crate) y_root: i32,
953    /// Active modifier mask.
954    pub(crate) state: u32,
955    /// Motion hint byte.
956    pub(crate) is_hint: c_char,
957    /// Same-screen flag.
958    pub(crate) same_screen: i32,
959}
960
961/// X11 `XConfigureEvent` ABI layout on LP64 Linux.
962#[repr(C)]
963#[derive(Clone, Copy)]
964pub(crate) struct X11ConfigureEvent {
965    /// Event discriminant (`ConfigureNotify`).
966    pub(crate) event_type: i32,
967    /// X server serial number.
968    pub(crate) serial: usize,
969    /// Send-event flag.
970    pub(crate) send_event: i32,
971    /// Connection `Display*`.
972    pub(crate) display: *mut c_void,
973    /// Event-delivery window XID.
974    pub(crate) event_window: u64,
975    /// Reconfigured target window XID.
976    pub(crate) window: u64,
977    /// New window X position.
978    pub(crate) x: i32,
979    /// New window Y position.
980    pub(crate) y: i32,
981    /// New window client width in physical pixels.
982    pub(crate) width: i32,
983    /// New window client height in physical pixels.
984    pub(crate) height: i32,
985}
986
987/// X11 `XClientMessageEvent` ABI layout on LP64 Linux.
988#[repr(C)]
989#[derive(Clone, Copy)]
990pub(crate) struct X11ClientMessageEvent {
991    /// Event discriminant (`ClientMessage`).
992    pub(crate) event_type: i32,
993    /// X server serial number.
994    pub(crate) serial: usize,
995    /// Send-event flag.
996    pub(crate) send_event: i32,
997    /// Connection `Display*`.
998    pub(crate) display: *mut c_void,
999    /// Target `Window` XID.
1000    pub(crate) window: u64,
1001    /// Message type atom (`WM_PROTOCOLS`).
1002    pub(crate) message_type: u64,
1003    /// Data format (`8`, `16`, or `32`).
1004    pub(crate) format: i32,
1005    /// 32-bit protocol data payload (`l[0]` holds `WM_DELETE_WINDOW`).
1006    pub(crate) data: [u64; 5],
1007}
1008
1009/// Bundle returned when opening a native Linux X11 or Wayland window.
1010#[derive(Clone, Copy, Data, Debug)]
1011pub(crate) struct LinuxNativeWindowHandle {
1012    /// Dynamically loaded `libX11` or `libwayland-client` handle.
1013    #[get(type(copy))]
1014    pub(crate) lib: usize,
1015    /// True when backed by Wayland; false when backed by X11.
1016    #[get(type(copy))]
1017    pub(crate) is_wayland: bool,
1018    /// Raw `Display*` or `wl_display*`.
1019    #[get(type(copy))]
1020    pub(crate) display: usize,
1021    /// Native X11 `Window` XID or Wayland surface pointer.
1022    #[get(type(copy))]
1023    pub(crate) window: u64,
1024    /// Cached X11 `GC` handle for `XPutImage`.
1025    #[get(type(copy))]
1026    pub(crate) gc: usize,
1027    /// Cached X11 `Visual*` pointer for `XCreateImage`.
1028    #[get(type(copy))]
1029    pub(crate) visual: usize,
1030    /// X11 default visual color depth (e.g., `24` or `32`).
1031    #[get(type(copy))]
1032    pub(crate) depth: u32,
1033    /// Interned `WM_DELETE_WINDOW` atom for graceful window closing.
1034    #[get(type(copy))]
1035    pub(crate) wm_delete_atom: u64,
1036    /// Probed display DPI scale factor (`1.0..=4.0`).
1037    #[get(type(copy))]
1038    pub(crate) scale_factor: f32,
1039    /// True when X11 MIT-SHM (`XShmQueryExtension`) is supported on this display.
1040    #[get(type(copy))]
1041    pub(crate) mit_shm_available: bool,
1042    /// True when Wayland Vulkan WSI (`VK_KHR_wayland_surface`) is available.
1043    #[get(type(copy))]
1044    pub(crate) wayland_vulkan_wsi: bool,
1045    /// True when X11 Vulkan WSI (`VK_KHR_xlib_surface`) is available.
1046    #[get(type(copy))]
1047    pub(crate) xlib_vulkan_wsi: bool,
1048    /// Bound Wayland `wl_compositor*` proxy pointer (`0` on X11 or unavailable).
1049    #[get(type(copy))]
1050    pub(crate) wl_compositor: usize,
1051    /// Bound Wayland `wl_shm*` proxy pointer (`0` on X11 or unavailable).
1052    #[get(type(copy))]
1053    pub(crate) wl_shm: usize,
1054    /// Negotiated Wayland `wl_surface` interface version (`0` on X11).
1055    #[get(type(copy))]
1056    pub(crate) wl_surface_version: u32,
1057}
1058
1059/// Native Linux X11 / Wayland window record.
1060#[derive(Clone, Data, Debug)]
1061pub struct LinuxWindowRecord {
1062    /// Window configuration.
1063    pub(crate) config: WindowConfig,
1064    /// Live window state.
1065    #[get(type(copy))]
1066    pub(crate) state: WindowState,
1067    /// True when backed by Wayland; false when backed by X11 Xlib.
1068    #[get(type(copy))]
1069    pub(crate) is_wayland: bool,
1070    /// Raw display handle (`Display*` or `wl_display*`).
1071    #[get(type(copy))]
1072    pub(crate) display: usize,
1073    /// Raw window or surface identifier (`Window` or `wl_surface*`).
1074    #[get(type(copy))]
1075    pub(crate) window: u64,
1076    /// Cached X11 `GC` handle used by `XPutImage`.
1077    #[get(type(copy))]
1078    pub(crate) gc: usize,
1079    /// Cached X11 `Visual*` pointer used by `XCreateImage`.
1080    #[get(type(copy))]
1081    pub(crate) visual: usize,
1082    /// X11 visual depth in bits (`24` or `32`).
1083    #[get(type(copy))]
1084    pub(crate) depth: u32,
1085    /// Interned `WM_DELETE_WINDOW` protocol atom.
1086    #[get(type(copy))]
1087    pub(crate) wm_delete_atom: u64,
1088    /// Whether `XMapWindow` has been issued after Frame 1 presentation (eliminates unmapped flash).
1089    #[get(type(copy))]
1090    pub(crate) revealed: bool,
1091    /// Whether X11 MIT-SHM shared-memory image transport is supported by the X server.
1092    #[get(type(copy))]
1093    pub(crate) mit_shm_available: bool,
1094    /// Whether Wayland Vulkan WSI (`VK_KHR_wayland_surface`) is ready on this display.
1095    #[get(type(copy))]
1096    pub(crate) wayland_vulkan_wsi: bool,
1097    /// Whether X11 Vulkan WSI (`VK_KHR_xlib_surface`) is ready on this display.
1098    #[get(type(copy))]
1099    pub(crate) xlib_vulkan_wsi: bool,
1100    /// Bound Wayland `wl_compositor*` proxy pointer (`0` on X11).
1101    #[get(type(copy))]
1102    pub(crate) wl_compositor: usize,
1103    /// Bound Wayland `wl_shm*` proxy pointer (`0` on X11).
1104    #[get(type(copy))]
1105    pub(crate) wl_shm: usize,
1106    /// Negotiated Wayland `wl_surface` interface version (`>= 4` supports `damage_buffer`).
1107    #[get(type(copy))]
1108    pub(crate) wl_surface_version: u32,
1109    /// Reported `wl_output.mode` refresh rate in millihertz (e.g. `240000` for `240Hz`, `0` if unset).
1110    #[get(type(copy))]
1111    pub(crate) wayland_output_refresh_milli_hz: u32,
1112    /// Latest `wp_presentation` feedback timestamp in nanoseconds (`0` before first presentation).
1113    #[get(type(copy))]
1114    pub(crate) wayland_presentation_time_ns: u64,
1115    /// Whether a `wl_surface::frame` callback is currently armed awaiting compositor VSync.
1116    #[get(type(copy))]
1117    pub(crate) wayland_frame_callback_pending: bool,
1118    /// Active Linux presentation mode (`GpuDirect`, `WaylandShmSoftware`, or `X11Software`).
1119    #[get(type(copy))]
1120    pub(crate) presentation_mode: LinuxPresentationMode,
1121    /// Explicit CPU-mirror telemetry flag (`true` on Wayland shm / X11 software; `false` on direct GPU).
1122    #[get(type(copy))]
1123    pub(crate) cpu_mirror_active: bool,
1124    /// Most recent per-frame Linux presentation telemetry snapshot.
1125    #[get(type(copy))]
1126    pub(crate) last_telemetry: LinuxPresentTelemetry,
1127    /// Double-buffered Wayland `wl_shm` software swapchain attached to this window when Wayland is active.
1128    #[get(skip)]
1129    #[get_mut(skip)]
1130    #[set(skip)]
1131    pub(crate) wayland_shm: Option<Arc<Mutex<WaylandShmSwapchain>>>,
1132    /// Optional dynamically loaded EGL + GLES3 instanced direct-GPU surface over Wayland or X11.
1133    #[get(skip)]
1134    #[get_mut(skip)]
1135    #[set(skip)]
1136    pub(crate) egl_gles: Option<Arc<Mutex<LinuxEglGlesSurface>>>,
1137}
1138
1139/// Direct Linux X11 / Wayland (`dlopen`-loaded) + Vulkan platform backend.
1140#[derive(Clone, Data, Debug)]
1141pub struct LinuxPlatform {
1142    /// Monotonic window handle generator.
1143    #[get(pub(crate), type(copy))]
1144    #[get_mut(pub(crate))]
1145    #[set(pub(crate))]
1146    pub(crate) next_id: u64,
1147    /// Dynamically loaded `libX11` handle if present.
1148    #[get(pub(crate), type(copy))]
1149    #[get_mut(pub(crate))]
1150    #[set(pub(crate))]
1151    pub(crate) x11_lib: usize,
1152    /// Active native Linux windows.
1153    pub(crate) windows: HashMap<WindowId, LinuxWindowRecord>,
1154    /// Queued window and input events.
1155    pub(crate) pending_events: Vec<WindowEvent>,
1156    /// Clipboard text cache.
1157    #[get(skip)]
1158    pub(crate) clipboard_cache: Option<String>,
1159    /// Whether the Linux X11/Wayland frame pump is paused for background freeze.
1160    #[get(pub(crate), type(copy))]
1161    #[set(pub(crate))]
1162    pub(crate) pump_paused: bool,
1163    /// Non-blocking wakeup pipe read end passed to `poll(display_fd, wakeup_pipe)` (`-1` when unavailable).
1164    #[get(pub(crate), type(copy))]
1165    #[set(pub(crate))]
1166    pub(crate) wake_read_fd: i32,
1167    /// Non-blocking wakeup pipe write end signaled by `wake_event_loop()` (`-1` when unavailable).
1168    #[get(pub(crate), type(copy))]
1169    #[set(pub(crate))]
1170    pub(crate) wake_write_fd: i32,
1171}