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

◆ GetBackBufferData< T >() [1/3]

unsafe void Microsoft.Xna.Framework.Graphics.GraphicsDevice.GetBackBufferData< T > ( Rectangle? rect,
T[] data,
int startIndex,
int elementCount )
inline
Type Constraints
T :struct 

Definition at line 2222 of file GraphicsDevice.cs.

2222 : struct
2223 {
2224 IntPtr intPtr = (IntPtr)pComPtr;
2225 Helpers.CheckDisposed(this, intPtr);
2227 {
2228 _profileCapabilities.ThrowNotSupportedException(FrameworkResources.ProfileFeatureNotSupported, "GetBackBufferData");
2229 }
2230 if (data != null)
2231 {
2232 int num = data.Length;
2233 if (num != 0)
2234 {
2235 Helpers.ValidateCopyParameters(num, startIndex, elementCount);
2237 {
2238 throw new InvalidOperationException(FrameworkResources.CannotGetBackBufferActiveRenderTargets);
2239 }
2240 if (lazyClearFlags != 0)
2241 {
2243 }
2244 IDirect3DSurface9* ptr = null;
2245 IDirect3DTexture9* ptr2 = null;
2246 IDirect3DSurface9* ptr3 = null;
2247 bool flag = false;
2248 try
2249 {
2250 IDirect3DDevice9* ptr4 = pComPtr;
2251 int num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, uint, _D3DBACKBUFFER_TYPE, IDirect3DSurface9**, int>)(int)(*(uint*)(*(int*)ptr4 + 72)))((nint)ptr4, 0u, 0u, (_D3DBACKBUFFER_TYPE)0, &ptr);
2252 if (num2 >= 0)
2253 {
2254 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DSURFACE_DESC d3DSURFACE_DESC);
2255 num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DSURFACE_DESC*, int>)(int)(*(uint*)(*(int*)ptr + 48)))((nint)ptr, &d3DSURFACE_DESC);
2256 if (num2 >= 0)
2257 {
2258 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint dwFormatSize);
2259 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint dwElementSize);
2260 Texture.GetAndValidateSizes<T>(&d3DSURFACE_DESC, &dwFormatSize, &dwElementSize);
2261 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint dwLockWidth);
2262 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint dwLockHeight);
2263 Texture.GetAndValidateRect(&d3DSURFACE_DESC, &dwLockWidth, &dwLockHeight, rect);
2264 Texture.ValidateTotalSize(&d3DSURFACE_DESC, dwLockWidth, dwLockHeight, dwFormatSize, dwElementSize, (uint)elementCount);
2265 if (_insideScene)
2266 {
2267 ptr4 = pComPtr;
2268 IDirect3DDevice9* intPtr2 = ptr4;
2269 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)intPtr2 + 168)))((nint)intPtr2);
2270 flag = true;
2271 }
2272 ptr4 = pComPtr;
2273 num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, uint, uint, uint, _D3DFORMAT, _D3DPOOL, IDirect3DTexture9**, void**, int>)(int)(*(uint*)(*(int*)ptr4 + 92)))((nint)ptr4, System.Runtime.CompilerServices.Unsafe.As<_D3DSURFACE_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DSURFACE_DESC, 24)), System.Runtime.CompilerServices.Unsafe.As<_D3DSURFACE_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DSURFACE_DESC, 28)), 1u, 0u, *(_D3DFORMAT*)(&d3DSURFACE_DESC), (_D3DPOOL)2, &ptr2, null);
2274 if (num2 >= 0)
2275 {
2276 num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, IDirect3DSurface9**, int>)(int)(*(uint*)(*(int*)ptr2 + 72)))((nint)ptr2, 0u, &ptr3);
2277 if (num2 >= 0)
2278 {
2279 num2 = _003CModule_003E.D3DXLoadSurfaceFromSurface(ptr3, null, null, ptr, null, null, uint.MaxValue, 0u);
2280 if (num2 >= 0)
2281 {
2282 tagRECT* ptr5 = null;
2283 Rectangle rectangle = default(Rectangle);
2284 if (rect.HasValue)
2285 {
2286 rectangle = rect.Value;
2287 ptr5 = (tagRECT*)(int)(ref rectangle);
2288 if (ptr5 != null)
2289 {
2290 *(int*)((byte*)ptr5 + 8) += *(int*)ptr5;
2291 *(int*)((byte*)ptr5 + 12) += *(int*)((byte*)ptr5 + 4);
2292 }
2293 }
2294 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DLOCKED_RECT d3DLOCKED_RECT);
2295 num2 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, _D3DLOCKED_RECT*, tagRECT*, uint, int>)(int)(*(uint*)(*(int*)ptr3 + 52)))((nint)ptr3, &d3DLOCKED_RECT, ptr5, 0u);
2296 if (num2 >= 0)
2297 {
2298 try
2299 {
2300 Texture.CopyData((void*)(int)System.Runtime.CompilerServices.Unsafe.As<_D3DLOCKED_RECT, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DLOCKED_RECT, 4)), *(int*)(&d3DLOCKED_RECT), data, startIndex, elementCount, &d3DSURFACE_DESC, dwLockWidth, dwLockHeight, isSetting: false);
2301 }
2302 finally
2303 {
2304 IDirect3DSurface9* intPtr3 = ptr3;
2305 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)intPtr3 + 56)))((nint)intPtr3);
2306 }
2307 if (pInternalCachedParams.RenderTargetUsage == RenderTargetUsage.DiscardContents)
2308 {
2310 }
2311 if (num2 >= 0)
2312 {
2313 return;
2314 }
2315 }
2316 }
2317 }
2318 }
2319 }
2320 }
2321 throw GraphicsHelpers.GetExceptionFromResult((uint)num2);
2322 }
2323 finally
2324 {
2325 if (ptr3 != null)
2326 {
2327 IDirect3DSurface9* intPtr4 = ptr3;
2328 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)intPtr4 + 8)))((nint)intPtr4);
2329 ptr3 = null;
2330 }
2331 if (ptr2 != null)
2332 {
2333 IDirect3DTexture9* intPtr5 = ptr2;
2334 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)intPtr5 + 8)))((nint)intPtr5);
2335 ptr2 = null;
2336 }
2337 if (ptr != null)
2338 {
2339 IDirect3DSurface9* intPtr6 = ptr;
2340 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint>)(int)(*(uint*)(*(int*)intPtr6 + 8)))((nint)intPtr6);
2341 ptr = null;
2342 }
2343 if (flag)
2344 {
2345 IDirect3DDevice9* intPtr7 = pComPtr;
2346 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)intPtr7 + 164)))((nint)intPtr7);
2347 }
2348 }
2349 }
2350 }
2351 throw new ArgumentNullException("data", FrameworkResources.NullNotAllowed);
2352 }

References Microsoft.Xna.Framework.Graphics.GraphicsDevice._insideScene, Microsoft.Xna.Framework.Graphics.GraphicsDevice._profileCapabilities, Microsoft.Xna.Framework.FrameworkResources.CannotGetBackBufferActiveRenderTargets, Microsoft.Xna.Framework.Helpers.CheckDisposed(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.ClearDirtyBuffers(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.currentRenderTargetCount, Microsoft.Xna.Framework.Graphics.GraphicsDevice.DefaultClearOptions, Microsoft.Xna.Framework.Graphics.Texture.GetAndValidateRect(), Microsoft.Xna.Framework.Graphics.ProfileCapabilities.GetBackBufferData, Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.lazyClearFlags, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pComPtr, Microsoft.Xna.Framework.Graphics.GraphicsDevice.pInternalCachedParams, Microsoft.Xna.Framework.FrameworkResources.ProfileFeatureNotSupported, Microsoft.Xna.Framework.Graphics.PresentationParameters.RenderTargetUsage, System.startIndex, Microsoft.Xna.Framework.Graphics.ProfileCapabilities.ThrowNotSupportedException(), Microsoft.Xna.Framework.Helpers.ValidateCopyParameters(), and Microsoft.Xna.Framework.Graphics.Texture.ValidateTotalSize().