forked from google/neuroglancer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.ts
118 lines (95 loc) · 3.13 KB
/
base.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* @license
* Copyright 2016 Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export enum ChunkState {
// Chunk is stored in GPU memory in addition to system memory.
GPU_MEMORY = 0,
// Chunk is stored only in system memory but not in GPU memory.
SYSTEM_MEMORY = 1,
// Chunk is stored in system memory on worker.
SYSTEM_MEMORY_WORKER = 2,
// Chunk is downloading.
DOWNLOADING = 3,
// Chunk is not yet downloading.
QUEUED = 4,
// Chunk has just been added.
NEW = 5,
// Download failed.
FAILED = 6,
EXPIRED = 7,
// If new states are added, keep numChangeStates in sync.
}
export const numChunkStates = 8;
export enum ChunkPriorityTier {
FIRST_TIER = 0,
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
FIRST_ORDERED_TIER = 0,
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
VISIBLE = 0,
PREFETCH = 1,
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
LAST_ORDERED_TIER = 1,
RECENT = 2,
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
LAST_TIER = 2,
}
export const numChunkPriorityTiers = 3;
export enum ChunkDownloadStatistics {
totalTime = 0,
totalChunks = 1,
}
export enum ChunkMemoryStatistics {
numChunks = 0,
systemMemoryBytes = 1,
gpuMemoryBytes = 2,
}
export const numChunkMemoryStatistics = 3;
export const numChunkDownloadStatistics = 2;
export const numChunkStatistics =
numChunkStates * numChunkPriorityTiers * numChunkMemoryStatistics +
numChunkDownloadStatistics;
export function getChunkStateStatisticIndex(
state: ChunkState,
priorityTier: ChunkPriorityTier,
) {
return state * numChunkPriorityTiers + priorityTier;
}
export function getChunkDownloadStatisticIndex(
statistic: ChunkDownloadStatistics,
) {
return (
numChunkStates * numChunkPriorityTiers * numChunkMemoryStatistics +
statistic
);
}
export const PREFETCH_PRIORITY_MULTIPLIER = 1e13;
export const CHUNK_QUEUE_MANAGER_RPC_ID = "ChunkQueueManager";
export const CHUNK_MANAGER_RPC_ID = "ChunkManager";
export const CHUNK_SOURCE_INVALIDATE_RPC_ID = "ChunkSource.invalidate";
export const REQUEST_CHUNK_STATISTICS_RPC_ID =
"ChunkQueueManager.requestChunkStatistics";
// Used for sending per-layer visible/prefetch chunk statistics from backend to frontend.
export const CHUNK_LAYER_STATISTICS_RPC_ID =
"ChunkManager.chunkLayerStatistics";
export interface ChunkSourceParametersConstructor<T> {
new (): T;
RPC_ID: string;
}
export class LayerChunkProgressInfo {
numVisibleChunksNeeded = 0;
numVisibleChunksAvailable = 0;
numPrefetchChunksNeeded = 0;
numPrefetchChunksAvailable = 0;
}