From 88ce786d0510eb4d0a4b26118039992df0d3345c Mon Sep 17 00:00:00 2001 From: routersys Date: Thu, 2 Jul 2026 13:18:39 +0900 Subject: [PATCH] =?UTF-8?q?GpuKernel=E3=81=A7=E5=8A=B9=E6=9E=9C=E3=81=AEOu?= =?UTF-8?q?tput=E3=82=92=E7=94=9F=E6=88=90=E6=99=82=E3=81=AB=E4=B8=80?= =?UTF-8?q?=E5=BA=A6=E3=81=A0=E3=81=91=E5=8F=96=E5=BE=97=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript/Engine/Kernel/GpuKernel.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/LuaScript/Engine/Kernel/GpuKernel.cs b/LuaScript/Engine/Kernel/GpuKernel.cs index abf1df3..c804fac 100644 --- a/LuaScript/Engine/Kernel/GpuKernel.cs +++ b/LuaScript/Engine/Kernel/GpuKernel.cs @@ -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(); + } } }