Skip to content

Commit 2336f1c

Browse files
committed
gfx/video_shader_parse: accept float values for absolute scale_x/y
Many community .slangp presets — notably Mega_Bezel — write absolute scale dimensions as floats, e.g. scale_type_x26 = absolute scale_x26 = 800.0 Before commit 1d9ed2e ("file/config_file: reject non-numeric input in integer getters"), config_get_int silently accepted "800.0" as 800 because strtol stops at the '.', returns 800, and leaves errno == 0. The old getter only checked errno, so it returned true with *in = 800. After 1d9ed2e — correctly — config_get_int rejects strings with trailing garbage and leaves *in untouched. In video_shader_parse_pass the local iattr is initialised to 0 but scale->abs_x / abs_y are not assigned on failure, so the absolute-scaled passes end up with a 0 dimension. The Vulkan driver then tries to build a 0×N (or 0×0) framebuffer and crashes. Fall back to config_get_float + roundf on the absolute branches so the long-tail of presets using float-shaped absolute scales keeps working without resurrecting the silent-accept behaviour in config_file. Hopefully fixes #18981.
1 parent 64949e7 commit 2336f1c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

gfx/video_shader_parse.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <stdlib.h>
1818
#include <string.h>
19+
#include <math.h>
1920

2021
#ifdef HAVE_CONFIG_H
2122
#include "../config.h"
@@ -779,14 +780,19 @@ static bool video_shader_parse_pass(config_file_t *conf,
779780
if (scale->type_x == RARCH_SCALE_ABSOLUTE)
780781
{
781782
int iattr = 0;
783+
float fattr = 0.0f;
782784
if (config_get_int(conf, shader_var, &iattr))
783785
scale->abs_x = iattr;
786+
else if (config_get_float(conf, shader_var, &fattr))
787+
scale->abs_x = (unsigned)roundf(fattr);
784788
else
785789
{
786790
_len = strlcpy(shader_var, "scale_x", sizeof(shader_var));
787791
strlcpy(shader_var + _len, formatted_num, sizeof(shader_var) - _len);
788792
if (config_get_int(conf, shader_var, &iattr))
789793
scale->abs_x = iattr;
794+
else if (config_get_float(conf, shader_var, &fattr))
795+
scale->abs_x = (unsigned)roundf(fattr);
790796
}
791797
}
792798
else
@@ -809,14 +815,19 @@ static bool video_shader_parse_pass(config_file_t *conf,
809815
if (scale->type_y == RARCH_SCALE_ABSOLUTE)
810816
{
811817
int iattr = 0;
818+
float fattr = 0.0f;
812819
if (config_get_int(conf, shader_var, &iattr))
813820
scale->abs_y = iattr;
821+
else if (config_get_float(conf, shader_var, &fattr))
822+
scale->abs_y = (unsigned)roundf(fattr);
814823
else
815824
{
816825
_len = strlcpy(shader_var, "scale_y", sizeof(shader_var));
817826
strlcpy(shader_var + _len, formatted_num, sizeof(shader_var) - _len);
818827
if (config_get_int(conf, shader_var, &iattr))
819828
scale->abs_y = iattr;
829+
else if (config_get_float(conf, shader_var, &fattr))
830+
scale->abs_y = (unsigned)roundf(fattr);
820831
}
821832
}
822833
else

0 commit comments

Comments
 (0)