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'.
This commit is contained in:
Manuel Stoeckl 2022-07-20 20:11:37 -04:00
parent 6b97c4fa71
commit 1351c4e505
4 changed files with 13 additions and 3 deletions

View file

@ -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,
};
/**

View file

@ -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;

View file

@ -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,

View file

@ -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* <name> render_bit_depth 8|10
*output* <name> 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