Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4e16308
fix(vr): allow underwater hookshot selection
Oct 14, 2026
9242196
fix(vr): support physical Bombchus in bowling
Oct 14, 2026
d58a070
fix: restore non-vr pause menu rendering
Oct 14, 2026
ec77244
fix(vr): support physical archery in shooting galleries
Oct 14, 2026
db4df38
feat(vr): add optional physical archery aim dot
Oct 14, 2026
5968abb
feat(vr): support physical bow combat on horseback
Oct 14, 2026
21e3cce
feat(vr): cycle physical bow arrow types
Oct 15, 2026
a1fa53c
feat(vr): add D3D11 single-pass stereo
Oct 15, 2026
8f4d24e
perf(vr): add D3D11 performance controls
Oct 16, 2026
b01ee51
feat(vr): add automated benchmark suite
Oct 16, 2026
e12ef7b
fix(crash): preserve original exception diagnostics
Oct 16, 2026
7d07b1e
feat(vr): report detailed benchmark timing
Oct 16, 2026
9c5da9b
feat(vr): render notifications in headset
Oct 16, 2026
0acdc8f
feat(vr): add physical door interactions
Oct 16, 2026
fcefb94
feat(vr): allow hiding physical door grab markers
Oct 16, 2026
87a4c42
feat(vr): add physical dungeon key inventory
Oct 16, 2026
70a3bcd
feat(anchor): share VR head and hand tracking
Oct 16, 2026
bdab311
Add adjustable VR hammer ground-pound reach
Oct 17, 2026
bc1e998
feat(vr): allow physically throwing Bombchus
Oct 18, 2026
6d3a44f
feat(vr): expand physical dungeon door interactions
Oct 18, 2026
6031f1b
fix(vr): limit boss key to locked boss doors
Oct 19, 2026
976602c
fix(vr): support back-facing climbable surfaces
Oct 19, 2026
74c0531
fix(vr): address physical interaction review findings
Oct 19, 2026
fc7e8b0
perf(vr): add optional interpreter cache
Oct 19, 2026
b196ddc
Revert "feat(vr): allow physically throwing Bombchus"
Oct 19, 2026
6cca0f2
fix(vr): preserve physical Bomb Flower throws
Oct 19, 2026
5290151
fix(vr): keep owned boss key visible in dungeon
Oct 19, 2026
d576012
Fix VR shutter door hand interaction
Oct 21, 2026
4888cf8
fix(vr): align physical key card grabbing
Oct 22, 2026
043efb0
perf(vr): smooth physical door room preloading
Oct 22, 2026
eb6f651
fix(vr): fit shutter hand placement to rendered geometry
Oct 23, 2026
b515164
feat(vr): add physical Jabu membrane doors
Oct 23, 2026
99b72c3
refactor(vr): cache shutter visuals per room side
Oct 23, 2026
1ccb38a
fix(vr): preserve shutter close state and locomotion
Oct 23, 2026
a240640
Add physical VR Gerudo cell doors
Oct 23, 2026
dad20df
Add physical VR treasure chests
Oct 24, 2026
71b6b4d
Fix VR heading after scene loads
Oct 24, 2026
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
156 changes: 156 additions & 0 deletions run-vr-benchmark-suite.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
param(
[ValidateRange(1, 10)]
[int]$RunsPerPreset = 3,
[string]$ReleaseDirectory = (Join-Path $PSScriptRoot 'x64\Release')
)

$ErrorActionPreference = 'Stop'
$releaseDirectory = (Resolve-Path -LiteralPath $ReleaseDirectory).Path
$executable = Join-Path $releaseDirectory 'soh.exe'
$resultsDirectory = Join-Path $releaseDirectory 'benchmarks'

if (-not (Test-Path -LiteralPath $executable -PathType Leaf)) {
throw "Shipwright executable not found: $executable"
}

New-Item -ItemType Directory -Path $resultsDirectory -Force | Out-Null

function Get-Median([double[]]$Values) {
if ($Values.Count -eq 0) { return 0.0 }
$sorted = @($Values | Sort-Object)
$middle = [math]::Floor($sorted.Count / 2)
if (($sorted.Count % 2) -eq 1) { return [double]$sorted[$middle] }
return ([double]$sorted[$middle - 1] + [double]$sorted[$middle]) / 2.0
}

$records = [System.Collections.Generic.List[object]]::new()
$suiteStarted = Get-Date

Write-Host ''
Write-Host 'VR BENCHMARK SUITE'
Write-Host "Runs: $RunsPerPreset baseline + $RunsPerPreset optimized"
Write-Host 'Keep the headset worn and focused until all runs finish.'
Write-Host ''

foreach ($preset in @('baseline', 'optimized')) {
for ($run = 1; $run -le $RunsPerPreset; $run++) {
Write-Host "[$preset $run/$RunsPerPreset] Starting Hyrule Field introduction..."
$started = Get-Date
$process = Start-Process -FilePath $executable `
-ArgumentList '--vr-benchmark', '--benchmark-name', $preset `
-WorkingDirectory $releaseDirectory `
-Wait -PassThru

$summaryFile = Get-ChildItem -LiteralPath $resultsDirectory -Filter "*_${preset}-summary.json" |
Where-Object { $_.LastWriteTime -ge $started } |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if ($null -eq $summaryFile) {
throw "Benchmark $preset run $run exited with code $($process.ExitCode) without producing a new summary."
}
if ($process.ExitCode -ne 0) {
Write-Warning "Benchmark $preset run $run produced a complete summary but exited with code $($process.ExitCode); keeping the result."
}

$summary = Get-Content -LiteralPath $summaryFile.FullName -Raw | ConvertFrom-Json
$records.Add([pscustomobject]@{
preset = $preset
run = $run
file = $summaryFile.Name
cadence_valid = [bool]$summary.cadence_valid
target_rate_frame_percent = [double]$summary.target_rate_frame_percent
average_submitted_fps = [double]$summary.average_submitted_fps
one_percent_low_submitted_fps = [double]$summary.one_percent_low_submitted_fps
frame_interval_p99_ms = [double]$summary.frame_interval_p99_ms
xr_wait_average_ms = [double]$summary.xr_wait_average_ms
xr_wait_p99_ms = [double]$summary.xr_wait_p99_ms
cpu_active_average_ms = [double]$summary.cpu_active_average_ms
cpu_active_p99_ms = [double]$summary.cpu_active_p99_ms
gpu_eyes_average_ms = [double]$summary.gpu_eyes_average_ms
gpu_eyes_p99_ms = [double]$summary.gpu_eyes_p99_ms
gpu_total_average_ms = [double]$summary.gpu_total_average_ms
gpu_total_p99_ms = [double]$summary.gpu_total_p99_ms
cpu_total_average_ms = [double]$summary.cpu_total_average_ms
cpu_total_p99_ms = [double]$summary.cpu_total_p99_ms
cpu_eyes_average_ms = [double]$summary.cpu_eyes_average_ms
cpu_eyes_p99_ms = [double]$summary.cpu_eyes_p99_ms
})
Write-Host ("[{0} {1}/{2}] Complete: {3:N2} FPS, eye CPU {4:N2} ms, cadence {5}" -f `
$preset, $run, $RunsPerPreset, $summary.average_submitted_fps, $summary.cpu_eyes_average_ms, `
$(if ($summary.cadence_valid) { 'VALID' } else { 'INVALID' }))
}
}

$aggregates = foreach ($preset in @('baseline', 'optimized')) {
$set = @($records | Where-Object preset -eq $preset)
[pscustomobject]@{
preset = $preset
runs = $set.Count
valid_cadence_runs = @($set | Where-Object cadence_valid).Count
median_target_rate_frame_percent = Get-Median @($set.target_rate_frame_percent)
median_submitted_fps = Get-Median @($set.average_submitted_fps)
median_one_percent_low_fps = Get-Median @($set.one_percent_low_submitted_fps)
median_frame_interval_p99_ms = Get-Median @($set.frame_interval_p99_ms)
median_xr_wait_average_ms = Get-Median @($set.xr_wait_average_ms)
median_xr_wait_p99_ms = Get-Median @($set.xr_wait_p99_ms)
median_cpu_active_average_ms = Get-Median @($set.cpu_active_average_ms)
median_cpu_active_p99_ms = Get-Median @($set.cpu_active_p99_ms)
median_gpu_eyes_average_ms = Get-Median @($set.gpu_eyes_average_ms)
median_gpu_eyes_p99_ms = Get-Median @($set.gpu_eyes_p99_ms)
median_gpu_total_average_ms = Get-Median @($set.gpu_total_average_ms)
median_gpu_total_p99_ms = Get-Median @($set.gpu_total_p99_ms)
median_cpu_total_average_ms = Get-Median @($set.cpu_total_average_ms)
median_cpu_total_p99_ms = Get-Median @($set.cpu_total_p99_ms)
median_cpu_eyes_average_ms = Get-Median @($set.cpu_eyes_average_ms)
median_cpu_eyes_p99_ms = Get-Median @($set.cpu_eyes_p99_ms)
}
}

$baseline = $aggregates | Where-Object preset -eq 'baseline'
$optimized = $aggregates | Where-Object preset -eq 'optimized'
function Percent-Change([double]$Before, [double]$After) {
if ([math]::Abs($Before) -lt 0.000001) { return 0.0 }
return (($After - $Before) / $Before) * 100.0
}

$comparison = [pscustomobject]@{
submitted_fps_percent = Percent-Change $baseline.median_submitted_fps $optimized.median_submitted_fps
one_percent_low_fps_percent = Percent-Change $baseline.median_one_percent_low_fps $optimized.median_one_percent_low_fps
frame_interval_p99_percent = Percent-Change $baseline.median_frame_interval_p99_ms $optimized.median_frame_interval_p99_ms
cpu_active_average_percent = Percent-Change $baseline.median_cpu_active_average_ms $optimized.median_cpu_active_average_ms
cpu_active_p99_percent = Percent-Change $baseline.median_cpu_active_p99_ms $optimized.median_cpu_active_p99_ms
gpu_eyes_average_percent = Percent-Change $baseline.median_gpu_eyes_average_ms $optimized.median_gpu_eyes_average_ms
gpu_total_average_percent = Percent-Change $baseline.median_gpu_total_average_ms $optimized.median_gpu_total_average_ms
cpu_total_average_percent = Percent-Change $baseline.median_cpu_total_average_ms $optimized.median_cpu_total_average_ms
cpu_total_p99_percent = Percent-Change $baseline.median_cpu_total_p99_ms $optimized.median_cpu_total_p99_ms
cpu_eyes_average_percent = Percent-Change $baseline.median_cpu_eyes_average_ms $optimized.median_cpu_eyes_average_ms
cpu_eyes_p99_percent = Percent-Change $baseline.median_cpu_eyes_p99_ms $optimized.median_cpu_eyes_p99_ms
}

$suite = [pscustomobject]@{
started = $suiteStarted.ToString('o')
completed = (Get-Date).ToString('o')
runs_per_preset = $RunsPerPreset
runs = $records
medians = $aggregates
optimized_change_percent = $comparison
}
$timestamp = Get-Date -Format 'yyyyMMdd-HHmmss'
$suiteFile = Join-Path $resultsDirectory "suite-$timestamp-summary.json"
$suite | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $suiteFile -Encoding UTF8

Write-Host ''
Write-Host 'MEDIAN RESULTS'
$aggregates | Format-Table preset, valid_cadence_runs, median_submitted_fps, median_one_percent_low_fps, `
median_cpu_eyes_average_ms, median_cpu_eyes_p99_ms -AutoSize
Write-Host "Suite summary: $suiteFile"

if ($aggregates.valid_cadence_runs -contains 0) {
[System.Media.SystemSounds]::Exclamation.Play()
Write-Warning 'At least one preset had no cadence-valid runs. Inspect target-rate percentages before comparing.'
} else {
1..3 | ForEach-Object {
[System.Media.SystemSounds]::Asterisk.Play()
Start-Sleep -Milliseconds 250
}
}
1 change: 1 addition & 0 deletions soh/include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx**
s32 Player_OverrideLimbDrawGameplayDefault(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* data);
s32 Player_OverrideLimbDrawGameplayFirstPerson(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* data);
s32 Player_OverrideLimbDrawGameplayVRFirstPerson(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* data);
s32 Anchor_ApplyRemoteVrLimbPose(Player* player, s32 limbIndex);
s32 Player_OverrideLimbDrawGameplayCrawling(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* data);
u8 func_80090480(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponDim, Vec3f* newTip,
Vec3f* newBase);
Expand Down
19 changes: 18 additions & 1 deletion soh/soh/CrashHandlerExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <array>
#include "soh/ActorDB.h"
#include <fast/interpreter.h>
#ifdef _WIN32
#include <Windows.h>
#endif

#define WRITE_VAR_LINE(buff, len, varName, varValue) \
append_str(buff, len, varName); \
Expand Down Expand Up @@ -63,7 +66,7 @@ static void CrashHandler_WriteActorData(char* buffer, size_t* pos) {
}
}

extern "C" void CrashHandler_PrintSohData(char* buffer, size_t* pos) {
static void CrashHandler_PrintSohDataImpl(char* buffer, size_t* pos) {
char intCharBuffer[16];
append_line(buffer, pos, "Build Information:");
WRITE_VAR_LINE(buffer, pos, " Game Version: ", (const char*)gBuildVersion);
Expand All @@ -90,3 +93,17 @@ extern "C" void CrashHandler_PrintSohData(char* buffer, size_t* pos) {
}
}
}

extern "C" void CrashHandler_PrintSohData(char* buffer, size_t* pos) {
#ifdef _WIN32
// A crash may leave gPlayState or its actor lists invalid. Never allow
// optional diagnostic collection to replace the original exception.
__try {
CrashHandler_PrintSohDataImpl(buffer, pos);
} __except (EXCEPTION_EXECUTE_HANDLER) {
append_line(buffer, pos, "Shipwright runtime data unavailable (invalid state during crash).");
}
#else
CrashHandler_PrintSohDataImpl(buffer, pos);
#endif
}
81 changes: 72 additions & 9 deletions soh/soh/Enhancements/Items/ArrowCycle.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/Enhancements/vr-combat/VrCombat.h"
#include "soh/ShipInit.hpp"

extern "C" {
Expand All @@ -17,6 +18,7 @@ extern PlayState* gPlayState;
#define CVAR_ARROW_CYCLE_NAME CVAR_ENHANCEMENT("BowArrowCycle")
#define CVAR_ARROW_CYCLE_DEFAULT 0
#define CVAR_ARROW_CYCLE_VALUE CVarGetInteger(CVAR_ARROW_CYCLE_NAME, CVAR_ARROW_CYCLE_DEFAULT)
#define CVAR_VR_ARROW_CYCLE_VALUE CVarGetInteger("gVrBowTriggerArrowCycle", 0)

static const s16 sMagicArrowCosts[] = { 4, 4, 8 };

Expand All @@ -27,6 +29,8 @@ static const PlayerItemAction sArrowCycleOrder[] = {
PLAYER_IA_BOW_LIGHT,
};

static int32_t sPendingMountedIconItem = ITEM_NONE;

static bool IsHoldingBow(Player* player) {
return player->heldItemAction >= PLAYER_IA_BOW && player->heldItemAction <= PLAYER_IA_BOW_LIGHT;
}
Expand Down Expand Up @@ -80,12 +84,62 @@ static ArrowType GetArrowTypeForArrow(s8 itemAction) {
}
}

static PlayerItemAction GetItemActionForArrow(const EnArrow* arrow, const Player* player) {
switch (arrow->actor.params) {
case ARROW_FIRE:
return PLAYER_IA_BOW_FIRE;
case ARROW_ICE:
return PLAYER_IA_BOW_ICE;
case ARROW_LIGHT:
return PLAYER_IA_BOW_LIGHT;
default:
return (PlayerItemAction)player->heldItemAction;
}
}

static void ChangeMountedArrowType(EnArrow* arrow, PlayerItemAction itemAction) {
// Mounted Link's bow state only accepts PLAYER_IA_BOW. Changing itemAction or re-running
// EnArrow_Init makes the horse action release the parented arrow and can leave Link stuck
// aiming. Change only the live projectile's elemental payload; EnArrow_Update will create
// the corresponding elemental child on its next update.
if (arrow->actor.child != NULL) {
Actor_Kill(arrow->actor.child);
arrow->actor.child = NULL;
}

static const u32 damageFlags[] = { 0x00000020, 0x00000800, 0x00001000, 0x00002000 };
const int index = itemAction - PLAYER_IA_BOW;
arrow->actor.params = itemAction == PLAYER_IA_BOW ? ARROW_NORMAL_HORSE : GetArrowTypeForArrow(itemAction);
arrow->collider.info.toucher.dmgFlags = damageFlags[index];

// Epona must keep ITEM_BOW in the temporary B slot, but the HUD texture can still show the
// selected elemental arrow. Interface_LoadItemIcon1 resolves the texture synchronously from
// buttonItems[0], so expose the display item only for that load.
sPendingMountedIconItem = GetBowItemForArrow(itemAction);
}

static void FlushMountedBowIcon() {
if (sPendingMountedIconItem == ITEM_NONE || gPlayState == nullptr) {
return;
}

// Run after the ordinary interface update, which restores Epona's temporary B icon during
// the frame. Load only the alternate texture, then immediately restore the required B item.
const uint8_t horseBowItem = gSaveContext.equips.buttonItems[0];
gSaveContext.equips.buttonItems[0] = sPendingMountedIconItem;
Interface_LoadItemIcon1(gPlayState, 0);
gSaveContext.equips.buttonItems[0] = horseBowItem;
sPendingMountedIconItem = ITEM_NONE;
}

static bool CanCycleArrows() {
Player* player = GET_PLAYER(gPlayState);
const bool vrPhysicalCycle = CVAR_VR_ARROW_CYCLE_VALUE && VR_IsInitialized() && VrArchery_Covers(player);

return (LINK_IS_ADULT || CVarGetInteger(CVAR_CHEAT("TimelessEquipment"), 0)) && !gSaveContext.minigameState &&
gPlayState->sceneNum != SCENE_SHOOTING_GALLERY && !(player->stateFlags1 & PLAYER_STATE1_ON_HORSE) &&
player->rideActor == NULL && INV_CONTENT(SLOT_BOW) == ITEM_BOW &&
gPlayState->sceneNum != SCENE_SHOOTING_GALLERY &&
(!(player->stateFlags1 & PLAYER_STATE1_ON_HORSE) || vrPhysicalCycle) &&
(player->rideActor == NULL || vrPhysicalCycle) && INV_CONTENT(SLOT_BOW) == ITEM_BOW &&
(INV_CONTENT(ITEM_ARROW_FIRE) == ITEM_ARROW_FIRE || INV_CONTENT(ITEM_ARROW_ICE) == ITEM_ARROW_ICE ||
INV_CONTENT(ITEM_ARROW_LIGHT) == ITEM_ARROW_LIGHT);
}
Expand Down Expand Up @@ -136,7 +190,7 @@ static void UpdateEquippedBow(PlayState* play, s8 arrowType) {
}
}

bool ArrowCycleMain() {
extern "C" bool ArrowCycleMain(void) {
if (gPlayState == nullptr || !CanCycleArrows()) {
return false;
}
Expand All @@ -152,7 +206,15 @@ bool ArrowCycleMain() {
// reset magic state to IDLE before cycling to prevent error sound
gSaveContext.magicState = MAGIC_STATE_IDLE;

s8 nextArrow = GetNextArrowType(player->heldItemAction);
EnArrow* enArrow = (EnArrow*)player->heldActor;
const bool mounted = (player->stateFlags1 & PLAYER_STATE1_ON_HORSE) != 0;
s8 nextArrow = GetNextArrowType(mounted ? GetItemActionForArrow(enArrow, player) : player->heldItemAction);

if (mounted) {
ChangeMountedArrowType(enArrow, (PlayerItemAction)nextArrow);
return true;
}

player->heldItemAction = nextArrow;
player->itemAction = nextArrow;
Actor* arrow = player->heldActor;
Expand All @@ -170,11 +232,12 @@ bool ArrowCycleMain() {
}

void RegisterArrowCycle() {
COND_HOOK(OnPlayDrawEnd, CVAR_VR_ARROW_CYCLE_VALUE, FlushMountedBowIcon);
// suppress shield input when R is held while aiming to allow arrow cycling
COND_VB_SHOULD(VB_EXECUTE_PLAYER_ACTION_FUNC, CVAR_ARROW_CYCLE_VALUE, {
COND_VB_SHOULD(VB_EXECUTE_PLAYER_ACTION_FUNC, CVAR_ARROW_CYCLE_VALUE || CVAR_VR_ARROW_CYCLE_VALUE, {
Player* player = (Player*)va_arg(args, void*);
Input* input = (Input*)va_arg(args, void*);
if (IsAimingBow(player) && CHECK_BTN_ANY(input->press.button, BTN_R)) {
if (CVAR_ARROW_CYCLE_VALUE && IsAimingBow(player) && CHECK_BTN_ANY(input->press.button, BTN_R)) {
if (ArrowCycleMain()) {
input->cur.button &= ~BTN_R;
input->press.button &= ~BTN_R;
Expand All @@ -183,7 +246,7 @@ void RegisterArrowCycle() {
});

// don't consume magic on draw, but check if we have enough to fire
COND_VB_SHOULD(VB_PLAYER_ARROW_MAGIC_CONSUMPTION, CVAR_ARROW_CYCLE_VALUE, {
COND_VB_SHOULD(VB_PLAYER_ARROW_MAGIC_CONSUMPTION, CVAR_ARROW_CYCLE_VALUE || CVAR_VR_ARROW_CYCLE_VALUE, {
Player* player = va_arg(args, Player*);
int32_t magicArrowType = va_arg(args, int32_t);
int32_t* arrowType = va_arg(args, int32_t*);
Expand All @@ -195,7 +258,7 @@ void RegisterArrowCycle() {
}
});

COND_VB_SHOULD(VB_EN_ARROW_MAGIC_CONSUMPTION, CVAR_ARROW_CYCLE_VALUE, {
COND_VB_SHOULD(VB_EN_ARROW_MAGIC_CONSUMPTION, CVAR_ARROW_CYCLE_VALUE || CVAR_VR_ARROW_CYCLE_VALUE, {
EnArrow* arrow = va_arg(args, EnArrow*);

if (arrow->actor.params < ARROW_FIRE || arrow->actor.params > ARROW_LIGHT) {
Expand All @@ -207,4 +270,4 @@ void RegisterArrowCycle() {
});
}

static RegisterShipInitFunc initFunc(RegisterArrowCycle, { CVAR_ARROW_CYCLE_NAME });
static RegisterShipInitFunc initFunc(RegisterArrowCycle, { CVAR_ARROW_CYCLE_NAME, "gVrBowTriggerArrowCycle" });
Loading