Skip to content

NFSU2 Revived v0.15.21

Choose a tag to compare

@mininxd mininxd released this 10 Nov 12:44
· 33 commits to main since this release

What's Changed in v0.15.21

D3D9 Bridge & DXVK Enhancements

  • Tile-Based Architecture MSAA Clamping: Clamped backbuffer multisample types (D3DMULTISAMPLE_NONE) and multisample quality levels to zero in both device creation and presentation layers. Eliminates mobile GPU Universal Bandwidth Compression (UBWC) decompression failures on Adreno architectures:
    // Disable MSAA on swapchain and device surfaces to prevent UBWC decompress corruption
    if (d3d9Presentation.MultiSampleType != D3DMULTISAMPLE_NONE) {
        d3d9Presentation.MultiSampleType = D3DMULTISAMPLE_NONE;
        d3d9Presentation.MultiSampleQuality = 0;
    }
  • Dynamic DXVK Configuration Tuning: Added auto-configured dxvk.conf profiles with d3d9.forceSwapchainMSAA = False and dxvk.enableMemoryDefrag = False, ensuring high-resolution backbuffers remain stable across varying driver implementations:
    // Generate optimized dxvk.conf for mobile Adreno and tile-based GPUs
    lines.push("d3d9.forceSwapchainMSAA = False".to_string());
    lines.push("dxvk.enableMemoryDefrag = False".to_string());
    lines.push("d3d9.maxFrameLatency = 1".to_string());
    lines.push("d3d9.deferSurfaceCreation = True".to_string());
  • Device MultiSample Surface Safety: CheckDeviceMultiSampleType safely returns D3DERR_NOTAVAILABLE, preventing the game from reconfiguring backbuffers and render targets into incompatible multi-sample resolve states:
    case 11: { // CheckDeviceMultiSampleType
        *argumentCount = 6;
        if (args[5]) write(args[5], 0);
        return D3DERR_NOTAVAILABLE;
    }

Rain Splatter & Weather Effects Fix

  • Viewport & Sampler State Synchronization: Restructured D3D9 viewport filtering so that full-screen post-processing blits and rain droplet render passes always synchronize properly with DXVK viewports:
    // Guarantee zero-drop viewport forwarding for full-screen rain and post-passes
    pub fn should_filter_viewport(&self, _vp: &[u32; 6]) -> bool {
        false // Always forward to DXVK so render targets never desynchronize
    }
  • Render Target State Invalidation: Automatically invalidates sampler and texture stage states upon SetRenderTarget and StretchRect calls, eliminating checkered artifacts, horizontal scanline noise, and screen distortion during rain splatter and wet weather conditions (Fixes #67):
    // Invalidate sampler and texture stage states on render target changes
    pub fn notify_render_target_change(&self, rt_handle: u32) {
        if let Ok(mut state) = self.state.lock() {
            state.active_rt = rt_handle;
            state.ss_valid = false;
            state.tss_valid = false;
            state.tex_valid.fill(false);
            state.viewport_valid = false;
        }
    }
  • Transient State Reset: Added graceful rain splatter filter state resets on device presentation and cooperative level restoration:
    case 16: { // Reset
        static auto s_rs_reset = reinterpret_cast<void(*)()>(dlsym(RTLD_DEFAULT, "nfs_rain_splatter_reset"));
        if (s_rs_reset) s_rs_reset();
        ...
    }

Dynamic Forward-Only Camera Back-Culling Engine

  • Zero-Cost Backward Geometry Elimination: Evaluates 3D world geometry and draw calls against the active player camera in pure Rust (camera_cull.rs in graphics_cache). Draw calls located in the backward half-space behind the camera plane or beyond the draw distance horizon are rejected before submission:
    // Back-Cull Check: Discard draw calls strictly behind player camera plane
    let fwd_distance = (wx - cx) * fx + (wy - cy) * fy + (wz - cz) * fz;
    if fwd_distance < -margin {
        self.culled_draws.fetch_add(1, Ordering::Relaxed);
        return true; // Culled
    }
    // Far Horizon Check: Discard draw calls beyond active draw distance
    if far_dist > 0.0 && fwd_distance > (far_dist + margin) {
        self.culled_draws.fetch_add(1, Ordering::Relaxed);
        return true; // Culled
    }
  • Screen-Space & HUD Protection: Preserves 2D screen-space transformed primitives (UI, HUD, minimap, tachometer) and orthographic projection passes from culling.
  • Overdraw & Vertex Load Reduction: Significantly reduces vertex shading, triangle rasterization, and overdraw on mobile GPUs by eliminating occluded geometry behind the player's vehicle.

Full Changelog: v0.15.20...v0.15.21