mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add inline DX device getters
This commit is contained in:
parent
ee1a2c5207
commit
0fe7b40506
@ -183,10 +183,13 @@ bool CEngineAPI::MainLoop()
|
||||
params.minimumIntervalUs = fpsMax > 0 ? (NvU32)((1000.0f / fpsMax) * 1000.0f) : 0;
|
||||
params.bUseMarkersToOptimize = false;
|
||||
|
||||
NvAPI_Status status = NvAPI_D3D_SetSleepMode(*g_ppGameDevice, ¶ms);
|
||||
ID3D11Device* pGameDevice = D3D11Device();
|
||||
Assert(pGameDevice);
|
||||
|
||||
NvAPI_Status status = NvAPI_D3D_SetSleepMode(pGameDevice, ¶ms);
|
||||
|
||||
if (status == NVAPI_OK)
|
||||
NvAPI_D3D_Sleep(*g_ppGameDevice);
|
||||
NvAPI_D3D_Sleep(pGameDevice);
|
||||
|
||||
CEngineAPI_PumpMessages();
|
||||
#endif // !DEDICATED
|
||||
|
@ -90,7 +90,7 @@ void ImGui_Init()
|
||||
io.ConfigFlags |= ImGuiConfigFlags_IsSRGB;
|
||||
|
||||
ImGui_ImplWin32_Init(*g_pGameWindow);
|
||||
ImGui_ImplDX11_Init(*g_ppGameDevice, *g_ppImmediateContext);
|
||||
ImGui_ImplDX11_Init(D3D11Device(), D3D11DeviceContext());
|
||||
}
|
||||
|
||||
void ImGui_Shutdown()
|
||||
@ -231,7 +231,7 @@ void CreateTextureResource(TextureHeader_t* textureHeader, INT_PTR imageData)
|
||||
|
||||
const uint32_t offsetStartResourceData = mipLevel << 4u;
|
||||
const D3D11_SUBRESOURCE_DATA* subResData = (D3D11_SUBRESOURCE_DATA*)((uint8_t*)initialData + offsetStartResourceData);
|
||||
const HRESULT createTextureRes = (*g_ppGameDevice)->CreateTexture2D(&textureDesc, subResData, &textureHeader->m_ppTexture);
|
||||
const HRESULT createTextureRes = D3D11Device()->CreateTexture2D(&textureDesc, subResData, &textureHeader->m_ppTexture);
|
||||
if (createTextureRes < S_OK)
|
||||
Error(eDLL_T::RTECH, EXIT_FAILURE, "Couldn't create texture \"%s\": error code = %08x\n", textureHeader->m_pDebugName, createTextureRes);
|
||||
|
||||
@ -249,7 +249,7 @@ void CreateTextureResource(TextureHeader_t* textureHeader, INT_PTR imageData)
|
||||
shaderResource.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D;
|
||||
}
|
||||
|
||||
const HRESULT createShaderResourceRes = (*g_ppGameDevice)->CreateShaderResourceView(textureHeader->m_ppTexture, &shaderResource, &textureHeader->m_ppShaderResourceView);
|
||||
const HRESULT createShaderResourceRes = D3D11Device()->CreateShaderResourceView(textureHeader->m_ppTexture, &shaderResource, &textureHeader->m_ppShaderResourceView);
|
||||
if (createShaderResourceRes < S_OK)
|
||||
Error(eDLL_T::RTECH, EXIT_FAILURE, "Couldn't create shader resource view for texture \"%s\": error code = %08x\n", textureHeader->m_pDebugName, createShaderResourceRes);
|
||||
}
|
||||
@ -290,7 +290,7 @@ bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView*
|
||||
subResource.pSysMem = pImageData;
|
||||
subResource.SysMemPitch = desc.Width * 4;
|
||||
subResource.SysMemSlicePitch = 0;
|
||||
(*g_ppGameDevice)->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||
D3D11Device()->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||
|
||||
// Create texture view
|
||||
ZeroMemory(&srvDesc, sizeof(srvDesc));
|
||||
@ -301,7 +301,7 @@ bool LoadTextureBuffer(unsigned char* buffer, int len, ID3D11ShaderResourceView*
|
||||
|
||||
if (pTexture)
|
||||
{
|
||||
(*g_ppGameDevice)->CreateShaderResourceView(pTexture, &srvDesc, out_srv);
|
||||
D3D11Device()->CreateShaderResourceView(pTexture, &srvDesc, out_srv);
|
||||
pTexture->Release();
|
||||
}
|
||||
|
||||
|
@ -107,9 +107,13 @@ enum class DXGISwapChainVTbl : short
|
||||
};
|
||||
|
||||
#ifndef BUILDING_LIBIMGUI
|
||||
inline ID3D11Device** g_ppGameDevice = nullptr;
|
||||
inline ID3D11Device** g_ppGameDevice = nullptr;
|
||||
inline ID3D11DeviceContext** g_ppImmediateContext = nullptr;
|
||||
inline IDXGISwapChain** g_ppSwapChain = nullptr;
|
||||
inline IDXGISwapChain** g_ppSwapChain = nullptr;
|
||||
|
||||
FORCEINLINE ID3D11Device* D3D11Device() { Assert(g_ppGameDevice); return (*g_ppGameDevice); }
|
||||
FORCEINLINE ID3D11DeviceContext* D3D11DeviceContext() { Assert(g_ppImmediateContext); return (*g_ppImmediateContext); }
|
||||
FORCEINLINE IDXGISwapChain* D3D11SwapChain() { Assert(g_ppSwapChain); return (*g_ppSwapChain); }
|
||||
|
||||
class VDXGI : public IDetour
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user