FF13Fix/d3d9ex/VertexFix.cpp
Robert Krawczyk 3a844cc3ca Changes:
Fixed DXVK window starting in background and required clicking to activate
Added experimental (disabled by default) DiscardUIVertexBuffer option
Improved D3D9 reference counting
Two step initialization, check is correct window was created, then initialize 2s after IDirect3D9::CreateDevice call

Other:
Fix some include hell
Settings.h now include all comments so it will autogenerated ini file
Deleted IDirect3DVertexBuffer9.cpp/h
2021-03-13 03:54:05 +01:00

33 lines
1 KiB
C++

#define CINTERFACE
#include <d3d9.h>
#include "Logger.h"
#include "MinHook.h"
namespace cinterface
{
HRESULT(STDMETHODCALLTYPE* TrueLock)(IDirect3DVertexBuffer9* This, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) = nullptr;
HRESULT STDMETHODCALLTYPE HookLock(IDirect3DVertexBuffer9* This, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags)
{
//PrintLog(__FUNCTION__" %u", SizeToLock);
if (SizeToLock == 358400)
Flags = D3DLOCK_DISCARD;
return TrueLock(This, OffsetToLock, SizeToLock, ppbData, Flags);
}
void VertexBufferFix(IDirect3DVertexBuffer9* pVertexBuffer)
{
if (pVertexBuffer->lpVtbl->Lock && TrueLock == nullptr)
{
PrintLog("WARINING: Experimental DiscardUIVertexBuffer enabled!");
const MH_STATUS createHookLock = MH_CreateHook(pVertexBuffer->lpVtbl->Lock, HookLock, reinterpret_cast<void**>(&TrueLock));
PrintLog("CreateHookLock = %d", createHookLock);
const MH_STATUS enableHookLock = MH_EnableHook(pVertexBuffer->lpVtbl->Lock);
PrintLog("EnableHookLock = %d", enableHookLock);
}
}
}