mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 21:37:58 +03:00
LibSoftGPU: Convert width and height to f32x4
just once
We were passing along a `u32x4` only for it to be converted to `f32x4` as soon as we'd use it.
This commit is contained in:
parent
b62dba6bbf
commit
759ef82e75
Notes:
sideshowbarker
2024-07-17 07:16:17 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/759ef82e75 Pull-request: https://github.com/SerenityOS/serenity/pull/15150 Reviewed-by: https://github.com/linusg ✅ Reviewed-by: https://github.com/sunverwerth ✅
@ -37,13 +37,13 @@ static f32x4 wrap_repeat(f32x4 value)
|
||||
return clamp(value, expand4(0.0f), expand4(1.0f));
|
||||
}
|
||||
|
||||
static f32x4 wrap_clamp_to_edge(f32x4 value, u32x4 num_texels)
|
||||
static f32x4 wrap_clamp_to_edge(f32x4 value, f32x4 num_texels)
|
||||
{
|
||||
f32x4 const clamp_limit = 1.f / to_f32x4(2 * num_texels);
|
||||
return clamp(value, clamp_limit, 1.0f - clamp_limit);
|
||||
f32x4 const clamp_limit = .5f / num_texels;
|
||||
return clamp(value, clamp_limit, 1.f - clamp_limit);
|
||||
}
|
||||
|
||||
static f32x4 wrap_mirrored_repeat(f32x4 value, u32x4 num_texels)
|
||||
static f32x4 wrap_mirrored_repeat(f32x4 value, f32x4 num_texels)
|
||||
{
|
||||
f32x4 integer = floor_int_range(value);
|
||||
f32x4 frac = value - integer;
|
||||
@ -51,7 +51,7 @@ static f32x4 wrap_mirrored_repeat(f32x4 value, u32x4 num_texels)
|
||||
return wrap_clamp_to_edge(is_odd ? 1 - frac : frac, num_texels);
|
||||
}
|
||||
|
||||
static f32x4 wrap(f32x4 value, GPU::TextureWrapMode mode, u32x4 num_texels)
|
||||
static f32x4 wrap(f32x4 value, GPU::TextureWrapMode mode, f32x4 num_texels)
|
||||
{
|
||||
switch (mode) {
|
||||
case GPU::TextureWrapMode::Repeat:
|
||||
@ -167,14 +167,14 @@ Vector4<AK::SIMD::f32x4> Sampler::sample_2d_lod(Vector2<AK::SIMD::f32x4> const&
|
||||
image.level_height(level[3]),
|
||||
};
|
||||
|
||||
auto f_width = to_f32x4(width);
|
||||
auto f_height = to_f32x4(height);
|
||||
|
||||
u32x4 width_mask = width - 1;
|
||||
u32x4 height_mask = height - 1;
|
||||
|
||||
f32x4 s = wrap(uv.x(), m_config.texture_wrap_u, width);
|
||||
f32x4 t = wrap(uv.y(), m_config.texture_wrap_v, height);
|
||||
|
||||
f32x4 u = s * to_f32x4(width);
|
||||
f32x4 v = t * to_f32x4(height);
|
||||
f32x4 u = wrap(uv.x(), m_config.texture_wrap_u, f_width) * f_width;
|
||||
f32x4 v = wrap(uv.y(), m_config.texture_wrap_v, f_height) * f_height;
|
||||
|
||||
if (filter == GPU::TextureFilter::Nearest) {
|
||||
u32x4 i = to_u32x4(u);
|
||||
|
Loading…
Reference in New Issue
Block a user