カーネルIRを式ツリーへコンパイルするCPUレーンを追加

Co-Authored-By: Claude Opus 4.8 <[email protected]>
このコミットが含まれているのは:
routersysとClaude Opus 4.8 committed 2026-06-29 18:56:39 +09:00
1 親 c657892b7b
コミット 270cf025ff
3ファイル変更
+246

検索条件に一致するファイルはありません

+28
ファイルの表示
@@ -0,0 +1,28 @@
using System.Threading.Tasks;
namespace LuaScript.Engine.Kernel
{
internal sealed class CpuKernel(CpuKernel.RowDelegate row)
{
public delegate void RowDelegate(byte[] buffer, int width, int rowBase, double y, double[] uniforms);
private const int ParallelThreshold = 64;
private readonly RowDelegate _row = row;
public void Execute(byte[] buffer, int width, int height, double[] uniforms)
{
var row = _row;
int stride = width * 4;
if (height < ParallelThreshold)
{
for (int y = 0; y < height; y++)
row(buffer, width, y * stride, y, uniforms);
return;
}
Parallel.For(0, height, y => row(buffer, width, y * stride, y, uniforms));
}
}
}