@plasius/gpu-world-generator 0.0.8 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1784,6 +1784,591 @@ function createMeshBuilder(sizeOrOptions = 1) {
1784
1784
  }
1785
1785
  };
1786
1786
  }
1787
+
1788
+ // src/worker.ts
1789
+ var worldGeneratorDebugOwner = "world-generator";
1790
+ var worldGeneratorWorkerQueueClass = "voxel";
1791
+ var defaultWorldGeneratorWorkerProfile = "streaming";
1792
+ function buildBudgetLevels(jobType, queueClass, levels) {
1793
+ return Object.freeze(
1794
+ levels.map(
1795
+ (level) => Object.freeze({
1796
+ id: level.id,
1797
+ estimatedCostMs: level.estimatedCostMs,
1798
+ config: Object.freeze({
1799
+ maxDispatchesPerFrame: level.config.maxDispatchesPerFrame,
1800
+ maxJobsPerDispatch: level.config.maxJobsPerDispatch,
1801
+ cadenceDivisor: level.config.cadenceDivisor,
1802
+ workgroupScale: level.config.workgroupScale,
1803
+ maxQueueDepth: level.config.maxQueueDepth,
1804
+ metadata: Object.freeze({
1805
+ owner: worldGeneratorDebugOwner,
1806
+ queueClass,
1807
+ jobType,
1808
+ quality: level.id
1809
+ })
1810
+ })
1811
+ })
1812
+ )
1813
+ );
1814
+ }
1815
+ var worldGeneratorWorkerProfileSpecs = {
1816
+ streaming: {
1817
+ description: "Runtime chunk generation DAG for fractal prepass, terrain synthesis, voxel materialization, mesh build, and tile bake.",
1818
+ suggestedAllocationIds: [
1819
+ "world.chunk.field.scratch",
1820
+ "world.chunk.height.buffer",
1821
+ "world.chunk.voxel.buffer",
1822
+ "world.chunk.mesh.buffer"
1823
+ ],
1824
+ jobs: {
1825
+ fractalPrepass: {
1826
+ priority: 4,
1827
+ dependencies: [],
1828
+ domain: "custom",
1829
+ authority: "authoritative",
1830
+ importance: "high",
1831
+ levels: [
1832
+ {
1833
+ id: "fixed",
1834
+ estimatedCostMs: 0.6,
1835
+ config: {
1836
+ maxDispatchesPerFrame: 1,
1837
+ maxJobsPerDispatch: 1,
1838
+ cadenceDivisor: 1,
1839
+ workgroupScale: 1,
1840
+ maxQueueDepth: 32
1841
+ }
1842
+ }
1843
+ ],
1844
+ suggestedAllocationIds: ["world.chunk.field.scratch"]
1845
+ },
1846
+ fieldSynthesis: {
1847
+ priority: 4,
1848
+ dependencies: [],
1849
+ domain: "custom",
1850
+ authority: "authoritative",
1851
+ importance: "critical",
1852
+ levels: [
1853
+ {
1854
+ id: "fixed",
1855
+ estimatedCostMs: 0.9,
1856
+ config: {
1857
+ maxDispatchesPerFrame: 1,
1858
+ maxJobsPerDispatch: 2,
1859
+ cadenceDivisor: 1,
1860
+ workgroupScale: 1,
1861
+ maxQueueDepth: 48
1862
+ }
1863
+ }
1864
+ ],
1865
+ suggestedAllocationIds: ["world.chunk.field.scratch"]
1866
+ },
1867
+ terrainSynthesis: {
1868
+ priority: 5,
1869
+ dependencies: ["fractalPrepass", "fieldSynthesis"],
1870
+ domain: "custom",
1871
+ authority: "authoritative",
1872
+ importance: "critical",
1873
+ levels: [
1874
+ {
1875
+ id: "fixed",
1876
+ estimatedCostMs: 1.4,
1877
+ config: {
1878
+ maxDispatchesPerFrame: 1,
1879
+ maxJobsPerDispatch: 1,
1880
+ cadenceDivisor: 1,
1881
+ workgroupScale: 1,
1882
+ maxQueueDepth: 32
1883
+ }
1884
+ }
1885
+ ],
1886
+ suggestedAllocationIds: ["world.chunk.height.buffer"]
1887
+ },
1888
+ voxelMaterialize: {
1889
+ priority: 3,
1890
+ dependencies: ["terrainSynthesis"],
1891
+ domain: "custom",
1892
+ authority: "non-authoritative-simulation",
1893
+ importance: "high",
1894
+ levels: [
1895
+ {
1896
+ id: "low",
1897
+ estimatedCostMs: 0.8,
1898
+ config: {
1899
+ maxDispatchesPerFrame: 1,
1900
+ maxJobsPerDispatch: 1,
1901
+ cadenceDivisor: 2,
1902
+ workgroupScale: 0.6,
1903
+ maxQueueDepth: 24
1904
+ }
1905
+ },
1906
+ {
1907
+ id: "medium",
1908
+ estimatedCostMs: 1.2,
1909
+ config: {
1910
+ maxDispatchesPerFrame: 1,
1911
+ maxJobsPerDispatch: 2,
1912
+ cadenceDivisor: 1,
1913
+ workgroupScale: 0.8,
1914
+ maxQueueDepth: 32
1915
+ }
1916
+ },
1917
+ {
1918
+ id: "high",
1919
+ estimatedCostMs: 1.8,
1920
+ config: {
1921
+ maxDispatchesPerFrame: 2,
1922
+ maxJobsPerDispatch: 2,
1923
+ cadenceDivisor: 1,
1924
+ workgroupScale: 1,
1925
+ maxQueueDepth: 40
1926
+ }
1927
+ }
1928
+ ],
1929
+ suggestedAllocationIds: ["world.chunk.voxel.buffer"]
1930
+ },
1931
+ meshBuild: {
1932
+ priority: 2,
1933
+ dependencies: ["terrainSynthesis", "voxelMaterialize"],
1934
+ domain: "geometry",
1935
+ authority: "visual",
1936
+ importance: "high",
1937
+ levels: [
1938
+ {
1939
+ id: "low",
1940
+ estimatedCostMs: 0.7,
1941
+ config: {
1942
+ maxDispatchesPerFrame: 1,
1943
+ maxJobsPerDispatch: 1,
1944
+ cadenceDivisor: 2,
1945
+ workgroupScale: 0.6,
1946
+ maxQueueDepth: 16
1947
+ }
1948
+ },
1949
+ {
1950
+ id: "medium",
1951
+ estimatedCostMs: 1.1,
1952
+ config: {
1953
+ maxDispatchesPerFrame: 1,
1954
+ maxJobsPerDispatch: 1,
1955
+ cadenceDivisor: 1,
1956
+ workgroupScale: 0.8,
1957
+ maxQueueDepth: 24
1958
+ }
1959
+ },
1960
+ {
1961
+ id: "high",
1962
+ estimatedCostMs: 1.6,
1963
+ config: {
1964
+ maxDispatchesPerFrame: 2,
1965
+ maxJobsPerDispatch: 2,
1966
+ cadenceDivisor: 1,
1967
+ workgroupScale: 1,
1968
+ maxQueueDepth: 32
1969
+ }
1970
+ }
1971
+ ],
1972
+ suggestedAllocationIds: ["world.chunk.mesh.buffer"]
1973
+ },
1974
+ tileBake: {
1975
+ priority: 2,
1976
+ dependencies: ["terrainSynthesis"],
1977
+ domain: "textures",
1978
+ authority: "non-authoritative-simulation",
1979
+ importance: "medium",
1980
+ levels: [
1981
+ {
1982
+ id: "low",
1983
+ estimatedCostMs: 0.6,
1984
+ config: {
1985
+ maxDispatchesPerFrame: 1,
1986
+ maxJobsPerDispatch: 1,
1987
+ cadenceDivisor: 3,
1988
+ workgroupScale: 0.5,
1989
+ maxQueueDepth: 16
1990
+ }
1991
+ },
1992
+ {
1993
+ id: "medium",
1994
+ estimatedCostMs: 0.9,
1995
+ config: {
1996
+ maxDispatchesPerFrame: 1,
1997
+ maxJobsPerDispatch: 1,
1998
+ cadenceDivisor: 2,
1999
+ workgroupScale: 0.75,
2000
+ maxQueueDepth: 24
2001
+ }
2002
+ },
2003
+ {
2004
+ id: "high",
2005
+ estimatedCostMs: 1.3,
2006
+ config: {
2007
+ maxDispatchesPerFrame: 2,
2008
+ maxJobsPerDispatch: 2,
2009
+ cadenceDivisor: 1,
2010
+ workgroupScale: 1,
2011
+ maxQueueDepth: 32
2012
+ }
2013
+ }
2014
+ ],
2015
+ suggestedAllocationIds: ["world.chunk.height.buffer"]
2016
+ }
2017
+ }
2018
+ },
2019
+ bake: {
2020
+ description: "Offline tile bake DAG for terrain generation, voxel materialization, mesh build, and asset serialization.",
2021
+ suggestedAllocationIds: [
2022
+ "world.bake.field.scratch",
2023
+ "world.bake.height.buffer",
2024
+ "world.bake.mesh.buffer",
2025
+ "world.bake.asset.binary"
2026
+ ],
2027
+ jobs: {
2028
+ fractalPrepass: {
2029
+ priority: 4,
2030
+ dependencies: [],
2031
+ domain: "custom",
2032
+ authority: "authoritative",
2033
+ importance: "high",
2034
+ levels: [
2035
+ {
2036
+ id: "fixed",
2037
+ estimatedCostMs: 0.7,
2038
+ config: {
2039
+ maxDispatchesPerFrame: 1,
2040
+ maxJobsPerDispatch: 1,
2041
+ cadenceDivisor: 1,
2042
+ workgroupScale: 1,
2043
+ maxQueueDepth: 32
2044
+ }
2045
+ }
2046
+ ],
2047
+ suggestedAllocationIds: ["world.bake.field.scratch"]
2048
+ },
2049
+ fieldSynthesis: {
2050
+ priority: 4,
2051
+ dependencies: [],
2052
+ domain: "custom",
2053
+ authority: "authoritative",
2054
+ importance: "critical",
2055
+ levels: [
2056
+ {
2057
+ id: "fixed",
2058
+ estimatedCostMs: 1,
2059
+ config: {
2060
+ maxDispatchesPerFrame: 1,
2061
+ maxJobsPerDispatch: 2,
2062
+ cadenceDivisor: 1,
2063
+ workgroupScale: 1,
2064
+ maxQueueDepth: 48
2065
+ }
2066
+ }
2067
+ ],
2068
+ suggestedAllocationIds: ["world.bake.field.scratch"]
2069
+ },
2070
+ terrainSynthesis: {
2071
+ priority: 5,
2072
+ dependencies: ["fractalPrepass", "fieldSynthesis"],
2073
+ domain: "custom",
2074
+ authority: "authoritative",
2075
+ importance: "critical",
2076
+ levels: [
2077
+ {
2078
+ id: "fixed",
2079
+ estimatedCostMs: 1.6,
2080
+ config: {
2081
+ maxDispatchesPerFrame: 1,
2082
+ maxJobsPerDispatch: 1,
2083
+ cadenceDivisor: 1,
2084
+ workgroupScale: 1,
2085
+ maxQueueDepth: 32
2086
+ }
2087
+ }
2088
+ ],
2089
+ suggestedAllocationIds: ["world.bake.height.buffer"]
2090
+ },
2091
+ voxelMaterialize: {
2092
+ priority: 3,
2093
+ dependencies: ["terrainSynthesis"],
2094
+ domain: "custom",
2095
+ authority: "non-authoritative-simulation",
2096
+ importance: "high",
2097
+ levels: [
2098
+ {
2099
+ id: "low",
2100
+ estimatedCostMs: 0.9,
2101
+ config: {
2102
+ maxDispatchesPerFrame: 1,
2103
+ maxJobsPerDispatch: 1,
2104
+ cadenceDivisor: 2,
2105
+ workgroupScale: 0.6,
2106
+ maxQueueDepth: 24
2107
+ }
2108
+ },
2109
+ {
2110
+ id: "medium",
2111
+ estimatedCostMs: 1.4,
2112
+ config: {
2113
+ maxDispatchesPerFrame: 1,
2114
+ maxJobsPerDispatch: 2,
2115
+ cadenceDivisor: 1,
2116
+ workgroupScale: 0.8,
2117
+ maxQueueDepth: 32
2118
+ }
2119
+ },
2120
+ {
2121
+ id: "high",
2122
+ estimatedCostMs: 2,
2123
+ config: {
2124
+ maxDispatchesPerFrame: 2,
2125
+ maxJobsPerDispatch: 2,
2126
+ cadenceDivisor: 1,
2127
+ workgroupScale: 1,
2128
+ maxQueueDepth: 48
2129
+ }
2130
+ }
2131
+ ],
2132
+ suggestedAllocationIds: ["world.bake.height.buffer"]
2133
+ },
2134
+ meshBuild: {
2135
+ priority: 2,
2136
+ dependencies: ["terrainSynthesis", "voxelMaterialize"],
2137
+ domain: "geometry",
2138
+ authority: "visual",
2139
+ importance: "high",
2140
+ levels: [
2141
+ {
2142
+ id: "low",
2143
+ estimatedCostMs: 0.9,
2144
+ config: {
2145
+ maxDispatchesPerFrame: 1,
2146
+ maxJobsPerDispatch: 1,
2147
+ cadenceDivisor: 2,
2148
+ workgroupScale: 0.6,
2149
+ maxQueueDepth: 16
2150
+ }
2151
+ },
2152
+ {
2153
+ id: "medium",
2154
+ estimatedCostMs: 1.3,
2155
+ config: {
2156
+ maxDispatchesPerFrame: 1,
2157
+ maxJobsPerDispatch: 1,
2158
+ cadenceDivisor: 1,
2159
+ workgroupScale: 0.8,
2160
+ maxQueueDepth: 24
2161
+ }
2162
+ },
2163
+ {
2164
+ id: "high",
2165
+ estimatedCostMs: 1.9,
2166
+ config: {
2167
+ maxDispatchesPerFrame: 2,
2168
+ maxJobsPerDispatch: 2,
2169
+ cadenceDivisor: 1,
2170
+ workgroupScale: 1,
2171
+ maxQueueDepth: 32
2172
+ }
2173
+ }
2174
+ ],
2175
+ suggestedAllocationIds: ["world.bake.mesh.buffer"]
2176
+ },
2177
+ tileBake: {
2178
+ priority: 2,
2179
+ dependencies: ["terrainSynthesis"],
2180
+ domain: "textures",
2181
+ authority: "non-authoritative-simulation",
2182
+ importance: "medium",
2183
+ levels: [
2184
+ {
2185
+ id: "low",
2186
+ estimatedCostMs: 0.8,
2187
+ config: {
2188
+ maxDispatchesPerFrame: 1,
2189
+ maxJobsPerDispatch: 1,
2190
+ cadenceDivisor: 3,
2191
+ workgroupScale: 0.5,
2192
+ maxQueueDepth: 16
2193
+ }
2194
+ },
2195
+ {
2196
+ id: "medium",
2197
+ estimatedCostMs: 1.1,
2198
+ config: {
2199
+ maxDispatchesPerFrame: 1,
2200
+ maxJobsPerDispatch: 1,
2201
+ cadenceDivisor: 2,
2202
+ workgroupScale: 0.75,
2203
+ maxQueueDepth: 24
2204
+ }
2205
+ },
2206
+ {
2207
+ id: "high",
2208
+ estimatedCostMs: 1.5,
2209
+ config: {
2210
+ maxDispatchesPerFrame: 2,
2211
+ maxJobsPerDispatch: 2,
2212
+ cadenceDivisor: 1,
2213
+ workgroupScale: 1,
2214
+ maxQueueDepth: 32
2215
+ }
2216
+ }
2217
+ ],
2218
+ suggestedAllocationIds: ["world.bake.height.buffer"]
2219
+ },
2220
+ assetSerialize: {
2221
+ priority: 1,
2222
+ dependencies: ["meshBuild", "tileBake"],
2223
+ domain: "custom",
2224
+ authority: "non-authoritative-simulation",
2225
+ importance: "medium",
2226
+ levels: [
2227
+ {
2228
+ id: "low",
2229
+ estimatedCostMs: 0.4,
2230
+ config: {
2231
+ maxDispatchesPerFrame: 1,
2232
+ maxJobsPerDispatch: 1,
2233
+ cadenceDivisor: 4,
2234
+ workgroupScale: 0.5,
2235
+ maxQueueDepth: 8
2236
+ }
2237
+ },
2238
+ {
2239
+ id: "medium",
2240
+ estimatedCostMs: 0.7,
2241
+ config: {
2242
+ maxDispatchesPerFrame: 1,
2243
+ maxJobsPerDispatch: 1,
2244
+ cadenceDivisor: 2,
2245
+ workgroupScale: 0.75,
2246
+ maxQueueDepth: 12
2247
+ }
2248
+ },
2249
+ {
2250
+ id: "high",
2251
+ estimatedCostMs: 1,
2252
+ config: {
2253
+ maxDispatchesPerFrame: 2,
2254
+ maxJobsPerDispatch: 2,
2255
+ cadenceDivisor: 1,
2256
+ workgroupScale: 1,
2257
+ maxQueueDepth: 16
2258
+ }
2259
+ }
2260
+ ],
2261
+ suggestedAllocationIds: ["world.bake.asset.binary"]
2262
+ }
2263
+ }
2264
+ }
2265
+ };
2266
+ function buildWorldGeneratorWorkerProfile(name, spec) {
2267
+ return Object.freeze({
2268
+ name,
2269
+ description: spec.description,
2270
+ jobs: Object.freeze(Object.keys(spec.jobs))
2271
+ });
2272
+ }
2273
+ function buildWorldGeneratorWorkerManifestJob(profileName, jobName, spec) {
2274
+ const label = `world-generator.${profileName}.${jobName}`;
2275
+ return Object.freeze({
2276
+ key: jobName,
2277
+ label,
2278
+ worker: Object.freeze({
2279
+ jobType: label,
2280
+ queueClass: worldGeneratorWorkerQueueClass,
2281
+ priority: spec.priority,
2282
+ dependencies: Object.freeze(
2283
+ spec.dependencies.map(
2284
+ (dependency) => `world-generator.${profileName}.${dependency}`
2285
+ )
2286
+ ),
2287
+ schedulerMode: "dag"
2288
+ }),
2289
+ performance: Object.freeze({
2290
+ id: label,
2291
+ jobType: label,
2292
+ queueClass: worldGeneratorWorkerQueueClass,
2293
+ domain: spec.domain,
2294
+ authority: spec.authority,
2295
+ importance: spec.importance,
2296
+ levels: buildBudgetLevels(
2297
+ label,
2298
+ worldGeneratorWorkerQueueClass,
2299
+ spec.levels
2300
+ )
2301
+ }),
2302
+ debug: Object.freeze({
2303
+ owner: worldGeneratorDebugOwner,
2304
+ queueClass: worldGeneratorWorkerQueueClass,
2305
+ jobType: label,
2306
+ tags: Object.freeze(["world-generator", profileName, jobName, spec.domain]),
2307
+ suggestedAllocationIds: Object.freeze([...spec.suggestedAllocationIds])
2308
+ })
2309
+ });
2310
+ }
2311
+ function buildWorldGeneratorWorkerManifest(name, spec) {
2312
+ return Object.freeze({
2313
+ schemaVersion: 1,
2314
+ owner: worldGeneratorDebugOwner,
2315
+ profile: name,
2316
+ description: spec.description,
2317
+ queueClass: worldGeneratorWorkerQueueClass,
2318
+ schedulerMode: "dag",
2319
+ suggestedAllocationIds: Object.freeze([...spec.suggestedAllocationIds]),
2320
+ jobs: Object.freeze(
2321
+ Object.entries(spec.jobs).map(
2322
+ ([jobName, jobSpec]) => buildWorldGeneratorWorkerManifestJob(name, jobName, jobSpec)
2323
+ )
2324
+ )
2325
+ });
2326
+ }
2327
+ var worldGeneratorWorkerProfiles = Object.freeze(
2328
+ Object.fromEntries(
2329
+ Object.entries(worldGeneratorWorkerProfileSpecs).map(([name, spec]) => [
2330
+ name,
2331
+ buildWorldGeneratorWorkerProfile(
2332
+ name,
2333
+ spec
2334
+ )
2335
+ ])
2336
+ )
2337
+ );
2338
+ var worldGeneratorWorkerProfileNames = Object.freeze(
2339
+ Object.keys(worldGeneratorWorkerProfiles)
2340
+ );
2341
+ var worldGeneratorWorkerManifests = Object.freeze(
2342
+ Object.fromEntries(
2343
+ Object.entries(worldGeneratorWorkerProfileSpecs).map(([name, spec]) => [
2344
+ name,
2345
+ buildWorldGeneratorWorkerManifest(
2346
+ name,
2347
+ spec
2348
+ )
2349
+ ])
2350
+ )
2351
+ );
2352
+ function getWorldGeneratorWorkerProfile(name = defaultWorldGeneratorWorkerProfile) {
2353
+ const profile = worldGeneratorWorkerProfiles[name];
2354
+ if (!profile) {
2355
+ const available = worldGeneratorWorkerProfileNames.join(", ");
2356
+ throw new Error(
2357
+ `Unknown world-generator worker profile "${name}". Available: ${available}.`
2358
+ );
2359
+ }
2360
+ return profile;
2361
+ }
2362
+ function getWorldGeneratorWorkerManifest(name = defaultWorldGeneratorWorkerProfile) {
2363
+ const manifest = worldGeneratorWorkerManifests[name];
2364
+ if (!manifest) {
2365
+ const available = worldGeneratorWorkerProfileNames.join(", ");
2366
+ throw new Error(
2367
+ `Unknown world-generator worker profile "${name}". Available: ${available}.`
2368
+ );
2369
+ }
2370
+ return manifest;
2371
+ }
1787
2372
  export {
1788
2373
  DEFAULT_TILE_SIZE_WORLD,
1789
2374
  FIELD_DOWNWARD_MAX,
@@ -1813,11 +2398,14 @@ export {
1813
2398
  createPerfMonitor,
1814
2399
  defaultFieldParams,
1815
2400
  defaultFractalMandelSettings,
2401
+ defaultWorldGeneratorWorkerProfile,
1816
2402
  encodeTerrainParams,
1817
2403
  fieldWgslUrl,
1818
2404
  fractalPrepassWgslUrl,
1819
2405
  generateHexGrid,
1820
2406
  generateTemperateMixedForest,
2407
+ getWorldGeneratorWorkerManifest,
2408
+ getWorldGeneratorWorkerProfile,
1821
2409
  hexAreaFromSide,
1822
2410
  hexSideFromArea,
1823
2411
  loadFieldWgsl,
@@ -1843,6 +2431,11 @@ export {
1843
2431
  tileKeyFromWorldPosition,
1844
2432
  tileKeyToString,
1845
2433
  unpackTerrain,
1846
- validateTileAssetPayload
2434
+ validateTileAssetPayload,
2435
+ worldGeneratorDebugOwner,
2436
+ worldGeneratorWorkerManifests,
2437
+ worldGeneratorWorkerProfileNames,
2438
+ worldGeneratorWorkerProfiles,
2439
+ worldGeneratorWorkerQueueClass
1847
2440
  };
1848
2441
  //# sourceMappingURL=index.js.map