euv-core 0.53.0

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
use super::*;

/// Cached `libX11.so.6` function pointer table resolved once per process.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxX11Syms {
    /// Handle returned by `dlopen("libX11.so.6")`.
    pub(crate) lib: usize,
    /// `XOpenDisplay` symbol address.
    pub(crate) open_display: usize,
    /// `XDefaultScreen` symbol address.
    pub(crate) default_screen: usize,
    /// `XRootWindow` symbol address.
    pub(crate) root_window: usize,
    /// `XCreateSimpleWindow` symbol address.
    pub(crate) create_simple_window: usize,
    /// `XStoreName` symbol address.
    pub(crate) store_name: usize,
    /// `XMapWindow` symbol address.
    pub(crate) map_window: usize,
    /// `XResizeWindow` symbol address.
    pub(crate) resize_window: usize,
    /// `XDestroyWindow` symbol address.
    pub(crate) destroy_window: usize,
    /// `XFlush` symbol address.
    pub(crate) flush: usize,
    /// `XDefaultGC` symbol address.
    pub(crate) default_gc: usize,
    /// `XDefaultVisual` symbol address.
    pub(crate) default_visual: usize,
    /// `XDefaultDepth` symbol address.
    pub(crate) default_depth: usize,
    /// `XCreateImage` symbol address.
    pub(crate) create_image: usize,
    /// `XPutImage` symbol address.
    pub(crate) put_image: usize,
    /// `XFree` symbol address.
    pub(crate) free: usize,
    /// `XSelectInput` symbol address.
    pub(crate) select_input: usize,
    /// `XInternAtom` symbol address.
    pub(crate) intern_atom: usize,
    /// `XSetWMProtocols` symbol address.
    pub(crate) set_wm_protocols: usize,
    /// `XPending` symbol address.
    pub(crate) pending: usize,
    /// `XNextEvent` symbol address.
    pub(crate) next_event: usize,
    /// `XLookupString` symbol address.
    pub(crate) lookup_string: usize,
    /// `XResourceManagerString` symbol address.
    pub(crate) resource_manager_string: usize,
    /// `XConnectionNumber` symbol address returning the display socket fd for `poll()`.
    pub(crate) connection_number: usize,
}

/// Cached `libXrandr.so.2` function pointer table resolved once per process.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxXRandrSyms {
    /// `XRRGetScreenInfo` symbol address.
    pub(crate) get_screen_info: usize,
    /// `XRRConfigCurrentRate` symbol address.
    pub(crate) config_current_rate: usize,
    /// `XRRFreeScreenConfigInfo` symbol address.
    pub(crate) free_screen_config_info: usize,
}

/// Cached `libXext.so.6` MIT-SHM function pointer table resolved once per process.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxXShmSyms {
    /// `XShmQueryExtension` symbol address.
    pub(crate) query_extension: usize,
    /// `XShmCreateImage` symbol address.
    pub(crate) create_image: usize,
    /// `XShmAttach` symbol address.
    pub(crate) attach: usize,
    /// `XShmDetach` symbol address.
    pub(crate) detach: usize,
    /// `XShmPutImage` symbol address.
    pub(crate) put_image: usize,
}

/// Cached `libwayland-client.so.0` + Vulkan WSI symbol table resolved once per process.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxWaylandSyms {
    /// Handle returned by `dlopen("libwayland-client.so.0")`.
    pub(crate) lib: usize,
    /// `wl_display_connect` symbol address.
    pub(crate) display_connect: usize,
    /// `wl_display_disconnect` symbol address.
    pub(crate) display_disconnect: usize,
    /// `wl_display_dispatch_pending` symbol address.
    pub(crate) display_dispatch_pending: usize,
    /// `wl_display_dispatch` symbol address.
    pub(crate) display_dispatch: usize,
    /// `wl_display_flush` symbol address.
    pub(crate) display_flush: usize,
    /// `wl_display_roundtrip` symbol address.
    pub(crate) display_roundtrip: usize,
    /// `wl_display_get_error` symbol address.
    pub(crate) display_get_error: usize,
    /// `wl_display_get_fd` symbol address for blocking `poll()`.
    pub(crate) display_get_fd: usize,
    /// `wl_display_prepare_read` symbol address for race-free Wayland `poll()`.
    pub(crate) display_prepare_read: usize,
    /// `wl_display_read_events` symbol address for draining events after `poll()`.
    pub(crate) display_read_events: usize,
    /// `wl_display_cancel_read` symbol address canceling a prepared read on wakeup pipe signal.
    pub(crate) display_cancel_read: usize,
    /// `wl_proxy_marshal_flags` symbol address.
    pub(crate) proxy_marshal_flags: usize,
    /// `wl_proxy_add_listener` symbol address.
    pub(crate) proxy_add_listener: usize,
    /// `wl_proxy_destroy` symbol address.
    pub(crate) proxy_destroy: usize,
    /// `wl_proxy_get_version` symbol address.
    pub(crate) proxy_get_version: usize,
    /// Exported `wl_registry_interface` pointer address.
    pub(crate) registry_interface: usize,
    /// Exported `wl_compositor_interface` pointer address.
    pub(crate) compositor_interface: usize,
    /// Exported `wl_surface_interface` pointer address.
    pub(crate) surface_interface: usize,
    /// Exported `wl_shm_interface` pointer address.
    pub(crate) shm_interface: usize,
    /// Exported `wl_shm_pool_interface` pointer address.
    pub(crate) shm_pool_interface: usize,
    /// Exported `wl_buffer_interface` pointer address.
    pub(crate) buffer_interface: usize,
    /// Exported `wl_callback_interface` pointer address for `wl_surface.frame` VSync pacing.
    pub(crate) callback_interface: usize,
    /// True when `vkCreateWaylandSurfaceKHR` is available in `libvulkan.so.1`.
    pub(crate) vulkan_wsi_available: bool,
    /// True when `vkCreateXlibSurfaceKHR` is available in `libvulkan.so.1`.
    pub(crate) xlib_vulkan_wsi_available: bool,
}

/// POSIX `struct pollfd` ABI layout for blocking `poll(display_fd, wakeup_pipe)`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxPollFd {
    /// Target file descriptor.
    pub(crate) fd: i32,
    /// Requested event bitmask (`LINUX_POLLIN`).
    pub(crate) events: i16,
    /// Returned event bitmask populated by kernel `poll()`.
    pub(crate) revents: i16,
}

/// Raw `wl_callback_listener` ABI table tracking `wl_surface.frame` VSync completion.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct WlCallbackListener {
    /// Callback invoked on compositor VBlank (`(data, callback, callback_data)`).
    pub(crate) done: unsafe extern "C" fn(*mut c_void, *mut c_void, u32),
}

/// Cached `libEGL.so.1`, `libGLESv2.so.2`, and `libwayland-egl.so.1` symbol table resolved once per process.
#[derive(Clone, Copy, Data, Debug, Default)]
pub(crate) struct LinuxEglGlesSyms {
    /// True when core EGL and GLES3 instanced symbols resolved cleanly.
    #[get(type(copy))]
    pub(crate) ready: bool,
    /// True when `libwayland-egl.so.1` resolved cleanly.
    #[get(type(copy))]
    pub(crate) wayland_egl_ready: bool,
    /// `eglGetDisplay` address.
    #[get(type(copy))]
    pub(crate) egl_get_display: usize,
    /// `eglInitialize` address.
    #[get(type(copy))]
    pub(crate) egl_initialize: usize,
    /// `eglBindAPI` address.
    #[get(type(copy))]
    pub(crate) egl_bind_api: usize,
    /// `eglChooseConfig` address.
    #[get(type(copy))]
    pub(crate) egl_choose_config: usize,
    /// `eglCreateContext` address.
    #[get(type(copy))]
    pub(crate) egl_create_context: usize,
    /// `eglCreateWindowSurface` address.
    #[get(type(copy))]
    pub(crate) egl_create_window_surface: usize,
    /// `eglMakeCurrent` address.
    #[get(type(copy))]
    pub(crate) egl_make_current: usize,
    /// `eglSwapInterval` address.
    #[get(type(copy))]
    pub(crate) egl_swap_interval: usize,
    /// `eglSwapBuffers` address.
    #[get(type(copy))]
    pub(crate) egl_swap_buffers: usize,
    /// `eglDestroySurface` address.
    #[get(type(copy))]
    pub(crate) egl_destroy_surface: usize,
    /// `eglDestroyContext` address.
    #[get(type(copy))]
    pub(crate) egl_destroy_context: usize,
    /// `eglTerminate` address.
    #[get(type(copy))]
    pub(crate) egl_terminate: usize,
    /// `wl_egl_window_create` address.
    #[get(type(copy))]
    pub(crate) wl_egl_window_create: usize,
    /// `wl_egl_window_resize` address.
    #[get(type(copy))]
    pub(crate) wl_egl_window_resize: usize,
    /// `wl_egl_window_destroy` address.
    #[get(type(copy))]
    pub(crate) wl_egl_window_destroy: usize,
    /// `glCreateShader` address.
    #[get(type(copy))]
    pub(crate) gl_create_shader: usize,
    /// `glShaderSource` address.
    #[get(type(copy))]
    pub(crate) gl_shader_source: usize,
    /// `glCompileShader` address.
    #[get(type(copy))]
    pub(crate) gl_compile_shader: usize,
    /// `glGetShaderiv` address.
    #[get(type(copy))]
    pub(crate) gl_get_shaderiv: usize,
    /// `glDeleteShader` address.
    #[get(type(copy))]
    pub(crate) gl_delete_shader: usize,
    /// `glCreateProgram` address.
    #[get(type(copy))]
    pub(crate) gl_create_program: usize,
    /// `glAttachShader` address.
    #[get(type(copy))]
    pub(crate) gl_attach_shader: usize,
    /// `glLinkProgram` address.
    #[get(type(copy))]
    pub(crate) gl_link_program: usize,
    /// `glGetProgramiv` address.
    #[get(type(copy))]
    pub(crate) gl_get_programiv: usize,
    /// `glDeleteProgram` address.
    #[get(type(copy))]
    pub(crate) gl_delete_program: usize,
    /// `glUseProgram` address.
    #[get(type(copy))]
    pub(crate) gl_use_program: usize,
    /// `glGetUniformLocation` address.
    #[get(type(copy))]
    pub(crate) gl_get_uniform_location: usize,
    /// `glUniform1i` address.
    #[get(type(copy))]
    pub(crate) gl_uniform1i: usize,
    /// `glUniform2f` address.
    #[get(type(copy))]
    pub(crate) gl_uniform2f: usize,
    /// `glGenVertexArrays` address.
    #[get(type(copy))]
    pub(crate) gl_gen_vertex_arrays: usize,
    /// `glBindVertexArray` address.
    #[get(type(copy))]
    pub(crate) gl_bind_vertex_array: usize,
    /// `glDeleteVertexArrays` address.
    #[get(type(copy))]
    pub(crate) gl_delete_vertex_arrays: usize,
    /// `glGenBuffers` address.
    #[get(type(copy))]
    pub(crate) gl_gen_buffers: usize,
    /// `glBindBuffer` address.
    #[get(type(copy))]
    pub(crate) gl_bind_buffer: usize,
    /// `glBufferData` address.
    #[get(type(copy))]
    pub(crate) gl_buffer_data: usize,
    /// `glBufferSubData` address.
    #[get(type(copy))]
    pub(crate) gl_buffer_sub_data: usize,
    /// `glDeleteBuffers` address.
    #[get(type(copy))]
    pub(crate) gl_delete_buffers: usize,
    /// `glEnableVertexAttribArray` address.
    #[get(type(copy))]
    pub(crate) gl_enable_vertex_attrib_array: usize,
    /// `glVertexAttribPointer` address.
    #[get(type(copy))]
    pub(crate) gl_vertex_attrib_pointer: usize,
    /// `glVertexAttribIPointer` address.
    #[get(type(copy))]
    pub(crate) gl_vertex_attrib_ipointer: usize,
    /// `glVertexAttribDivisor` address.
    #[get(type(copy))]
    pub(crate) gl_vertex_attrib_divisor: usize,
    /// `glGenTextures` address.
    #[get(type(copy))]
    pub(crate) gl_gen_textures: usize,
    /// `glBindTexture` address.
    #[get(type(copy))]
    pub(crate) gl_bind_texture: usize,
    /// `glTexParameteri` address.
    #[get(type(copy))]
    pub(crate) gl_tex_parameteri: usize,
    /// `glTexStorage2D` address.
    #[get(type(copy))]
    pub(crate) gl_tex_storage_2d: usize,
    /// `glTexImage2D` address.
    #[get(type(copy))]
    pub(crate) gl_tex_image_2d: usize,
    /// `glTexSubImage2D` address.
    #[get(type(copy))]
    pub(crate) gl_tex_sub_image_2d: usize,
    /// `glDeleteTextures` address.
    #[get(type(copy))]
    pub(crate) gl_delete_textures: usize,
    /// `glActiveTexture` address.
    #[get(type(copy))]
    pub(crate) gl_active_texture: usize,
    /// `glPixelStorei` address.
    #[get(type(copy))]
    pub(crate) gl_pixel_storei: usize,
    /// `glViewport` address.
    #[get(type(copy))]
    pub(crate) gl_viewport: usize,
    /// `glEnable` address.
    #[get(type(copy))]
    pub(crate) gl_enable: usize,
    /// `glDisable` address.
    #[get(type(copy))]
    pub(crate) gl_disable: usize,
    /// `glBlendFuncSeparate` address.
    #[get(type(copy))]
    pub(crate) gl_blend_func_separate: usize,
    /// `glScissor` address.
    #[get(type(copy))]
    pub(crate) gl_scissor: usize,
    /// `glClearColor` address.
    #[get(type(copy))]
    pub(crate) gl_clear_color: usize,
    /// `glClear` address.
    #[get(type(copy))]
    pub(crate) gl_clear: usize,
    /// `glDrawArraysInstanced` address.
    #[get(type(copy))]
    pub(crate) gl_draw_arrays_instanced: usize,
    /// `glDrawArrays` address.
    #[get(type(copy))]
    pub(crate) gl_draw_arrays: usize,
    /// `glUniform4f` address.
    #[get(type(copy))]
    pub(crate) gl_uniform4f: usize,
    /// `glUniformMatrix4fv` address.
    #[get(type(copy))]
    pub(crate) gl_uniform_matrix4fv: usize,
    /// `glGetIntegerv` address.
    #[get(type(copy))]
    pub(crate) gl_get_integerv: usize,
    /// `glGenFramebuffers` address.
    #[get(type(copy))]
    pub(crate) gl_gen_framebuffers: usize,
    /// `glBindFramebuffer` address.
    #[get(type(copy))]
    pub(crate) gl_bind_framebuffer: usize,
    /// `glFramebufferTexture2D` address.
    #[get(type(copy))]
    pub(crate) gl_framebuffer_texture_2d: usize,
    /// `glDeleteFramebuffers` address.
    #[get(type(copy))]
    pub(crate) gl_delete_framebuffers: usize,
    /// `glGenRenderbuffers` address.
    #[get(type(copy))]
    pub(crate) gl_gen_renderbuffers: usize,
    /// `glBindRenderbuffer` address.
    #[get(type(copy))]
    pub(crate) gl_bind_renderbuffer: usize,
    /// `glRenderbufferStorage` address.
    #[get(type(copy))]
    pub(crate) gl_renderbuffer_storage: usize,
    /// `glFramebufferRenderbuffer` address.
    #[get(type(copy))]
    pub(crate) gl_framebuffer_renderbuffer: usize,
    /// `glDeleteRenderbuffers` address.
    #[get(type(copy))]
    pub(crate) gl_delete_renderbuffers: usize,
    /// `glDepthMask` address.
    #[get(type(copy))]
    pub(crate) gl_depth_mask: usize,
    /// `glDepthFunc` address.
    #[get(type(copy))]
    pub(crate) gl_depth_func: usize,
    /// `glClearDepthf` address.
    #[get(type(copy))]
    pub(crate) gl_clear_depthf: usize,
}

/// Retained Linux GLES 3.0 offscreen GPU scene pipeline executing `DirectGpuScenePass` (`OceanFluid` + `World3d`).
#[derive(Data, Debug, Default)]
pub(crate) struct LinuxEglScenePipeline {
    /// Offscreen scene framebuffer handle.
    #[get(type(copy))]
    pub(crate) scene_fbo: u32,
    /// Offscreen RGBA8 scene color texture bound to `GL_TEXTURE3` (`u_external_tex`).
    #[get(type(copy))]
    pub(crate) scene_color_tex: u32,
    /// Offscreen 24-bit depth renderbuffer handle for 3D Z-buffered rendering.
    #[get(type(copy))]
    pub(crate) scene_depth_rbo: u32,
    /// Active offscreen scene width in pixels.
    #[get(type(copy))]
    pub(crate) scene_w: u32,
    /// Active offscreen scene height in pixels.
    #[get(type(copy))]
    pub(crate) scene_h: u32,
    /// Resident PBF interactive wake RGBA8 texture handle.
    #[get(type(copy))]
    pub(crate) wake_tex: u32,
    /// Active wake texture width in texels.
    #[get(type(copy))]
    pub(crate) wake_w: u32,
    /// Active wake texture height in texels.
    #[get(type(copy))]
    pub(crate) wake_h: u32,
    /// Compiled Gerstner ocean + storm sky program ID.
    #[get(type(copy))]
    pub(crate) ocean_program: u32,
    /// Cached ocean uniform `u_time_agit_hor_aspect`.
    #[get(type(copy))]
    pub(crate) ocean_time_loc: i32,
    /// Cached ocean uniform `u_roll_boat_uv`.
    #[get(type(copy))]
    pub(crate) ocean_roll_loc: i32,
    /// Cached ocean uniform `u_sun_dir_wake`.
    #[get(type(copy))]
    pub(crate) ocean_sun_loc: i32,
    /// Compiled origami paper boat overlay program ID.
    #[get(type(copy))]
    pub(crate) boat_program: u32,
    /// Boat vertex array object handle.
    #[get(type(copy))]
    pub(crate) boat_vao: u32,
    /// Streaming boat vertex buffer handle.
    #[get(type(copy))]
    pub(crate) boat_vbo: u32,
    /// Allocated byte capacity of `boat_vbo`.
    #[get(type(copy))]
    pub(crate) boat_vbo_cap: usize,
    /// Compiled 3D atmospheric sky program ID.
    #[get(type(copy))]
    pub(crate) sky3d_program: u32,
    /// Cached 3D sky uniform `u_view_proj`.
    #[get(type(copy))]
    pub(crate) sky3d_vp_loc: i32,
    /// Cached 3D sky uniform `u_camera_pos`.
    #[get(type(copy))]
    pub(crate) sky3d_cam_loc: i32,
    /// Cached 3D sky uniform `u_sun_dir_fog`.
    #[get(type(copy))]
    pub(crate) sky3d_sun_dir_loc: i32,
    /// Cached 3D sky uniform `u_sun_color_ambient`.
    #[get(type(copy))]
    pub(crate) sky3d_sun_loc: i32,
    /// Cached 3D sky uniform `u_sky_horizon_tod`.
    #[get(type(copy))]
    pub(crate) sky3d_hor_loc: i32,
    /// Cached 3D sky uniform `u_sky_zenith_aspect`.
    #[get(type(copy))]
    pub(crate) sky3d_zen_loc: i32,
    /// Compiled instanced 3D PBR open-world program ID.
    #[get(type(copy))]
    pub(crate) mesh3d_program: u32,
    /// Instanced 3D mesh vertex array object handle.
    #[get(type(copy))]
    pub(crate) mesh3d_vao: u32,
    /// Static 3D mesh vertex buffer handle.
    #[get(type(copy))]
    pub(crate) mesh3d_vert_vbo: u32,
    /// Allocated byte capacity of `mesh3d_vert_vbo`.
    #[get(type(copy))]
    pub(crate) mesh3d_vert_cap: usize,
    /// Uploaded mesh vertex buffer revision.
    #[get(type(copy))]
    pub(crate) mesh3d_vert_rev: u64,
    /// Streaming 3D instance buffer handle.
    #[get(type(copy))]
    pub(crate) mesh3d_inst_vbo: u32,
    /// Allocated byte capacity of `mesh3d_inst_vbo`.
    #[get(type(copy))]
    pub(crate) mesh3d_inst_cap: usize,
    /// Cached 3D mesh uniform `u_view_proj`.
    #[get(type(copy))]
    pub(crate) mesh3d_vp_loc: i32,
    /// Cached 3D mesh uniform `u_camera_pos`.
    #[get(type(copy))]
    pub(crate) mesh3d_cam_loc: i32,
    /// Cached 3D mesh uniform `u_sun_dir_fog`.
    #[get(type(copy))]
    pub(crate) mesh3d_sun_fog_loc: i32,
    /// Cached 3D mesh uniform `u_sun_color_ambient`.
    #[get(type(copy))]
    pub(crate) mesh3d_sun_col_loc: i32,
    /// Cached 3D mesh uniform `u_sky_horizon_tod`.
    #[get(type(copy))]
    pub(crate) mesh3d_hor_loc: i32,
    /// Cached 3D mesh uniform `u_sky_zenith_aspect`.
    #[get(type(copy))]
    pub(crate) mesh3d_zen_loc: i32,
}

/// Live dynamic EGL + GLES3 instanced uber-shader presentation surface over Wayland (`wl_egl_window`) or X11 (`Window`).
#[derive(Data, Debug)]
pub(crate) struct LinuxEglGlesSurface {
    /// Active `EGLDisplay` handle stored as `usize`.
    #[get(type(copy))]
    pub(crate) egl_display: usize,
    /// Active `EGLContext` handle stored as `usize`.
    #[get(type(copy))]
    pub(crate) egl_context: usize,
    /// Active `EGLSurface` handle stored as `usize`.
    #[get(type(copy))]
    pub(crate) egl_surface: usize,
    /// Active `wl_egl_window*` pointer (`0` on X11).
    #[get(type(copy))]
    pub(crate) wl_egl_window: usize,
    /// Compiled GLES3 instanced UI uber-shader program ID.
    #[get(type(copy))]
    pub(crate) program: u32,
    /// Vertex array object binding quad + instanced attribute descriptors.
    #[get(type(copy))]
    pub(crate) vao: u32,
    /// Static 6-vertex unit quad buffer bound at attribute location `0`.
    #[get(type(copy))]
    pub(crate) quad_vbo: u32,
    /// Streaming 64-byte `GpuPrimitiveInstance` VBO.
    #[get(type(copy))]
    pub(crate) instance_vbo: u32,
    /// Allocated byte capacity of `instance_vbo`.
    #[get(type(copy))]
    pub(crate) instance_vbo_cap: usize,
    /// Persistent `GL_R8` glyph atlas texture ID.
    #[get(type(copy))]
    pub(crate) glyph_r8_tex: u32,
    /// Width of `glyph_r8_tex` in texels.
    #[get(type(copy))]
    pub(crate) glyph_r8_w: u32,
    /// Height of `glyph_r8_tex` in texels.
    #[get(type(copy))]
    pub(crate) glyph_r8_h: u32,
    /// Uploaded revision of `glyph_r8_tex`.
    #[get(type(copy))]
    pub(crate) glyph_r8_rev: u64,
    /// Color `GL_RGBA8` glyph texture ID.
    #[get(type(copy))]
    pub(crate) glyph_rgba8_tex: u32,
    /// Persistent `GL_RGBA8` image atlas texture ID.
    #[get(type(copy))]
    pub(crate) image_tex: u32,
    /// Width of `image_tex` in texels.
    #[get(type(copy))]
    pub(crate) image_w: u32,
    /// Height of `image_tex` in texels.
    #[get(type(copy))]
    pub(crate) image_h: u32,
    /// Uploaded revision of `image_tex`.
    #[get(type(copy))]
    pub(crate) image_rev: u64,
    /// External/video `GL_RGBA8` texture ID.
    #[get(type(copy))]
    pub(crate) external_tex: u32,
    /// Cached uniform location for `u_viewport`.
    #[get(type(copy))]
    pub(crate) viewport_loc: i32,
    /// Cached uniform location for `u_scroll_offset`.
    #[get(type(copy))]
    pub(crate) scroll_loc: i32,
    /// Active surface width in physical pixels.
    #[get(type(copy))]
    pub(crate) width: u32,
    /// Active surface height in physical pixels.
    #[get(type(copy))]
    pub(crate) height: u32,
    /// True when backed by `wl_egl_window`; false when backed by X11 `Window`.
    #[get(type(copy))]
    pub(crate) is_wayland: bool,
    /// Maximum supported GLES3 texture dimension queried via `GL_MAX_TEXTURE_SIZE`.
    #[get(type(copy))]
    pub(crate) max_tex_dim: u32,
    /// Lazily initialized offscreen GLES3 scene pass pipeline (`OceanFluid` + `World3d`).
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) scene: Option<LinuxEglScenePipeline>,
    /// Reusable flat primitive staging buffer avoiding per-frame allocations on direct submission.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) scratch_prims: Vec<GpuPrimitiveInstance>,
    /// Reusable draw-range metadata buffer paired with `scratch_prims`.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) scratch_ranges: Vec<(usize, usize, Rect, [f32; 2])>,
    /// Heap-stable atomic VSync latch cleared by `wl_surface.frame` callback on Wayland.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) vsync_pending: Box<AtomicBool>,
}

/// Raw `wl_registry_listener` ABI table registered during Wayland global discovery.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct WlRegistryListener {
    /// Callback invoked for each advertised Wayland global `(data, registry, name, interface, version)`.
    pub(crate) global: unsafe extern "C" fn(*mut c_void, *mut c_void, u32, *const c_char, u32),
    /// Callback invoked when a Wayland global is removed `(data, registry, name)`.
    pub(crate) global_remove: unsafe extern "C" fn(*mut c_void, *mut c_void, u32),
}

/// Raw `wl_buffer_listener` ABI table tracking compositor buffer release notifications.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct WlBufferListener {
    /// Callback invoked when the compositor finishes reading a `wl_buffer` (`(data, buffer)`).
    pub(crate) release: unsafe extern "C" fn(*mut c_void, *mut c_void),
}

/// Mutable state populated by `WL_REGISTRY_LISTENER` during initial `wl_display_roundtrip`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct WlRegistryBindState {
    /// Bound `wl_compositor*` proxy handle.
    pub(crate) compositor: usize,
    /// Negotiated `wl_compositor` protocol version.
    pub(crate) compositor_version: u32,
    /// Bound `wl_shm*` proxy handle.
    pub(crate) shm: usize,
}

/// Descriptor carrying POSIX shared-memory FD, geometry, format, and release flag pointer for `WaylandShmCommitOps`.
#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
pub struct WaylandShmBufferDescriptor {
    /// Open shared-memory file descriptor (`memfd_create` or `/dev/shm`).
    #[get(type(copy))]
    pub(crate) fd: i32,
    /// Total mapped buffer byte size.
    #[get(type(copy))]
    pub(crate) size: i32,
    /// Physical buffer width in pixels.
    #[get(type(copy))]
    pub(crate) width: i32,
    /// Physical buffer height in pixels.
    #[get(type(copy))]
    pub(crate) height: i32,
    /// Row stride in bytes (`width * 4`).
    #[get(type(copy))]
    pub(crate) stride: i32,
    /// Wayland shm pixel format (`WL_SHM_FORMAT_ARGB8888` or `WL_SHM_FORMAT_XRGB8888`).
    #[get(type(copy))]
    pub(crate) format: u32,
    /// Raw pointer to the slot's release `AtomicBool` userdata registered on `wl_buffer.release`.
    #[get(type(copy))]
    pub(crate) release_flag_ptr: usize,
}

/// Single double-buffered Wayland `wl_shm` memory mapping and protocol buffer slot.
#[derive(Debug)]
pub struct WaylandShmBufferSlot {
    /// Open POSIX shared-memory file descriptor (`-1` when unallocated).
    pub(crate) fd: i32,
    /// Base pointer returned by `mmap(..., MAP_SHARED, fd, 0)` (`0` when unmapped).
    pub(crate) mapped_ptr: usize,
    /// Mapped byte capacity of this shared-memory region.
    pub(crate) mapped_len: usize,
    /// Current allocated buffer width in physical pixels.
    pub(crate) width: u32,
    /// Current allocated buffer height in physical pixels.
    pub(crate) height: u32,
    /// Row stride in bytes (`width * 4`).
    pub(crate) stride: u32,
    /// Bound Wayland shm pixel format (`WL_SHM_FORMAT_ARGB8888` or `WL_SHM_FORMAT_XRGB8888`).
    pub(crate) format: u32,
    /// Associated `wl_shm_pool*` proxy handle (`0` when detached).
    pub(crate) wl_pool: usize,
    /// Associated `wl_buffer*` proxy handle (`0` when detached).
    pub(crate) wl_buffer: usize,
    /// Atomic busy flag cleared asynchronously by `wl_buffer.release` (`true` while held by compositor).
    pub(crate) busy: Box<AtomicBool>,
    /// True once this slot has received a complete full-frame pixel copy for its current dimensions.
    pub(crate) has_full_copy: bool,
}

/// Double-buffered Wayland `wl_shm` software swapchain owning two POSIX shm mappings and dirty-rect tracking.
#[derive(Debug)]
pub struct WaylandShmSwapchain {
    /// Two ping-pong shared-memory slots enabling tear-free double-buffered Wayland commits.
    pub(crate) slots: [WaylandShmBufferSlot; WL_SHM_SLOT_COUNT],
    /// Wayland shm pixel format (`WL_SHM_FORMAT_XRGB8888` or `WL_SHM_FORMAT_ARGB8888`).
    pub(crate) pixel_format: u32,
    /// Dirty rectangles from the immediately preceding submitted frame so double-buffered back slots stay coherent.
    pub(crate) previous_dirty_rects: Vec<(u32, u32, u32, u32)>,
    /// Index (`0` or `1`) of the most recently committed buffer slot.
    pub(crate) last_committed_slot: u8,
    /// Cumulative count of successfully committed Wayland shm frames.
    pub(crate) submitted_frames: u64,
    /// Cumulative count of unchanged frames skipped without commit.
    pub(crate) skipped_unchanged_frames: u64,
    /// Cumulative count of failed presentation attempts.
    pub(crate) failed_frames: u64,
}

/// Native `libwayland-client.so.0` transport invoking `wl_shm_pool`, `wl_buffer`, `wl_surface`, and `wl_display_flush`.
#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
pub struct NativeWaylandShmTransport {
    /// Live `wl_display*` connection pointer.
    #[get(type(copy))]
    pub(crate) display: usize,
    /// Live `wl_surface*` proxy pointer.
    #[get(type(copy))]
    pub(crate) surface: usize,
    /// Live `wl_shm*` global proxy pointer.
    #[get(type(copy))]
    pub(crate) wl_shm: usize,
    /// Negotiated `wl_surface` interface version (`>= 4` uses `damage_buffer`, `< 4` uses `damage`).
    #[get(type(copy))]
    pub(crate) surface_version: u32,
    /// Integer `wl_surface.set_buffer_scale` divisor applied prior to commit (`<= 0` defaults to `1`).
    #[new(skip)]
    #[get(type(copy))]
    pub(crate) buffer_scale: i32,
}

/// Explicit per-frame Linux presentation telemetry separating direct GPU vs Wayland shm vs X11 software blits.
#[derive(Clone, Copy, Data, Debug, Default, Eq, PartialEq)]
pub struct LinuxPresentTelemetry {
    /// Active presentation transport (`GpuDirect`, `WaylandShmSoftware`, or `X11Software`).
    #[get(type(copy))]
    pub(crate) mode: LinuxPresentationMode,
    /// Explicit frame outcome (`Submitted`, `SkippedUnchanged`, or `Failed`).
    #[get(type(copy))]
    pub(crate) outcome: LinuxPresentOutcome,
    /// True whenever a CPU software framebuffer mirror is active (`false` for `GpuDirect`).
    #[get(type(copy))]
    pub(crate) cpu_mirror_active: bool,
    /// Exact pixel bytes copied into Wayland shm or uploaded via X11 `XPutImage` (`0` for `GpuDirect` or skip).
    #[get(type(copy))]
    pub(crate) upload_bytes: u64,
    /// Number of dirty rectangles damaged or uploaded during this frame.
    #[get(type(copy))]
    pub(crate) dirty_rect_count: u32,
    /// Double-buffered Wayland shm slot index (`0` or `1`) committed on this frame.
    #[get(type(copy))]
    pub(crate) committed_buffer_slot: u8,
    /// Cumulative submitted frames recorded on this window.
    #[get(type(copy))]
    pub(crate) submitted_frames: u64,
    /// Cumulative unchanged frames skipped on this window.
    #[get(type(copy))]
    pub(crate) skipped_unchanged_frames: u64,
    /// Cumulative failed frames recorded on this window.
    #[get(type(copy))]
    pub(crate) failed_frames: u64,
}

/// Raw 192-byte X11 `XEvent` union storage aligned for 64-bit Linux LP64 ABI.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11EventRaw {
    /// Raw union payload words.
    pub(crate) pad: [isize; 24],
}

/// X11 `XKeyEvent` / `XButtonEvent` ABI layout on LP64 Linux.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11KeyOrButtonEvent {
    /// Event discriminant (`KeyPress`, `KeyRelease`, `ButtonPress`, `ButtonRelease`).
    pub(crate) event_type: i32,
    /// X server serial number.
    pub(crate) serial: usize,
    /// Non-zero when generated by `SendEvent`.
    pub(crate) send_event: i32,
    /// Connection `Display*`.
    pub(crate) display: *mut c_void,
    /// Target `Window` XID.
    pub(crate) window: u64,
    /// Root window XID.
    pub(crate) root: u64,
    /// Subwindow XID.
    pub(crate) subwindow: u64,
    /// Event timestamp in milliseconds.
    pub(crate) time: u64,
    /// Pointer X coordinate relative to window.
    pub(crate) x: i32,
    /// Pointer Y coordinate relative to window.
    pub(crate) y: i32,
    /// Pointer X relative to root window.
    pub(crate) x_root: i32,
    /// Pointer Y relative to root window.
    pub(crate) y_root: i32,
    /// Modifier key / button mask.
    pub(crate) state: u32,
    /// Hardware keycode or mouse button number.
    pub(crate) detail: u32,
    /// Same-screen flag.
    pub(crate) same_screen: i32,
}

/// X11 `XMotionEvent` ABI layout on LP64 Linux.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11MotionEvent {
    /// Event discriminant (`MotionNotify`).
    pub(crate) event_type: i32,
    /// X server serial number.
    pub(crate) serial: usize,
    /// Send-event flag.
    pub(crate) send_event: i32,
    /// Connection `Display*`.
    pub(crate) display: *mut c_void,
    /// Target `Window` XID.
    pub(crate) window: u64,
    /// Root window XID.
    pub(crate) root: u64,
    /// Subwindow XID.
    pub(crate) subwindow: u64,
    /// Timestamp in milliseconds.
    pub(crate) time: u64,
    /// Pointer X coordinate relative to window.
    pub(crate) x: i32,
    /// Pointer Y coordinate relative to window.
    pub(crate) y: i32,
    /// Pointer X relative to root window.
    pub(crate) x_root: i32,
    /// Pointer Y relative to root window.
    pub(crate) y_root: i32,
    /// Active modifier mask.
    pub(crate) state: u32,
    /// Motion hint byte.
    pub(crate) is_hint: c_char,
    /// Same-screen flag.
    pub(crate) same_screen: i32,
}

/// X11 `XConfigureEvent` ABI layout on LP64 Linux.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11ConfigureEvent {
    /// Event discriminant (`ConfigureNotify`).
    pub(crate) event_type: i32,
    /// X server serial number.
    pub(crate) serial: usize,
    /// Send-event flag.
    pub(crate) send_event: i32,
    /// Connection `Display*`.
    pub(crate) display: *mut c_void,
    /// Event-delivery window XID.
    pub(crate) event_window: u64,
    /// Reconfigured target window XID.
    pub(crate) window: u64,
    /// New window X position.
    pub(crate) x: i32,
    /// New window Y position.
    pub(crate) y: i32,
    /// New window client width in physical pixels.
    pub(crate) width: i32,
    /// New window client height in physical pixels.
    pub(crate) height: i32,
}

/// X11 `XClientMessageEvent` ABI layout on LP64 Linux.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11ClientMessageEvent {
    /// Event discriminant (`ClientMessage`).
    pub(crate) event_type: i32,
    /// X server serial number.
    pub(crate) serial: usize,
    /// Send-event flag.
    pub(crate) send_event: i32,
    /// Connection `Display*`.
    pub(crate) display: *mut c_void,
    /// Target `Window` XID.
    pub(crate) window: u64,
    /// Message type atom (`WM_PROTOCOLS`).
    pub(crate) message_type: u64,
    /// Data format (`8`, `16`, or `32`).
    pub(crate) format: i32,
    /// 32-bit protocol data payload (`l[0]` holds `WM_DELETE_WINDOW`).
    pub(crate) data: [u64; 5],
}

/// Bundle returned when opening a native Linux X11 or Wayland window.
#[derive(Clone, Copy, Data, Debug)]
pub(crate) struct LinuxNativeWindowHandle {
    /// Dynamically loaded `libX11` or `libwayland-client` handle.
    #[get(type(copy))]
    pub(crate) lib: usize,
    /// True when backed by Wayland; false when backed by X11.
    #[get(type(copy))]
    pub(crate) is_wayland: bool,
    /// Raw `Display*` or `wl_display*`.
    #[get(type(copy))]
    pub(crate) display: usize,
    /// Native X11 `Window` XID or Wayland surface pointer.
    #[get(type(copy))]
    pub(crate) window: u64,
    /// Cached X11 `GC` handle for `XPutImage`.
    #[get(type(copy))]
    pub(crate) gc: usize,
    /// Cached X11 `Visual*` pointer for `XCreateImage`.
    #[get(type(copy))]
    pub(crate) visual: usize,
    /// X11 default visual color depth (e.g., `24` or `32`).
    #[get(type(copy))]
    pub(crate) depth: u32,
    /// Interned `WM_DELETE_WINDOW` atom for graceful window closing.
    #[get(type(copy))]
    pub(crate) wm_delete_atom: u64,
    /// Probed display DPI scale factor (`1.0..=4.0`).
    #[get(type(copy))]
    pub(crate) scale_factor: f32,
    /// True when X11 MIT-SHM (`XShmQueryExtension`) is supported on this display.
    #[get(type(copy))]
    pub(crate) mit_shm_available: bool,
    /// True when Wayland Vulkan WSI (`VK_KHR_wayland_surface`) is available.
    #[get(type(copy))]
    pub(crate) wayland_vulkan_wsi: bool,
    /// True when X11 Vulkan WSI (`VK_KHR_xlib_surface`) is available.
    #[get(type(copy))]
    pub(crate) xlib_vulkan_wsi: bool,
    /// Bound Wayland `wl_compositor*` proxy pointer (`0` on X11 or unavailable).
    #[get(type(copy))]
    pub(crate) wl_compositor: usize,
    /// Bound Wayland `wl_shm*` proxy pointer (`0` on X11 or unavailable).
    #[get(type(copy))]
    pub(crate) wl_shm: usize,
    /// Negotiated Wayland `wl_surface` interface version (`0` on X11).
    #[get(type(copy))]
    pub(crate) wl_surface_version: u32,
}

/// Native Linux X11 / Wayland window record.
#[derive(Clone, Data, Debug)]
pub struct LinuxWindowRecord {
    /// Window configuration.
    pub(crate) config: WindowConfig,
    /// Live window state.
    #[get(type(copy))]
    pub(crate) state: WindowState,
    /// True when backed by Wayland; false when backed by X11 Xlib.
    #[get(type(copy))]
    pub(crate) is_wayland: bool,
    /// Raw display handle (`Display*` or `wl_display*`).
    #[get(type(copy))]
    pub(crate) display: usize,
    /// Raw window or surface identifier (`Window` or `wl_surface*`).
    #[get(type(copy))]
    pub(crate) window: u64,
    /// Cached X11 `GC` handle used by `XPutImage`.
    #[get(type(copy))]
    pub(crate) gc: usize,
    /// Cached X11 `Visual*` pointer used by `XCreateImage`.
    #[get(type(copy))]
    pub(crate) visual: usize,
    /// X11 visual depth in bits (`24` or `32`).
    #[get(type(copy))]
    pub(crate) depth: u32,
    /// Interned `WM_DELETE_WINDOW` protocol atom.
    #[get(type(copy))]
    pub(crate) wm_delete_atom: u64,
    /// Whether `XMapWindow` has been issued after Frame 1 presentation (eliminates unmapped flash).
    #[get(type(copy))]
    pub(crate) revealed: bool,
    /// Whether X11 MIT-SHM shared-memory image transport is supported by the X server.
    #[get(type(copy))]
    pub(crate) mit_shm_available: bool,
    /// Whether Wayland Vulkan WSI (`VK_KHR_wayland_surface`) is ready on this display.
    #[get(type(copy))]
    pub(crate) wayland_vulkan_wsi: bool,
    /// Whether X11 Vulkan WSI (`VK_KHR_xlib_surface`) is ready on this display.
    #[get(type(copy))]
    pub(crate) xlib_vulkan_wsi: bool,
    /// Bound Wayland `wl_compositor*` proxy pointer (`0` on X11).
    #[get(type(copy))]
    pub(crate) wl_compositor: usize,
    /// Bound Wayland `wl_shm*` proxy pointer (`0` on X11).
    #[get(type(copy))]
    pub(crate) wl_shm: usize,
    /// Negotiated Wayland `wl_surface` interface version (`>= 4` supports `damage_buffer`).
    #[get(type(copy))]
    pub(crate) wl_surface_version: u32,
    /// Reported `wl_output.mode` refresh rate in millihertz (e.g. `240000` for `240Hz`, `0` if unset).
    #[get(type(copy))]
    pub(crate) wayland_output_refresh_milli_hz: u32,
    /// Latest `wp_presentation` feedback timestamp in nanoseconds (`0` before first presentation).
    #[get(type(copy))]
    pub(crate) wayland_presentation_time_ns: u64,
    /// Whether a `wl_surface::frame` callback is currently armed awaiting compositor VSync.
    #[get(type(copy))]
    pub(crate) wayland_frame_callback_pending: bool,
    /// Active Linux presentation mode (`GpuDirect`, `WaylandShmSoftware`, or `X11Software`).
    #[get(type(copy))]
    pub(crate) presentation_mode: LinuxPresentationMode,
    /// Explicit CPU-mirror telemetry flag (`true` on Wayland shm / X11 software; `false` on direct GPU).
    #[get(type(copy))]
    pub(crate) cpu_mirror_active: bool,
    /// Most recent per-frame Linux presentation telemetry snapshot.
    #[get(type(copy))]
    pub(crate) last_telemetry: LinuxPresentTelemetry,
    /// Double-buffered Wayland `wl_shm` software swapchain attached to this window when Wayland is active.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) wayland_shm: Option<Arc<Mutex<WaylandShmSwapchain>>>,
    /// Optional dynamically loaded EGL + GLES3 instanced direct-GPU surface over Wayland or X11.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) egl_gles: Option<Arc<Mutex<LinuxEglGlesSurface>>>,
}

/// Direct Linux X11 / Wayland (`dlopen`-loaded) + Vulkan platform backend.
#[derive(Clone, Data, Debug)]
pub struct LinuxPlatform {
    /// Monotonic window handle generator.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) next_id: u64,
    /// Dynamically loaded `libX11` handle if present.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) x11_lib: usize,
    /// Active native Linux windows.
    pub(crate) windows: HashMap<WindowId, LinuxWindowRecord>,
    /// Queued window and input events.
    pub(crate) pending_events: Vec<WindowEvent>,
    /// Clipboard text cache.
    #[get(skip)]
    pub(crate) clipboard_cache: Option<String>,
    /// Whether the Linux X11/Wayland frame pump is paused for background freeze.
    #[get(pub(crate), type(copy))]
    #[set(pub(crate))]
    pub(crate) pump_paused: bool,
    /// Non-blocking wakeup pipe read end passed to `poll(display_fd, wakeup_pipe)` (`-1` when unavailable).
    #[get(pub(crate), type(copy))]
    #[set(pub(crate))]
    pub(crate) wake_read_fd: i32,
    /// Non-blocking wakeup pipe write end signaled by `wake_event_loop()` (`-1` when unavailable).
    #[get(pub(crate), type(copy))]
    #[set(pub(crate))]
    pub(crate) wake_write_fd: i32,
}