mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
c/client: Get the supported formats from the fd compositor
This commit is contained in:
parent
0ad9a7406c
commit
ccb1b911f6
1
doc/changes/compositor/mr.282.1.md
Normal file
1
doc/changes/compositor/mr.282.1.md
Normal file
|
@ -0,0 +1 @@
|
|||
client: Propegate the supported formats from the real compositor to the client ones.
|
|
@ -160,6 +160,20 @@ gl_format_to_vk(int64_t format)
|
|||
}
|
||||
}
|
||||
|
||||
static int64_t
|
||||
vk_format_to_gl(int64_t format)
|
||||
{
|
||||
switch (format) {
|
||||
case 37 /*VK_FORMAT_R8G8B8A8_UNORM*/: return GL_RGBA8;
|
||||
case 43 /*VK_FORMAT_R8G8B8A8_SRGB*/: return GL_SRGB8_ALPHA8;
|
||||
case 44 /*VK_FORMAT_B8G8R8A8_UNORM*/: return 0;
|
||||
case 50 /*VK_FORMAT_B8G8R8A8_SRGB*/: return 0;
|
||||
default:
|
||||
printf("Cannot convert VK format %ld to GL format!\n", format);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static struct xrt_swapchain *
|
||||
client_gl_swapchain_create(struct xrt_compositor *xc,
|
||||
enum xrt_swapchain_create_flags create,
|
||||
|
@ -266,11 +280,20 @@ client_gl_compositor_init(struct client_gl_compositor *c,
|
|||
c->base.base.discard_frame = client_gl_compositor_discard_frame;
|
||||
c->base.base.end_frame = client_gl_compositor_end_frame;
|
||||
c->base.base.destroy = client_gl_compositor_destroy;
|
||||
c->base.base.formats[0] = GL_SRGB8_ALPHA8;
|
||||
c->base.base.formats[1] = GL_RGBA8;
|
||||
c->base.base.num_formats = 2;
|
||||
c->xcfd = xcfd;
|
||||
|
||||
// Passthrough our formats from the fd compositor to the client.
|
||||
size_t count = 0;
|
||||
for (uint32_t i = 0; i < xcfd->base.num_formats; i++) {
|
||||
int64_t f = vk_format_to_gl(xcfd->base.formats[i]);
|
||||
if (f == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->base.base.formats[count++] = f;
|
||||
}
|
||||
c->base.base.num_formats = count;
|
||||
|
||||
gladLoadGL(get_gl_procaddr);
|
||||
|
||||
if (!GLAD_GL_EXT_memory_object_fd) {
|
||||
|
|
|
@ -262,14 +262,13 @@ client_vk_compositor_create(struct xrt_compositor_fd *xcfd,
|
|||
c->base.base.discard_frame = client_vk_compositor_discard_frame;
|
||||
c->base.base.end_frame = client_vk_compositor_end_frame;
|
||||
c->base.base.destroy = client_vk_compositor_destroy;
|
||||
|
||||
c->base.base.formats[0] = VK_FORMAT_B8G8R8A8_SRGB;
|
||||
c->base.base.formats[1] = VK_FORMAT_R8G8B8A8_SRGB;
|
||||
c->base.base.formats[2] = VK_FORMAT_B8G8R8A8_UNORM;
|
||||
c->base.base.formats[3] = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
c->base.base.num_formats = 4;
|
||||
|
||||
c->xcfd = xcfd;
|
||||
// passthrough our formats from the fd compositor to the client
|
||||
for (uint32_t i = 0; i < xcfd->base.num_formats; i++) {
|
||||
c->base.base.formats[i] = xcfd->base.formats[i];
|
||||
}
|
||||
|
||||
c->base.base.num_formats = xcfd->base.num_formats;
|
||||
|
||||
ret = vk_init_from_given(&c->vk, getProc, instance, physicalDevice,
|
||||
device, queueFamilyIndex, queueIndex);
|
||||
|
|
|
@ -41,26 +41,24 @@
|
|||
* behavior.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
|
||||
#include "os/os_time.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_var.h"
|
||||
#include "util/u_misc.h"
|
||||
#include "util/u_time.h"
|
||||
#include "util/u_debug.h"
|
||||
|
||||
#include "main/comp_compositor.h"
|
||||
|
||||
#include "xrt/xrt_gfx_fd.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "util/u_var.h"
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -501,6 +499,7 @@ compositor_init_vulkan(struct comp_compositor *c)
|
|||
return ret == VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Other functions.
|
||||
|
@ -798,7 +797,6 @@ compositor_init_renderer(struct comp_compositor *c)
|
|||
return c->r != NULL;
|
||||
}
|
||||
|
||||
|
||||
struct xrt_compositor_fd *
|
||||
xrt_gfx_provider_create_fd(struct xrt_device *xdev, bool flip_y)
|
||||
{
|
||||
|
@ -848,6 +846,16 @@ xrt_gfx_provider_create_fd(struct xrt_device *xdev, bool flip_y)
|
|||
|
||||
COMP_DEBUG(c, "Done %p", (void *)c);
|
||||
|
||||
/*!
|
||||
* @todo Support more like, depth/float formats etc,
|
||||
* remember to update the GL client as well.
|
||||
*/
|
||||
// These are the available formats we will expose to our clients.
|
||||
c->base.base.formats[0] = VK_FORMAT_B8G8R8A8_SRGB;
|
||||
c->base.base.formats[1] = VK_FORMAT_R8G8B8A8_SRGB;
|
||||
c->base.base.formats[2] = VK_FORMAT_B8G8R8A8_UNORM;
|
||||
c->base.base.formats[3] = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
c->base.base.num_formats = 4;
|
||||
|
||||
u_var_add_root(c, "Compositor", true);
|
||||
u_var_add_ro_f32(c, &c->compositor_frame_times.fps, "FPS (Compositor)");
|
||||
|
|
Loading…
Reference in a new issue