@@ -196,20 +196,20 @@ XrCompositionLayerBaseHeader *OpenXRViewportCompositionLayerProvider::get_compos
196196 return nullptr ;
197197 }
198198
199- if (swapchain_info.swapchain == XR_NULL_HANDLE) {
199+ if (swapchain_info.get_swapchain () == XR_NULL_HANDLE) {
200200 // Don't have a swapchain to display? Ignore our layer.
201201 return nullptr ;
202202 }
203203
204- if (swapchain_info.image_acquired ) {
205- openxr_api-> release_image ( swapchain_info);
204+ if (swapchain_info.is_image_acquired () ) {
205+ swapchain_info. release ( );
206206 }
207207
208208 // Update the layer struct for the swapchain.
209209 switch (composition_layer->type ) {
210210 case XR_TYPE_COMPOSITION_LAYER_QUAD: {
211211 XrCompositionLayerQuad *quad_layer = (XrCompositionLayerQuad *)composition_layer;
212- quad_layer->subImage .swapchain = swapchain_info.swapchain ;
212+ quad_layer->subImage .swapchain = swapchain_info.get_swapchain () ;
213213 quad_layer->subImage .imageArrayIndex = 0 ;
214214 quad_layer->subImage .imageRect .offset .x = 0 ;
215215 quad_layer->subImage .imageRect .offset .y = 0 ;
@@ -219,7 +219,7 @@ XrCompositionLayerBaseHeader *OpenXRViewportCompositionLayerProvider::get_compos
219219
220220 case XR_TYPE_COMPOSITION_LAYER_CYLINDER_KHR: {
221221 XrCompositionLayerCylinderKHR *cylinder_layer = (XrCompositionLayerCylinderKHR *)composition_layer;
222- cylinder_layer->subImage .swapchain = swapchain_info.swapchain ;
222+ cylinder_layer->subImage .swapchain = swapchain_info.get_swapchain () ;
223223 cylinder_layer->subImage .imageArrayIndex = 0 ;
224224 cylinder_layer->subImage .imageRect .offset .x = 0 ;
225225 cylinder_layer->subImage .imageRect .offset .y = 0 ;
@@ -229,7 +229,7 @@ XrCompositionLayerBaseHeader *OpenXRViewportCompositionLayerProvider::get_compos
229229
230230 case XR_TYPE_COMPOSITION_LAYER_EQUIRECT2_KHR: {
231231 XrCompositionLayerEquirect2KHR *equirect_layer = (XrCompositionLayerEquirect2KHR *)composition_layer;
232- equirect_layer->subImage .swapchain = swapchain_info.swapchain ;
232+ equirect_layer->subImage .swapchain = swapchain_info.get_swapchain () ;
233233 equirect_layer->subImage .imageArrayIndex = 0 ;
234234 equirect_layer->subImage .imageRect .offset .x = 0 ;
235235 equirect_layer->subImage .imageRect .offset .y = 0 ;
@@ -269,14 +269,16 @@ bool OpenXRViewportCompositionLayerProvider::update_and_acquire_swapchain(bool p
269269 }
270270
271271 // See if our current swapchain is outdated.
272- if (swapchain_info.swapchain != XR_NULL_HANDLE) {
272+ if (swapchain_info.get_swapchain () != XR_NULL_HANDLE) {
273273 // If this swap chain, or the previous one, were static, then we can't reuse it.
274274 if (swapchain_size == viewport_size && !p_static_image && !static_image) {
275275 // We're all good! Just acquire it.
276- return openxr_api->acquire_image (swapchain_info);
276+ // We can ignore should_render here, return will be false.
277+ XrBool32 should_render = true ;
278+ return swapchain_info.acquire (should_render);
277279 }
278280
279- openxr_api-> free_swapchain ( swapchain_info);
281+ swapchain_info. queue_free ( );
280282 }
281283
282284 // Create our new swap chain
@@ -287,22 +289,24 @@ bool OpenXRViewportCompositionLayerProvider::update_and_acquire_swapchain(bool p
287289 if (p_static_image) {
288290 create_flags |= XR_SWAPCHAIN_CREATE_STATIC_IMAGE_BIT;
289291 }
290- if (!openxr_api-> create_swapchain (create_flags, XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT, swapchain_format, viewport_size.width , viewport_size.height , sample_count, array_size, swapchain_info. swapchain , &swapchain_info. swapchain_graphics_data )) {
292+ if (!swapchain_info. create (create_flags, XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT | XR_SWAPCHAIN_USAGE_MUTABLE_FORMAT_BIT, swapchain_format, viewport_size.width , viewport_size.height , sample_count, array_size)) {
291293 swapchain_size = Size2i ();
292294 return false ;
293295 }
294296
295- // Acquire our image so we can start rendering into it
296- bool ret = openxr_api->acquire_image (swapchain_info);
297+ // Acquire our image so we can start rendering into it,
298+ // we can ignore should_render here, ret will be false.
299+ XrBool32 should_render = true ;
300+ bool ret = swapchain_info.acquire (should_render);
297301
298302 swapchain_size = viewport_size;
299303 static_image = p_static_image;
300304 return ret;
301305}
302306
303307void OpenXRViewportCompositionLayerProvider::free_swapchain () {
304- if (swapchain_info.swapchain != XR_NULL_HANDLE) {
305- openxr_api-> free_swapchain ( swapchain_info);
308+ if (swapchain_info.get_swapchain () != XR_NULL_HANDLE) {
309+ swapchain_info. queue_free ( );
306310 }
307311
308312 swapchain_size = Size2i ();
@@ -314,5 +318,5 @@ RID OpenXRViewportCompositionLayerProvider::get_current_swapchain_texture() {
314318 return RID ();
315319 }
316320
317- return openxr_api-> get_image (swapchain_info );
321+ return swapchain_info. get_image ();
318322}
0 commit comments