mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 01:04:29 +00:00
Host the batch 1 IrisApi: module setup and timings on every runner
Iris's own modules (biome, custom, structure model) and the test modules move to IrisModule.setup, and built-ins are set up through ModuleSetups.run. Iris now passes StageMetrics to the placement and mantle runners as well as the chunk runner. The biome module no longer times itself; iris:biome/write feeds the biome metric through StageMetrics instead.
This commit is contained in:
1 parent
bc7f9127b5
commit
466d5149db
32 files changed
+142
-192
No files matched your search
@@ -34,11 +34,10 @@ import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import art.arcane.volmlib.util.matter.MatterBiomeInject;
|
||||
import art.arcane.volmlib.util.matter.slices.BiomeInjectMatter;
|
||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/**
|
||||
* Module {@code iris:biome}: writes each column's biome into the chunk's biome hunk, a custom biome under the
|
||||
@@ -53,8 +52,8 @@ public final class BiomeModule implements IrisModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(IrisStages.Biome.WRITE).run(BiomeModule::write);
|
||||
public void setup(ModuleSetup setup) {
|
||||
setup.stages().define(IrisStages.Biome.WRITE).run(BiomeModule::write);
|
||||
}
|
||||
|
||||
private static void write(ChunkStageContext context) {
|
||||
@@ -75,7 +74,6 @@ public final class BiomeModule implements IrisModule {
|
||||
|
||||
/** A partial biome write fails the chunk: a chunk flagged done with default biomes would keep them forever. */
|
||||
void write(int originX, int originZ, Hunk<PlatformBiome> biomes, ChunkContext context) {
|
||||
PrecisionStopwatch stopwatch = PrecisionStopwatch.start();
|
||||
Mantle<Matter> mantle = engine.getMantle().getMantle();
|
||||
ChunkedDataCache<IrisBiome> biomeCache = context.getBiome();
|
||||
for (int localX = 0; localX < biomes.getWidth(); localX++) {
|
||||
@@ -89,7 +87,6 @@ public final class BiomeModule implements IrisModule {
|
||||
mantle.set(worldX, 0, worldZ, resolved.matter());
|
||||
}
|
||||
}
|
||||
engine.getMetrics().getBiome().put(stopwatch.getMilliseconds());
|
||||
}
|
||||
|
||||
private String keyOf(IrisBiome biome, int worldX, int worldZ) {
|
||||
|
||||
@@ -30,8 +30,8 @@ import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||
import art.arcane.volmlib.util.matter.Matter;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.stage.ChunkStageContext;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/**
|
||||
* Module {@code iris:custom}: records the chunk's content-plugin blocks for the server to place later: each
|
||||
@@ -49,9 +49,9 @@ public final class CustomModule implements IrisModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
public void setup(ModuleSetup setup) {
|
||||
// Ordering only: iris:perfection ships in the built-ins jar, which a pack may not have.
|
||||
graph.define(IrisStages.Custom.BLOCKS).softAfter(IrisStages.Perfection.SURFACE.ref()).run(CustomModule::record);
|
||||
setup.stages().define(IrisStages.Custom.BLOCKS).softAfter(IrisStages.Perfection.SURFACE).run(CustomModule::record);
|
||||
}
|
||||
|
||||
private static void record(ChunkStageContext context) {
|
||||
|
||||
@@ -118,6 +118,7 @@ public final class ModuleMantleComponent implements MantleComponent {
|
||||
/** Runs the stage for chunk {@code x}, {@code z}, with the mantle chunks within the stage's reach of it. */
|
||||
void generate(int x, int z, IrisModuleMantle.Chunks chunks) {
|
||||
IrisMantleGenerationContext inputs = new IrisMantleGenerationContext(engine, x, z, reachBlocks, chunks, pack.catalog().mantle());
|
||||
runner.generate(stage.stage(), inputs, ModuleSeeds.chunk(engine.getSeedManager().getSeed(), x, z));
|
||||
runner.generate(stage.stage(), inputs, ModuleSeeds.chunk(engine.getSeedManager().getSeed(), x, z),
|
||||
new StageMetrics(engine.getMetrics()));
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,9 @@ public final class ModuleObjectPlacement {
|
||||
new PlacementModuleSettings(worldSettings(engine, ids), config.getModuleSettings(), source),
|
||||
new PlacerBlockView(placer, area, states), data.getPackResources(), engine);
|
||||
long seed = ModuleSeeds.placement(worldSeed, objectKey, x, requestedY, z);
|
||||
StageMetrics metrics = new StageMetrics(engine != null ? engine.getMetrics() : null);
|
||||
PlacementOutcome outcome = placement.runBound(() -> new PlacementRunner(graph)
|
||||
.place(request, edit, inputs, seed, config.getModuleSettings().placement(source)));
|
||||
.place(request, edit, inputs, seed, config.getModuleSettings().placement(source), metrics));
|
||||
return outcome.isPlaced()
|
||||
? ObjectPlacementResult.placed(placement.anchorY())
|
||||
: ObjectPlacementResult.rejected(outcome.rejection().orElseThrow());
|
||||
|
||||
@@ -33,7 +33,9 @@ import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.host.DiscoveredModule;
|
||||
import com.volmit.host.ModuleRegistry;
|
||||
import com.volmit.host.ModuleSetups;
|
||||
import com.volmit.host.ServiceRegistration;
|
||||
import com.volmit.host.StageGraphBuilder;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.VanillaStructures;
|
||||
@@ -88,7 +90,7 @@ public final class ModuleStructureFitting implements NativeStructureFitting {
|
||||
/** The built-in modules' registrations only: their stage graph needs the modules of the built-ins jar too. */
|
||||
public static NativeStructureFitting builtInModules() {
|
||||
ModuleRegistry registry = new ModuleRegistry();
|
||||
IrisModuleHost.builtInModules().forEach(module -> registry.register(DiscoveredModule.builtIn(module)));
|
||||
IrisModuleHost.builtInModules().forEach(module -> ModuleSetups.run(DiscoveredModule.builtIn(module), new StageGraphBuilder(), registry));
|
||||
return new ModuleStructureFitting(registry.freeze().registrations(VanillaStructures.class), () -> {
|
||||
throw new IllegalStateException("The built-in modules fit outside a world here: a start needs its memo"
|
||||
+ " and a fit without palettes");
|
||||
|
||||
@@ -27,9 +27,10 @@ import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Iris's generation metrics for the built-in chunk stages that Iris timed under a name of its own before they were
|
||||
* modules, so studio and the integration metrics keep showing them: Iris times each such stage around its run
|
||||
* instead of the module timing itself. A ported built-in that reported a metric adds its stage here.
|
||||
* Iris's generation metrics for the built-in stages that Iris timed under a name of its own before they were
|
||||
* modules, so studio and the integration metrics keep showing them: Iris passes this to the placement, mantle and
|
||||
* chunk runners, which time each stage around its run instead of the module timing itself. A ported built-in that
|
||||
* reported a metric adds its stage here.
|
||||
*/
|
||||
final class StageMetrics implements StageTimings {
|
||||
private static final double NANOS_PER_MILLISECOND = 1_000_000D;
|
||||
@@ -39,7 +40,8 @@ final class StageMetrics implements StageTimings {
|
||||
"iris:carve/apply", EngineMetrics::getCave,
|
||||
"iris:deposit/ores", EngineMetrics::getDeposit,
|
||||
"iris:decorant/decorate", EngineMetrics::getDecoration,
|
||||
"iris:terrain/shape", EngineMetrics::getTerrain);
|
||||
"iris:terrain/shape", EngineMetrics::getTerrain,
|
||||
"iris:biome/write", EngineMetrics::getBiome);
|
||||
|
||||
private final EngineMetrics metrics;
|
||||
|
||||
|
||||
@@ -22,12 +22,11 @@ import art.arcane.iris.engine.framework.structure.StructureLocating;
|
||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||
import art.arcane.iris.engine.framework.structure.StructureValidator;
|
||||
import art.arcane.iris.engine.framework.structure.StructureVanillaStructures;
|
||||
import com.volmit.FeatureRegistry;
|
||||
import com.volmit.IrisModule;
|
||||
import com.volmit.ModuleInfo;
|
||||
import com.volmit.ModuleSetup;
|
||||
import com.volmit.service.StructureLocator;
|
||||
import com.volmit.service.VanillaStructures;
|
||||
import com.volmit.stage.StageGraph;
|
||||
|
||||
/**
|
||||
* Module {@code iris:structure-model}: Iris's jigsaw structure model, which the structure placements of
|
||||
@@ -52,11 +51,8 @@ public final class StructureModelModule implements IrisModule {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
public void setup(ModuleSetup setup) {
|
||||
var registry = setup.registry();
|
||||
StructureResources.kinds().forEach(registry::registerResourceKind);
|
||||
registry.registerValidator(new StructureValidator());
|
||||
registry.registerService(StructureLocator.class, new StructureLocating());
|
||||
|
||||
Reference in new issue
Block a user