From 1e042dbb084090ecfd2f63cddd61615544715d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Thu, 8 Feb 2024 19:57:28 +0100 Subject: [PATCH] shaders/sampling: change loop iterator to uint in sample ortho Fixes warning: `integer modulus may be much slower, try using uints if possible` --- src/shaders/sampling.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/shaders/sampling.c b/src/shaders/sampling.c index 30814b93..5442789f 100644 --- a/src/shaders/sampling.c +++ b/src/shaders/sampling.c @@ -1055,20 +1055,20 @@ bool pl_shader_sample_ortho2(pl_shader sh, const struct pl_sample_src *src, ${vecType: comps} lo = ${vecType: comps}(1e9); \ @} \ #pragma unroll 4 \ - for (int n = 0; n < ${int: N}; n += ${const int: use_linear ? 2 : 1}) { \ - if (n % 4 == 0) \ - ws = $lut(vec2(float(n / 4) / ${const float: denom}, fcoord)); \ + for (uint n = 0u; n < ${uint: N}; n += ${const uint: use_linear ? 2u : 1u}) { \ + if (n % 4u == 0u) \ + ws = $lut(vec2(float(n / 4u) / ${const float: denom}, fcoord)); \ off = float(n); \ @if (use_linear) \ - off += ws[n % 4 + 1]; \ + off += ws[n % 4u + 1u]; \ c = textureLod($src_tex, base + pt * off, 0.0).${swizzle: comps}; \ @if (use_ar) { \ - if (n == ${uint: N} / 2 - 1 || n == ${uint: N} / 2) { \ + if (n == ${uint: N} / 2u - 1u || n == ${uint: N} / 2u) { \ lo = min(lo, c); \ hi = max(hi, c); \ } \ @} \ - ca += ws[n % 4] * c; \ + ca += ws[n % 4u] * c; \ } \ @if (use_ar) \ ca = mix(ca, clamp(ca, lo, hi), ${float: cfg.antiring}); \