From 6fe02588f96ebc1e26d865eab69d021a6e5e56fa Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 8 Apr 2020 15:13:28 +0100 Subject: [PATCH] comp: Get num_images from the fd compositor --- doc/changes/compositor/mr.270.md | 1 + src/xrt/compositor/client/comp_gl_client.c | 13 +++++++------ src/xrt/compositor/client/comp_vk_client.c | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 doc/changes/compositor/mr.270.md diff --git a/doc/changes/compositor/mr.270.md b/doc/changes/compositor/mr.270.md new file mode 100644 index 000000000..c8090fa2b --- /dev/null +++ b/doc/changes/compositor/mr.270.md @@ -0,0 +1 @@ +client: Make sure that the number of images is decided by the fd compositor. diff --git a/src/xrt/compositor/client/comp_gl_client.c b/src/xrt/compositor/client/comp_gl_client.c index 6881bb1d0..29da6c4b5 100644 --- a/src/xrt/compositor/client/comp_gl_client.c +++ b/src/xrt/compositor/client/comp_gl_client.c @@ -173,7 +173,6 @@ client_gl_swapchain_create(struct xrt_compositor *xc, uint32_t mip_count) { struct client_gl_compositor *c = client_gl_compositor(xc); - uint32_t num_images = 3; if (array_size > 1) { const char *version_str = (const char *)glGetString(GL_VERSION); @@ -200,13 +199,15 @@ client_gl_swapchain_create(struct xrt_compositor *xc, return NULL; } + struct client_gl_swapchain *sc = U_TYPED_CALLOC(struct client_gl_swapchain); sc->base.base.destroy = client_gl_swapchain_destroy; sc->base.base.acquire_image = client_gl_swapchain_acquire_image; sc->base.base.wait_image = client_gl_swapchain_wait_image; sc->base.base.release_image = client_gl_swapchain_release_image; - sc->base.base.num_images = num_images; + // Fetch the number of images from the fd swapchain. + sc->base.base.num_images = xsc->num_images; sc->xscfd = xrt_swapchain_fd(xsc); GLuint prev_texture = 0; @@ -214,14 +215,14 @@ client_gl_swapchain_create(struct xrt_compositor *xc, : GL_TEXTURE_BINDING_2D_ARRAY, (GLint *)&prev_texture); - glGenTextures(num_images, sc->base.images); - for (uint32_t i = 0; i < num_images; i++) { + glGenTextures(xsc->num_images, sc->base.images); + for (uint32_t i = 0; i < xsc->num_images; i++) { glBindTexture(array_size == 1 ? GL_TEXTURE_2D : GL_TEXTURE_2D_ARRAY, sc->base.images[i]); } - glCreateMemoryObjectsEXT(num_images, &sc->base.memory[0]); - for (uint32_t i = 0; i < num_images; i++) { + glCreateMemoryObjectsEXT(xsc->num_images, &sc->base.memory[0]); + for (uint32_t i = 0; i < xsc->num_images; i++) { GLint dedicated = GL_TRUE; glMemoryObjectParameterivEXT(sc->base.memory[i], GL_DEDICATED_MEMORY_OBJECT_EXT, diff --git a/src/xrt/compositor/client/comp_vk_client.c b/src/xrt/compositor/client/comp_vk_client.c index 40b164845..7cda4b66c 100644 --- a/src/xrt/compositor/client/comp_vk_client.c +++ b/src/xrt/compositor/client/comp_vk_client.c @@ -183,7 +183,6 @@ client_vk_swapchain_create(struct xrt_compositor *xc, { struct client_vk_compositor *c = client_vk_compositor(xc); VkCommandBuffer cmd_buffer; - uint32_t num_images = 3; VkResult ret; struct xrt_swapchain *xsc = c->xcfd->base.create_swapchain( @@ -213,11 +212,12 @@ client_vk_swapchain_create(struct xrt_compositor *xc, sc->base.base.acquire_image = client_vk_swapchain_acquire_image; sc->base.base.wait_image = client_vk_swapchain_wait_image; sc->base.base.release_image = client_vk_swapchain_release_image; - sc->base.base.num_images = num_images; + // Fetch the number of images from the fd swapchain. + sc->base.base.num_images = xsc->num_images; sc->c = c; sc->xscfd = xrt_swapchain_fd(xsc); - for (uint32_t i = 0; i < num_images; i++) { + for (uint32_t i = 0; i < xsc->num_images; i++) { ret = vk_create_image_from_fd( &c->vk, bits, format, width, height, array_size, mip_count, &sc->xscfd->images[i], &sc->base.images[i],