mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-03-03 13:16:38 +00:00
st/oxr: Clean up GL/GLES image enumeration a bit for easier maintenance
This commit is contained in:
parent
852c9b589d
commit
4c5b38c836
|
@ -18,7 +18,8 @@
|
|||
#include "oxr_logger.h"
|
||||
|
||||
|
||||
#ifdef XR_USE_GRAPHICS_API_OPENGL
|
||||
#if defined(XR_USE_GRAPHICS_API_OPENGL) || \
|
||||
defined(XR_USE_GRAPHICS_API_OPENGL_ES)
|
||||
|
||||
static XrResult
|
||||
oxr_swapchain_gl_destroy(struct oxr_logger *log, struct oxr_swapchain *sc)
|
||||
|
@ -43,45 +44,69 @@ oxr_swapchain_gl_destroy(struct oxr_logger *log, struct oxr_swapchain *sc)
|
|||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
#if defined(XR_USE_GRAPHICS_API_OPENGL)
|
||||
static XrResult
|
||||
oxr_swapchain_gl_enumerate_images_gl(struct oxr_logger *log,
|
||||
struct oxr_swapchain *sc,
|
||||
uint32_t count,
|
||||
XrSwapchainImageOpenGLKHR *images)
|
||||
{
|
||||
struct xrt_swapchain_gl *xsc = (struct xrt_swapchain_gl *)sc->swapchain;
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
if (images[i].type != images[0].type) {
|
||||
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
|
||||
"Images array contains mixed types");
|
||||
}
|
||||
images[i].image = xsc->images[i];
|
||||
}
|
||||
|
||||
return oxr_session_success_result(sc->sess);
|
||||
}
|
||||
|
||||
#endif // XR_USE_GRAPHICS_API_OPENGL
|
||||
|
||||
#if defined(XR_USE_GRAPHICS_API_OPENGL_ES)
|
||||
static XrResult
|
||||
oxr_swapchain_gl_enumerate_images_gles(struct oxr_logger *log,
|
||||
struct oxr_swapchain *sc,
|
||||
uint32_t count,
|
||||
XrSwapchainImageOpenGLESKHR *images)
|
||||
{
|
||||
struct xrt_swapchain_gl *xsc = (struct xrt_swapchain_gl *)sc->swapchain;
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
if (images[i].type != images[0].type) {
|
||||
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
|
||||
"Images array contains mixed types");
|
||||
}
|
||||
images[i].image = xsc->images[i];
|
||||
}
|
||||
|
||||
return oxr_session_success_result(sc->sess);
|
||||
}
|
||||
#endif // XR_USE_GRAPHICS_API_OPENGL_ES
|
||||
|
||||
static XrResult
|
||||
oxr_swapchain_gl_enumerate_images(struct oxr_logger *log,
|
||||
struct oxr_swapchain *sc,
|
||||
uint32_t count,
|
||||
XrSwapchainImageBaseHeader *images)
|
||||
{
|
||||
struct xrt_swapchain_gl *xsc = (struct xrt_swapchain_gl *)sc->swapchain;
|
||||
|
||||
XrSwapchainImageOpenGLKHR *gl_imgs = NULL;
|
||||
XrSwapchainImageOpenGLESKHR *gles_imgs = NULL;
|
||||
assert(count > 0);
|
||||
switch (images[0].type) {
|
||||
#if defined(XR_USE_GRAPHICS_API_OPENGL)
|
||||
case XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR:
|
||||
gl_imgs = (XrSwapchainImageOpenGLKHR *)images;
|
||||
break;
|
||||
return oxr_swapchain_gl_enumerate_images_gl(
|
||||
log, sc, count, (XrSwapchainImageOpenGLKHR *)images);
|
||||
#endif // XR_USE_GRAPHICS_API_OPENGL
|
||||
#if defined(XR_USE_GRAPHICS_API_OPENGL_ES)
|
||||
case XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR:
|
||||
gles_imgs = (XrSwapchainImageOpenGLESKHR *)images;
|
||||
break;
|
||||
return oxr_swapchain_gl_enumerate_images_gles(
|
||||
log, sc, count, (XrSwapchainImageOpenGLESKHR *)images);
|
||||
#endif // XR_USE_GRAPHICS_API_OPENGL_ES
|
||||
default:
|
||||
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
|
||||
"Unsupported XrSwapchainImageBaseHeader type");
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
if ((gl_imgs != NULL && gl_imgs[i].type != images[0].type) ||
|
||||
(gles_imgs != NULL &&
|
||||
gles_imgs[i].type != images[0].type)) {
|
||||
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
|
||||
"Images array contains mixed types");
|
||||
}
|
||||
if (gl_imgs != NULL) {
|
||||
gl_imgs[i].image = xsc->images[i];
|
||||
}
|
||||
if (gles_imgs != NULL) {
|
||||
gles_imgs[i].image = xsc->images[i];
|
||||
}
|
||||
}
|
||||
|
||||
return oxr_session_success_result(sc->sess);
|
||||
}
|
||||
|
||||
XrResult
|
||||
|
@ -105,5 +130,4 @@ oxr_swapchain_gl_create(struct oxr_logger *log,
|
|||
|
||||
return XR_SUCCESS;
|
||||
}
|
||||
|
||||
#endif // XR_USE_GRAPHICS_API_OPENGL
|
||||
#endif // XR_USE_GRAPHICS_API_OPENGL || XR_USE_GRAPHICS_API_OPENGL_ES
|
||||
|
|
Loading…
Reference in a new issue