The open source OpenXR runtime

st/oxr: Validate max sample count

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

authored by

Jakob Bornecrantz and committed by
Marge Bot
74c11b62 7da4d657

+19
+19
src/xrt/state_trackers/oxr/oxr_api_swapchain.c
··· 84 84 // Short hand. 85 85 struct oxr_instance *inst = sess->sys->inst; 86 86 struct xrt_compositor_info *xc_info = &sess->compositor->info; 87 + struct xrt_system_compositor_info *xsysc_info = &sess->sys->xsysc->info; 87 88 88 89 89 90 /* ··· 153 154 } 154 155 } 155 156 #endif 157 + 158 + 159 + /* 160 + * Sample count. 161 + */ 162 + 163 + if (createInfo->sampleCount == 0) { 164 + return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE, "(createInfo->sampleCount == 0) must not be zero"); 165 + } 166 + 167 + // TODO Find the max of the views[0].max.sample_count limits. 168 + uint32_t max_sample_count = xsysc_info->views[0].max.sample_count; 169 + 170 + if (createInfo->sampleCount > max_sample_count) { 171 + return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE, 172 + "(createInfo->sampleCount == %u) must not be larger then max (%u)", 173 + createInfo->sampleCount, max_sample_count); 174 + } 156 175 157 176 158 177 /*