# DriveClub Recomp 0.2.5

**DriveClub for PS4 (version 1.28), running natively on Windows.**

The source code is in this repository.

## Highlights of 0.2.0

### DLSS and FSR anti-aliasing
The game's own anti-aliasing is replaced by a modern one, chosen in the launcher:
- **NVIDIA DLAA** (GeForce RTX): the sharpest and steadiest picture, with thin lines, wires, fences and foliage held cleanly.
- **AMD FSR 3.1** (any graphics card): the same idea on every GPU, no special hardware needed.

Both use the game's own camera motion, run at the native resolution, and can be compared live in the game: **F9** switches between the new anti-aliasing and the game's own, **F10** switches between FSR and DLSS on RTX cards. The overlay shows what is active. Leave the "Disable motion blur and depth of field" patch off, they do not work together.

### Also new
Intel processor support, a language choice with all 21 languages, a launcher that fits every screen, one-folder 1.28 dumps, and a fix for a crash in long races. Details below.

## Changelog

### 0.2.5
- **New: steering wheel support.** Any wheel Windows lists as a game controller works: the game sees a PS4 wheel, with force feedback and an H-pattern shifter. Run `WheelSetup.exe` once next to `DriveClub.exe`: it asks you to turn the wheel, press each pedal and button and put the shifter in each gear, and writes `default.ini`. Set the rotation in the wheel's own software and give `WheelSetup.exe` the same number. `wheel_ffb_gain` and `wheel_ffb_vibration` make the forces and the road vibrations stronger or weaker (100 is as the game sends them, up to 2000; the game's steering forces are light on most wheels, so a few hundred is normal), `wheel_ffb_invert = true` turns them around if the wheel pulls the wrong way and `wheel_ffb = off` drops back to a wheel without forces. `FfbTest.exe` plays single forces on the wheel without the game, to check the directions. Contributed by @igorexa225 in #77, with the gain corrected for wheels set to inverted in #92.
- **New: a benchmark in the launcher.** The Benchmark tab picks a circuit, a car, the time of day, the weather and the rain, boots straight into the event, lets the game's own AI drive and reports the average frame rate with the 1% and 0.1% lows, the worst frames and the load time. It ends by itself, and the last result stays on the card. Without the window: `DriveClub.exe --play` with `BB_BENCHMARK` set. Contributed by @MoonFuji in #87.
- **Fixed: the game closing when the graphics card runs out of memory** ("vk::Result=ErrorOutOfDeviceMemory"; #80 on a 4 GB card, #83 on a 6 GB one, #86). Buffer data now moves to system memory when the card's own memory is full and the game keeps running at a lower frame rate instead of ending. The log says once: "the card's memory is full, buffer data goes to system memory".
- **Fixed: a crash when leaving a race** (#88, stormy weather in Scotland). Two surfaces shared one address and the case none of the rules could handle stopped the port. The old image is now dropped and the game makes a new one, as it already did in the other address-reuse cases.
- **Fixed: a grid of tiles, and white specks that grew through a race** (#61, #75). Some surfaces were switched between their depth and colour form and the pixels were never moved, so the new surface was shown unwritten. It is now filled from the game's own memory, and the game's own copy is no longer skipped.
- **Fixed: replays were never listed** (#62). The files were on disk; the directory listing call the game uses was missing from the runtime, so it always answered "no entries".
- **Changed: AMD and Intel "device lost" crashes** (#90, #93, #89, #84, #79, #74, #72, #66, #63, #60, #58, #65, #16). Every one of those logs ends the same way: the card reports reading a page-aligned GPU address that was never bound, in the same band of memory across twelve different machines, and the port then stops itself. The blocks just before and just after each buffer are now bound to one page of zeros, so a read that steps past the end of a buffer returns zeros the way it already does on NVIDIA. This is the largest group of crash reports and it cannot be tested on the hardware here, so the log now prints "GPU: guard page for buffers that are read past the end: on/off" and a report from an AMD player either way is worth having.
- **Changed: a surface that switches between its depth and colour form is switched in place** instead of being destroyed and rebuilt each time, which is quicker and keeps the game's own description of it (tiling, mip layout, metadata). Contributed by @MoonFuji in #70.
- **Changed: frame pacing.** Frames are released with a minimum spacing by default, which removes the alternating 16 and 33 ms frames that shook the camera in some setups. `BB_PACE_CREDIT` says how far a release may come early. Contributed by @MoonFuji in #68.
- **New: the launcher keeps programs that add themselves to the game's graphics out of the game** (Steam, Epic, Discord, OBS, tuning tools). Two of the crash reports had such a program loaded inside the game process. "Let overlay programs into the game" in the launcher puts them back if you want the in-game overlay.
- **Changed: the launcher is split into three tabs**, Graphics, Gameplay and Benchmark, and the settings that belong to a page stay on it. Wider windows still reflow the cards into more columns, and the game folders card now takes a column of its own when there are three or four.
- **New: "Start the game without this window"** in the launcher. Double-clicking `DriveClub.exe` goes straight to the game; when it cannot start, the window opens with the reason. (#82)
- **New: ultrawide 32:10 3440x1080 and 21:9 5120x2160** in the Widescreen choice, both already patchable and not offered before. (#30)
- **Changed: the resolution rows say what is scaled to what**, and the game log writes one whole line at a time. Lines from different threads used to arrive spliced into each other, which made most reports impossible to read.
- **Fixed: a freeze at boot when the GPU profiler was on.** It waited for the timing queries instead of the submission. Contributed by @MoonFuji in #69.

### 0.2.4
- **Fixed: the freeze when a career event starts** (Cayoosh Trials and other time trials, #23, #24, #49, #53, and the same reports on Quiver). The game takes a read lock it already holds while another thread waits for the write lock. The system lock queues the second read behind the writer, so the two threads wait for each other forever and every other thread goes idle. The runtime now uses its own read-write lock that lets the second read through, as the PS4 does. The freeze was found in a live freeze report: both stuck threads were waiting on the same lock.
- **Fixed: random crash right after pressing Play or while a track loads** ("read access to 0000000000000000 at guest offset 0x64db13"). The game function that crashed keeps values below the stack pointer, and on Windows a memory-tracking fault taken inside it overwrote them. It now gets a real stack frame. Found and patched by @Ianespaa, reported by @wormmayhem.
- **Fixed: coloured stripes, blocks and noisy edges on AMD graphics cards, and the very dark picture after the 0.2.3 fallback.** The 0.2.3 change that made AMD run shaders at 32 lanes is undone: shaders run at 64 lanes again where the driver lets compute require it, and only the stages the driver allows are pinned. This includes the RADV fix by @ClaudioVarandas in #39.
- **Changed: the fallback that skipped the shaders running when the graphics device was lost is off.** It left the picture dark and did not stop the crashes.
- **Fixed: quiet game and music on stereo outputs** (TV over HDMI, headphones, laptop speakers). The 7.1 mix is now downmixed to stereo with a limiter instead of letting the system convert it at about -13 dB. Contributed by @MoonFuji in #52, reported in #47.
- **Fixed: replays could not be saved** ("no free space" when saving a replay, #32). The game asks the save data how many blocks are free before it writes, and the runtime did not answer.
- **New: the launcher now refuses to start when a game file is cut short** and names it (for example `game961.dat`). An incomplete copy of the game made the game read forever and show a black screen (#48). The log also warns when the game reads past the end of an archive file.
- **New: a freeze report lists what every game thread is waiting for**, the locks that are contended and the program addresses of the other threads, for any future freeze.
- **Changed: AMD "device lost" crashes** (#16, #46). The logs show the graphics card reading a GPU address that is no longer mapped, and most of them follow a "Migrating arena" line: a buffer arena that grew was bound to the same memory as the arena it replaced, which Vulkan only allows with aliased sparse binding. AMD cards now use it. This could not be tested on AMD hardware here; please report if the crash still happens, with the newest log.

### 0.2.3
- **New: Anisotropic filtering** in the launcher (Anti-aliasing card). Automatic is 16x, or 4x on integrated graphics; Off, 2x, 4x, 8x and 16x are available. Roads and terrain stay sharp at a shallow angle. Thanks for asking, @MaNE-17.
- **New: the European release (CUSA00003) version 1.28 is accepted.** It has been played less than the US release. Contributed by @ClaudioVarandas in #26.
- **Fixed: crash at boot with Output 4K and the Default render size.** The memory patch is now sized from the output resolution as well as the render resolution. Contributed by @ClaudioVarandas in #25.
- **Fixed: texture memory kept growing in long sessions.** Textures the game cannot release right now no longer use up the cleanup, so the texture cache stays within its budget.
- **Changed: freezes when an event starts.** The lock that guards the game's memory map was replaced by one that cannot block a thread that already holds it. This may fix the freezes after "Start Event" reported on RTX 3060, RTX 3070 and GTX 1650 cards (#23, #24); please say whether it helped.
- **Changed: AMD graphics cards.** The shader width the driver really allows is used, so shaders no longer run at another width than they were built for. This may fix the grid of white squares in the sky (#21) and "device lost" crashes (#16) on AMD cards. It could not be tested on AMD hardware here; please report.
- **New: the game heals itself after a lost graphics device** ("SubmitExecution: Assertion Failed", "Device lost during submit"; #16 and others on Radeon RX 6000 cards). The shaders that were running when the card hung are written to `data\user\gpu_quarantine.txt`, and the next start skips them, so the game plays on without that one effect instead of crashing again. The log says which shaders are skipped. Delete the file to run them again. This cannot prevent the first crash; please report if it still repeats.
- **Changed: Intel graphics** no longer use dynamic vertex input, which can draw black silhouettes with some Intel drivers.
- **Changed: NVIDIA and Intel graphics keep small per-draw data in cached system memory** instead of video memory, which costs the processor less time. AMD keeps video memory.
- **Changed: running out of video memory** no longer ends the game; the memory is allocated past the budget instead. A graphics pipeline the driver fails to build for a passing reason is built again.
- **Changed: faster in busy races.** Several costs on the command thread were cut. In our test race at 4K the frame rate went from about 62 to 71 FPS; results depend on the scene and your processor.
- **Changed: more in the logs**: the graphics driver and its shader width, which memory path is in use, and how many samplers got filtering. After a lost graphics device the log also holds the driver's own fault report (faulting address and code), the video memory in use, and the last 48 pieces of GPU work; the driver's crash data is saved as `data\user\gpu_fault_vendor.bin`.

### 0.2.2
- **New: the launcher checks your processor.** The game's code needs AVX, BMI1, LZCNT and MOVBE (Intel Haswell from 2013, AMD Excavator or Ryzen, or newer). On older processors the game stopped right after the start with "exception 0xc000001d"; the launcher now says what is missing instead. "Skip the hardware check" (renamed from "Skip the graphics card check") turns it off.
- **Changed: "Unlock DLC content" is off by default**, also for everyone who had it on: turn it on in the launcher if you want the add-on cars, bikes, tours and decals.
- **Changed: "Unlock DLC content" no longer makes the Nissan R34 GT-R V-Spec II customisable.** The game archive has no livery template for it, which may have caused crashes when a race started. Cars are only made customisable when their template exists, and the unlock files rebuild by themselves on the next start.
- **Fixed: "The update folder must be DriveClub version 1.28" for merged or repacked dumps.** The version is also accepted when `eboot.bin` is the very file of the 1.28 update, even if `param.sfo` has another version.
- **New: ultrawide 32:9 5120x1440** in the Widescreen choice.
- **New: an `eboot.bin` that is a plain ELF file** (an already decrypted dump) is accepted, and the message for any other kind of file shows what the file starts with.
- **Changed: AMD graphics cards no longer read GPU results straight from host-visible memory by default.** AMD cards showed "device lost" crashes and broken frames with it.
- **New: the launcher checks before starting** that the program files are all there, that its folder can be written to and that the game folders hold every archive file (`game*.dat`), and says what is wrong instead of failing later. What it saw goes into `logs\launcher.log`.

### 0.2.1
- **Fixed: crash at boot with 1440p render resolution.** The memory patch the 1440p choice needs was not being switched on. Thanks to everyone who reported it.
- **Fixed: "The update folder must be DriveClub version 1.28" after the launcher showed the folder as fine.** The launcher and the preparation step now read the version the same way, accept it from either version field of the folder's `param.sfo`, and say what the file contains when it is rejected.
- **Changed: clearer message when `eboot.bin` is not a PS4 SELF file** (a converted or renamed file).
- **Changed: crash reports in the log now list the return addresses found on the stack**, so crashes in code without frame pointers can be traced.

### 0.2.0
- **New: runs on Intel processors.** The game used an instruction set that only AMD processors have, so on Intel CPUs it stopped right after the start. It is now rewritten at load. Thanks to @Alexbeav. Intel players, please report whether it works for you.
- **New: launcher fits every screen.** The window opens wide enough to show everything in up to four columns, and when the screen is still too small, the mouse wheel scrolls the settings while the Play button stays in view. Thanks to @Alexbeav for the scrolling.
- **Fixed: a crash in the middle of races.** A use-after-free in the texture cache could crash the game with a memory fault once the cache grew, mostly in long events with many cars.
- **New: a dump that already is version 1.28 in one folder works.** Choose it as the base game folder and leave the update field empty.
- **New: language choice** in the launcher, with all 21 languages the game has. Click it to go to the next one. Japanese, Korean and Chinese may show missing characters.
- **New: anti-aliasing with FSR 3.1 or NVIDIA DLAA.** Replaces the game's own anti-aliasing for a sharper, steadier picture. In the game the overlay shows what is active, F9 switches it off and on to compare, F10 switches between FSR and DLSS.
- **Changed: two experimental shader behaviours that were on in 0.1.1 are now off by default.** Shaders rebuild on the first start after updating, so expect some stutter for a few minutes.
- **Changed: the download is larger (about 90 MB)** because it now includes the NVIDIA DLSS libraries.

### 0.1.1
- **New: Unlock DLC content.** A switch in the launcher (on by default) that unlocks the add-on cars, bikes, tours and livery decals. The launcher reads the vehicle list, the tour list and the livery list from your own game archive and builds changed copies for the game to use. Cars you earn by playing still unlock through normal progression. Your game folders are not modified, and the copies are rebuilt when your game files change.
- **New: `mods` folder.** Files you put in the `mods` folder next to the launcher replace the game's own files of the same path, so loose-file mods work without touching your game folders. Your files take priority over everything else.
- **New: resizable launcher.** Drag any edge or corner. Wider windows give the columns more room, taller ones give the rows more space. The text stays sharp and the window follows the display scale when you move it between monitors.
- **Changed: shaders rebuild on the first start after updating**, so expect some stutter for a few minutes.
- **Performance will keep being worked on and improved in future versions.**

### 0.1.0
- First release.

## Updating from an older version
Extract the new zip over your existing folder, or copy the new `DriveClub.exe`, the `runtime` folder and the `licenses` folder into it. Your folder choices and settings are kept.

## How to play
1. Download `driveclub-recomp-0.2.5-win64.zip` and extract it anywhere you can write to.
2. Have **your own** game dumps ready: the version 1.28 update folder (it contains `eboot.bin`) and the base game folder (it contains `game000.dat`).
3. Double-click `DriveClub.exe`, press **Browse** next to each folder, check the settings and press **Play**.

Nothing to install. Your own files are never modified or copied.

Logs are in the `logs` folder.

## Highlights
- The game's own x86-64 code runs directly on your CPU, with no CPU emulation. The PS4 system libraries are reimplemented and the GPU commands are translated to Vulkan, similar to Wine and DXVK
- Playable from the menus through races, photo mode and saves
- About 60 FPS at 4K in the heaviest scenes on our test PC (RTX 5070 Ti, Ryzen 7 5800X3D), higher in lighter ones
- Keyboard racing layout and any gamepad (Xbox, PlayStation, Switch Pro, 8BitDo)

## Controls
Any gamepad works. Keyboard, mouse and gamepad can be used at the same time.

| Action | Keyboard |
|---|---|
| Accelerate | W |
| Brake / reverse | S |
| Steer | A / D |
| Handbrake | Space |
| Shift down / up | Q / E |
| Change camera | C |
| Touchpad left / right half | R / T (R is Reset to Track) |
| Accept | Enter / Z |
| Back | Backspace |
| Pause | Esc / P |
| D-pad | Arrow keys |
| Look around | I J K L or the mouse |

F7 turns mouse look on or off.

## Known issues
- **Some reflections are too bright**, for example rain drops on the side window and the paint on cars on the vehicle select and paint job screens.
- **Static (faster)** stops reflections and rain on the glass from updating.
- **The US version (CUSA00093) 1.28 is the tested one.** The European version (CUSA00003) 1.28 is accepted but has been played less.
- **Anti-aliasing:** fast cars can leave a faint trail. It does not work together with the patch "Disable motion blur and depth of field" (the game then keeps its own anti-aliasing).
- **The processor is the limit.** Heavy scenes (many cars, trees and rain) drop frames first on slower CPUs.
- **First play builds shaders:** short stutters in the first minutes until they are cached.
- **Online features do not work.**
- **Mostly tested on NVIDIA.** AMD and Intel are worked on from player reports, which is how most of the fixes in 0.2.5 were found: please include your GPU model, driver version and the newest file from the `logs` folder.
- **An event built around a car whose data is not in your dump can freeze when it starts** (#85, #76, #81). The game waits for asset files that a disc dump does not hold.
- **A few PCs stop at a black screen right after the start** (#64, #71, #54). The game reads a pointer that nothing ever fills; this is the next thing being worked on.

## Notes
- You must supply your own, legally obtained dump of the game. No game files are included.
- **Tested with:** DriveClub, title ID `CUSA00093`, version 1.28 (the European `CUSA00003` 1.28 is accepted too). Other versions and repacked dumps have not been tested and may not work.
- SmartScreen may warn (*More info*, then *Run anyway*). Verify with the checksum.
- Requires Windows 10/11 64-bit and a graphics card with a Vulkan 1.3 driver. About 40 GB of free space is needed for the game dumps.

## Checksums (SHA-256)
`TODO`  `driveclub-recomp-0.2.5-win64.zip`
`TODO`  `driveclub-recomp-0.2.5-source.tar.gz`

## Reporting problems
Please open an [issue](https://github.com/OverkillLabs3/driveclub-recomp/issues/new/choose) and **attach the log files**, because without them an issue usually cannot be solved. In the folder next to `DriveClub.exe`, open `logs` and drag these into the issue:
- the newest `driveclub_<date>_<time>.log` (one per start: take the one from the run that went wrong)
- `launcher.log` (it exists even when the game never started, for example when the launcher shows an error)
- any `crash_*.dmp` (a small file written when the game crashes)

Also say what you were doing when it happened (menu, loading, which event and car).

DriveClub is a trademark and copyright of its respective owners; this project is not affiliated with or endorsed by them.
