mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-31 07:11:09 -04:00
config: add tweak.min-stride-alignment
This allows the user to configure the value by which a surface buffer's stride must be an even multiple of. This can be used to ensure the stride meets the GPU driver's requirements for direct import. Defaults to 256. Set to 0 to disable. Closes #2182
This commit is contained in:
parent
80951ab7a6
commit
fac3994154
6 changed files with 29 additions and 1 deletions
5
config.c
5
config.c
|
|
@ -2848,6 +2848,10 @@ parse_section_tweak(struct context *ctx)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (streq(key, "min-stride-alignment")) {
|
||||||
|
return value_to_uint32(ctx, 10, &conf->tweak.min_stride_alignment);
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
LOG_CONTEXTUAL_ERR("not a valid option: %s", key);
|
LOG_CONTEXTUAL_ERR("not a valid option: %s", key);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -3496,6 +3500,7 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
.font_monospace_warn = true,
|
.font_monospace_warn = true,
|
||||||
.sixel = true,
|
.sixel = true,
|
||||||
.surface_bit_depth = SHM_BITS_AUTO,
|
.surface_bit_depth = SHM_BITS_AUTO,
|
||||||
|
.min_stride_alignment = 256,
|
||||||
},
|
},
|
||||||
|
|
||||||
.touch = {
|
.touch = {
|
||||||
|
|
|
||||||
1
config.h
1
config.h
|
|
@ -435,6 +435,7 @@ struct config {
|
||||||
bool font_monospace_warn;
|
bool font_monospace_warn;
|
||||||
bool sixel;
|
bool sixel;
|
||||||
enum shm_bit_depth surface_bit_depth;
|
enum shm_bit_depth surface_bit_depth;
|
||||||
|
uint32_t min_stride_alignment;
|
||||||
} tweak;
|
} tweak;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
1
main.c
1
main.c
|
|
@ -597,6 +597,7 @@ main(int argc, char *const *argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
shm_set_max_pool_size(conf.tweak.max_shm_pool_size);
|
shm_set_max_pool_size(conf.tweak.max_shm_pool_size);
|
||||||
|
shm_set_min_stride_alignment(conf.tweak.min_stride_alignment);
|
||||||
|
|
||||||
if ((fdm = fdm_init()) == NULL)
|
if ((fdm = fdm_init()) == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
17
shm.c
17
shm.c
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#include <pixman.h>
|
#include <pixman.h>
|
||||||
|
|
||||||
#include <fcft/stride.h>
|
|
||||||
#include <tllist.h>
|
#include <tllist.h>
|
||||||
|
|
||||||
#define LOG_MODULE "shm"
|
#define LOG_MODULE "shm"
|
||||||
|
|
@ -21,6 +20,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
#include "stride.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#if !defined(MAP_UNINITIALIZED)
|
#if !defined(MAP_UNINITIALIZED)
|
||||||
|
|
@ -61,6 +61,8 @@ static off_t max_pool_size = 512 * 1024 * 1024;
|
||||||
static bool can_punch_hole = false;
|
static bool can_punch_hole = false;
|
||||||
static bool can_punch_hole_initialized = false;
|
static bool can_punch_hole_initialized = false;
|
||||||
|
|
||||||
|
static size_t min_stride_alignment = 0;
|
||||||
|
|
||||||
struct buffer_pool {
|
struct buffer_pool {
|
||||||
int fd; /* memfd */
|
int fd; /* memfd */
|
||||||
struct wl_shm_pool *wl_pool;
|
struct wl_shm_pool *wl_pool;
|
||||||
|
|
@ -113,6 +115,12 @@ shm_set_max_pool_size(off_t _max_pool_size)
|
||||||
max_pool_size = _max_pool_size;
|
max_pool_size = _max_pool_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
shm_set_min_stride_alignment(size_t _min_stride_alignment)
|
||||||
|
{
|
||||||
|
min_stride_alignment = _min_stride_alignment;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
buffer_destroy_dont_close(struct buffer *buf)
|
buffer_destroy_dont_close(struct buffer *buf)
|
||||||
{
|
{
|
||||||
|
|
@ -342,6 +350,13 @@ get_new_buffers(struct buffer_chain *chain, size_t count,
|
||||||
? chain->pixman_fmt_with_alpha
|
? chain->pixman_fmt_with_alpha
|
||||||
: chain->pixman_fmt_without_alpha,
|
: chain->pixman_fmt_without_alpha,
|
||||||
widths[i]);
|
widths[i]);
|
||||||
|
|
||||||
|
if (min_stride_alignment > 0) {
|
||||||
|
const size_t m = min_stride_alignment;
|
||||||
|
stride[i] = (stride[i] + m - 1) / m * m;
|
||||||
|
}
|
||||||
|
|
||||||
|
xassert(min_stride_alignment == 0 || stride[i] % min_stride_alignment == 0);
|
||||||
sizes[i] = stride[i] * heights[i];
|
sizes[i] = stride[i] * heights[i];
|
||||||
total_size += sizes[i];
|
total_size += sizes[i];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
shm.h
3
shm.h
|
|
@ -42,7 +42,10 @@ struct buffer {
|
||||||
};
|
};
|
||||||
|
|
||||||
void shm_fini(void);
|
void shm_fini(void);
|
||||||
|
|
||||||
|
/* TODO: combine into shm_init() */
|
||||||
void shm_set_max_pool_size(off_t max_pool_size);
|
void shm_set_max_pool_size(off_t max_pool_size);
|
||||||
|
void shm_set_min_stride_alignment(size_t min_stride_alignment);
|
||||||
|
|
||||||
struct buffer_chain;
|
struct buffer_chain;
|
||||||
struct buffer_chain *shm_chain_new(
|
struct buffer_chain *shm_chain_new(
|
||||||
|
|
|
||||||
|
|
@ -1413,6 +1413,9 @@ test_section_tweak(void)
|
||||||
test_float(&ctx, &parse_section_tweak, "bold-text-in-bright-amount",
|
test_float(&ctx, &parse_section_tweak, "bold-text-in-bright-amount",
|
||||||
&conf.bold_in_bright.amount);
|
&conf.bold_in_bright.amount);
|
||||||
|
|
||||||
|
test_uint32(&ctx, &parse_section_tweak, "min-stride-alignment",
|
||||||
|
&conf.tweak.min_stride_alignment);
|
||||||
|
|
||||||
#if 0 /* Must be equal to, or less than INT32_MAX */
|
#if 0 /* Must be equal to, or less than INT32_MAX */
|
||||||
test_uint32(&ctx, &parse_section_tweak, "max-shm-pool-size-mb",
|
test_uint32(&ctx, &parse_section_tweak, "max-shm-pool-size-mb",
|
||||||
&conf.tweak.max_shm_pool_size);
|
&conf.tweak.max_shm_pool_size);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue