Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New perf patch: ForceSyncSceneSwitch #250

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions GameData/KSPCommunityFixes/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ KSP_COMMUNITY_FIXES
// Reduce scene loading time by caching the current save in memory instead of loading it from disk
SceneLoadSpeedBoost = true

// Forces all scene transitions to happen synchronously.
// Mainly benefits highly modded installs by reducing asset cleanup run count from 3 to 1.
ForceSyncSceneSwitch = true

// Prevent the buoyancy integrator from eating CPU cycles when the vessel isn't submerged
OnDemandPartBuoyancy = true

Expand Down
1 change: 1 addition & 0 deletions KSPCommunityFixes/KSPCommunityFixes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<Compile Include="Library\LocalizationUtils.cs" />
<Compile Include="Library\ObjectPool.cs" />
<Compile Include="Modding\ModUpgradePipeline.cs" />
<Compile Include="Performance\ForceSyncSceneSwitch.cs" />
<Compile Include="Performance\AsteroidAndCometDrillCache.cs" />
<Compile Include="BugFixes\DoubleCurvePreserveTangents.cs" />
<Compile Include="BugFixes\RestoreMaxPhysicsDT.cs" />
Expand Down
23 changes: 23 additions & 0 deletions KSPCommunityFixes/Performance/ForceSyncSceneSwitch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using HarmonyLib;
using System;
using System.Collections.Generic;

namespace KSPCommunityFixes
{
public class ForceSyncSceneSwitch : BasePatch
{
protected override void ApplyPatches(List<PatchInfo> patches)
{
patches.Add(new PatchInfo(
PatchMethodType.Prefix,
AccessTools.Method(typeof(SceneTransitionMatrix), "GetTransitionValue", new Type[] { typeof(GameScenes), typeof(GameScenes) }),
this));
}

static bool SceneTransitionMatrix_GetTransitionValue_Prefix(out bool __result)
{
__result = false;
return false;
}
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ User options are available from the "ESC" in-game settings menu :<br/><img src="
#### Performance tweaks

- **SceneLoadSpeedBoost** [KSP 1.8.0 - 1.12.5]<br/>Reduce scene switches loading time with large/modded saves by caching the current save in memory instead of loading it from disk.
- [**ForceSyncSceneSwitch**](https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/250) [KSP 1.12.0 - 1.12.5]<br/>Forces all scene transitions to happen synchronously. Mainly benefits highly modded installs by reducing asset cleanup run count from 3 to 1.
- **OnDemandPartBuoyancy** [KSP 1.8.0 - 1.12.5]<br/>Prevent the part buoyancy integrator from running when not needed. Improves performance for large part count vessels while in the SOI of a body that has an ocean (Kerbin, Eve, Laythe...)
- [**FastLoader**](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/108) [KSP 1.12.3 - 1.12.5]<br/>Complete rewrite of the KSP asset/part loader : prevent GPU framerate limits from affecting loading speed, implement multithreaded asset loading (20% to 40% speedup depending on CPU & storage specs), provides an opt-in mechanism for caching PNG textures in the DXT5 format, also implements loading of additional DDS formats (see **BetterDDSSupport** patch in the API/modding tools section).
- **PQSUpdateNoMemoryAlloc** [KSP 1.11.0 - 1.12.5]<br/> Prevent huge memory allocations and resulting occasional stutter on PQS creation happening when moving around near a body surface.
Expand Down Expand Up @@ -190,6 +191,9 @@ If doing so in the `Debug` configuration and if your KSP install is modified to

### Changelog

##### 1.36.0
- **SceneLoadSpeedBoost** : Reduce scene switch times further by forcing them to happen synchronously.

##### 1.35.2
- **FastLoader** : Fixed a regression introduced in 1.35.1, causing PNG normal maps to be generated with empty mipmaps.

Expand Down
Loading