The open source OpenXR runtime

ipc: document alignas requirements for IPC

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2396>

authored by

Patrick Nicolas and committed by
Marge Bot
16a0876f 25bd1abc

+20 -1
+9
doc/ipc-design.md
··· 228 228 [SCM_RIGHTS]: https://man7.org/linux/man-pages/man3/cmsg.3.html 229 229 [win32handles]: https://lackingrhoticity.blogspot.com/2015/05/passing-fds-handles-between-processes.html 230 230 [WinSCM_RIGHTS]: https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/#unsupportedunavailable 231 + 232 + ## 32 bits client support on 64 bits server 233 + 234 + On 64 bits system, the server process will typically be a 64 bits executable, 235 + clients may be 32 or 64 bits. As IPC either through socket or shared memory will 236 + share C struct directly, we must pay attention to memory layout. 237 + 238 + All data types must be fixed size and alignments must be based on the 64 bits 239 + targets. On Linux this mostly means `alignas(8)` must be used for (u)int64_t.
+8 -1
src/xrt/include/xrt/xrt_compositor.h
··· 409 409 * 410 410 * The layer may be displayed after this point, but must never be 411 411 * displayed before. 412 + * 413 + * alignas for 32 bit client support, 412 414 */ 413 415 alignas(8) int64_t timestamp; 414 416 ··· 478 480 */ 479 481 struct xrt_layer_frame_data 480 482 { 483 + //! alignas for 32 bit client support, see @ref ipc-design 481 484 alignas(8) int64_t frame_id; 482 485 int64_t display_time_ns; 483 486 enum xrt_blend_mode env_blend_mode; ··· 931 934 struct xrt_session_info 932 935 { 933 936 bool is_overlay; 937 + //! alignas for 32 bit client support, see @ref ipc-design 934 938 alignas(8) uint64_t flags; 935 939 uint32_t z_order; 936 940 }; ··· 945 949 //! Number of formats, never changes. 946 950 uint32_t format_count; 947 951 948 - //! Supported formats, never changes. 952 + /*! 953 + * Supported formats, never changes. 954 + * alignas for 32 bit client support, see @ref ipc-design 955 + */ 949 956 alignas(8) int64_t formats[XRT_MAX_SWAPCHAIN_FORMATS]; 950 957 951 958 //! Max texture size that GPU supports (size of a single dimension), zero means any size.
+1
src/xrt/include/xrt/xrt_device.h
··· 164 164 //! Is this input active. 165 165 bool active; 166 166 167 + //! alignas for 32 bit client support, see @ref ipc-design 167 168 alignas(8) int64_t timestamp; 168 169 169 170 enum xrt_input_name name;
+2
src/xrt/include/xrt/xrt_system.h
··· 169 169 * All valid values are greater then zero; this is to 170 170 * make init easier where any cache can start at zero and be guaranteed 171 171 * to be replaced with a new @ref xrt_system_roles. 172 + * 173 + * alignas for 32 bit client support, see @ref ipc-design 172 174 */ 173 175 alignas(8) uint64_t generation_id; 174 176