Skip to content

feat: add support for frame time budget to configs and mcm#4

Open
KaninHop wants to merge 7 commits intoDaymareOn:mainfrom
KaninHop:feat/add-support-for-frame-time-budget-to-configs-and-MCM
Open

feat: add support for frame time budget to configs and mcm#4
KaninHop wants to merge 7 commits intoDaymareOn:mainfrom
KaninHop:feat/add-support-for-frame-time-budget-to-configs-and-MCM

Conversation

@KaninHop
Copy link
Copy Markdown
Contributor

@KaninHop KaninHop commented Mar 29, 2026

Swap to frame time budget from % of frame time.

Tested with a AVX2 ci build of DaymareOn/hdtSMP64#256

Summary by CodeRabbit

  • Chores

    • Switched SMP performance settings across presets from percentage-of-frame-time to millisecond-based budgets.
    • Bumped config version and trigger reinitialization on upgrade.
  • New Features

    • UI exposes a millisecond budget slider with updated ranges, defaults, and float precision.
    • Preset handling improved: clearer "loaded" highlighting, reliable preset selection and tracking.
  • Bug Fixes

    • Safer handling for missing config values and more robust preset loading behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

Replaces percentage-based SMP frame-time budgeting with millisecond-based budgetMs in main config and presets; updates the MCM script to use a budget slider (float budgetMs), change preset selection/tracking logic, add a version upgrade hook, and bump script config version to 3.

Changes

Cohort / File(s) Summary
Main Configuration
SKSE/Plugins/hdtSkinnedMeshConfigs/configs.xml
Replaced <percentageOfFrameTime>18</percentageOfFrameTime> with <budgetMs>3</budgetMs> in the <smp> section.
Configuration Presets
SKSE/Plugins/hdtSkinnedMeshConfigs/configsPresets/Debug.xml, SKSE/Plugins/hdtSkinnedMeshConfigs/configsPresets/Performance.xml, SKSE/Plugins/hdtSkinnedMeshConfigs/configsPresets/Quality.xml, SKSE/Plugins/hdtSkinnedMeshConfigs/configsPresets/Reasonable.xml
Replaced percentageOfFrameTime entries with budgetMs values: Debug 30%→5ms, Performance 18%→2.8ms, Quality 30%→5ms, Reasonable 30%→4ms.
MCM Script
Source/Scripts/FSMPM.psc
Bumped config version to 3 and added upgrade hook; replaced percentage slider/state with SliderTimeFrameBudget (budgetMs, float) and updated ranges/format; switched to setFloatTag and float storage; changed preset UI/selection logic (added sLastLoadedPresetName, bLastTagFound, constrained preset option generation, clear unused slots); loadConfigFile now returns bool and detects missing tags; renamed OnHighlightOnOptionHighlight.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • DaymareOn

Poem

🐰 I nudge the slider, small and swift,
Percent to milliseconds — a tidy gift.
Presets keep names, the menu hums,
Version three arrives with tiny drums,
🥕 Hooray for clean configs and joyful skims!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: migrating from percentage-based to millisecond-based frame time budget across all configuration files and MCM script, which is the core objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Source/Scripts/FSMPM.psc`:
- Line 91: The AddSliderOptionST call currently uses JMap.getStr(configMapId,
"budgetMs", 3.5) as float which drops legacy values; change it to prefer a
migrated legacy key by first checking JMap.getStr(configMapId,
"percentageOfFrameTime", null) (or equivalent "percentageOfFrameTime" getter)
and if present convert/parse that value into the new budgetMs, otherwise fall
back to the shipped default of 3 (not 3.5); apply the same migration/fallback
change wherever JMap.getStr(..., "budgetMs", 3.5) appears (e.g., the other
occurrences referenced at the other ranges) so existing configs/presets are
preserved on load.
- Around line 140-145: OnPageReset populates only up to min(presetsFiles.Length,
presetsInt.Length), but OnOptionSelect still scans the full presetsInt length
which can pick stale tails; update OnOptionSelect to iterate only to count =
min(presetsFiles.Length, presetsInt.Length) when mapping selected option to
presetFileIndex and ensure presetFileIndex is validated against that same bound,
and modify OnPageReset to explicitly clear any unused tail entries in presetsInt
beyond that count so stale entries cannot be selected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 150e58ff-8951-47ec-8623-5af87ea722b7

📥 Commits

Reviewing files that changed from the base of the PR and between dfdf1d1 and 3825b27.

📒 Files selected for processing (8)
  • SKSE/Plugins/hdtSkinnedMeshConfigs/configs.xml
  • SKSE/Plugins/hdtSkinnedMeshConfigs/configsPresets/Debug.xml
  • SKSE/Plugins/hdtSkinnedMeshConfigs/configsPresets/Performance.xml
  • SKSE/Plugins/hdtSkinnedMeshConfigs/configsPresets/Quality.xml
  • SKSE/Plugins/hdtSkinnedMeshConfigs/configsPresets/Reasonable.xml
  • Scripts/FSMPM.pex
  • Scripts/FSMPMPlayerScript.pex
  • Source/Scripts/FSMPM.psc

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
Source/Scripts/FSMPM.psc (1)

152-155: ⚠️ Potential issue | 🟠 Major

Prefer -1 over 0 for empty preset slots.

The bounded scan is the right fix, but SkyUI only documents AddTextOption() as returning a unique option ID; it does not reserve 0 as invalid. Clearing the tail to 0 and then rejecting 0 at Line 165 makes selection depend on an undocumented API detail, so the first preset can become unselectable if its ID is 0. Use -1 for unused slots instead. (github.com)

🛠️ Suggested hardening
 		While (index < presetsInt.Length)
-			presetsInt[index] = 0
+			presetsInt[index] = -1
 			index += 1
 		EndWhile
 ...
-		if (presetsInt[index] != 0 && presetsInt[index] == a_option) ; found
+		if (presetsInt[index] != -1 && presetsInt[index] == a_option) ; found
 			presetFileIndex = index
 		endif

Also applies to: 164-165

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Source/Scripts/FSMPM.psc` around lines 152 - 155, The preset clearing loop
resets unused slots to 0 which collides with AddTextOption() potentially
returning 0; update the tail-clearing in the While that writes to
presetsInt[index] to use -1 for unused slots instead of 0, and ensure any code
that checks for invalid selection (the logic around rejecting 0 at selection
time) treats -1 as the sentinel; modify the While block that assigns
presetsInt[index] and any selection filter that currently checks for 0 so they
consistently use -1 as the unused-slot marker.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Source/Scripts/FSMPM.psc`:
- Around line 145-146: sLastLoadedPresetName is being set before
loadConfigFile() can fall back via tagDefaultValue(), causing the UI to mark
presets as "Loaded!" even when the resulting config is a hybrid; change the
logic so you only set sLastLoadedPresetName (or mark the preset in presetsInt
via AddTextOption/OPTION_FLAG_DISABLED) after loadConfigFile() successfully
returns a fully-applied preset with no fallbacks — for example, call
loadConfigFile() first, verify that no defaults were substituted (or compare the
resulting config against tagDefaultValue() behavior), then set
sLastLoadedPresetName = presetFile and update presetsInt[index] with
AddTextOption; alternatively derive the "Loaded" badge from the actual resulting
config rather than preemptively from presetFile.

---

Duplicate comments:
In `@Source/Scripts/FSMPM.psc`:
- Around line 152-155: The preset clearing loop resets unused slots to 0 which
collides with AddTextOption() potentially returning 0; update the tail-clearing
in the While that writes to presetsInt[index] to use -1 for unused slots instead
of 0, and ensure any code that checks for invalid selection (the logic around
rejecting 0 at selection time) treats -1 as the sentinel; modify the While block
that assigns presetsInt[index] and any selection filter that currently checks
for 0 so they consistently use -1 as the unused-slot marker.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 02e45029-db0b-4948-b896-2161fa8b7401

📥 Commits

Reviewing files that changed from the base of the PR and between 3825b27 and 5f9f78d.

📒 Files selected for processing (3)
  • Scripts/FSMPM.pex
  • Scripts/FSMPMPlayerScript.pex
  • Source/Scripts/FSMPM.psc

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5e5bdd8e-ab23-4413-99a8-a3c5f4fdb1e3

📥 Commits

Reviewing files that changed from the base of the PR and between 5f9f78d and b3e9105.

📒 Files selected for processing (3)
  • Scripts/FSMPM.pex
  • Scripts/FSMPMPlayerScript.pex
  • Source/Scripts/FSMPM.psc

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Source/Scripts/FSMPM.psc`:
- Around line 162-182: The loop in Event OnOptionSelect scans
presetsFiles/presetsInt to find a matching preset but continues iterating after
finding it; modify the While in OnOptionSelect to break out immediately when you
set presetFileIndex (i.e., after detecting presetsInt[index] == a_option) so you
avoid unnecessary iterations, then proceed with the existing
loadConfigFile/preset name logic and subsequent calls to
storeConfigAndSmpReset() and ForcePageReset().
- Line 95: The fallback default for the SMP frame-time slider is inconsistent
with shipped configs: change the hardcoded 3.5 to 3.0 in the slider creation
call AddSliderOptionST("SliderTimeFrameBudget", ...) and also update the
corresponding fallback entries at defaultValues[11] and the initial value in
setOpenedSlider to 3.0 so all three locations (AddSliderOptionST,
defaultValues[11], setOpenedSlider) consistently use 3.0.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4a1e3aae-b752-43a5-811e-850a583208fe

📥 Commits

Reviewing files that changed from the base of the PR and between b3e9105 and 42ce147.

📒 Files selected for processing (3)
  • Scripts/FSMPM.pex
  • Scripts/FSMPMPlayerScript.pex
  • Source/Scripts/FSMPM.psc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant