Commit Graph

3543 Commits

Author SHA1 Message Date
Fisherman166 9d19bece19 Add reversed engineered implementations of RtlEnterCriticalSectionAndRegion, RtlEnterCriticalSection, RtlInitializeCriticalSection, RtlLeaveCriticalSectionAndRegion, RtlLeaveCriticalSection, and RtlTryEnterCriticalSection kernel functions 2018-02-07 19:36:22 -08:00
Fisherman166 49fc9be353 Add reversed engineered KeLeaveCriticalRegion and KeEnterCriticalRegion kernel functions 2018-02-07 19:36:22 -08:00
PatrickvL 735a4bcfc5
Merge pull request #907 from Voxel9/Settings-Initialize
Implement 'Reset to Defaults' menu feature.
2018-02-07 08:10:27 +01:00
PatrickvL 907c67cb25
Merge pull request #908 from CakeLancelot/less-debug-file-clutter
Less debug file clutter
2018-02-07 08:08:24 +01:00
CakeLancelot fcec6231c1 Correct from _DEBUG to _DEBUG_TRACK_PS 2018-02-07 00:15:40 -06:00
Voxel c412935da5 Move code into its own function. 2018-02-06 23:43:42 +00:00
Voxel d09ebb106b Implement 'Reset to Defaults' menu feature. 2018-02-06 21:22:56 +00:00
CakeLancelot 28907a5b49 Only do debug tracking on debug builds 2018-02-06 12:49:24 -06:00
CakeLancelot 4aa09ee9c3 Add check for define before dumping pixel shaders to file 2018-02-06 12:46:25 -06:00
Luke Usher b656816eb4
Merge pull request #906 from LukeUsher/patch-removal-experiment
Direct3D Unpatching
2018-02-06 13:04:51 +00:00
PatrickvL b41a50de31 Use a macro to import Xbox function trampolines 2018-02-06 13:37:32 +01:00
Luke Usher a3c6974804 Host Vertex Buffers are no longer returned to Xbox code from VertexBuffer_Lock
- This brings it inline to how Lock2DSurface/3DSurface work
 - Seems to fix the Crimson Skies memory leak.
2018-02-06 10:24:31 +00:00
Luke Usher 7b8c20dd5c Give Lock3DSurface the same treatment as Lock2DSurface 2018-02-06 08:37:21 +00:00
Luke Usher 673826be79 Fixed the regression causing some frames to not render in Zelda - Oni Link Begins
- Added a ForceRehash flag to the resource information structure
 - Lock2DSurface now is a trampoline which calls the xbox function, but also marks our resource as needs rehash. If a title calls Lock2DSurface, we can assume it's to modify a resource.
2018-02-06 06:47:04 +00:00
Luke Usher c36911843b Fix a regression causing various XDK samples to crash.
Thanks to Patrick for his CxbxGetPixelContainerMeasures function.
2018-02-05 20:51:16 +00:00
Luke Usher ecb00b442d Fix a regression introduced when rebasing on master 2018-02-05 18:15:35 +00:00
Luke Usher 206e4a9c84 Restore same line endings as master
- Changed line endings are messing up the diff
2018-02-05 16:22:35 +00:00
Luke Usher 31cffb5bcd Fix compilation after rebase on master 2018-02-05 13:47:29 +00:00
Luke Usher f34267e984 Fix an issue where CreatePixelShader could crash when called from LoadVertexShader program in a title that does not have CreatePixelShader present 2018-02-05 13:33:53 +00:00
Luke Usher 954c16c32a Update to latest Cxbx-Reloaded subhook 2018-02-05 13:33:52 +00:00
Luke Usher 35e412a88a Refactor CreatePixelShader to correctly return Xbox handles.
This fixes the exception preventing Sonic Heroes E3 Demo from reaching ingame: It expected to be able to read from the Handle.
2018-02-05 13:33:52 +00:00
Luke Usher 90ab16534e Introduce LoadVertexShaderCache
- (Sonic Heroes E3 Demo goes from ~5fps to 60fps)

Restore patching of CreatePalette
 - Egg Mania renders better
 - Fonts in Burnout render better
2018-02-05 13:33:51 +00:00
Luke Usher 4fb38b9636 Reducing the impact of hashing by increasing the hash duration if no changes are detected 2018-02-05 13:33:51 +00:00
Luke Usher 0c2a2d85fe Oops, the previous commit actually made hashing NEVER happen, no wonder it was so fast 2018-02-05 13:33:51 +00:00
Luke Usher 9ebee168a9 Only rehash textures after 1ms has passed since the last hash
This massively improves the framerate in many titles, for example the
title screen on Turok sees a jump from ~2fps to 160fps with this alone.

I understand this isn't the best solution, but it is the best tradeoff
so far between not hashing resources at all (texture updates by xbox won't
propegate to host textures) or hashing every usage (extremely slow).

A better method would be dirty pages/memory watches, but it's not easily
possible with the current Cxbx-Reloaded design.
2018-02-05 13:33:51 +00:00
Luke Usher 06516410a6 Fix textures in Turok Evolution 2018-02-05 13:33:17 +00:00
Luke Usher c0ccf190bc Call Xbox SetTextur from within our patch: This handles correct reference counting for us, and ensures the underlying Xbox structures get updated.
Also refactured SwitchTexture, still not 100% correct, but likely the best we can do for now.
2018-02-05 13:33:17 +00:00
Luke Usher c9f331837b Implement Hashing of Textures and Surfaces to detect changes
Not the best way of doing things, but it will dof or now.
2018-02-05 13:33:17 +00:00
Luke Usher 79a5ae3d8b Better fallback shader, thanks: blueshogun 2018-02-05 13:33:16 +00:00
Luke Usher 3a8cab2b0f Update VshHandleIsVertexShader to use a different detection method
This is incorrect when compared to real hardware, but both our previous
approach and using the same method as real hardware are insufficient
right now, so this approach can be a suitable interim fix.

Our previous method breaks in some titles such as Kingdom Under Fire
that uses a higher than 0xFFFF value for an FVF

The real hardware method (checking D3DFVD_RESERVED0) fixes Kingdom Under
Fire but breaks rendering in many titles: This cannot be made to work
properly until we unpatch CreateVertexShader, which is outside the scope
of this current experimental branch
2018-02-05 13:33:16 +00:00
Luke Usher 8e3aa52299 Revert "Update VshHandleIsVertexShader to work the same way as the Xbox counterpart."
This reverts commit b3a6f1156276949caa277b1ca229920e7ba1831d.

This is how the Xbox does things, however, due to our patching of
CreateVertexShader and other related functions, the same approach
doesn't work too well for us here. We'll have to do something a little
more smart.
2018-02-05 13:33:15 +00:00
Luke Usher faddf405b4 Move unused patches to a backup file 2018-02-05 13:33:15 +00:00
Luke Usher e5fec80b85 Add Experimental support for Copying host BackBuffers back to Xbox surfaces. Disabled with an IFDEF 2018-02-05 13:31:56 +00:00
Luke Usher 5c69725bbd Update included subhook 2018-02-05 13:31:56 +00:00
Luke Usher 53f60e179a Move Subhook submodule into our own organisation so we can make changes if required 2018-02-05 13:31:56 +00:00
Luke Usher 7b596b2220 Update subhook to the latest version 2018-02-05 13:31:55 +00:00
Luke Usher 987571ee2e Update VshHandleIsVertexShader to work the same way as the Xbox counterpart.
It turns out the D3DFVF_RESERVED0 bit is used for this, making our old method unreliable.

This fixes a crash in Kingdom Under Fire (and likely other titles too)
2018-02-05 13:31:55 +00:00
Luke Usher ad8a181a19 Implement YuvEnable flag 2018-02-05 13:31:55 +00:00
Luke Usher d3506b8a45 Unpatch CopyRects, this won't be needed soon as we will have only draw time conversion 2018-02-05 13:31:55 +00:00
Luke Usher 0e4b623fc2 Don't call _Register on resources with no Data pointer 2018-02-05 13:31:55 +00:00
patrickvl 00dae2954f Disabled D3DDevice_CreatePalette and D3DDevice_CreatePalette2 patches 2018-02-05 13:31:54 +00:00
patrickvl 7417e1310f Introduced FreeHostResource,
only call it once an Xbox resource got freeed.
Also reduced the number of calls to GetResourceKey.
2018-02-05 13:31:54 +00:00
Luke Usher 3031078017 Fix an issue where g_RegisteredResources wasn't cleaned up properly 2018-02-05 13:31:54 +00:00
Luke Usher 0b799be6e5 Use the same key for g_RegisteredResources as HostResourcs 2018-02-05 13:31:54 +00:00
Luke Usher 16e038229b Fix a crash when GetDisplayMode cannot be found 2018-02-05 13:31:53 +00:00
Luke Usher 881d48b19c Revert "Fix compilation after addition of HasHostResource"
This commit accidentally included the removal of g_RegisteredResources which breaks re-used vertex buffers.
2018-02-05 13:31:53 +00:00
Luke Usher a804d65ebe Fix Debug mode build 2018-02-05 13:31:53 +00:00
Luke Usher 31bf658330 Fix compilation after addition of HasHostResource 2018-02-05 13:31:53 +00:00
Luke Usher 27fb0d7652 Move g_HostResources key generation into a function
Also refactored D3DResource_Release to store an iterator, no longer
need to hackily store a backup of the surface data as we call
GetHostResource before the XB_D3DResource_Release now.
2018-02-05 13:31:52 +00:00
Luke Usher a4816aa05b Use a uint64_t composite key for the registered resource map
This fixes a crash in Crash Bandicoot tWoc and most likely many other titles too.
2018-02-05 13:31:52 +00:00