The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

xrt: Fix bitwise operation on signed integer warnings

authored by

Ryan Pavlik and committed by
Jakob Bornecrantz
bdc526b7 cff131da

+56 -23
+6 -6
src/xrt/include/xrt/xrt_compositor.h
··· 67 67 enum xrt_swapchain_create_flags 68 68 { 69 69 //! Our compositor just ignores this bit. 70 - XRT_SWAPCHAIN_CREATE_PROTECTED_CONTENT = (1 << 0), 70 + XRT_SWAPCHAIN_CREATE_PROTECTED_CONTENT = (1u << 0u), 71 71 //! Signals that the allocator should only allocate one image. 72 - XRT_SWAPCHAIN_CREATE_STATIC_IMAGE = (1 << 1), 72 + XRT_SWAPCHAIN_CREATE_STATIC_IMAGE = (1u << 1u), 73 73 }; 74 74 75 75 /*! ··· 115 115 */ 116 116 enum xrt_layer_composition_flags 117 117 { 118 - XRT_LAYER_COMPOSITION_CORRECT_CHROMATIC_ABERRATION_BIT = 1 << 0, 119 - XRT_LAYER_COMPOSITION_BLEND_TEXTURE_SOURCE_ALPHA_BIT = 1 << 1, 120 - XRT_LAYER_COMPOSITION_UNPREMULTIPLIED_ALPHA_BIT = 1 << 2, 118 + XRT_LAYER_COMPOSITION_CORRECT_CHROMATIC_ABERRATION_BIT = 1u << 0u, 119 + XRT_LAYER_COMPOSITION_BLEND_TEXTURE_SOURCE_ALPHA_BIT = 1u << 1u, 120 + XRT_LAYER_COMPOSITION_UNPREMULTIPLIED_ALPHA_BIT = 1u << 2u, 121 121 /*! 122 122 * The layer is locked to the device and the pose should only be 123 123 * adjusted for the IPD. 124 124 */ 125 - XRT_LAYER_COMPOSITION_VIEW_SPACE_BIT = 1 << 3, 125 + XRT_LAYER_COMPOSITION_VIEW_SPACE_BIT = 1u << 3u, 126 126 }; 127 127 128 128 /*!
+50 -17
src/xrt/include/xrt/xrt_defines.h
··· 102 102 enum xrt_distortion_model 103 103 { 104 104 // clang-format off 105 - XRT_DISTORTION_MODEL_NONE = 1 << 0, 106 - XRT_DISTORTION_MODEL_COMPUTE = 1 << 1, 107 - XRT_DISTORTION_MODEL_MESHUV = 1 << 2, 105 + XRT_DISTORTION_MODEL_NONE = 1u << 0u, 106 + XRT_DISTORTION_MODEL_COMPUTE = 1u << 1u, 107 + XRT_DISTORTION_MODEL_MESHUV = 1u << 2u, 108 108 // clang-format on 109 109 }; 110 110 ··· 523 523 enum xrt_space_relation_flags 524 524 { 525 525 // clang-format off 526 - XRT_SPACE_RELATION_ORIENTATION_VALID_BIT = (1 << 0), 527 - XRT_SPACE_RELATION_POSITION_VALID_BIT = (1 << 1), 528 - XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT = (1 << 2), 529 - XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT = (1 << 3), 530 - XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT = (1 << 4), 531 - XRT_SPACE_RELATION_POSITION_TRACKED_BIT = (1 << 5), 526 + XRT_SPACE_RELATION_ORIENTATION_VALID_BIT = (1u << 0u), 527 + XRT_SPACE_RELATION_POSITION_VALID_BIT = (1u << 1u), 528 + XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT = (1u << 2u), 529 + XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT = (1u << 3u), 530 + XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT = (1u << 4u), 531 + XRT_SPACE_RELATION_POSITION_TRACKED_BIT = (1u << 5u), 532 532 // clang-format on 533 - XRT_SPACE_RELATION_BITMASK_ALL = 534 - XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | XRT_SPACE_RELATION_POSITION_VALID_BIT | 535 - XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT | XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT | 536 - XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | XRT_SPACE_RELATION_POSITION_TRACKED_BIT, 533 + XRT_SPACE_RELATION_BITMASK_ALL = (uint32_t)XRT_SPACE_RELATION_ORIENTATION_VALID_BIT | // 534 + (uint32_t)XRT_SPACE_RELATION_POSITION_VALID_BIT | // 535 + (uint32_t)XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT | // 536 + (uint32_t)XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT | // 537 + (uint32_t)XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT | // 538 + (uint32_t)XRT_SPACE_RELATION_POSITION_TRACKED_BIT, 537 539 XRT_SPACE_RELATION_BITMASK_NONE = 0 538 540 }; 539 541 ··· 677 679 }; 678 680 679 681 /*! 682 + * The number of bits reserved for the input type in @ref xrt_input_name 683 + * 684 + * @see xrt_input_name 685 + * @ingroup xrt_iface 686 + */ 687 + #define XRT_INPUT_TYPE_BITWIDTH 8u 688 + 689 + /*! 690 + * The mask associated with @ref XRT_INPUT_TYPE_BITWIDTH 691 + * 692 + * @see xrt_input_name 693 + * @ingroup xrt_iface 694 + */ 695 + 696 + #define XRT_INPUT_TYPE_BITMASK 0xffu 697 + 698 + /*! 680 699 * @brief Create an enum value for xrt_input_name that packs an ID and input 681 700 * type. 682 701 * ··· 687 706 * @see xrt_input_name 688 707 * @ingroup xrt_iface 689 708 */ 690 - #define XRT_INPUT_NAME(id, type) ((id << 8) | XRT_INPUT_TYPE_##type) 709 + #define XRT_INPUT_NAME(id, type) ((UINT32_C(id) << XRT_INPUT_TYPE_BITWIDTH) | (uint32_t)XRT_INPUT_TYPE_##type) 691 710 692 711 /*! 693 712 * @brief Extract the xrt_input_type from an xrt_input_name. ··· 698 717 * @returns @ref xrt_input_type 699 718 * @ingroup xrt_iface 700 719 */ 701 - #define XRT_GET_INPUT_TYPE(name) ((enum xrt_input_type)(name & 0xff)) 720 + #define XRT_GET_INPUT_TYPE(name) ((enum xrt_input_type)(name & XRT_INPUT_TYPE_BITMASK)) 702 721 703 722 /*! 704 723 * @brief Extract the xrt_input_name id from an xrt_input_name. ··· 709 728 * @returns @ref xrt_input_type 710 729 * @ingroup xrt_iface 711 730 */ 712 - #define XRT_GET_INPUT_ID(name) ((uint32_t)(name >> 8)) 731 + #define XRT_GET_INPUT_ID(name) ((uint32_t)(name >> XRT_INPUT_TYPE_BITWIDTH)) 713 732 714 733 /*! 715 734 * Every internal input source known to monado with a baked in type. ··· 1019 1038 }; 1020 1039 1021 1040 /*! 1041 + * The number of bits reserved for the input type in @ref xrt_output_name 1042 + * @see xrt_output_type 1043 + * @ingroup xrt_iface 1044 + */ 1045 + #define XRT_OUTPUT_TYPE_BITWIDTH 8u 1046 + 1047 + /*! 1048 + * The mask associated with @ref XRT_OUTPUT_TYPE_BITWIDTH 1049 + * @see xrt_output_type 1050 + * @ingroup xrt_iface 1051 + */ 1052 + #define XRT_OUTPUT_TYPE_BITMASK 0xffu 1053 + 1054 + /*! 1022 1055 * Base type of this output. 1023 1056 * 1024 1057 * @ingroup xrt_iface ··· 1031 1064 // clang-format on 1032 1065 }; 1033 1066 1034 - #define XRT_OUTPUT_NAME(id, type) ((id << 8) | XRT_OUTPUT_TYPE_##type) 1067 + #define XRT_OUTPUT_NAME(id, type) ((UINT32_C(id) << XRT_OUTPUT_TYPE_BITWIDTH) | (uint32_t)XRT_OUTPUT_TYPE_##type) 1035 1068 1036 1069 /*! 1037 1070 * Name of a output with a baked in type.