From 623d77e5317818d9a96c6485838c9b397db8aa79 Mon Sep 17 00:00:00 2001 From: gramps Date: Mon, 5 Oct 2026 17:40:05 -0700 Subject: [PATCH] Compositor: parallelize BlitContentRaw row loop (4 threads, BelowNormal intent) to speed scaled blits (Unit 5) --- Services/Compositor/SceneCompositor.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Services/Compositor/SceneCompositor.cs b/Services/Compositor/SceneCompositor.cs index 58249f8..bf0a7ba 100644 --- a/Services/Compositor/SceneCompositor.cs +++ b/Services/Compositor/SceneCompositor.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading.Tasks; using ytLive.Helpers; using ytLive.Models; @@ -575,10 +576,11 @@ public sealed class SceneCompositor sxLut[xi] = sxCanvas; } - for (var y = y0; y <= y1; y++) + var parallelOpts = new ParallelOptions { MaxDegreeOfParallelism = 4 }; + Parallel.For(y0, y1 + 1, parallelOpts, y => { var py = y - ey; - if (py < oy || py > oy + drawnH) continue; + if (py < oy || py > oy + drawnH) return; // syNorm: normalized [0,1] position within the drawn content (vertically) var syNorm = (py - oy) / drawnH; @@ -656,7 +658,7 @@ public sealed class SceneCompositor } } } - } + }); } /// Two-stage bilinear in 8.8 fixed point; result within ±1 of the