mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-04 06:06:17 +00:00
c/main: Let main compositor decide size of scratch image
This commit is contained in:
parent
84a0277ee7
commit
7a9aa05d46
|
@ -1006,7 +1006,7 @@ compositor_init_renderer(struct comp_compositor *c)
|
||||||
{
|
{
|
||||||
COMP_TRACE_MARKER();
|
COMP_TRACE_MARKER();
|
||||||
|
|
||||||
c->r = comp_renderer_create(c);
|
c->r = comp_renderer_create(c, c->view_extents);
|
||||||
|
|
||||||
#ifdef XRT_FEATURE_WINDOW_PEEK
|
#ifdef XRT_FEATURE_WINDOW_PEEK
|
||||||
c->peek = comp_window_peek_create(c);
|
c->peek = comp_window_peek_create(c);
|
||||||
|
|
|
@ -466,13 +466,7 @@ renderer_create_layer_renderer(struct comp_renderer *r)
|
||||||
comp_layer_renderer_destroy(&r->lr);
|
comp_layer_renderer_destroy(&r->lr);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkExtent2D extent;
|
VkExtent2D extent = r->scratch.extent;
|
||||||
|
|
||||||
extent = (VkExtent2D){
|
|
||||||
.width = r->c->view_extents.width,
|
|
||||||
.height = r->c->view_extents.height,
|
|
||||||
};
|
|
||||||
|
|
||||||
r->lr = comp_layer_renderer_create(vk, &r->c->shaders, extent, VK_FORMAT_B8G8R8A8_SRGB);
|
r->lr = comp_layer_renderer_create(vk, &r->c->shaders, extent, VK_FORMAT_B8G8R8A8_SRGB);
|
||||||
if (layer_count != 0) {
|
if (layer_count != 0) {
|
||||||
comp_layer_renderer_allocate_layers(r->lr, layer_count);
|
comp_layer_renderer_allocate_layers(r->lr, layer_count);
|
||||||
|
@ -562,7 +556,7 @@ renderer_ensure_images_and_renderings(struct comp_renderer *r, bool force_recrea
|
||||||
|
|
||||||
//! Create renderer and initialize non-image-dependent members
|
//! Create renderer and initialize non-image-dependent members
|
||||||
static void
|
static void
|
||||||
renderer_init(struct comp_renderer *r, struct comp_compositor *c)
|
renderer_init(struct comp_renderer *r, struct comp_compositor *c, VkExtent2D scratch_extent)
|
||||||
{
|
{
|
||||||
r->c = c;
|
r->c = c;
|
||||||
r->settings = &c->settings;
|
r->settings = &c->settings;
|
||||||
|
@ -571,6 +565,12 @@ renderer_init(struct comp_renderer *r, struct comp_compositor *c)
|
||||||
r->fenced_buffer = -1;
|
r->fenced_buffer = -1;
|
||||||
r->rtr_array = NULL;
|
r->rtr_array = NULL;
|
||||||
|
|
||||||
|
bool bret = render_scratch_images_ensure(&c->nr, &r->scratch, scratch_extent);
|
||||||
|
if (!bret) {
|
||||||
|
COMP_ERROR(c, "render_scratch_images_ensure: false");
|
||||||
|
assert(false && "Whelp, can't return an error. But should never really fail.");
|
||||||
|
}
|
||||||
|
|
||||||
// Try to early-allocate these, in case we can.
|
// Try to early-allocate these, in case we can.
|
||||||
renderer_ensure_images_and_renderings(r, false);
|
renderer_ensure_images_and_renderings(r, false);
|
||||||
|
|
||||||
|
@ -1030,28 +1030,6 @@ get_view_poses(struct comp_renderer *r, struct xrt_pose out_world[2], struct xrt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
ensure_scratch_image(struct comp_renderer *r)
|
|
||||||
{
|
|
||||||
struct xrt_view *l_v = &r->c->xdev->hmd->views[0];
|
|
||||||
struct xrt_view *r_v = &r->c->xdev->hmd->views[1];
|
|
||||||
|
|
||||||
uint32_t w = MAX(l_v->viewport.w_pixels, r_v->viewport.w_pixels);
|
|
||||||
uint32_t h = MAX(l_v->viewport.h_pixels, r_v->viewport.h_pixels);
|
|
||||||
|
|
||||||
// Adjust size to be bigger, 140%, to match default recommended viewport size.
|
|
||||||
//! @todo Make this match fully, or even match app provided layers.
|
|
||||||
w = (uint32_t)(w * 1.4f);
|
|
||||||
h = (uint32_t)(h * 1.4f);
|
|
||||||
|
|
||||||
VkExtent2D extent = {w, h};
|
|
||||||
|
|
||||||
if (!render_scratch_images_ensure(&r->c->nr, &r->scratch, extent)) {
|
|
||||||
U_LOG_E("Failed to create scratch image!");
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @pre render_compute_init(crc, &c->nr)
|
* @pre render_compute_init(crc, &c->nr)
|
||||||
*/
|
*/
|
||||||
|
@ -1063,9 +1041,6 @@ dispatch_compute(struct comp_renderer *r, struct render_compute *crc)
|
||||||
struct comp_compositor *c = r->c;
|
struct comp_compositor *c = r->c;
|
||||||
struct comp_target *ct = c->target;
|
struct comp_target *ct = c->target;
|
||||||
|
|
||||||
// In case the scratch images are needed, make sure they are created.
|
|
||||||
ensure_scratch_image(r);
|
|
||||||
|
|
||||||
// Basics
|
// Basics
|
||||||
const struct comp_layer *layers = c->base.slot.layers;
|
const struct comp_layer *layers = c->base.slot.layers;
|
||||||
uint32_t layer_count = c->base.slot.layer_count;
|
uint32_t layer_count = c->base.slot.layer_count;
|
||||||
|
@ -1576,11 +1551,11 @@ comp_renderer_destroy_layers(struct comp_renderer *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct comp_renderer *
|
struct comp_renderer *
|
||||||
comp_renderer_create(struct comp_compositor *c)
|
comp_renderer_create(struct comp_compositor *c, VkExtent2D scratch_extent)
|
||||||
{
|
{
|
||||||
struct comp_renderer *r = U_TYPED_CALLOC(struct comp_renderer);
|
struct comp_renderer *r = U_TYPED_CALLOC(struct comp_renderer);
|
||||||
|
|
||||||
renderer_init(r, c);
|
renderer_init(r, c, scratch_extent);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright 2019-2021, Collabora, Ltd.
|
// Copyright 2019-2023, Collabora, Ltd.
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
/*!
|
/*!
|
||||||
* @file
|
* @file
|
||||||
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
#include "xrt/xrt_compiler.h"
|
#include "xrt/xrt_compiler.h"
|
||||||
#include "xrt/xrt_defines.h"
|
#include "xrt/xrt_defines.h"
|
||||||
|
#include "xrt/xrt_vulkan_includes.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -28,12 +30,15 @@ struct comp_renderer;
|
||||||
/*!
|
/*!
|
||||||
* Called by the main compositor code to create the renderer.
|
* Called by the main compositor code to create the renderer.
|
||||||
*
|
*
|
||||||
|
* @param c Owning compositor.
|
||||||
|
* @param scratch_extent Size for scratch image used when squashing layers.
|
||||||
|
*
|
||||||
* @public @memberof comp_renderer
|
* @public @memberof comp_renderer
|
||||||
* @see comp_compositor
|
* @see comp_compositor
|
||||||
* @ingroup comp_main
|
* @ingroup comp_main
|
||||||
*/
|
*/
|
||||||
struct comp_renderer *
|
struct comp_renderer *
|
||||||
comp_renderer_create(struct comp_compositor *c);
|
comp_renderer_create(struct comp_compositor *c, VkExtent2D scratch_extent);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Clean up and free the renderer.
|
* Clean up and free the renderer.
|
||||||
|
|
Loading…
Reference in a new issue