Fix model rendering stutter: eliminate dummy D3D9 device, defer vtable hooks

The dummy device technique (Direct3DCreate9 + CreateDevice) corrupted the
d3d9 proxy's internal state when run on the main rendering thread, causing
model rendering to update at ~10fps while camera remained smooth.

Replace dummy device with direct vtable read from the game's existing
device via GxDevice global (0xC0ED38 + 0x38A8), sourced from UnitXP_SP3.

Also defer D3D9 hook installation until first rendered frame (triggered
from renderDrawDetour) to guarantee the device exists, and add
forceD24S8IfNeeded() in EndScene to force a Reset with D24S8 stencil
format since the deferred install misses the initial device Reset.

Other changes carried from prior session:
- model_hook.zig: native thiscall/naked detours (thunks eliminated)
- tracker.zig: tracked_obj_count made pub
This commit is contained in:
MarcelineVQ
2026-02-24 02:28:13 -08:00
parent 0278097034
commit 3ec7796cc1
4 changed files with 173 additions and 102 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ const TrackedObj = struct {
};
var tracked_objs: [MAX_TRACKED_OBJS]TrackedObj = undefined;
var tracked_obj_count: usize = 0;
pub var tracked_obj_count: usize = 0;
// All unit/player object pointers for stencil occlusion detection.
var unit_obj_ptrs: [MAX_UNIT_OBJS]u32 = .{0} ** MAX_UNIT_OBJS;