feat: add ISlideComputer interface and GPU implementation
ISlideComputer abstracts batched directional-distance computation so GPU implementations can process all slide offsets in a single kernel launch. GpuSlideComputer uses ILGPU with prepared edge data (precomputed inverse deltas and min/max bounds) and caches stationary/moving buffers across calls. GpuEvaluatorFactory exposes a singleton factory method. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,8 @@ namespace OpenNest.Gpu
|
||||
private static bool _probed;
|
||||
private static bool _gpuAvailable;
|
||||
private static string _deviceName;
|
||||
private static GpuSlideComputer _slideComputer;
|
||||
private static readonly object _slideLock = new object();
|
||||
|
||||
public static bool GpuAvailable
|
||||
{
|
||||
@@ -46,6 +48,29 @@ namespace OpenNest.Gpu
|
||||
}
|
||||
}
|
||||
|
||||
public static ISlideComputer CreateSlideComputer()
|
||||
{
|
||||
if (!GpuAvailable)
|
||||
return null;
|
||||
|
||||
lock (_slideLock)
|
||||
{
|
||||
if (_slideComputer != null)
|
||||
return _slideComputer;
|
||||
|
||||
try
|
||||
{
|
||||
_slideComputer = new GpuSlideComputer();
|
||||
return _slideComputer;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"[GpuEvaluatorFactory] GPU slide computer failed: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Probe()
|
||||
{
|
||||
_probed = true;
|
||||
|
||||
Reference in New Issue
Block a user