st/oxr: Enforce static swapchain acquire semantics

This commit is contained in:
Jakob Bornecrantz 2020-05-30 17:13:07 +01:00
parent cdfd03a762
commit d693bc2ef9
3 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,3 @@
OpenXR: Enforce that static swapchains can only be acquired once, this is
required by the spec and make sure that a image is only rendered to once, and
allows the runtime to perform special optimizations on the image.

View file

@ -1332,6 +1332,8 @@ struct oxr_swapchain
int index;
} released;
// Is this a static swapchain, needed for acquire semantics.
bool is_static;
XrResult (*destroy)(struct oxr_logger *, struct oxr_swapchain *);

View file

@ -31,6 +31,11 @@ oxr_swapchain_acquire_image(struct oxr_logger *log,
" all images have been acquired");
}
if (sc->is_static && (sc->released.yes || sc->waited.yes)) {
return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID,
"Can only acquire once on a static swapchain");
}
struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain;
if (!xsc->acquire_image(xsc, &index)) {
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
@ -198,6 +203,8 @@ oxr_create_swapchain(struct oxr_logger *log,
sc->acquire_image = oxr_swapchain_acquire_image;
sc->wait_image = oxr_swapchain_wait_image;
sc->release_image = oxr_swapchain_release_image;
sc->is_static = (createInfo->createFlags &
XR_SWAPCHAIN_CREATE_STATIC_IMAGE_BIT) != 0;
*out_swapchain = sc;