From e9d2f9a95e91b188a8d062177c1488c21249f0b0 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Wed, 14 Sep 2022 14:32:23 +0200 Subject: [PATCH] LibSoftGPU: Use `memcpy` instead of a loop to blit the color buffer Looking at `Tubes` before and after this change, comparing the original loop to the one using `memcpy`, including the time for `memcpy` itself, resulted in ~15% fewer samples in profiles on my machine. --- Userland/Libraries/LibSoftGPU/Buffer/Typed2DBuffer.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Userland/Libraries/LibSoftGPU/Buffer/Typed2DBuffer.h b/Userland/Libraries/LibSoftGPU/Buffer/Typed2DBuffer.h index f8069a19cb..dbbe0f3e1f 100644 --- a/Userland/Libraries/LibSoftGPU/Buffer/Typed2DBuffer.h +++ b/Userland/Libraries/LibSoftGPU/Buffer/Typed2DBuffer.h @@ -42,10 +42,7 @@ public: for (int y = target.bottom(); y >= target.top(); --y) { auto const* buffer_scanline = scanline(source_y++); auto* bitmap_scanline = bitmap.scanline(y); - - int source_x = 0; - for (int x = target.left(); x <= target.right(); ++x) - bitmap_scanline[x] = buffer_scanline[source_x++]; + memcpy(bitmap_scanline + target.left(), buffer_scanline, sizeof(u32) * target.width()); } }