Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Reset() [3/3]

unsafe void Microsoft.Xna.Framework.Graphics.GraphicsDevice.Reset ( PresentationParameters presentationParameters,
GraphicsAdapter graphicsAdapter )
inline

Definition at line 1183 of file GraphicsDevice.cs.

1184 {
1185 IntPtr intPtr = (IntPtr)pComPtr;
1186 Helpers.CheckDisposed(this, intPtr);
1187 bool flag = false;
1188 if (presentationParameters == null)
1189 {
1190 throw new ArgumentNullException("presentationParameters", FrameworkResources.NullNotAllowed);
1191 }
1192 if (graphicsAdapter == null)
1193 {
1194 throw new ArgumentNullException("graphicsAdapter", FrameworkResources.NullNotAllowed);
1195 }
1196 EventArgs empty = EventArgs.Empty;
1197 _003Cbacking_store_003EDeviceResetting?.Invoke(this, empty);
1198 int num = ((currentRenderTargetCount == 0 && presentationParameters.BackBufferWidth == pInternalCachedParams.BackBufferWidth && presentationParameters.BackBufferHeight == pInternalCachedParams.BackBufferHeight) ? 1 : 0);
1199 bool saveViewport = (byte)num != 0;
1200 SavedDeviceState savedDeviceState = new SavedDeviceState(this, saveViewport);
1201 if (graphicsAdapter != pCurrentAdapter && _deviceType == (_D3DDEVTYPE)1 && graphicsAdapter.IsProfileSupported((_D3DDEVTYPE)1, _graphicsProfile))
1202 {
1203 flag = true;
1204 }
1205 EffectPass effectPass = activePass;
1206 if (effectPass != null)
1207 {
1208 effectPass.EndPass();
1209 activePass = null;
1210 }
1212 lazyClearFlags = 0;
1214 Indices = null;
1215 SetVertexBuffers(null, 0);
1216 SetRenderTargets(null, 0);
1219 StateTrackerDevice* ptr = pStateTracker;
1220 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, IDirect3DVertexDeclaration9*, int>)(int)(*(uint*)(*(int*)ptr + 348)))((nint)ptr, null);
1221 ptr = pStateTracker;
1222 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, IDirect3DVertexShader9*, int>)(int)(*(uint*)(*(int*)ptr + 368)))((nint)ptr, null);
1223 ptr = pStateTracker;
1224 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, IDirect3DPixelShader9*, int>)(int)(*(uint*)(*(int*)ptr + 428)))((nint)ptr, null);
1226 IDirect3DSurface9* ptr2 = pImplicitDepthSurface;
1227 if (ptr2 != null)
1228 {
1229 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)ptr2 + 8)))((nint)ptr2);
1230 pImplicitDepthSurface = null;
1231 }
1232 if (flag)
1233 {
1235 ptr = pStateTracker;
1236 if (ptr != null)
1237 {
1238 StateTrackerDevice* intPtr2 = ptr;
1239 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)intPtr2 + 8)))((nint)intPtr2);
1240 pStateTracker = null;
1241 }
1242 IDirect3DDevice9* ptr3 = pComPtr;
1243 IDirect3DDevice9* intPtr3 = ptr3;
1244 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)intPtr3 + 8)))((nint)intPtr3);
1245 pComPtr = null;
1246 CreateDevice(graphicsAdapter, presentationParameters);
1247 pResourceManager.RecreateResources((_D3DPOOL)1, flag);
1248 pCurrentAdapter = graphicsAdapter;
1249 }
1250 else
1251 {
1252 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DPRESENT_PARAMETERS_ d3DPRESENT_PARAMETERS_);
1253 *(int*)(&d3DPRESENT_PARAMETERS_) = 0;
1254 // IL initblk instruction
1255 System.Runtime.CompilerServices.Unsafe.InitBlock(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DPRESENT_PARAMETERS_, 4), 0, 52);
1256 ConvertPresentationParametersToNative(pCurrentAdapter, presentationParameters, &d3DPRESENT_PARAMETERS_);
1257 IDirect3DDevice9* ptr3 = pComPtr;
1258 int num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DPRESENT_PARAMETERS_*, int>)(int)(*(uint*)(*(int*)ptr3 + 64)))((nint)ptr3, &d3DPRESENT_PARAMETERS_);
1259 ConvertPresentationParametersToManaged(&d3DPRESENT_PARAMETERS_, presentationParameters);
1260 if (num2 < 0)
1261 {
1262 throw GraphicsHelpers.GetExceptionFromResult((uint)num2);
1263 }
1264 }
1265 fixed (IDirect3DSurface9** ptr4 = &pImplicitDepthSurface)
1266 {
1267 int num3 = *(int*)pComPtr + 160;
1268 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, IDirect3DSurface9**, int>)(int)(*(uint*)num3))((nint)pComPtr, ptr4);
1269 pResourceManager.RecreateResources((_D3DPOOL)0, flag);
1270 pInternalCachedParams = presentationParameters.Clone();
1271 pPublicCachedParams = presentationParameters.Clone();
1273 savedDeviceState.Restore();
1274 EventArgs empty2 = EventArgs.Empty;
1275 _003Cbacking_store_003EDeviceReset?.Invoke(this, empty2);
1276 _insideScene = false;
1277 }
1278 }
void RecreateResources(_D3DPOOL pool, [MarshalAs(UnmanagedType.U1)] bool deviceRecreated)
unsafe void SetRenderTargets(params RenderTargetBinding[] renderTargets)
EventHandler< EventArgs > _003Cbacking_store_003EDeviceReset
unsafe void CreateDevice(GraphicsAdapter adapter, PresentationParameters presentationParameters)
unsafe void SetVertexBuffers(VertexBufferBinding *pBindings, int vertexBufferCount)
unsafe void ConvertPresentationParametersToManaged(_D3DPRESENT_PARAMETERS_ *pp, PresentationParameters presentationParameters)
EventHandler< EventArgs > _003Cbacking_store_003EDeviceResetting
unsafe void ConvertPresentationParametersToNative(GraphicsAdapter adapter, PresentationParameters presentationParameters, _D3DPRESENT_PARAMETERS_ *pp)
static readonly EventArgs Empty
Definition EventArgs.cs:9
static unsafe void InitBlock(void *startAddress, byte value, uint byteCount)
Definition Unsafe.cs:117

References Microsoft.Xna.Framework.Graphics.GraphicsDevice._003Cbacking_store_003EDeviceReset, Microsoft.Xna.Framework.Graphics.GraphicsDevice._003Cbacking_store_003EDeviceResetting, Microsoft.Xna.Framework.Graphics.GraphicsDevice._deviceType, Microsoft.Xna.Framework.Graphics.GraphicsDevice._graphicsProfile, Microsoft.Xna.Framework.Graphics.GraphicsDevice._insideScene, Microsoft.Xna.Framework.Graphics.GraphicsDevice.activePass, Microsoft.Xna.Framework.Graphics.PresentationParameters.BackBufferHeight, Microsoft.Xna.Framework.Helpers.CheckDisposed(), Microsoft.Xna.Framework.Graphics.PresentationParameters.Clone(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.ConvertPresentationParametersToManaged(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.ConvertPresentationParametersToNative(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.CreateDevice(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentRenderTargetCount, System.EventArgs.Empty, Microsoft.Xna.Framework.Graphics.EffectPass.EndPass(), Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.Indices, System.Runtime.CompilerServices.Unsafe.InitBlock(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.InitializeDeviceState(), Microsoft.Xna.Framework.Graphics.GraphicsAdapter.IsProfileSupported(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.lazyClearFlags, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pCurrentAdapter, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pImplicitDepthSurface, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pInternalCachedParams, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pPublicCachedParams, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pResourceManager, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pStateTracker, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pTextureCollection, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pVertexTextureCollection, Microsoft.Xna.Framework.Graphics.DeviceResourceManager.RecreateResources(), Microsoft.Xna.Framework.Graphics.DeclarationManager.ReleaseAllDeclarations(), Microsoft.Xna.Framework.Graphics.DeviceResourceManager.ReleaseAllDefaultPoolResources(), Microsoft.Xna.Framework.Graphics.DeviceResourceManager.ReleaseAutomaticResources(), Microsoft.Xna.Framework.Graphics.TextureCollection.ResetState(), Microsoft.Xna.Framework.Graphics.SavedDeviceState.Restore(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.savedBackBufferClearFlags, Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetRenderTargets(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetVertexBuffers(), and Microsoft.Xna.Framework.Graphics.GraphicsDevice.vertexDeclarationManager.