Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ProfileChecker.cs
Go to the documentation of this file.
1using System;
5
7
8internal static class ProfileChecker
9{
11
12 [return: MarshalAs(UnmanagedType.U1)]
13 public unsafe static bool IsProfileSupported(IDirect3D9* pD3D, uint adapter, _D3DDEVTYPE deviceType, GraphicsProfile graphicsProfile)
14 {
17 if (((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DDEVTYPE, _D3DCAPS9*, int>)(int)(*(uint*)(*(int*)pD3D + 56)))((nint)pD3D, adapter, deviceType, &d3DCAPS) < 0)
18 {
19 return false;
20 }
21 if (deviceType == (_D3DDEVTYPE)1 && (System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 28)) & 0x10000) == 0)
22 {
25 }
27 {
28 return false;
29 }
31 {
32 return false;
33 }
34 if ((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 180)) < (uint)instance.MaxPrimitiveCount)
35 {
36 return false;
37 }
38 if ((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 188)) < (uint)instance.MaxVertexStreams)
39 {
40 return false;
41 }
42 if ((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 192)) < (uint)instance.MaxStreamStride)
43 {
44 return false;
45 }
46 int num = (instance.IndexElementSize32 ? 16777214 : 65534);
47 if ((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 184)) < (uint)num)
48 {
49 return false;
50 }
52 {
53 return false;
54 }
56 {
57 return false;
58 }
60 {
61 return false;
62 }
64 {
65 return false;
66 }
68 {
69 return false;
70 }
72 {
73 return false;
74 }
76 {
77 return false;
78 }
80 {
81 return false;
82 }
84 {
85 return false;
86 }
88 {
89 return false;
90 }
92 {
93 return false;
94 }
96 {
97 return false;
98 }
100 {
101 return false;
102 }
104 {
105 return false;
106 }
108 {
109 return false;
110 }
112 {
113 return false;
114 }
116 {
117 return false;
118 }
120 {
121 return false;
122 }
124 {
125 return false;
126 }
128 {
129 return false;
130 }
132 {
133 return false;
134 }
136 {
137 return false;
138 }
140 {
141 return false;
142 }
144 {
145 return false;
146 }
148 {
149 return false;
150 }
151 if ((System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 136)) & 1) == 0)
152 {
153 return false;
154 }
155 if ((System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 136)) & 2) == 0)
156 {
157 return false;
158 }
159 if ((System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 136)) & 4) == 0)
160 {
161 return false;
162 }
163 if ((System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 136)) & 8) == 0)
164 {
165 return false;
166 }
168 {
169 return false;
170 }
172 {
173 return false;
174 }
176 {
177 return false;
178 }
180 {
181 return false;
182 }
184 {
185 return false;
186 }
188 {
189 return false;
190 }
192 {
193 return false;
194 }
196 {
197 return false;
198 }
200 {
201 return false;
202 }
204 {
205 return false;
206 }
208 {
209 return false;
210 }
212 {
213 return false;
214 }
216 {
217 return false;
218 }
220 {
221 return false;
222 }
224 {
225 return false;
226 }
228 {
229 return false;
230 }
232 {
233 return false;
234 }
236 {
237 return false;
238 }
240 {
241 return false;
242 }
244 {
245 return false;
246 }
248 {
249 return false;
250 }
252 {
253 return false;
254 }
256 {
257 return false;
258 }
260 {
261 return false;
262 }
264 {
265 return false;
266 }
268 {
269 return false;
270 }
272 {
273 return false;
274 }
276 {
277 return false;
278 }
280 {
281 return false;
282 }
284 {
285 return false;
286 }
287 int maxRenderTargets = instance.MaxRenderTargets;
289 {
290 return false;
291 }
292 if (maxRenderTargets > 1)
293 {
295 {
296 return false;
297 }
299 {
300 return false;
301 }
302 }
303 int maxTextureSize = instance.MaxTextureSize;
305 {
306 return false;
307 }
309 {
310 return false;
311 }
313 {
314 return false;
315 }
317 {
318 return false;
319 }
321 {
322 return false;
323 }
325 {
326 return false;
327 }
329 {
330 return false;
331 }
333 {
334 return false;
335 }
336 if (((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 60)) & 0x20u) != 0)
337 {
338 return false;
339 }
341 {
342 return false;
343 }
345 {
346 return false;
347 }
349 {
350 return false;
351 }
353 {
354 return false;
355 }
357 {
358 return false;
359 }
361 {
362 return false;
363 }
365 {
366 return false;
367 }
369 {
370 return false;
371 }
373 {
374 return false;
375 }
377 {
378 return false;
379 }
381 {
382 return false;
383 }
385 {
386 return false;
387 }
389 {
390 return false;
391 }
393 {
394 return false;
395 }
397 {
398 return false;
399 }
401 {
402 return false;
403 }
404 int maxVolumeExtent = instance.MaxVolumeExtent;
405 if (maxVolumeExtent > 0)
406 {
408 {
409 return false;
410 }
412 {
413 return false;
414 }
416 {
417 return false;
418 }
420 {
421 return false;
422 }
424 {
425 return false;
426 }
428 {
429 return false;
430 }
432 {
433 return false;
434 }
436 {
437 return false;
438 }
440 {
441 return false;
442 }
444 {
445 return false;
446 }
448 {
449 return false;
450 }
452 {
453 return false;
454 }
456 {
457 return false;
458 }
459 }
460 if (instance.NonPow2Unconditional)
461 {
462 if (((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 60)) & 2u) != 0)
463 {
464 return false;
465 }
466 }
467 else if (((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 60)) & 2u) != 0 && (System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 60)) & 0x100) == 0)
468 {
469 return false;
470 }
471 if (instance.NonPow2Cube && ((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 60)) & 0x20000u) != 0)
472 {
473 return false;
474 }
475 if (instance.NonPow2Volume && ((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 60)) & 0x40000u) != 0)
476 {
477 return false;
478 }
479 if (instance.MaxVertexSamplers > 0)
480 {
482 {
483 return false;
484 }
486 {
487 return false;
488 }
489 }
491 if (enumerator.MoveNext())
492 {
493 do
494 {
495 switch (enumerator.Current)
496 {
497 case VertexElementFormat.Color:
498 if (((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 236)) & 2u) != 0)
499 {
500 break;
501 }
502 return false;
503 case VertexElementFormat.Byte4:
504 if (((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 236)) & (true ? 1u : 0u)) != 0)
505 {
506 break;
507 }
508 return false;
509 case VertexElementFormat.NormalizedShort2:
510 if (((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 236)) & 4u) != 0)
511 {
512 break;
513 }
514 return false;
515 case VertexElementFormat.NormalizedShort4:
516 if (((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 236)) & 8u) != 0)
517 {
518 break;
519 }
520 return false;
521 case VertexElementFormat.HalfVector2:
522 if (((uint)System.Runtime.CompilerServices.Unsafe.As<_D3DCAPS9, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DCAPS, 236)) & 0x100u) != 0)
523 {
524 break;
525 }
526 return false;
527 case VertexElementFormat.HalfVector4:
529 {
530 return false;
531 }
532 break;
533 }
534 }
535 while (enumerator.MoveNext());
536 }
538 if (enumerator2.MoveNext())
539 {
540 do
541 {
542 SurfaceFormat current = enumerator2.Current;
543 if (!CheckTextureFormat(instance, pD3D, adapter, deviceType, (_D3DRESOURCETYPE)3, current))
544 {
545 return false;
546 }
547 }
548 while (enumerator2.MoveNext());
549 }
551 if (enumerator3.MoveNext())
552 {
553 do
554 {
556 if (!CheckTextureFormat(instance, pD3D, adapter, deviceType, (_D3DRESOURCETYPE)5, current2))
557 {
558 return false;
559 }
560 }
561 while (enumerator3.MoveNext());
562 }
564 if (enumerator4.MoveNext())
565 {
566 do
567 {
569 if (!CheckTextureFormat(instance, pD3D, adapter, deviceType, (_D3DRESOURCETYPE)4, current3))
570 {
571 return false;
572 }
573 }
574 while (enumerator4.MoveNext());
575 }
577 if (enumerator5.MoveNext())
578 {
579 do
580 {
582 if (!CheckVertexTextureFormat(instance, pD3D, adapter, deviceType, current4))
583 {
584 return false;
585 }
586 }
587 while (enumerator5.MoveNext());
588 }
589 if (!CheckRenderTargetFormat(instance, pD3D, adapter, deviceType, SurfaceFormat.Color))
590 {
591 return false;
592 }
593 if (instance.ValidTextureFormats.Contains(SurfaceFormat.HdrBlendable) && !CheckRenderTargetFormat(instance, pD3D, adapter, deviceType, SurfaceFormat.HdrBlendable))
594 {
595 return false;
596 }
597 return true;
598 }
599
600 [return: MarshalAs(UnmanagedType.U1)]
602 {
603 _D3DFORMAT d3DFORMAT = _003CModule_003E.ConvertXnaFormatToWindows(format);
604 int num = *(int*)pD3D + 40;
605 if (((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DDEVTYPE, _D3DFORMAT, uint, _D3DRESOURCETYPE, _D3DFORMAT, int>)(int)(*(uint*)num))((nint)pD3D, adapter, deviceType, IRRELEVANT_ADAPTER_FORMAT, 0u, resourceType, d3DFORMAT) < 0)
606 {
607 return false;
608 }
609 int num2 = *(int*)pD3D + 40;
610 if (((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DDEVTYPE, _D3DFORMAT, uint, _D3DRESOURCETYPE, _D3DFORMAT, int>)(int)(*(uint*)num2))((nint)pD3D, adapter, deviceType, IRRELEVANT_ADAPTER_FORMAT, 2097152u, resourceType, d3DFORMAT) < 0)
611 {
612 return false;
613 }
614 if (!profileCapabilities.InvalidFilterFormats.Contains(format))
615 {
616 int num3 = *(int*)pD3D + 40;
617 if (((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DDEVTYPE, _D3DFORMAT, uint, _D3DRESOURCETYPE, _D3DFORMAT, int>)(int)(*(uint*)num3))((nint)pD3D, adapter, deviceType, IRRELEVANT_ADAPTER_FORMAT, 131072u, resourceType, d3DFORMAT) < 0)
618 {
619 return false;
620 }
621 }
622 return true;
623 }
624
625 [return: MarshalAs(UnmanagedType.U1)]
627 {
628 _D3DFORMAT d3DFORMAT = _003CModule_003E.ConvertXnaFormatToWindows(format);
629 uint num = 3145728u;
630 if (!profileCapabilities.InvalidFilterFormats.Contains(format))
631 {
632 num = 3276800u;
633 }
634 int num2 = *(int*)pD3D + 40;
635 if (((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DDEVTYPE, _D3DFORMAT, uint, _D3DRESOURCETYPE, _D3DFORMAT, int>)(int)(*(uint*)num2))((nint)pD3D, adapter, deviceType, IRRELEVANT_ADAPTER_FORMAT, num, (_D3DRESOURCETYPE)3, d3DFORMAT) < 0)
636 {
637 return false;
638 }
639 int num3 = *(int*)pD3D + 40;
640 if (((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DDEVTYPE, _D3DFORMAT, uint, _D3DRESOURCETYPE, _D3DFORMAT, int>)(int)(*(uint*)num3))((nint)pD3D, adapter, deviceType, IRRELEVANT_ADAPTER_FORMAT, num, (_D3DRESOURCETYPE)5, d3DFORMAT) < 0)
641 {
642 return false;
643 }
644 int num4 = *(int*)pD3D + 40;
645 return ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DDEVTYPE, _D3DFORMAT, uint, _D3DRESOURCETYPE, _D3DFORMAT, int>)(int)(*(uint*)num4))((nint)pD3D, adapter, deviceType, IRRELEVANT_ADAPTER_FORMAT, num, (_D3DRESOURCETYPE)4, d3DFORMAT) >= 0;
646 }
647
648 [return: MarshalAs(UnmanagedType.U1)]
650 {
651 uint num = 1u;
652 if (!profileCapabilities.InvalidBlendFormats.Contains(format))
653 {
654 num = 524289u;
655 }
656 int num2 = *(int*)pD3D + 40;
657 return ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DDEVTYPE, _D3DFORMAT, uint, _D3DRESOURCETYPE, _D3DFORMAT, int>)(int)(*(uint*)num2))((nint)pD3D, adapter, deviceType, IRRELEVANT_ADAPTER_FORMAT, num, (_D3DRESOURCETYPE)1, _003CModule_003E.ConvertXnaFormatToWindows(format)) >= 0;
658 }
659}
static ProfileCapabilities GetInstance(GraphicsProfile graphicsProfile)
static unsafe bool CheckVertexTextureFormat(ProfileCapabilities profileCapabilities, IDirect3D9 *pD3D, uint adapter, _D3DDEVTYPE deviceType, SurfaceFormat format)
static unsafe bool CheckRenderTargetFormat(ProfileCapabilities profileCapabilities, IDirect3D9 *pD3D, uint adapter, _D3DDEVTYPE deviceType, SurfaceFormat format)
static unsafe bool CheckTextureFormat(ProfileCapabilities profileCapabilities, IDirect3D9 *pD3D, uint adapter, _D3DDEVTYPE deviceType, _D3DRESOURCETYPE resourceType, SurfaceFormat format)
static unsafe bool IsProfileSupported(IDirect3D9 *pD3D, uint adapter, _D3DDEVTYPE deviceType, GraphicsProfile graphicsProfile)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)