From adc6ca8e8adb6125abe98116aaa7c2d2f6bda964 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 6 Aug 2020 12:09:15 +0100 Subject: [PATCH] c/main: Fill out all of the compositor info struct --- src/xrt/compositor/main/comp_compositor.c | 47 +++++++++++++++++++---- src/xrt/compositor/main/comp_settings.c | 2 + src/xrt/compositor/main/comp_settings.h | 3 ++ src/xrt/state_trackers/oxr/oxr_system.c | 2 +- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index 6ae485d9f..7f68cfe9d 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -984,6 +984,8 @@ xrt_gfx_provider_create_native(struct xrt_device *xdev) COMP_DEBUG(c, "Done %p", (void *)c); + struct xrt_compositor_info *info = &c->base.base.info; + /*! * @todo Support more like, depth/float formats etc, * remember to update the GL client as well. @@ -997,14 +999,45 @@ xrt_gfx_provider_create_native(struct xrt_device *xdev) * two formats should not be used as they are linear but doesn't have * enough bits to express it without resulting in banding. */ + info->formats[0] = VK_FORMAT_R8G8B8A8_SRGB; // OGL VK + info->formats[1] = VK_FORMAT_A2B10G10R10_UNORM_PACK32; // OGL VK + info->formats[2] = VK_FORMAT_R16G16B16A16_SFLOAT; // OGL VK + info->formats[3] = VK_FORMAT_B8G8R8A8_SRGB; // VK + info->formats[4] = VK_FORMAT_R8G8B8A8_UNORM; // OGL VK + info->formats[5] = VK_FORMAT_B8G8R8A8_UNORM; // VK + info->num_formats = 6; + + float scale = c->settings.viewport_scale; + + if (scale > 2.0) { + scale = 2.0; + COMP_DEBUG(c, "Clamped scale to 200%%\n"); + } + + uint32_t w0 = (uint32_t)(xdev->hmd->views[0].display.w_pixels * scale); + uint32_t h0 = (uint32_t)(xdev->hmd->views[0].display.h_pixels * scale); + uint32_t w1 = (uint32_t)(xdev->hmd->views[1].display.w_pixels * scale); + uint32_t h1 = (uint32_t)(xdev->hmd->views[1].display.h_pixels * scale); + + uint32_t w0_2 = xdev->hmd->views[0].display.w_pixels * 2; + uint32_t h0_2 = xdev->hmd->views[0].display.h_pixels * 2; + uint32_t w1_2 = xdev->hmd->views[1].display.w_pixels * 2; + uint32_t h1_2 = xdev->hmd->views[1].display.h_pixels * 2; + // clang-format off - c->base.base.info.formats[0] = VK_FORMAT_R8G8B8A8_SRGB; // OGL VK - c->base.base.info.formats[1] = VK_FORMAT_A2B10G10R10_UNORM_PACK32; // OGL VK - c->base.base.info.formats[2] = VK_FORMAT_R16G16B16A16_SFLOAT; // OGL VK - c->base.base.info.formats[3] = VK_FORMAT_B8G8R8A8_SRGB; // VK - c->base.base.info.formats[4] = VK_FORMAT_R8G8B8A8_UNORM; // OGL VK - c->base.base.info.formats[5] = VK_FORMAT_B8G8R8A8_UNORM; // VK - c->base.base.info.num_formats = 6; + info->views[0].recommended.width_pixels = w0; + info->views[0].recommended.height_pixels = h0; + info->views[0].recommended.sample_count = 1; + info->views[0].max.width_pixels = w0_2; + info->views[0].max.height_pixels = h0_2; + info->views[0].max.sample_count = 1; + + info->views[1].recommended.width_pixels = w1; + info->views[1].recommended.height_pixels = h1; + info->views[1].recommended.sample_count = 1; + info->views[1].max.width_pixels = w1_2; + info->views[1].max.height_pixels = h1_2; + info->views[1].max.sample_count = 1; // clang-format on u_var_add_root(c, "Compositor", true); diff --git a/src/xrt/compositor/main/comp_settings.c b/src/xrt/compositor/main/comp_settings.c index 5b316ea78..37d7f10ee 100644 --- a/src/xrt/compositor/main/comp_settings.c +++ b/src/xrt/compositor/main/comp_settings.c @@ -21,6 +21,7 @@ DEBUG_GET_ONCE_BOOL_OPTION(force_wayland, "XRT_COMPOSITOR_FORCE_WAYLAND", false) DEBUG_GET_ONCE_BOOL_OPTION(wireframe, "XRT_COMPOSITOR_WIREFRAME", false) DEBUG_GET_ONCE_NUM_OPTION(force_gpu_index, "XRT_COMPOSITOR_FORCE_GPU_INDEX", -1) DEBUG_GET_ONCE_NUM_OPTION(desired_mode, "XRT_COMPOSITOR_DESIRED_MODE", -1) +DEBUG_GET_ONCE_NUM_OPTION(scale_percentage, "XRT_COMPOSITOR_SCALE_PERCENTAGE", 140) // clang-format on void @@ -48,6 +49,7 @@ comp_settings_init(struct comp_settings *s, struct xrt_device *xdev) s->gpu_index = debug_get_num_option_force_gpu_index(); s->debug.wireframe = debug_get_bool_option_wireframe(); s->desired_mode = debug_get_num_option_desired_mode(); + s->viewport_scale = debug_get_num_option_scale_percentage() / 100.0; if (debug_get_bool_option_force_nvidia()) { s->window_type = WINDOW_DIRECT_NVIDIA; diff --git a/src/xrt/compositor/main/comp_settings.h b/src/xrt/compositor/main/comp_settings.h index d55688595..d64258e71 100644 --- a/src/xrt/compositor/main/comp_settings.h +++ b/src/xrt/compositor/main/comp_settings.h @@ -76,6 +76,9 @@ struct comp_settings bool wireframe; } debug; + //! Procentage to scale the viewport by. + double viewport_scale; + //! Not used with direct mode. bool fullscreen; diff --git a/src/xrt/state_trackers/oxr/oxr_system.c b/src/xrt/state_trackers/oxr/oxr_system.c index 699a82333..45449f5d6 100644 --- a/src/xrt/state_trackers/oxr/oxr_system.c +++ b/src/xrt/state_trackers/oxr/oxr_system.c @@ -21,7 +21,7 @@ #include "oxr_two_call.h" // clang-format off -DEBUG_GET_ONCE_NUM_OPTION(scale_percentage, "OXR_VIEWPORT_SCALE_PERCENTAGE", 140) +DEBUG_GET_ONCE_NUM_OPTION(scale_percentage, "OXR_VIEWPORT_SCALE_PERCENTAGE", 100) // clang-format on static bool