GpuKernelで効果のOutputを生成時に一度だけ取得してキャッシュ

このコミットが含まれているのは:
routersys committed 2026-07-02 13:18:39 +09:00
1 親 d69ae5f06e
コミット 88ce786d05
1ファイル変更
+8 -2
+8 -2
ファイルの表示
@@ -9,6 +9,7 @@ namespace LuaScript.Engine.Kernel
private readonly GpuKernelEffect _effect;
private readonly float[] _packed = new float[HlslKernelEmitter.ConstantFloatCount];
private readonly byte[] _bytes = new byte[HlslKernelEmitter.ConstantFloatCount * sizeof(float)];
private ID2D1Image? _output;
public GpuKernel(IGraphicsDevicesAndContext devices, KernelProgram program)
=> _effect = new GpuKernelEffect(devices, HlslKernelEmitter.Emit(program));
@@ -21,9 +22,14 @@ namespace LuaScript.Engine.Kernel
Buffer.BlockCopy(_packed, 0, _bytes, 0, _bytes.Length);
_effect.SetConstants(_bytes);
_effect.SetInput(0, input, true);
return _effect.Output;
return _output ??= _effect.Output;
}
public void Dispose() => _effect.Dispose();
public void Dispose()
{
_output?.Dispose();
_output = null;
_effect.Dispose();
}
}
}