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
This commit is contained in:
Luke Usher 2018-01-30 16:48:31 +00:00
parent 8e3aa52299
commit 3a8cab2b0f
1 changed files with 7 additions and 4 deletions

View File

@ -75,10 +75,13 @@ extern void FreeVertexDynamicPatch(VERTEX_SHADER *pVertexShader);
extern boolean IsValidCurrentShader(void);
extern boolean VshHandleIsValidShader(DWORD Handle);
// Dxbx note : On Xbox, a FVF is recognizable when the handle <= 0x0000FFFF
// (as all values above are allocated VertexShader addresses).
inline boolean VshHandleIsFVF(DWORD Handle) { return (Handle > NULL) && (Handle <= 0x0000FFFF); }
inline boolean VshHandleIsVertexShader(DWORD Handle) { return (Handle > 0x0000FFFF) ? TRUE : FALSE; }
// NOTE: Comparing with 0xFFFF breaks some titles (like Kingdom Under Fire)
// The real Xbox checks the D3DFVF_RESERVED0 flag but we can't do that without
// breaking rendering in many titles: CreateVertexShader needs to be unpatched first.
// Instead, we assume any vertex shaders will be allocated by our memory manager and
// exist above the XBE reserved region, not great, but it'l do for now.
inline boolean VshHandleIsFVF(DWORD Handle) { return (Handle > NULL) && (Handle <= XBE_MAX_VA); }
inline boolean VshHandleIsVertexShader(DWORD Handle) { return (Handle > XBE_MAX_VA) ? TRUE : FALSE; }
inline X_D3DVertexShader *VshHandleGetVertexShader(DWORD Handle) { return VshHandleIsVertexShader(Handle) ? (X_D3DVertexShader *)Handle : nullptr; }
VERTEX_DYNAMIC_PATCH *VshGetVertexDynamicPatch(DWORD Handle);