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.
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
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.
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)
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.
D3DDevice_PersistDisplay
D3DDevice_GetPersistedSurface is a wrapper around
AvGetSavedDataAddress() and does not need to be patched.
D3DDevice_PersistDisplay needs to be patched for now, as it depends on
CMiniport::IsFlipPending, which only works with LLE NV2A at this moment
in time.
This fixed an issue in Crash Bandicoot: The Wrath of Cortex in which the
splash screen was corrupt (new issue to this branch)
Currently, this function does no hashing/dirty flags/any checks for
modification, so titles that modify textures on the fly will not display
correctly.
This will be addressed in a later commit.
This prevents the need for all the calls to this function throughout the
codebase, and also means that resources are only converted to their host
counterparts when this is actually required by Cxbx-Reloaded, rather
than anytime the resource is used.
- This prevents unwanted side effects when all we want to do is increment the Xbox reference count.
Cleanup around Set/Get RenderTarget
- This still isn't quite right, but a little bettter than what we had
- Turns out this as been wrong ever since we unpatched D3DDevice_CreateDevice!
- This restored textures in the 4361+ XDK samples
Move Host Resource lookup into a function to reduce code duplication.
- The new function (GetHostResource) is now used internally by all the other GetXXXResource functions.
- This fixes an issue where the XOnlineDash would crash when re-using resource data.
Fix a nullptr dereference in D3DResource_Release
Stop trashing resource data pointers within D3DResource_Register
- The xbox function now works unpatched and takes care of this before function executes.
Rename IsYuvSurface to IsYuvSurfaceOrTexture, apply the same changes to D3DTexture_LockRect as D3DSurface_LockRect (allows Silent Hill 2 to progress very slightly further)
Decouple host resources from the Resource->Lock field, I may have missed a few things, but now host resources no longer get lost if Xbox code or an unpatched function changes -> Lock!
For now, the actual (non-stub) implementations are still forwarding to Windows.
Still, this move centralizes the work to be done, and decouples it from our kernel implementation.