Azurik 3D rendering fix (D3DDevice_LoadVertexShaderProgram)
This commit is contained in:
parent
8bdc6ae6f9
commit
46259aeb02
|
@ -2743,6 +2743,8 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SelectVertexShader)
|
||||||
|
|
||||||
HRESULT hRet;
|
HRESULT hRet;
|
||||||
|
|
||||||
|
g_CurrentVertexShader = Handle;
|
||||||
|
|
||||||
if(VshHandleIsVertexShader(Handle))
|
if(VshHandleIsVertexShader(Handle))
|
||||||
{
|
{
|
||||||
VERTEX_SHADER *pVertexShader = (VERTEX_SHADER *)(((X_D3DVertexShader *)(Handle & 0x7FFFFFFF))->Handle);
|
VERTEX_SHADER *pVertexShader = (VERTEX_SHADER *)(((X_D3DVertexShader *)(Handle & 0x7FFFFFFF))->Handle);
|
||||||
|
@ -8967,7 +8969,36 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_LoadVertexShaderProgram)
|
||||||
LOG_FUNC_ARG(Address)
|
LOG_FUNC_ARG(Address)
|
||||||
LOG_FUNC_END;
|
LOG_FUNC_END;
|
||||||
|
|
||||||
LOG_UNIMPLEMENTED();
|
// NOTE: Azurik needs this to work, but this implementation makes
|
||||||
|
// Sonic Heroes (E3 Demo) run slower and look a bit worse. An investigation
|
||||||
|
// may be necessary...
|
||||||
|
#if 1
|
||||||
|
DWORD Handle = g_CurrentVertexShader;
|
||||||
|
|
||||||
|
// TODO: Cache vertex shaders? Azurik overwrites the same vertex shader
|
||||||
|
// slot over and over again with many different vertex shaders per frame...
|
||||||
|
if( VshHandleIsVertexShader(Handle) )
|
||||||
|
{
|
||||||
|
X_D3DVertexShader *pD3DVertexShader = (X_D3DVertexShader *)(Handle & 0x7FFFFFFF);
|
||||||
|
VERTEX_SHADER *pVertexShader = (VERTEX_SHADER *)pD3DVertexShader->Handle;
|
||||||
|
|
||||||
|
// Save the contents of the existing vertex shader program
|
||||||
|
DWORD* pDeclaration = (DWORD*) malloc( pVertexShader->DeclarationSize );
|
||||||
|
memmove( pDeclaration, pVertexShader->pDeclaration, pVertexShader->DeclarationSize );
|
||||||
|
|
||||||
|
// Delete the vertex shader
|
||||||
|
EMUPATCH(D3DDevice_DeleteVertexShader)(Handle);
|
||||||
|
|
||||||
|
// Re-create the vertex shader with the new code
|
||||||
|
HRESULT hr = EMUPATCH(D3DDevice_CreateVertexShader)( pDeclaration, pFunction, &Handle, 0 );
|
||||||
|
free(pDeclaration);
|
||||||
|
if( FAILED( hr ) )
|
||||||
|
CxbxKrnlCleanup( "Error re-creating vertex shader!" );
|
||||||
|
|
||||||
|
EMUPATCH(D3DDevice_LoadVertexShader)(Handle, Address);
|
||||||
|
EMUPATCH(D3DDevice_SelectVertexShader)(Handle, Address);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******************************************************************
|
// ******************************************************************
|
||||||
|
|
Loading…
Reference in New Issue