GpuKernelで効果のOutputを生成時に一度だけ取得してキャッシュ
このコミットが含まれているのは:
1ファイル変更
+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();
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする