forked from themrdemonized/xray-monolith
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice_destroy.cpp
More file actions
122 lines (95 loc) · 2.6 KB
/
Device_destroy.cpp
File metadata and controls
122 lines (95 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "stdafx.h"
#include "../Include/xrRender/DrawUtils.h"
#include "render.h"
#include "IGame_Persistent.h"
#include "xr_IOConsole.h"
void CRenderDevice::_Destroy(BOOL bKeepTextures)
{
DU->OnDeviceDestroy();
// before destroy
b_is_Ready = FALSE;
Statistic->OnDeviceDestroy();
m_imgui.OnDeviceDestroy();
::Render->destroy();
m_pRender->OnDeviceDestroy(bKeepTextures);
//Resources->OnDeviceDestroy (bKeepTextures);
//RCache.OnDeviceDestroy ();
Memory.mem_compact();
}
void CRenderDevice::Destroy(void)
{
if (!b_is_Ready) return;
Log("Destroying Direct3D...");
ShowCursor(TRUE);
ClipCursor(NULL);
m_pRender->ValidateHW();
_Destroy(FALSE);
// real destroy
m_pRender->DestroyHW();
//xr_delete (Resources);
//HW.DestroyDevice ();
seqRender.R.clear();
seqAppActivate.R.clear();
seqAppDeactivate.R.clear();
seqAppStart.R.clear();
seqAppEnd.R.clear();
seqFrame.R.clear();
seqFrameMT.R.clear();
seqDeviceReset.R.clear();
seqParallel.clear();
RenderFactory->DestroyRenderDeviceRender(m_pRender);
m_pRender = 0;
xr_delete(Statistic);
}
#include "IGame_Level.h"
#include "CustomHUD.h"
extern bool use_reshade;
extern bool init_reshade();
extern void unregister_reshade();
extern u32 g_screenmode;
extern void GetMonitorResolution(u32& horizontal, u32& vertical);
extern void GetMonitorPosition(int& x, int& y);
void CRenderDevice::Reset(bool precache)
{
if (use_reshade)
unregister_reshade();
use_reshade = false;
m_imgui.OnDeviceResetBegin();
u32 dwWidth_before = dwWidth;
u32 dwHeight_before = dwHeight;
ShowCursor(TRUE);
u32 tm_start = TimerAsync();
m_pRender->Reset(m_hWnd, dwWidth, dwHeight, fWidth_2, fHeight_2);
if (g_pGamePersistent)
g_pGamePersistent->Environment().bNeed_re_create_env = TRUE;
_SetupStates();
if (precache)
PreCache(20, true, false);
u32 tm_end = TimerAsync();
Msg("*** RESET [%d ms]", tm_end - tm_start);
// TODO: Remove this! It may hide crash
Memory.mem_compact();
seqDeviceReset.Process(rp_DeviceReset);
if (dwWidth_before != dwWidth || dwHeight_before != dwHeight)
{
seqResolutionChanged.Process(rp_ScreenResolutionChanged);
}
if (g_screenmode == 1)
{
u32 w, h;
int monX, monY;
GetMonitorResolution(w, h);
GetMonitorPosition(monX, monY);
SetWindowLongPtr(Device.m_hWnd, GWL_STYLE, WS_VISIBLE | WS_POPUP);
SetWindowPos(Device.m_hWnd, HWND_TOP, monX, monY, w, h, SWP_FRAMECHANGED);
}
#ifndef DEDICATED_SERVER
ShowCursor(FALSE);
RECT winRect;
GetClientRect(m_hWnd, &winRect);
MapWindowPoints(m_hWnd, nullptr, reinterpret_cast<LPPOINT>(&winRect), 2);
ClipCursor(&winRect);
#endif
m_imgui.OnDeviceResetEnd();
use_reshade = init_reshade();
}