aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneonloop2023-12-15 18:48:43 +0000
committerneonloop2023-12-15 18:48:43 +0000
commit9f688ec61a8f0a0140bbb3c57aaebb408f7b277c (patch)
tree0b977468104e876012d2af43a84ac1ca26738c71
parent8b063ec960b4ebc0068bddaa2d8cbbf8bc55b824 (diff)
downloadpicoarch-9f688ec61a8f0a0140bbb3c57aaebb408f7b277c.tar.gz
picoarch-9f688ec61a8f0a0140bbb3c57aaebb408f7b277c.tar.bz2
picoarch-9f688ec61a8f0a0140bbb3c57aaebb408f7b277c.zip
Fixes smooth shader on FunKey S
Musl or ffast-math caused round to round incorrectly. 0.6 rounded to 0, not 1. Avoid by using integer math instead.
-rw-r--r--scale.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/scale.c b/scale.c
index c220aac..682b6c1 100644
--- a/scale.c
+++ b/scale.c
@@ -528,7 +528,7 @@ static void scale_select_scaler(unsigned w, unsigned h, size_t pitch) {
blend_args.w_ratio_in = w / gcd_w;
blend_args.w_ratio_out = dst_w / gcd_w;
- div_w = round(blend_args.w_ratio_out / 5.0);
+ div_w = (blend_args.w_ratio_out + 2) / 5; /* rounded integer divide by 5 */
blend_args.w_bp[0] = div_w;
blend_args.w_bp[1] = blend_args.w_ratio_out >> 1;
@@ -536,7 +536,7 @@ static void scale_select_scaler(unsigned w, unsigned h, size_t pitch) {
blend_args.h_ratio_in = h / gcd_h;
blend_args.h_ratio_out = dst_h / gcd_h;
- div_h = round(blend_args.h_ratio_out / 5.0);
+ div_h = (blend_args.w_ratio_out + 2) / 5; /* rounded integer divide by 5 */
blend_args.h_bp[0] = div_h;
blend_args.h_bp[1] = blend_args.h_ratio_out >> 1;