From 4ee3c458bf7e8d96315a206687780faa6eb1ddbe Mon Sep 17 00:00:00 2001 From: mchughalex <25671999+mchughalex@users.noreply.github.com> Date: Sun, 19 Jul 2026 09:25:26 +0100 Subject: [PATCH] render: remove the shadow-mat observers and other dead diagnostics --- CMakeLists.txt | 1 - src/native/skate3_native_guest_read.cpp | 70 ++----------------------- src/native/skate3_native_guest_read.h | 17 ++---- src/skate3_native_render.cpp | 44 ---------------- src/skate3_native_scene.cpp | 8 ++- 5 files changed, 10 insertions(+), 130 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6718cd..203e3e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,7 +232,6 @@ set(SKATE3_COMMON_SOURCES src/native/skate3_native_guest_read.cpp src/native/skate3_native_lw.cpp src/native/skate3_native_v3_shadow.cpp - src/native/skate3_native_v3_shadow_mat.cpp src/skate3_native_debug_dialog.cpp src/skate3_native_render.cpp src/skate3_native_scene.cpp diff --git a/src/native/skate3_native_guest_read.cpp b/src/native/skate3_native_guest_read.cpp index 4fa5858..66d5949 100644 --- a/src/native/skate3_native_guest_read.cpp +++ b/src/native/skate3_native_guest_read.cpp @@ -1,6 +1,4 @@ // Shared sample-vertex decode + skin + spread helpers (see the header). -// Extracted verbatim from the five open-coded copies in -// skate3_native_scene.cpp, behavior-preserving. #include "native/skate3_native_guest_read.h" @@ -24,9 +22,9 @@ namespace skate3::native_scene { -// Lock-free guarded bulk copy for reads of guest payloads (moved verbatim -// from skate3_native_scene.cpp so every TU shares the one -// correctly-built guard). GuestRangeReadable's VirtualQuery loop takes the +// Lock-free guarded bulk copy for reads of guest payloads (shared here so +// every TU uses the one correctly-built guard). GuestRangeReadable's +// VirtualQuery loop takes the // process VAD lock, which the guest streaming threads hammer exactly while // panning streams the world in; every render-thread decode then queues // behind them (multi-ms stalls; same lock as the 3 fps PERF TRAP). An @@ -204,68 +202,6 @@ bool ReadSkinSamplesGuest(uint8_t* base, const DrawItem& item, uint32_t n, return true; } -int ReadSkinSamplesRaw(const uint8_t* vb, size_t vb_size, const DrawItem& item, - uint32_t n, SkinSampleVert* out) { - if (item.stride == 0) { - return -1; - } - const uint32_t count = item.vb_bytes / item.stride; - if (count < 2 || n < 2) { - return -1; - } - for (uint32_t s = 0; s < n; ++s) { - const uint32_t v = (s * (count - 1) / (n - 1)) * item.stride; - if (uint64_t(v) + item.stride > vb_size) { - return int(s); // short read: caller treats as nothing-to-judge - } - const uint8_t* vp = vb + v; - SkinSampleVert& sv = out[s]; - float* p = sv.p; - // Guest payload copied raw = big-endian attributes. - switch (item.pos_fmt) { - case 57: - for (int a = 0; a < 3; ++a) { - const uint8_t* b = vp + item.pos_offset + a * 4; - const uint32_t w = uint32_t(b[0]) << 24 | uint32_t(b[1]) << 16 | - uint32_t(b[2]) << 8 | b[3]; - p[a] = std::bit_cast(w); - } - break; - case 32: - for (int a = 0; a < 3; ++a) { - const uint8_t* b = vp + item.pos_offset + a * 2; - p[a] = GuestHalfToFloat(uint16_t(uint16_t(b[0]) << 8 | b[1])); - } - break; - case 26: { - constexpr float kScale = 2.0f / 32767.0f; - for (int a = 0; a < 3; ++a) { - const uint8_t* b = vp + item.pos_offset + a * 2; - p[a] = int16_t(uint16_t(b[0]) << 8 | b[1]) * kScale + (a == 1 ? 0.8f : 0.0f); - } - break; - } - default: - return -1; - } - sv.pos_finite = PosFinite(p); - if (item.bw_offset != 0 && item.bi_offset != 0) { - // Component k = guest byte k (matches the live path's - // byte-(24-8k)-of-host-load convention). - const uint8_t* bw = vp + item.bw_offset; - const uint8_t* bi = vp + item.bi_offset; - for (int k = 0; k < 4; ++k) { - sv.w[k] = bw[k]; - sv.bone[k] = bi[k]; - } - } else { - std::memset(sv.w, 0, sizeof(sv.w)); - std::memset(sv.bone, 0, sizeof(sv.bone)); - } - } - return int(n); -} - uint32_t SkinPointHostRows(const SkinSampleVert& sv, const float* rows, size_t rows_floats, float q[3]) { uint32_t total = 0; diff --git a/src/native/skate3_native_guest_read.h b/src/native/skate3_native_guest_read.h index 3a7b0ca..52f23af 100644 --- a/src/native/skate3_native_guest_read.h +++ b/src/native/skate3_native_guest_read.h @@ -1,16 +1,15 @@ #pragma once // Shared sample-vertex decode + skin + spread helpers for the native scene -// renderer: the ONE copy of the decode+skin loop that was open-coded five -// times (RefinePaletteBase, ScoreRigidAffine, RopaPayloadCoherent, +// renderer: the one copy of the decode+skin loop shared by the palette and +// coherence gates (RefinePaletteBase, ScoreRigidAffine, RopaPayloadCoherent, // PublishedPaletteSane, the InterpolateDynamicItems centroid pass). // -// Decode conventions unified here (verified against the original sites): +// Decode conventions unified here: // - guest u8x4 blend attribs are big-endian per 32-bit word: influence k is // guest byte k, i.e. byte (24 - 8k) of the host-order load; // - position fmt 57 = float3, 32 = half4 (xyz), 26 = s16x4 with scale -// 2/32767 and the +0.8 Y bias; -// - a raw copied payload holds the same guest bytes (big-endian). +// 2/32767 and the +0.8 Y bias. #include #include @@ -54,14 +53,6 @@ bool ReadSkinVertGuest(uint8_t* base, const DrawItem& item, uint32_t vtx, bool ReadSkinSamplesGuest(uint8_t* base, const DrawItem& item, uint32_t n, SkinSampleVert* out); -// Same sampling from a COPIED raw payload (big-endian guest bytes). Sample -// addressing uses the item's stride/count (item.vb_bytes), bounds-checked -// against the copy: returns the number of samples decoded before the first -// out-of-bounds sample (callers treat a short read as "nothing to judge"), -// or -1 when the position format is unsupported / count < 2. -int ReadSkinSamplesRaw(const uint8_t* vb, size_t vb_size, const DrawItem& item, - uint32_t n, SkinSampleVert* out); - // Weighted [R | t] skin with HOST palette rows (DrawItem::bones layout: // 3 float4 rows per bone, column-vector affine). Influences whose rows fall // outside the palette are skipped. Returns the total u8 weight (0 = nothing diff --git a/src/skate3_native_render.cpp b/src/skate3_native_render.cpp index 014f5aa..23b420d 100644 --- a/src/skate3_native_render.cpp +++ b/src/skate3_native_render.cpp @@ -526,9 +526,6 @@ void OnFrameEnd(uint8_t* base) { } } } - // The synthetic camera pan probe (judder isolation) is cvar/debug-dialog - // only: skate3_native_render_scene_synthetic_pan. Its P hotkey was removed - // - a bare letter key fired constantly during normal play. // F11: paired A/B parity capture; one keypress produces // shot__native.png + shot__emulated.png (same viewpoint, ~half a // second apart while the renderer toggles) + an immediate F10-style @@ -1113,22 +1110,6 @@ extern "C" REX_FUNC(sub_82B7A970) { } } -// Fourth SetPending_AluConstants caller (symbol mislabeled as -// D3DQuery_GetData: it stages draw constants, so it is a draw variant; -// never observed firing in gameplay). Hooked so the draw-sequence counter -// and recording stay complete if it ever does. -extern "C" REX_FUNC(sub_82B7A458) { - const bool enabled = skate3::native_render::Enabled(); - const uint32_t r4 = ctx.r4.u32; - const uint32_t r5 = ctx.r5.u32; - const uint32_t r6 = ctx.r6.u32; - const uint32_t r7 = ctx.r7.u32; - __imp__sub_82B7A458(ctx, base); - if (enabled) { - skate3::native_scene::OnDrawDone(base, 3, r4, r5, r6, r7); - } -} - // ---- 2D / APT (Flash-converted HUD) reconnaissance hooks ----------------- // Every HUD/menu 2D element is a Flash SWF converted to EA APT, rendered by // Sk8::FE::AptRenderingIntegration through the same guest D3D draw functions @@ -1254,31 +1235,6 @@ extern "C" REX_FUNC(sub_82B79FC0) { } } -// ---- v3 shadow-mat reader hooks (observers only; see -// native/skate3_native_v3_shadow_mat.h). Declared here instead of including -// the header so this section is a pure append. - -namespace skate3::native_v3_mat { -void OnConstantTable(uint8_t* base, uint32_t table, uint32_t count); -} // namespace skate3::native_v3_mat - -// renderengine::ProgramBuffer::Xbox2CreateConstantTable: builds a shader's -// 8-byte {name, register, dataType, numConstants} record array. Register -// conventions VERIFIED in generated/skate3_recomp.60.cpp:37720: ENTRY r3 = -// shader-blob holder (+16 = CTAB rel offset), r4 = destination record array -// (NULL on the sizing pass: the Initialize caller at .60.cpp:38221 passes -// ProgramBuffer + *(u32*)(PB+8) + 20 on the fill pass and stores the return -// count at PB+4), r5 = out name-bytes; EXIT r3 = record count. Firing once -// per shader table as it is built gives the reflect reader every table with -// no ProgramBuffer back-pointer needed. -extern "C" REX_FUNC(sub_82A77EA0) { - const uint32_t table = ctx.r4.u32; - __imp__sub_82A77EA0(ctx, base); - if (skate3::native_render::Enabled()) { - skate3::native_v3_mat::OnConstantTable(base, table, ctx.r3.u32); - } -} - // LivingWorld batch pack writer (unnamed; called per entity per sim tick // from the tail of cLivingWorldPresEntityManager::Update), the LOD- // pedestrian skinning-palette source: fused UpdateBoneTransforms+Pack writing the diff --git a/src/skate3_native_scene.cpp b/src/skate3_native_scene.cpp index 91a387a..078af00 100644 --- a/src/skate3_native_scene.cpp +++ b/src/skate3_native_scene.cpp @@ -35,7 +35,6 @@ #include "native/skate3_native_guest_read.h" #include "native/skate3_native_lw.h" #include "native/skate3_native_v3_shadow.h" -#include "native/skate3_native_v3_shadow_mat.h" // Offline-compiled SPIR-V for the native shaders (compiled from the HLSL // sources with DXC): the Vulkan RHI backend consumes these blobs; the D3D12 // backend runtime-compiles the embedded HLSL as before. @@ -9654,13 +9653,12 @@ void BuildFrameScene(uint8_t* base, const SubmitRecord* records, size_t count) { g_frame_draw_fetch.clear(); } - // v3 tail: shadow-mode compares (Phase 2 observers) and the shadow-mat - // readers. Timed as one block (`v3=` in the perf line); this tail is on - // the guest render thread, and its spikes were the pan stutter. + // Frame tail: rotate the bone-palette snapshot ring (and run its optional + // shadow-mode compares). Timed as its own block in the perf line; this + // tail runs on the guest render thread, where spikes are visible stutter. { const auto v3_t0 = PerfClock::now(); skate3::native_v3::OnFrameBuilt(base, records, count, scene); - skate3::native_v3_mat::OnFrameBuilt(base, records, count, scene); g_frame_v3_ns = uint64_t(std::chrono::duration_cast( PerfClock::now() - v3_t0) .count());