Skip to content

Commit 8443af6

Browse files
committed
Merge remote-tracking branch 'intorr/intorr_dev' into xd_dev
2 parents 5693362 + e3680b7 commit 8443af6

File tree

11 files changed

+33
-147
lines changed

11 files changed

+33
-147
lines changed

src/Layers/xrRender/HW.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,6 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window)
206206
DevAdapter = D3DADAPTER_DEFAULT;
207207
DevT = Caps.bForceGPU_REF ? D3DDEVTYPE_REF : D3DDEVTYPE_HAL;
208208

209-
#ifndef MASTER_GOLD
210-
// Look for 'NVIDIA NVPerfHUD' adapter
211-
// If it is present, override default settings
212-
for (UINT Adapter = 0; Adapter < pD3D->GetAdapterCount(); Adapter++)
213-
{
214-
D3DADAPTER_IDENTIFIER9 Identifier;
215-
HRESULT Res = pD3D->GetAdapterIdentifier(Adapter, 0, &Identifier);
216-
if (SUCCEEDED(Res) && (xr_strcmp(Identifier.Description, "NVIDIA PerfHUD") == 0))
217-
{
218-
DevAdapter = Adapter;
219-
DevT = D3DDEVTYPE_REF;
220-
break;
221-
}
222-
}
223-
#endif // MASTER_GOLD
224-
225209
// Display the name of video board
226210
D3DADAPTER_IDENTIFIER9 adapterID;
227211
R_CHK(pD3D->GetAdapterIdentifier(DevAdapter, 0, &adapterID));

src/Layers/xrRender/HW.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class CHW
8989

9090
D3D_DRIVER_TYPE m_DriverType; // DevT equivalent
9191
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
92-
bool m_bUsePerfhud;
9392
D3D_FEATURE_LEVEL FeatureLevel;
9493
#elif defined(USE_DX10)
9594
public:
@@ -106,7 +105,6 @@ class CHW
106105

107106
D3D10_DRIVER_TYPE m_DriverType; // DevT equivalent
108107
DXGI_SWAP_CHAIN_DESC m_ChainDesc; // DevPP equivalent
109-
bool m_bUsePerfhud;
110108
D3D_FEATURE_LEVEL FeatureLevel;
111109
#else
112110
private:

src/Layers/xrRenderDX10/dx10HW.cpp

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -80,35 +80,10 @@ void CHW::CreateD3D()
8080
*/
8181

8282
IDXGIFactory* pFactory;
83-
R_CHK(CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory)));
84-
85-
m_pAdapter = 0;
86-
m_bUsePerfhud = false;
8783

88-
#ifndef MASTER_GOLD
89-
// Look for 'NVIDIA NVPerfHUD' adapter
90-
// If it is present, override default settings
91-
UINT i = 0;
92-
while (pFactory->EnumAdapters(i, &m_pAdapter) != DXGI_ERROR_NOT_FOUND)
93-
{
94-
DXGI_ADAPTER_DESC desc;
95-
m_pAdapter->GetDesc(&desc);
96-
if (!wcscmp(desc.Description, L"NVIDIA PerfHUD"))
97-
{
98-
m_bUsePerfhud = true;
99-
break;
100-
}
101-
else
102-
{
103-
m_pAdapter->Release();
104-
m_pAdapter = 0;
105-
}
106-
++i;
107-
}
108-
#endif // MASTER_GOLD
84+
R_CHK(CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)(&pFactory)));
10985

110-
if (!m_pAdapter)
111-
pFactory->EnumAdapters(0, &m_pAdapter);
86+
pFactory->EnumAdapters(0, &m_pAdapter);
11287

11388
pFactory->Release();
11489

@@ -164,27 +139,6 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window)
164139

165140
m_DriverType = Caps.bForceGPU_REF ? D3D_DRIVER_TYPE_REFERENCE : D3D_DRIVER_TYPE_HARDWARE;
166141

167-
if (m_bUsePerfhud)
168-
m_DriverType = D3D_DRIVER_TYPE_REFERENCE;
169-
170-
// For DirectX 10 adapter is already created in create D3D.
171-
/*
172-
//. #ifdef DEBUG
173-
// Look for 'NVIDIA NVPerfHUD' adapter
174-
// If it is present, override default settings
175-
for (UINT Adapter=0;Adapter<pD3D->GetAdapterCount();Adapter++) {
176-
D3DADAPTER_IDENTIFIER9 Identifier;
177-
HRESULT Res=pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
178-
if (SUCCEEDED(Res) && (xr_strcmp(Identifier.Description,"NVIDIA PerfHUD")==0))
179-
{
180-
DevAdapter =Adapter;
181-
DevT =D3DDEVTYPE_REF;
182-
break;
183-
}
184-
}
185-
//. #endif
186-
*/
187-
188142
// Display the name of video board
189143
DXGI_ADAPTER_DESC Desc;
190144
R_CHK(m_pAdapter->GetDesc(&Desc));

src/Layers/xrRenderPC_R3/r3.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,9 +1526,7 @@ HRESULT CRender::shader_compile(LPCSTR name, DWORD const* pSrcData, UINT SrcData
15261526
includer Includer;
15271527
LPD3DBLOB pShaderBuf = NULL;
15281528
LPD3DBLOB pErrorBuf = NULL;
1529-
_result = D3DCompile(pSrcData, SrcDataLen,
1530-
"", // NULL, //LPCSTR pFileName, // NVPerfHUD bug workaround.
1531-
defines, &Includer, pFunctionName, pTarget, Flags, 0, &pShaderBuf, &pErrorBuf);
1529+
_result = D3DCompile(pSrcData, SrcDataLen, "", defines, &Includer, pFunctionName, pTarget, Flags, 0, &pShaderBuf, &pErrorBuf);
15321530

15331531
if (SUCCEEDED(_result))
15341532
{

src/Layers/xrRenderPC_R4/r2_test_hw.cpp

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
66
return DefWindowProc(hWnd, message, wParam, lParam);
77
}
88

9-
typedef HRESULT(__stdcall* FuncPtrD3D11CreateDeviceAndSwapChain)(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType,
10-
HMODULE Software, UINT Flags, CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion,
11-
CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, IDXGISwapChain** ppSwapChain, ID3D11Device** ppDevice,
12-
D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext);
13-
149
bool TestDX11Present()
1510
{
16-
const auto hD3D11 = XRay::LoadModule("d3d11.dll");
17-
18-
if (!hD3D11->exist())
19-
{
20-
Log("* DX11: failed to load d3d11.dll");
21-
return false;
22-
}
23-
24-
auto pD3D11CreateDeviceAndSwapChain =
25-
(FuncPtrD3D11CreateDeviceAndSwapChain)hD3D11->getProcAddress("D3D11CreateDeviceAndSwapChain");
26-
27-
if (!pD3D11CreateDeviceAndSwapChain)
28-
{
29-
Log("* DX11: failed to get address of D3D11CreateDeviceAndSwapChain");
30-
return false;
31-
}
32-
3311
// Register class
3412
WNDCLASSEX wcex;
3513
ZeroMemory(&wcex, sizeof(wcex));
@@ -47,16 +25,13 @@ bool TestDX11Present()
4725
HWND hWnd = CreateWindow("TestDX11WindowClass", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
4826
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
4927

50-
DXGI_SWAP_CHAIN_DESC sd;
51-
5228
if (!hWnd)
5329
{
5430
Msg("* DX11: failed to create window");
5531
return false;
5632
}
5733

58-
HRESULT hr = E_FAIL;
59-
34+
DXGI_SWAP_CHAIN_DESC sd;
6035
ZeroMemory(&sd, sizeof(sd));
6136
sd.BufferCount = 1;
6237
sd.BufferDesc.Width = 800;
@@ -77,20 +52,18 @@ bool TestDX11Present()
7752
ID3D11DeviceContext* pContext = NULL;
7853
IDXGISwapChain* pSwapChain = NULL;
7954

80-
hr = pD3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, pFeatureLevels, 1, D3D11_SDK_VERSION,
55+
HRESULT hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, pFeatureLevels, 1, D3D11_SDK_VERSION,
8156
&sd, &pSwapChain, &pd3dDevice, &FeatureLevel, &pContext);
8257

8358
if (FAILED(hr))
8459
Msg("* D3D11: device creation failed with hr=0x%08x", hr);
8560

86-
if (pContext)
87-
pContext->Release();
88-
if (pSwapChain)
89-
pSwapChain->Release();
90-
if (pd3dDevice)
91-
pd3dDevice->Release();
61+
_RELEASE(pSwapChain);
62+
_RELEASE(pd3dDevice);
63+
_RELEASE(pContext);
9264

9365
DestroyWindow(hWnd);
66+
UnregisterClass("TestDX11WindowClass", GetModuleHandle(NULL));
9467

9568
return SUCCEEDED(hr);
9669
}

src/Layers/xrRenderPC_R4/r4.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,9 +1615,7 @@ HRESULT CRender::shader_compile(LPCSTR name, DWORD const* pSrcData, UINT SrcData
16151615
includer Includer;
16161616
LPD3DBLOB pShaderBuf = NULL;
16171617
LPD3DBLOB pErrorBuf = NULL;
1618-
_result = D3DCompile(pSrcData, SrcDataLen,
1619-
"", // NULL, //LPCSTR pFileName, // NVPerfHUD bug workaround.
1620-
defines, &Includer, pFunctionName, pTarget, Flags, 0, &pShaderBuf, &pErrorBuf);
1618+
_result = D3DCompile(pSrcData, SrcDataLen, "", defines, &Includer, pFunctionName, pTarget, Flags, 0, &pShaderBuf, &pErrorBuf);
16211619

16221620
if (SUCCEEDED(_result))
16231621
{

src/xrCore/FTimer.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,9 @@ void CStatTimer::FrameEnd() {
1818
result = 0.99f * result + 0.01f * time;
1919
}
2020

21-
XRCORE_API pauseMngr* g_pauseMngr()
21+
XRCORE_API pauseMngr& g_pauseMngr()
2222
{
23-
static pauseMngr* manager = nullptr;
24-
25-
if (!manager)
26-
{
27-
manager = new pauseMngr();
28-
}
29-
23+
static pauseMngr manager;
3024
return manager;
3125
}
3226

src/xrCore/FTimer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class XRCORE_API pauseMngr : Noncopyable
2323
void UnRegister(CTimer_paused& t);
2424
};
2525

26-
extern XRCORE_API pauseMngr* g_pauseMngr();
26+
extern XRCORE_API pauseMngr& g_pauseMngr();
2727

2828
class XRCORE_API CTimerBase
2929
{
@@ -142,8 +142,8 @@ class XRCORE_API CTimer_paused_ex : public CTimer
142142
class XRCORE_API CTimer_paused : public CTimer_paused_ex
143143
{
144144
public:
145-
CTimer_paused() { g_pauseMngr()->Register(*this); }
146-
virtual ~CTimer_paused() { g_pauseMngr()->UnRegister(*this); }
145+
CTimer_paused() { g_pauseMngr().Register(*this); }
146+
virtual ~CTimer_paused() { g_pauseMngr().UnRegister(*this); }
147147
};
148148

149149
extern XRCORE_API bool g_bEnableStatGather;

src/xrEngine/device.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
411411
TRUE;
412412
if (bTimer && (!g_pGamePersistent || g_pGamePersistent->CanBePaused()))
413413
{
414-
g_pauseMngr()->Pause(TRUE);
414+
g_pauseMngr().Pause(TRUE);
415415
#ifdef DEBUG
416416
if (!xr_strcmp(reason, "li_pause_key_no_clip"))
417417
TimerGlobal.Pause(FALSE);
@@ -422,10 +422,10 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
422422
}
423423
else
424424
{
425-
if (bTimer && g_pauseMngr()->Paused())
425+
if (bTimer && g_pauseMngr().Paused())
426426
{
427427
fTimeDelta = EPS_S + EPS_S;
428-
g_pauseMngr()->Pause(FALSE);
428+
g_pauseMngr().Pause(FALSE);
429429
}
430430
if (bSound)
431431
{
@@ -441,7 +441,7 @@ void CRenderDevice::Pause(BOOL bOn, BOOL bTimer, BOOL bSound, LPCSTR reason)
441441
}
442442
}
443443

444-
BOOL CRenderDevice::Paused() { return g_pauseMngr()->Paused(); }
444+
BOOL CRenderDevice::Paused() { return g_pauseMngr().Paused(); }
445445
void CRenderDevice::OnWM_Activate(WPARAM wParam, LPARAM /*lParam*/)
446446
{
447447
u16 fActive = LOWORD(wParam);

src/xrScriptEngine/script_engine.cpp

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,14 @@ bool RunJITCommand(lua_State* ls, const char* command)
9898

9999
const char* const CScriptEngine::GlobalNamespace = SCRIPT_GLOBAL_NAMESPACE;
100100
Lock CScriptEngine::stateMapLock;
101-
xr_unordered_map<lua_State*, CScriptEngine*>* CScriptEngine::stateMap = nullptr;
101+
xr_unordered_map<lua_State*, CScriptEngine*> CScriptEngine::stateMap;
102102

103103
string4096 CScriptEngine::g_ca_stdout;
104104

105105
void CScriptEngine::reinit()
106106
{
107107
stateMapLock.Enter();
108-
if (!stateMap)
109-
{
110-
stateMap = new xr_unordered_map<lua_State*, CScriptEngine*>();
111-
stateMap->reserve(32); // 32 lua states should be enough
112-
}
108+
stateMap.reserve(32); // 32 lua states should be enough
113109
stateMapLock.Leave();
114110
if (m_virtual_machine)
115111
{
@@ -1192,12 +1188,9 @@ CScriptEngine* CScriptEngine::GetInstance(lua_State* state)
11921188
{
11931189
CScriptEngine* instance = nullptr;
11941190
stateMapLock.Enter();
1195-
if (stateMap)
1196-
{
1197-
auto it = stateMap->find(state);
1198-
if (it != stateMap->end())
1199-
instance = it->second;
1200-
}
1191+
auto it = stateMap.find(state);
1192+
if (it != stateMap.end())
1193+
instance = it->second;
12011194
stateMapLock.Leave();
12021195
return instance;
12031196
}
@@ -1206,14 +1199,11 @@ bool CScriptEngine::RegisterState(lua_State* state, CScriptEngine* scriptEngine)
12061199
{
12071200
bool result = false;
12081201
stateMapLock.Enter();
1209-
if (stateMap)
1202+
auto it = stateMap.find(state);
1203+
if (it == stateMap.end())
12101204
{
1211-
auto it = stateMap->find(state);
1212-
if (it == stateMap->end())
1213-
{
1214-
stateMap->insert({state, scriptEngine});
1215-
result = true;
1216-
}
1205+
stateMap.insert({state, scriptEngine});
1206+
result = true;
12171207
}
12181208
stateMapLock.Leave();
12191209
return result;
@@ -1225,14 +1215,11 @@ bool CScriptEngine::UnregisterState(lua_State* state)
12251215
return true;
12261216
bool result = false;
12271217
stateMapLock.Enter();
1228-
if (stateMap)
1218+
auto it = stateMap.find(state);
1219+
if (it != stateMap.end())
12291220
{
1230-
auto it = stateMap->find(state);
1231-
if (it != stateMap->end())
1232-
{
1233-
stateMap->erase(it);
1234-
result = true;
1235-
}
1221+
stateMap.erase(it);
1222+
result = true;
12361223
}
12371224
stateMapLock.Leave();
12381225
return result;

0 commit comments

Comments
 (0)