mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 18:08:29 +00:00
c/client: Swapchain for Win32 GL
Co-authored-by: Ryan Pavlik <ryan.pavlik@collabora.com> Co-authored-by: Jakob Bornecrantz <jakob@collabora.com>
This commit is contained in:
parent
dc470ca6fe
commit
afe84a2c35
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2019-2021, Collabora, Ltd.
|
||||
// Copyright 2019-2022, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
|
@ -35,6 +35,7 @@ client_gl_memobj_swapchain(struct xrt_swapchain *xsc)
|
|||
return (struct client_gl_memobj_swapchain *)xsc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Swapchain functions.
|
||||
|
@ -72,16 +73,33 @@ client_gl_memobj_swapchain_destroy(struct xrt_swapchain *xsc)
|
|||
free(sc);
|
||||
}
|
||||
|
||||
static bool
|
||||
client_gl_memobj_swapchain_import(GLuint memory, size_t size, xrt_graphics_buffer_handle_t handle)
|
||||
{
|
||||
#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD)
|
||||
glImportMemoryFdEXT(memory, size, GL_HANDLE_TYPE_OPAQUE_FD_EXT, handle);
|
||||
return true;
|
||||
#elif defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_WIN32_HANDLE)
|
||||
glImportMemoryWin32HandleEXT(memory, size, GL_HANDLE_TYPE_OPAQUE_WIN32_EXT, handle);
|
||||
return true;
|
||||
#else
|
||||
(void)memory;
|
||||
(void)size;
|
||||
(void)handle;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct xrt_swapchain *
|
||||
client_gl_memobj_swapchain_create(struct xrt_compositor *xc,
|
||||
const struct xrt_swapchain_create_info *info,
|
||||
struct xrt_swapchain_native *xscn,
|
||||
struct client_gl_swapchain **out_cglsc)
|
||||
{
|
||||
#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD)
|
||||
struct client_gl_compositor *c = client_gl_compositor(xc);
|
||||
(void)c;
|
||||
|
||||
#if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_FD) || defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_WIN32_HANDLE)
|
||||
if (xscn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -110,8 +128,10 @@ client_gl_memobj_swapchain_create(struct xrt_compositor *xc,
|
|||
|
||||
GLint dedicated = xscn->images[i].use_dedicated_allocation ? GL_TRUE : GL_FALSE;
|
||||
glMemoryObjectParameterivEXT(sc->memory[i], GL_DEDICATED_MEMORY_OBJECT_EXT, &dedicated);
|
||||
glImportMemoryFdEXT(sc->memory[i], xscn->images[i].size, GL_HANDLE_TYPE_OPAQUE_FD_EXT,
|
||||
xscn->images[i].handle);
|
||||
|
||||
if (!client_gl_memobj_swapchain_import(sc->memory[i], xscn->images[i].size, xscn->images[i].handle)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// We have consumed this now, make sure it's not freed again.
|
||||
xscn->images[i].handle = XRT_GRAPHICS_BUFFER_HANDLE_INVALID;
|
||||
|
|
Loading…
Reference in a new issue