The open source OpenXR runtime
0
fork

Configure Feed

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

st/oxr: switch blend mode to array

+15 -16
+4 -4
src/xrt/state_trackers/oxr/oxr_session.c
··· 25 25 #include "util/u_debug.h" 26 26 #include "util/u_misc.h" 27 27 #include "util/u_time.h" 28 + #include "util/u_verify.h" 28 29 29 30 #include "math/m_api.h" 30 31 #include "math/m_mathinclude.h" ··· 1775 1776 return oxr_session_success_result(sess); 1776 1777 } 1777 1778 1778 - 1779 1779 /* 1780 1780 * Blend mode. 1781 1781 * XR_ERROR_ENVIRONMENT_BLEND_MODE_UNSUPPORTED must always be reported, ··· 1783 1783 */ 1784 1784 1785 1785 enum xrt_blend_mode blend_mode = oxr_blend_mode_to_xrt(frameEndInfo->environmentBlendMode); 1786 + struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head); 1786 1787 1787 - if (blend_mode == 0) { 1788 + if (!u_verify_blend_mode_valid(blend_mode)) { 1788 1789 return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, 1789 1790 "(frameEndInfo->environmentBlendMode == " 1790 1791 "0x%08x) unknown environment blend mode", 1791 1792 frameEndInfo->environmentBlendMode); 1792 1793 } 1793 1794 1794 - struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head); 1795 - if ((blend_mode & xdev->hmd->blend_mode) == 0) { 1795 + if (!u_verify_blend_mode_supported(xdev, blend_mode)) { 1796 1796 //! @todo Make integer print to string. 1797 1797 return oxr_error(log, XR_ERROR_ENVIRONMENT_BLEND_MODE_UNSUPPORTED, 1798 1798 "(frameEndInfo->environmentBlendMode == %u) "
+11 -12
src/xrt/state_trackers/oxr/oxr_system.c
··· 15 15 16 16 #include "xrt/xrt_device.h" 17 17 #include "util/u_debug.h" 18 + #include "util/u_verify.h" 18 19 19 20 #include "oxr_objects.h" 20 21 #include "oxr_logger.h" ··· 86 87 return XR_SUCCESS; 87 88 } 88 89 90 + 91 + 89 92 XrResult 90 93 oxr_system_fill_in(struct oxr_logger *log, struct oxr_instance *inst, XrSystemId systemId, struct oxr_system *sys) 91 94 { ··· 151 154 152 155 struct xrt_device *head = GET_XDEV_BY_ROLE(sys, head); 153 156 154 - uint32_t i = 0; 155 - if (head->hmd->blend_mode & XRT_BLEND_MODE_OPAQUE) { 156 - sys->blend_modes[i++] = XR_ENVIRONMENT_BLEND_MODE_OPAQUE; 157 + assert(head->hmd->num_blend_modes <= XRT_MAX_DEVICE_BLEND_MODES); 158 + assert(head->hmd->num_blend_modes != 0); 159 + 160 + for (size_t i = 0; i < head->hmd->num_blend_modes; i++) { 161 + assert(u_verify_blend_mode_valid(head->hmd->blend_modes[i])); 162 + sys->blend_modes[i] = (XrEnvironmentBlendMode)head->hmd->blend_modes[i]; 157 163 } 158 - if (head->hmd->blend_mode & XRT_BLEND_MODE_ADDITIVE) { 159 - sys->blend_modes[i++] = XR_ENVIRONMENT_BLEND_MODE_ADDITIVE; 160 - } 161 - if (head->hmd->blend_mode & XRT_BLEND_MODE_ALPHA_BLEND) { 162 - sys->blend_modes[i++] = XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND; 163 - } 164 - sys->num_blend_modes = i; 164 + sys->num_blend_modes = (uint32_t)head->hmd->num_blend_modes; 165 165 166 - assert(i < ARRAY_SIZE(sys->blend_modes)); 167 - 166 + assert(sys->num_blend_modes <= ARRAY_SIZE(sys->blend_modes)); 168 167 169 168 return XR_SUCCESS; 170 169 }