Skip to content

Commit 9e343b6

Browse files
committed
Allow stereo rendering patches to run without DLL for debugging
Due to RenderDoc and Nsight Graphics not really being compatible with large .DLL projects like BetterVR, you normally aren't able to use a graphical debugger to debug issues like shadows for example. With these changes, you can make a lite version of the mod that does all the stereo rendering things, but without the DLL, allowing a developer to still use RenderDoc to debug certain issues that just simply are way easier when you can see the intermediary drawing results of the game. To use this lite version, you need to copy these files into a separate graphic pack (or symlink them): - patch_PatchUtils.asm - patch_RND_Logging.asm - patch_RND_StereoRendering.asm - patch_RND_StereoRendering_ActorJobs.asm - patch_RND_StereoRendering_CameraAndProjection.asm - patch_STUB_StereoRenderingDebugging.asm - and of course a rules.txt file, but you should probably modify it. Then, if you switch the "useStubHooks" value from .int 0 to .int 1, you'll be able to go in-game with the appropriate performance impact that VR will have. The goal definitely isn't to make ALL patches run without VR, just enough that I can debug stereo rendering issues or issues related to the camera modifications and projection matrices used for VR.
1 parent 18ba775 commit 9e343b6

File tree

2 files changed

+133
-27
lines changed

2 files changed

+133
-27
lines changed

resources/BreathOfTheWild_BetterVR/patch_RND_StereoRendering_ActorJobs.asm

Lines changed: 100 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ moduleMatches = 0x6267BFD0
33

44
.origin = codecave
55

6-
7-
8-
9-
106
0x037A6EC4 = real_actor_job1_1:
117
0x101E5FFC = Player_vtable:
128

@@ -496,6 +492,29 @@ scopedDeltaSetter_float2:
496492
strActor_job0_1:
497493
.string "job0_1"
498494

495+
stub_routeActorJob_job0_1:
496+
li r6, 0
497+
cmpwi r5, 0
498+
bne exit_stub_routeActorJob_job0_1
499+
lwz r11, 0xE8(r3)
500+
lis r10, Player_vtable@ha
501+
addi r10, r10, Player_vtable@l
502+
cmpw r11, r10
503+
li r6, 1
504+
bne exit_stub_routeActorJob_job0_1
505+
li r6, 2
506+
507+
exit_stub_routeActorJob_job0_1:
508+
mr r3, r6
509+
blr
510+
511+
stub_routeActorJob_skipRight:
512+
li r3, 0
513+
cmpwi r5, 1
514+
bnelr
515+
li r3, 1
516+
blr
517+
499518
hook_actor_job0_1:
500519
mflr r0
501520
stwu r1, -0x20(r1)
@@ -510,7 +529,17 @@ lis r4, strActor_job0_1@ha
510529
addi r4, r4, strActor_job0_1@l
511530
lis r5, currentEyeSide@ha
512531
lwz r5, currentEyeSide@l(r5)
513-
bl import.coreinit.hook_RouteActorJob
532+
lis r12, useStubHooks@ha
533+
lwz r12, useStubHooks@l(r12)
534+
cmpwi r12, 1
535+
lis r12, stub_routeActorJob_job0_1@ha
536+
addi r12, r12, stub_routeActorJob_job0_1@l
537+
beq routeActorJob_job0_1
538+
lis r12, import.coreinit.hook_RouteActorJob@ha
539+
addi r12, r12, import.coreinit.hook_RouteActorJob@l
540+
routeActorJob_job0_1:
541+
mtctr r12
542+
bctrl
514543

515544
cmpwi r3, 0
516545
beq job0_1_normal
@@ -605,7 +634,17 @@ lis r4, strActor_job0_2@ha
605634
addi r4, r4, strActor_job0_2@l
606635
lis r5, currentEyeSide@ha
607636
lwz r5, currentEyeSide@l(r5)
608-
bl import.coreinit.hook_RouteActorJob
637+
lis r12, useStubHooks@ha
638+
lwz r12, useStubHooks@l(r12)
639+
cmpwi r12, 1
640+
lis r12, stub_routeActorJob_skipRight@ha
641+
addi r12, r12, stub_routeActorJob_skipRight@l
642+
beq routeActorJob_job0_2
643+
lis r12, import.coreinit.hook_RouteActorJob@ha
644+
addi r12, r12, import.coreinit.hook_RouteActorJob@l
645+
routeActorJob_job0_2:
646+
mtctr r12
647+
bctrl
609648

610649
cmpwi r3, 1
611650
beq finish_hook_actor_job0_2
@@ -648,7 +687,17 @@ lis r4, strActor_job1_1@ha
648687
addi r4, r4, strActor_job1_1@l
649688
lis r5, currentEyeSide@ha
650689
lwz r5, currentEyeSide@l(r5)
651-
bl import.coreinit.hook_RouteActorJob
690+
lis r12, useStubHooks@ha
691+
lwz r12, useStubHooks@l(r12)
692+
cmpwi r12, 1
693+
lis r12, stub_routeActorJob_skipRight@ha
694+
addi r12, r12, stub_routeActorJob_skipRight@l
695+
beq routeActorJob_job1_1
696+
lis r12, import.coreinit.hook_RouteActorJob@ha
697+
addi r12, r12, import.coreinit.hook_RouteActorJob@l
698+
routeActorJob_job1_1:
699+
mtctr r12
700+
bctrl
652701

653702
cmpwi r3, 1
654703
beq finish_hook_actor_job1_1
@@ -694,7 +743,17 @@ lis r4, strActor_job1_2@ha
694743
addi r4, r4, strActor_job1_2@l
695744
lis r5, currentEyeSide@ha
696745
lwz r5, currentEyeSide@l(r5)
697-
bl import.coreinit.hook_RouteActorJob
746+
lis r12, useStubHooks@ha
747+
lwz r12, useStubHooks@l(r12)
748+
cmpwi r12, 1
749+
lis r12, stub_routeActorJob_skipRight@ha
750+
addi r12, r12, stub_routeActorJob_skipRight@l
751+
beq routeActorJob_job1_2
752+
lis r12, import.coreinit.hook_RouteActorJob@ha
753+
addi r12, r12, import.coreinit.hook_RouteActorJob@l
754+
routeActorJob_job1_2:
755+
mtctr r12
756+
bctrl
698757

699758
cmpwi r3, 1
700759
beq finish_hook_actor_job1_2
@@ -739,7 +798,17 @@ lis r4, strActor_job2_1@ha
739798
addi r4, r4, strActor_job2_1@l
740799
lis r5, currentEyeSide@ha
741800
lwz r5, currentEyeSide@l(r5)
742-
bl import.coreinit.hook_RouteActorJob
801+
lis r12, useStubHooks@ha
802+
lwz r12, useStubHooks@l(r12)
803+
cmpwi r12, 1
804+
lis r12, stub_routeActorJob_skipRight@ha
805+
addi r12, r12, stub_routeActorJob_skipRight@l
806+
beq routeActorJob_job2_1
807+
lis r12, import.coreinit.hook_RouteActorJob@ha
808+
addi r12, r12, import.coreinit.hook_RouteActorJob@l
809+
routeActorJob_job2_1:
810+
mtctr r12
811+
bctrl
743812

744813
cmpwi r3, 1
745814
beq finish_hook_actor_job2_1
@@ -784,7 +853,17 @@ lis r4, strActor_job2_2@ha
784853
addi r4, r4, strActor_job2_2@l
785854
lis r5, currentEyeSide@ha
786855
lwz r5, currentEyeSide@l(r5)
787-
bl import.coreinit.hook_RouteActorJob
856+
lis r12, useStubHooks@ha
857+
lwz r12, useStubHooks@l(r12)
858+
cmpwi r12, 1
859+
lis r12, stub_routeActorJob_skipRight@ha
860+
addi r12, r12, stub_routeActorJob_skipRight@l
861+
beq routeActorJob_job2_2
862+
lis r12, import.coreinit.hook_RouteActorJob@ha
863+
addi r12, r12, import.coreinit.hook_RouteActorJob@l
864+
routeActorJob_job2_2:
865+
mtctr r12
866+
bctrl
788867

789868
cmpwi r3, 1
790869
beq finish_hook_actor_job2_2
@@ -829,7 +908,17 @@ lis r4, strActor_job4@ha
829908
addi r4, r4, strActor_job4@l
830909
lis r5, currentEyeSide@ha
831910
lwz r5, currentEyeSide@l(r5)
832-
bl import.coreinit.hook_RouteActorJob
911+
lis r12, useStubHooks@ha
912+
lwz r12, useStubHooks@l(r12)
913+
cmpwi r12, 1
914+
lis r12, stub_routeActorJob_skipRight@ha
915+
addi r12, r12, stub_routeActorJob_skipRight@l
916+
beq routeActorJob_job4
917+
lis r12, import.coreinit.hook_RouteActorJob@ha
918+
addi r12, r12, import.coreinit.hook_RouteActorJob@l
919+
routeActorJob_job4:
920+
mtctr r12
921+
bctrl
833922

834923
cmpwi r3, 1
835924
beq finish_hook_actor_job4

resources/BreathOfTheWild_BetterVR/patch_STUB_StereoRenderingDebugging.asm

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,67 @@ useStubHooks:
88

99
const_cameraHeightChange:
1010
.float 0.5
11+
.float -0.5
12+
; shouldn't use this, but we might upgrade to a bigger frame counter
13+
.float 0.5
14+
.float -0.5
1115

16+
; r3 = layer->renderCamera
17+
; r11 = currentEyeSide
18+
; r12 = modifiedCopy_seadLookAtCamera
1219
stub_hook_GetRenderCamera:
13-
;blr
14-
lis r11, currentEyeSide@ha
15-
lwz r11, currentEyeSide@l(r11)
1620
cmpwi r11, 0
1721
beqlr ; don't modify right eye
1822

23+
24+
lis r12, currentFrameCounter@ha
25+
lwz r12, currentFrameCounter@l(r12)
26+
cmpwi r12, 0
27+
; camera.pos.y += 0.5 or -0.5 depending on the frame
28+
lis r11, const_cameraHeightChange@ha
29+
addi r11, r11, const_cameraHeightChange@l
30+
beq .+0x08
31+
addi r12, r12, 1
32+
lfs f12, 0(r11)
33+
34+
1935
; camera->pos.y += 2.0;
2036
lfs f12, 0x34+0x04(r3)
21-
lis r11, const_cameraHeightChange@ha
22-
lfs f13, const_cameraHeightChange@l(r11)
23-
;fadd f13, f13, f12
24-
stfs f13, 0x34+0x04(r3)
37+
fadds f12, f12, f13
38+
stfs f12, 0x34+0x04(r3)
2539
; camera->at.y += 2.0;
2640
lfs f12, 0x40+0x04(r3)
27-
lis r11, const_cameraHeightChange@ha
28-
lfs f13, const_cameraHeightChange@l(r11)
29-
;fadd f13, f13, f12
30-
stfs f13, 0x40+0x04(r3)
41+
fadds f12, f12, f13
42+
stfs f12, 0x40+0x04(r3)
3143
; camera->mtx.pos_y += 2.0;
3244
lfs f12, 0x1C(r3)
33-
lis r11, const_cameraHeightChange@ha
34-
lfs f13, const_cameraHeightChange@l(r11)
35-
;fadd f13, f13, f12
36-
stfs f13, 0x1C(r3)
45+
fadds f12, f12, f13
46+
stfs f12, 0x1C(r3)
3747

3848
blr
3949

4050

4151
example_PerspectiveProjectionMatrix:
4252
.byte 1,1,0,0
43-
.int 0x3F9A678C
53+
; matrix
4454
.float 0.9300732,-107374176,-107374176,-107374176
4555
.float -107374176,0.86867154,-107374176,-107374176
4656
.float 0.06992682,-0.0352425,-1.000008,-1
4757
.float -107374176,-107374176,-0.2000008,0
58+
; deviceMatrix
4859
.float 0.9300732,-107374176,-107374176,-107374176
4960
.float -107374176,0.86867154,-107374176,-107374176
5061
.float 0.06992682,-0.0352425,-1.000008,-1
5162
.float -107374176,-107374176,-0.2000008,0
63+
; devicePosture
64+
.int 0
65+
; deviceZScale
5266
.float 1
67+
; deviceZOffset
5368
.float 0
69+
; lookAt vtable
5470
.int 0x1027B54C
71+
; near, far and fov
5572
.float 0.1
5673
.float 25000
5774
.float 1.7104228

0 commit comments

Comments
 (0)