From 1351c4e5053f24b99ead78e2c1f799c2a7c5404b Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Wed, 20 Jul 2022 20:11:37 -0400 Subject: [PATCH] Add 16f option to render_bit_depth command This change adds an option to let sway render onto XBGR16161616F buffers, assuming hardware and drivers support this. Such half-float formats may be used in the future for applications (including nested Sway) to submit high-dynamic-range buffers. Using this option is even more likely to reveal bugs in graphics drivers, monitors, and screenshot tools than 'render_bit_depth 10'. --- include/sway/config.h | 1 + sway/commands/output/render_bit_depth.c | 5 ++++- sway/config/output.c | 5 +++++ sway/sway-output.5.scd | 5 +++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 68c06846..0bef8585 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -258,6 +258,7 @@ enum render_bit_depth { RENDER_BIT_DEPTH_DEFAULT, // the default is currently 8 RENDER_BIT_DEPTH_8, RENDER_BIT_DEPTH_10, + RENDER_BIT_DEPTH_16F, }; /** diff --git a/sway/commands/output/render_bit_depth.c b/sway/commands/output/render_bit_depth.c index c419321e..ff660bb2 100644 --- a/sway/commands/output/render_bit_depth.c +++ b/sway/commands/output/render_bit_depth.c @@ -17,9 +17,12 @@ struct cmd_results *output_cmd_render_bit_depth(int argc, char **argv) { } else if (strcmp(*argv, "10") == 0) { config->handler_context.output_config->render_bit_depth = RENDER_BIT_DEPTH_10; + } else if (strcmp(*argv, "16f") == 0 || strcmp(*argv, "16F") == 0) { + config->handler_context.output_config->render_bit_depth = + RENDER_BIT_DEPTH_16F; } else { return cmd_results_new(CMD_INVALID, - "Invalid bit depth. Must be a value in (8|10)."); + "Invalid bit depth. Must be a value in (8|10|16f)."); } config->handler_context.leftovers.argc = argc - 1; diff --git a/sway/config/output.c b/sway/config/output.c index b3e8371e..14a2755f 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -376,6 +376,11 @@ static const uint32_t *bit_depth_preferences[] = { DRM_FORMAT_XRGB8888, DRM_FORMAT_INVALID, }, + [RENDER_BIT_DEPTH_16F] = (const uint32_t []){ + DRM_FORMAT_XBGR16161616F, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_INVALID, + }, }; static void queue_output_config(struct output_config *oc, diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd index 45429da2..15b523b1 100644 --- a/sway/sway-output.5.scd +++ b/sway/sway-output.5.scd @@ -165,9 +165,10 @@ must be separated by one space. For example: adaptive sync can improve latency, but can cause flickering on some hardware. -*output* render_bit_depth 8|10 +*output* render_bit_depth 8|10|16f Controls the color channel bit depth at which frames are rendered; the - default is currently 8 bits per channel. + default is currently 8 bits per channel. The "16f" option requests + color channels encoded in half-precision floating point format. Setting higher values will not have an effect if hardware and software lack support for such bit depths. Successfully increasing the render bit depth