From ab6a869f551b8d307df6d7801e80624c199d6560 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Thu, 30 Dec 2021 00:35:40 +0100 Subject: [PATCH] LibSoftGPU: Drop unnecessary FP divisions in `to_vec4` --- Userland/Libraries/LibSoftGPU/Device.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index 4dbde51b94..4b1eefa823 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -47,11 +47,12 @@ ALWAYS_INLINE constexpr static Gfx::RGBA32 to_rgba32(const FloatVector4& v) static FloatVector4 to_vec4(Gfx::RGBA32 rgba) { + auto constexpr one_over_255 = 1.0f / 255; return { - ((rgba >> 16) & 0xff) / 255.0f, - ((rgba >> 8) & 0xff) / 255.0f, - (rgba & 0xff) / 255.0f, - ((rgba >> 24) & 0xff) / 255.0f + ((rgba >> 16) & 0xff) * one_over_255, + ((rgba >> 8) & 0xff) * one_over_255, + (rgba & 0xff) * one_over_255, + ((rgba >> 24) & 0xff) * one_over_255, }; }