Disabled D3D_MakeSpace patch, let D3D_MakeRequestedSpace return a buffer

This buffer will receive push-buffer commands, pushed by unpatched
functions. For now we'll ignore them, but at least this prevents fatal
errors. Later we can execute these pushbuffer commands too.

Also prevented memory leaks in BeginPush / EndPush
This commit is contained in:
PatrickvL 2017-05-07 16:16:20 +01:00
parent 921cf5d45a
commit 9309575e7f
3 changed files with 44 additions and 18 deletions

View File

@ -1817,13 +1817,17 @@ PDWORD WINAPI XTL::EMUPATCH(D3DDevice_BeginPush)(DWORD Count)
LOG_FUNC_ONE_ARG(Count);
if (g_pPrimaryPB != nullptr)
{
EmuWarning("D3DDevice_BeginPush called without D3DDevice_EndPush in between?!");
delete[] g_pPrimaryPB; // prevent a memory leak
}
DWORD *pRet = new DWORD[Count];
g_dwPrimaryPBCount = Count;
g_pPrimaryPB = pRet;
return pRet;
}
@ -1840,14 +1844,17 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_EndPush)(DWORD *pPush)
// DbgDumpPushBuffer(g_pPrimaryPB, g_dwPrimaryPBCount*sizeof(DWORD));
#endif
if (g_pPrimaryPB == nullptr)
EmuWarning("D3DDevice_EndPush called without preceding D3DDevice_BeginPush?!");
else
{
EmuUnswizzleTextureStages();
EmuUnswizzleTextureStages();
EmuExecutePushBufferRaw(g_pPrimaryPB);
EmuExecutePushBufferRaw(g_pPrimaryPB);
delete[] g_pPrimaryPB;
g_pPrimaryPB = 0;
delete[] g_pPrimaryPB;
g_pPrimaryPB = nullptr;
}
}
// ******************************************************************
@ -9571,26 +9578,40 @@ HRESULT WINAPI XTL::EMUPATCH(D3D_GetAdapterIdentifier)
}
#endif
DWORD PushBuffer[64 * 1024 / sizeof(DWORD)];
// ******************************************************************
// * patch: D3D_MakeRequestedSpace
// ******************************************************************
HRESULT WINAPI XTL::EMUPATCH(D3D_MakeRequestedSpace)( DWORD Unknown1, DWORD Unknown2 )
PDWORD WINAPI XTL::EMUPATCH(D3D_MakeRequestedSpace)
(
DWORD MinimumSpace,
DWORD RequestedSpace
)
{
FUNC_EXPORTS
LOG_FUNC_BEGIN
LOG_FUNC_ARG(Unknown1)
LOG_FUNC_ARG(Unknown2)
LOG_FUNC_ARG(MinimumSpace)
LOG_FUNC_ARG(RequestedSpace)
LOG_FUNC_END;
// NOTE: This function is not meant to me emulated. Just use it to find out
// the function that is calling it, and emulate that instead!!! If necessary,
// create an XRef...
LOG_UNIMPLEMENTED();
// NOTE: This function is ignored, as we currently don't emulate the push buffer
LOG_IGNORED();
return S_OK;
return PushBuffer; // Return a buffer that will be filled with GPU commands
// Note: This should work together with functions like XMETAL_StartPush/
// D3DDevice_BeginPush(Buffer)/D3DDevice_EndPush(Buffer) and g_pPrimaryPB
// TODO : Once we start emulating the PushBuffer, this will have to be the
// actual pushbuffer, for which we should let CreateDevice run unpatched.
// Also, we will require a mechanism (thread) which handles the commands
// send to the pushbuffer, emulating them much like EmuExecutePushBufferRaw
// (maybe even use that).
}
#if 0 // patch disabled
// ******************************************************************
// * patch: D3DDevice_MakeSpace
// ******************************************************************
@ -9605,6 +9626,7 @@ void WINAPI XTL::EMUPATCH(D3DDevice_MakeSpace)()
LOG_UNIMPLEMENTED();
}
#endif
// ******************************************************************
// * patch: D3D_SetCommonDebugRegisters

View File

@ -1850,7 +1850,11 @@ HRESULT WINAPI EMUPATCH(D3D_GetAdapterIdentifier)
// ******************************************************************
// * patch: D3D::MakeRequestedSpace
// ******************************************************************
HRESULT WINAPI EMUPATCH(D3D_MakeRequestedSpace)( DWORD Unknown1, DWORD Unknown2 );
PDWOR WINAPI EMUPATCH(D3D_MakeRequestedSpace)
(
DWORD MinimumSpace,
DWORD RequestedSpace
);
// ******************************************************************
// * patch: D3DDevice_MakeSpace

View File

@ -1451,7 +1451,7 @@ OOVPATable D3D8_5558[] = {
REGISTER_OOVPA(D3DDevice_SetRenderState_FrontFace, 4134, PATCH),
REGISTER_OOVPA(Get2DSurfaceDesc, 5558, PATCH),
REGISTER_OOVPA(D3D_MakeRequestedSpace, 5558, PATCH),
REGISTER_OOVPA(D3DDevice_MakeSpace, 5558, PATCH),
REGISTER_OOVPA(D3DDevice_MakeSpace, 5558, DISABLED),
REGISTER_OOVPA(D3DDevice_SetRenderTarget, 5558, PATCH),
REGISTER_OOVPA(D3DDevice_SetPixelShaderConstant, 5558, PATCH),
REGISTER_OOVPA(Lock2DSurface, 3925, PATCH),