| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationOperationLimits.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | namespace Trailblazer.Pathing; |
| | | 9 | | |
| | | 10 | | /// <summary>Defines finite admission and candidate-overlay limits for map operations.</summary> |
| | | 11 | | public readonly struct NavigationOperationLimits |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// The hard ceiling that bounds conservative same-frame receipt coalescing work. |
| | | 15 | | /// Larger admitted queues carry over through multiple deterministic batches. |
| | | 16 | | /// </summary> |
| | | 17 | | public const int MaximumBatchItems = 256; |
| | | 18 | | |
| | | 19 | | /// <summary>Initializes explicit finite operation and overlay limits.</summary> |
| | | 20 | | public NavigationOperationLimits( |
| | | 21 | | int maxPendingOperations, |
| | | 22 | | long maxPendingDescriptorBytes, |
| | | 23 | | long maxPreparedMapBytes, |
| | | 24 | | int maxBatchItems, |
| | | 25 | | long maxBatchDescriptorBytes, |
| | | 26 | | long maxBatchSortScratchBytes, |
| | | 27 | | int maxCorridorCells, |
| | | 28 | | int maxMaps, |
| | | 29 | | int maxRetainedMapIdentities, |
| | | 30 | | int maxOverlayCellsPerMap, |
| | | 31 | | int maxOverlayConnectionsPerMap, |
| | | 32 | | int maxOverlayTransitionsPerMap, |
| | | 33 | | int maxOverlayCells, |
| | | 34 | | int maxOverlayConnections, |
| | | 35 | | int maxOverlayTransitions, |
| | | 36 | | int maxTransitionRulesPerMap, |
| | | 37 | | int maxTransitionRules) |
| | | 38 | | { |
| | 185 | 39 | | SwiftThrowHelper.ThrowIfArgument(maxPendingOperations <= 0, nameof(maxPendingOperations)); |
| | 185 | 40 | | SwiftThrowHelper.ThrowIfArgument(maxPendingDescriptorBytes <= 0, nameof(maxPendingDescriptorBytes)); |
| | 185 | 41 | | SwiftThrowHelper.ThrowIfArgument(maxPreparedMapBytes <= 0, nameof(maxPreparedMapBytes)); |
| | 185 | 42 | | SwiftThrowHelper.ThrowIfArgument( |
| | 185 | 43 | | maxBatchItems <= 0 || maxBatchItems > MaximumBatchItems, |
| | 185 | 44 | | nameof(maxBatchItems)); |
| | 183 | 45 | | SwiftThrowHelper.ThrowIfArgument(maxBatchDescriptorBytes <= 0, nameof(maxBatchDescriptorBytes)); |
| | 183 | 46 | | SwiftThrowHelper.ThrowIfArgument(maxBatchSortScratchBytes <= 0, nameof(maxBatchSortScratchBytes)); |
| | 183 | 47 | | SwiftThrowHelper.ThrowIfArgument(maxCorridorCells < 2, nameof(maxCorridorCells)); |
| | 183 | 48 | | SwiftThrowHelper.ThrowIfArgument(maxCorridorCells > int.MaxValue / 2, nameof(maxCorridorCells)); |
| | 183 | 49 | | SwiftThrowHelper.ThrowIfArgument(maxMaps <= 0, nameof(maxMaps)); |
| | 183 | 50 | | SwiftThrowHelper.ThrowIfArgument(maxRetainedMapIdentities < maxMaps, nameof(maxRetainedMapIdentities)); |
| | 183 | 51 | | SwiftThrowHelper.ThrowIfArgument(maxOverlayCellsPerMap < 0, nameof(maxOverlayCellsPerMap)); |
| | 183 | 52 | | SwiftThrowHelper.ThrowIfArgument(maxOverlayConnectionsPerMap < 0, nameof(maxOverlayConnectionsPerMap)); |
| | 183 | 53 | | SwiftThrowHelper.ThrowIfArgument(maxOverlayTransitionsPerMap < 0, nameof(maxOverlayTransitionsPerMap)); |
| | 183 | 54 | | SwiftThrowHelper.ThrowIfArgument(maxOverlayCells < maxOverlayCellsPerMap, nameof(maxOverlayCells)); |
| | 183 | 55 | | SwiftThrowHelper.ThrowIfArgument(maxOverlayConnections < maxOverlayConnectionsPerMap, nameof(maxOverlayConnectio |
| | 183 | 56 | | SwiftThrowHelper.ThrowIfArgument(maxOverlayTransitions < maxOverlayTransitionsPerMap, nameof(maxOverlayTransitio |
| | 183 | 57 | | SwiftThrowHelper.ThrowIfArgument(maxTransitionRulesPerMap <= 0, nameof(maxTransitionRulesPerMap)); |
| | 182 | 58 | | SwiftThrowHelper.ThrowIfArgument(maxTransitionRules < maxTransitionRulesPerMap, nameof(maxTransitionRules)); |
| | | 59 | | |
| | 181 | 60 | | MaxPendingOperations = maxPendingOperations; |
| | 181 | 61 | | MaxPendingDescriptorBytes = maxPendingDescriptorBytes; |
| | 181 | 62 | | MaxPreparedMapBytes = maxPreparedMapBytes; |
| | 181 | 63 | | MaxBatchItems = maxBatchItems; |
| | 181 | 64 | | MaxBatchDescriptorBytes = maxBatchDescriptorBytes; |
| | 181 | 65 | | MaxBatchSortScratchBytes = maxBatchSortScratchBytes; |
| | 181 | 66 | | MaxCorridorCells = maxCorridorCells; |
| | 181 | 67 | | MaxMaps = maxMaps; |
| | 181 | 68 | | MaxRetainedMapIdentities = maxRetainedMapIdentities; |
| | 181 | 69 | | MaxOverlayCellsPerMap = maxOverlayCellsPerMap; |
| | 181 | 70 | | MaxOverlayConnectionsPerMap = maxOverlayConnectionsPerMap; |
| | 181 | 71 | | MaxOverlayTransitionsPerMap = maxOverlayTransitionsPerMap; |
| | 181 | 72 | | MaxOverlayCells = maxOverlayCells; |
| | 181 | 73 | | MaxOverlayConnections = maxOverlayConnections; |
| | 181 | 74 | | MaxOverlayTransitions = maxOverlayTransitions; |
| | 181 | 75 | | MaxTransitionRulesPerMap = maxTransitionRulesPerMap; |
| | 181 | 76 | | MaxTransitionRules = maxTransitionRules; |
| | 181 | 77 | | } |
| | | 78 | | |
| | | 79 | | /// <summary>Gets the maximum number of admitted operations.</summary> |
| | | 80 | | public int MaxPendingOperations { get; } |
| | | 81 | | |
| | | 82 | | /// <summary>Gets the maximum submitted descriptor bytes retained by the queue.</summary> |
| | | 83 | | public long MaxPendingDescriptorBytes { get; } |
| | | 84 | | |
| | | 85 | | /// <summary>Gets the maximum retained bytes across prepared maps.</summary> |
| | | 86 | | public long MaxPreparedMapBytes { get; } |
| | | 87 | | |
| | | 88 | | /// <summary>Gets the maximum operation count admitted into one deterministic fold batch.</summary> |
| | | 89 | | public int MaxBatchItems { get; } |
| | | 90 | | |
| | | 91 | | /// <summary>Gets the maximum descriptor bytes admitted into one fold batch.</summary> |
| | | 92 | | public long MaxBatchDescriptorBytes { get; } |
| | | 93 | | |
| | | 94 | | /// <summary>Gets the maximum deterministic sorting-scratch bytes admitted for one fold batch.</summary> |
| | | 95 | | public long MaxBatchSortScratchBytes { get; } |
| | | 96 | | |
| | | 97 | | /// <summary>Gets the maximum number of prisms in one connection corridor validation chain.</summary> |
| | | 98 | | public int MaxCorridorCells { get; } |
| | | 99 | | |
| | | 100 | | /// <summary>Gets the maximum map count in a candidate registry.</summary> |
| | | 101 | | public int MaxMaps { get; } |
| | | 102 | | |
| | | 103 | | /// <summary> |
| | | 104 | | /// Gets the maximum number of map IDs whose bake-version high-water marks remain retained. |
| | | 105 | | /// Removed IDs remain counted so stale checkpoint identities cannot be reused. |
| | | 106 | | /// </summary> |
| | | 107 | | public int MaxRetainedMapIdentities { get; } |
| | | 108 | | |
| | | 109 | | /// <summary>Gets the maximum cell overlay entries retained for one map.</summary> |
| | | 110 | | public int MaxOverlayCellsPerMap { get; } |
| | | 111 | | |
| | | 112 | | /// <summary>Gets the maximum connection overlay entries retained for one map.</summary> |
| | | 113 | | public int MaxOverlayConnectionsPerMap { get; } |
| | | 114 | | |
| | | 115 | | /// <summary>Gets the maximum transition overlay entries retained for one map.</summary> |
| | | 116 | | public int MaxOverlayTransitionsPerMap { get; } |
| | | 117 | | |
| | | 118 | | /// <summary>Gets the maximum cell overlay entries retained across the context candidate.</summary> |
| | | 119 | | public int MaxOverlayCells { get; } |
| | | 120 | | |
| | | 121 | | /// <summary>Gets the maximum connection overlay entries retained across the context candidate.</summary> |
| | | 122 | | public int MaxOverlayConnections { get; } |
| | | 123 | | |
| | | 124 | | /// <summary>Gets the maximum transition overlay entries retained across the context candidate.</summary> |
| | | 125 | | public int MaxOverlayTransitions { get; } |
| | | 126 | | |
| | | 127 | | /// <summary>Gets the maximum procedural transition rules retained for one map.</summary> |
| | | 128 | | public int MaxTransitionRulesPerMap { get; } |
| | | 129 | | |
| | | 130 | | /// <summary>Gets the maximum procedural transition rules retained across all maps.</summary> |
| | | 131 | | public int MaxTransitionRules { get; } |
| | | 132 | | } |