xrt: use __declspec(align) instead of alignas on MSVC

some older versions of MSVC don't support alignas (idk why), use
a macro instead with the normal alignas on linux, but using
__declspec(align) on MSVC.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2505>
This commit is contained in:
Alex Niemi committed 2025-06-27 10:55:14 -07:00
1 parent f202b042ad
commit 2c8a7fe358
4 files changed
+12 -13

No files matched your search

+6 -1
View File
@@ -22,7 +22,12 @@
#include <intrin.h>
// for atomic intrinsics
#include "xrt_windows.h"
#endif // _MSC_VER
// Older MSVC versions do not have stdalign.h, define it manually using __declspec(align).
#define XRT_ALIGNAS(n) __declspec(align(n))
#else // _MSC_VER
#include <stdalign.h>
#define XRT_ALIGNAS(align) alignas(align)
#endif
#if (defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN) || \
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
+4 -6
View File
@@ -20,8 +20,6 @@
#include "xrt/xrt_config_have.h"
#include "xrt/xrt_windows.h"
#include <stdalign.h>
#if defined(XRT_HAVE_D3D11)
#include <d3d11.h>
#elif defined(XRT_DOXYGEN)
@@ -412,7 +410,7 @@ struct xrt_layer_data
*
* alignas for 32 bit client support,
*/
alignas(8) int64_t timestamp;
XRT_ALIGNAS(8) int64_t timestamp;
/*!
* Composition flags
@@ -481,7 +479,7 @@ struct xrt_layer_data
struct xrt_layer_frame_data
{
//! alignas for 32 bit client support, see @ref ipc-design
alignas(8) int64_t frame_id;
XRT_ALIGNAS(8) int64_t frame_id;
int64_t display_time_ns;
enum xrt_blend_mode env_blend_mode;
};
@@ -935,7 +933,7 @@ struct xrt_session_info
{
bool is_overlay;
//! alignas for 32 bit client support, see @ref ipc-design
alignas(8) uint64_t flags;
XRT_ALIGNAS(8) uint64_t flags;
uint32_t z_order;
};
@@ -953,7 +951,7 @@ struct xrt_compositor_info
* Supported formats, never changes.
* alignas for 32 bit client support, see @ref ipc-design
*/
alignas(8) int64_t formats[XRT_MAX_SWAPCHAIN_FORMATS];
XRT_ALIGNAS(8) int64_t formats[XRT_MAX_SWAPCHAIN_FORMATS];
//! Max texture size that GPU supports (size of a single dimension), zero means any size.
uint32_t max_texture_size;
+1 -3
View File
@@ -17,8 +17,6 @@
#include "xrt/xrt_visibility_mask.h"
#include "xrt/xrt_limits.h"
#include <stdalign.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -167,7 +165,7 @@ struct xrt_input
bool active;
//! alignas for 32 bit client support, see @ref ipc-design
alignas(8) int64_t timestamp;
XRT_ALIGNAS(8) int64_t timestamp;
enum xrt_input_name name;
+1 -3
View File
@@ -15,8 +15,6 @@
#include "xrt/xrt_defines.h"
#include "xrt/xrt_device.h"
#include <stdalign.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -172,7 +170,7 @@ struct xrt_system_roles
*
* alignas for 32 bit client support, see @ref ipc-design
*/
alignas(8) uint64_t generation_id;
XRT_ALIGNAS(8) uint64_t generation_id;
/*!
* Index in @ref xrt_system_devices::xdevs for the user's left