Use PerformanceTestChunkSource In Benchmark

This commit is contained in:
TheBrokenRail 2024-07-11 00:29:53 -04:00
parent d4c0f54245
commit 688bee1aaa
4 changed files with 23 additions and 1 deletions

View File

@ -153,10 +153,21 @@ static void Minecraft_update_injection(Minecraft *minecraft) {
}
}
// PerformanceTestChunkSource
static RandomLevelSource *PerformanceTestChunkSource_constructor(__attribute__((unused)) RandomLevelSource_constructor_t original, __attribute__((unused)) RandomLevelSource *self, Level *level, __attribute__((unused)) int seed, __attribute__((unused)) int version, __attribute__((unused)) bool enable_spawning) {
PerformanceTestChunkSource *self2 = (PerformanceTestChunkSource *) self;
self2->vtable = PerformanceTestChunkSource_vtable_base;
self2->level = level;
return self;
}
static bool LevelData_getSpawnMobs_injection(__attribute__((unused)) LevelData_getSpawnMobs_t original, __attribute__((unused)) LevelData *level_data) {
return false;
}
// Init Benchmark
void init_benchmark() {
// --benchmark: Activate Benchmark
bool active = getenv(_MCPI_BENCHMARK_ENV) != nullptr;
const bool active = getenv(_MCPI_BENCHMARK_ENV) != nullptr;
if (active) {
misc_run_on_update(Minecraft_update_injection);
// Track Frames
@ -167,5 +178,8 @@ void init_benchmark() {
media_set_interactable(0);
// Disable V-Sync
media_disable_vsync();
// Use PerformanceTestChunkSource
overwrite_calls(RandomLevelSource_constructor, PerformanceTestChunkSource_constructor);
overwrite_calls(LevelData_getSpawnMobs, LevelData_getSpawnMobs_injection);
}
}

View File

@ -83,6 +83,7 @@ set(SRC
src/level/LevelStorageSource.def
src/level/renderer/ParticleEngine.def
src/level/RandomLevelSource.def
src/level/PerformanceTestChunkSource.def
src/level/LevelData.def
src/level/LevelSettings.def
src/level/ServerLevel.def

View File

@ -0,0 +1,5 @@
extends ChunkSource;
vtable 0x110560;
property Level *level = 0x8;

View File

@ -1,5 +1,7 @@
extends ChunkSource;
constructor (Level *level, int seed, int version, bool enable_spawning) = 0xb4424;
vtable 0x110598;
method void buildSurface(int chunk_x, int chunk_y, uchar *chunk_data, Biome **biomes) = 0xb32ec;