-
Notifications
You must be signed in to change notification settings - Fork 226
/
SystemInfo.cpp
1889 lines (1536 loc) · 96.9 KB
/
SystemInfo.cpp
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//--------------------------------------------------------------------------------------
// SystemInfo.cpp
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#include "pch.h"
#include "SystemInfo.h"
#include "ATGColors.h"
#include "ControllerFont.h"
extern void ExitSample() noexcept;
using namespace DirectX;
using namespace DirectX::SimpleMath;
using Microsoft::WRL::ComPtr;
#include <libloaderapi2.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
namespace
{
inline float XM_CALLCONV DrawStringCenter(SpriteBatch* batch, SpriteFont* font, const wchar_t* text, float mid, float y, FXMVECTOR color, float scale)
{
XMVECTOR size = font->MeasureString(text);
XMFLOAT2 pos(mid - XMVectorGetX(size)*scale / 2.f, y);
font->DrawString(batch, text, pos, color, 0.f, Vector2::Zero, scale);
return font->GetLineSpacing() * scale;
}
inline void DrawStringLeft(SpriteBatch* batch, SpriteFont* font, const wchar_t* text, float mid, float y, float scale)
{
XMVECTOR size = font->MeasureString(text);
XMFLOAT2 pos(mid - XMVectorGetX(size)*scale, y);
font->DrawString(batch, text, pos, ATG::Colors::Blue, 0.f, Vector2::Zero, scale);
}
inline float DrawStringRight(SpriteBatch* batch, SpriteFont* font, const wchar_t* text, float mid, float y, float scale)
{
XMFLOAT2 pos(mid, y);
font->DrawString(batch, text, pos, ATG::Colors::White, 0.f, Vector2::Zero, scale);
return font->GetLineSpacing()*scale;
}
}
Sample::Sample() :
m_scale(1.f),
m_current(0),
m_gamepadPresent(false)
{
// Renders only 2D, so no need for a depth buffer.
m_deviceResources = std::make_unique<DX::DeviceResources>(DXGI_FORMAT_B8G8R8A8_UNORM, DXGI_FORMAT_UNKNOWN);
m_deviceResources->RegisterDeviceNotify(this);
}
// Initialize the Direct3D resources required to run.
void Sample::Initialize(IUnknown* window, int width, int height, DXGI_MODE_ROTATION rotation)
{
m_gamePad = std::make_unique<GamePad>();
m_keyboard = std::make_unique<Keyboard>();
m_keyboard->SetWindow(reinterpret_cast<ABI::Windows::UI::Core::ICoreWindow*>(window));
m_deviceResources->SetWindow(window, width, height, rotation);
m_deviceResources->CreateDeviceResources();
CreateDeviceDependentResources();
m_deviceResources->CreateWindowSizeDependentResources();
CreateWindowSizeDependentResources();
}
#pragma region Frame Update
// Executes basic render loop.
void Sample::Tick()
{
m_timer.Tick([&]()
{
Update(m_timer);
});
Render();
}
// Updates the world.
void Sample::Update(DX::StepTimer const&)
{
PIXBeginEvent(PIX_COLOR_DEFAULT, L"Update");
auto pad = m_gamePad->GetState(0);
m_gamepadPresent = pad.IsConnected();
if (m_gamepadPresent)
{
m_gamePadButtons.Update(pad);
if (pad.IsViewPressed())
{
ExitSample();
}
}
else
{
m_gamePadButtons.Reset();
}
auto kb = m_keyboard->GetState();
m_keyboardButtons.Update(kb);
if (kb.Escape)
{
ExitSample();
}
if (m_keyboardButtons.IsKeyPressed(Keyboard::Right)
|| m_keyboardButtons.IsKeyPressed(Keyboard::Enter)
|| m_keyboardButtons.IsKeyPressed(Keyboard::Space)
|| m_gamePadButtons.a == GamePad::ButtonStateTracker::PRESSED
|| m_gamePadButtons.dpadRight == GamePad::ButtonStateTracker::PRESSED)
{
++m_current;
if (m_current >= int(InfoPage::MAX))
m_current = 0;
}
if (m_keyboardButtons.IsKeyPressed(Keyboard::Left)
|| m_keyboardButtons.IsKeyPressed(Keyboard::Back)
|| m_gamePadButtons.b == GamePad::ButtonStateTracker::PRESSED
|| m_gamePadButtons.dpadLeft == GamePad::ButtonStateTracker::PRESSED)
{
--m_current;
if (m_current < 0)
m_current = int(InfoPage::MAX) - 1;
}
PIXEndEvent();
}
#pragma endregion
#pragma region Frame Render
// Draws the scene.
void Sample::Render()
{
// Don't try to render anything before the first Update.
if (m_timer.GetFrameCount() == 0)
{
return;
}
Clear();
auto context = m_deviceResources->GetD3DDeviceContext();
PIXBeginEvent(context, PIX_COLOR_DEFAULT, L"Render");
auto fullscreen = m_deviceResources->GetOutputSize();
auto safeRect = Viewport::ComputeTitleSafeArea(fullscreen.right - fullscreen.left, fullscreen.bottom - fullscreen.top);
float mid = float(safeRect.left) + float(safeRect.right - safeRect.left) / 2.f;
m_batch->Begin();
m_batch->Draw(m_background.Get(), fullscreen);
float y = float(safeRect.top);
XMFLOAT2 pos(float(safeRect.left), float(safeRect.bottom) - m_smallFont->GetLineSpacing());
if (m_gamepadPresent)
{
DX::DrawControllerString(m_batch.get(), m_smallFont.get(), m_ctrlFont.get(), L"Use [A], [B], or [DPad] to cycle pages", pos, ATG::Colors::LightGrey, m_scale);
}
else
{
m_smallFont->DrawString(m_batch.get(), L"Use Left/Right to cycle pages", pos, ATG::Colors::LightGrey, 0, Vector2::Zero, m_scale);
}
float spacer = XMVectorGetX(m_smallFont->MeasureString(L"X")*m_scale);
float left = mid - spacer;
float right = mid + spacer;
switch (static_cast<InfoPage>(m_current))
{
case InfoPage::SYSTEMINFO:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"GetNativeSystemInfo", mid, y, ATG::Colors::LightGrey, m_scale);
SYSTEM_INFO info = {};
GetNativeSystemInfo(&info);
const wchar_t* arch = L"UNKNOWN";
switch (info.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_AMD64: arch = L"AMD64"; break;
case PROCESSOR_ARCHITECTURE_ARM: arch = L"ARM"; break;
case PROCESSOR_ARCHITECTURE_ARM64: arch = L"ARM64"; break;
case PROCESSOR_ARCHITECTURE_INTEL: arch = L"INTEL"; break;
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"wProcessorArchitecture", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), arch, right, y, m_scale);
wchar_t buff[128] = {};
swprintf_s(buff, L"%u", info.wProcessorLevel);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"wProcessorLevel", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%04X", info.wProcessorRevision);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"wProcessorRevision", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%zX", info.dwActiveProcessorMask);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"dwActiveProcessorMask", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u", info.dwNumberOfProcessors);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"dwNumberOfProcessors", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u", info.dwPageSize);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"dwPageSize", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u", info.dwAllocationGranularity);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"dwAllocationGranularity", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%p", info.lpMinimumApplicationAddress);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"lpMinimumApplicationAddress", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%p", info.lpMaximumApplicationAddress);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"lpMaximumApplicationAddress", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
break;
case InfoPage::GETPROCESSINFO:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"GetProcessInformation", mid, y, ATG::Colors::LightGrey, m_scale);
APP_MEMORY_INFORMATION info = {};
if (GetProcessInformation(GetCurrentProcess(), ProcessAppMemoryInfo, &info, sizeof(info)))
{
auto ac = static_cast<uint32_t>(info.AvailableCommit / (1024 * 1024));
auto pc = static_cast<uint32_t>(info.PrivateCommitUsage / (1024 * 1024));
auto ppc = static_cast<uint32_t>(info.PeakPrivateCommitUsage / (1024 * 1024));
auto tc = static_cast<uint32_t>(info.TotalCommitUsage / (1024 * 1024));
wchar_t buff[128] = {};
swprintf_s(buff, L"%u (MiB)", ac);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"AvailableCommit", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u (MiB)", pc);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"PrivateCommitUsage", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u (MiB)", ppc);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"PeakPrivateCommitUsage", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u (MiB)", tc);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"TotalCommitUsage", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
}
break;
case InfoPage::GLOBALMEMORYSTATUS:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"GlobalMemoryStatusEx", mid, y, ATG::Colors::LightGrey, m_scale);
MEMORYSTATUSEX info = {};
info.dwLength = sizeof(MEMORYSTATUSEX);
if (GlobalMemoryStatusEx(&info))
{
auto tphys = static_cast<uint32_t>(info.ullTotalPhys / (1024 * 1024));
auto aphys = static_cast<uint32_t>(info.ullAvailPhys / (1024 * 1024));
auto tpage = static_cast<uint32_t>(info.ullTotalPageFile / (1024 * 1024));
auto apage = static_cast<uint32_t>(info.ullAvailPageFile / (1024 * 1024));
auto tvirt = static_cast<uint32_t>(info.ullTotalVirtual / (1024 * 1024));
auto avirt = static_cast<uint32_t>(info.ullAvailVirtual / (1024 * 1024));
wchar_t buff[128] = {};
swprintf_s(buff, L"%u / %u (MB)", aphys, tphys);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Physical Memory", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u / %u (MB)", apage, tpage);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Page File", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u (MB)", tvirt);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Total Virtual Memory", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u (MB)", avirt);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Available VM", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
if (info.ullAvailExtendedVirtual > 0)
{
auto axvirt = static_cast<uint32_t>(info.ullAvailExtendedVirtual / (1024 * 1024));
swprintf_s(buff, L"%u (MB)", axvirt);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Available Extended VM", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
}
}
break;
case InfoPage::ANALYTICSINFO:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"AnalyticsInfo", mid, y, ATG::Colors::LightGrey, m_scale);
auto deviceForm = Windows::System::Profile::AnalyticsInfo::DeviceForm;
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DeviceForm", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), deviceForm->Data(), right, y, m_scale);
auto versionInfo = Windows::System::Profile::AnalyticsInfo::VersionInfo;
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DeviceFamily", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), versionInfo->DeviceFamily->Data(), right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DeviceFamilyVersion", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), versionInfo->DeviceFamilyVersion->Data(), right, y, m_scale);
// For real-world use just log it as an opaque string, and do the decode in the reader instead
LARGE_INTEGER li;
li.QuadPart = _wtoi64(versionInfo->DeviceFamilyVersion->Data());
wchar_t buff[128] = {};
swprintf_s(buff, L"%u.%u.%u.%u", HIWORD(li.HighPart), LOWORD(li.HighPart), HIWORD(li.LowPart), LOWORD(li.LowPart));
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
break;
case InfoPage::EASCLIENTINFO:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"EasClientDeviceInformation", mid, y, ATG::Colors::LightGrey, m_scale);
using namespace Windows::Security::ExchangeActiveSyncProvisioning;
auto easinfo = ref new EasClientDeviceInformation;
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Id", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), easinfo->Id.ToString()->Data(), right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"FriendlyName", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), easinfo->FriendlyName->Data(), right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"OperatingSystem", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), easinfo->OperatingSystem->Data(), right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"SystemManufacturer", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), easinfo->SystemManufacturer->Data(), right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"SystemProductName", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), easinfo->SystemProductName->Data(), right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"SystemSku", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), easinfo->SystemSku->Data(), right, y, m_scale);
if (!easinfo->SystemHardwareVersion->IsEmpty())
{
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"SystemHardwareVersion", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), easinfo->SystemHardwareVersion->Data(), right, y, m_scale);
}
if (!easinfo->SystemFirmwareVersion->IsEmpty())
{
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"SystemFirmwareVersion", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), easinfo->SystemFirmwareVersion->Data(), right, y, m_scale);
}
}
break;
case InfoPage::GAMINGDEVICEINFO:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"GetGamingDeviceModelInformation", mid, y, ATG::Colors::LightGrey, m_scale);
bool gamingapis = false;
#if defined(NTDDI_WIN10_RS3) && (NTDDI_VERSION >= NTDDI_WIN10_RS3)
// Requires the linker settings to include /DELAYLOAD:api-ms-win-gaming-deviceinformation-l1-1-0.dll
//
// Note: You can avoid the need for delay loading if you require 10.0.16299 or later as your minimum OS version
// and/or you restrict your package to the Xbox device family
if (QueryOptionalDelayLoadedAPI(reinterpret_cast<HMODULE>(&__ImageBase),
"api-ms-win-gaming-deviceinformation-l1-1-0.dll",
"GetGamingDeviceModelInformation",
0))
{
gamingapis = true;
GAMING_DEVICE_MODEL_INFORMATION info = {};
GetGamingDeviceModelInformation(&info);
wchar_t buff[128] = {};
swprintf_s(buff, L"%08X", static_cast<unsigned int>(info.vendorId));
switch (info.vendorId)
{
case GAMING_DEVICE_VENDOR_ID_MICROSOFT: wcscat_s(buff, L" (Microsoft)"); break;
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"VendorId", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%08X", static_cast<unsigned int>(info.deviceId));
if (info.vendorId == GAMING_DEVICE_VENDOR_ID_MICROSOFT)
{
switch (info.deviceId)
{
case GAMING_DEVICE_DEVICE_ID_XBOX_ONE: wcscat_s(buff, L" (Xbox One)"); break;
case GAMING_DEVICE_DEVICE_ID_XBOX_ONE_S: wcscat_s(buff, L" (Xbox One S)"); break;
case GAMING_DEVICE_DEVICE_ID_XBOX_ONE_X: wcscat_s(buff, L" (Xbox One X)"); break;
case GAMING_DEVICE_DEVICE_ID_XBOX_ONE_X_DEVKIT: wcscat_s(buff, L" (Xbox One X Dev Kit)"); break;
#ifndef NTDDI_WIN10_NI
#pragma warning(disable : 4063)
#define GAMING_DEVICE_DEVICE_ID_XBOX_SERIES_S static_cast<GAMING_DEVICE_DEVICE_ID>(0x1D27FABB)
#define GAMING_DEVICE_DEVICE_ID_XBOX_SERIES_X static_cast<GAMING_DEVICE_DEVICE_ID>(0x2F7A3DFF)
#define GAMING_DEVICE_DEVICE_ID_XBOX_SERIES_X_DEVKIT static_cast<GAMING_DEVICE_DEVICE_ID>(0xDE8A5661)
#endif
case GAMING_DEVICE_DEVICE_ID_XBOX_SERIES_S: wcscat_s(buff, L" (Xbox Series S)"); break;
case GAMING_DEVICE_DEVICE_ID_XBOX_SERIES_X: wcscat_s(buff, L" (Xbox Series X)"); break;
case GAMING_DEVICE_DEVICE_ID_XBOX_SERIES_X_DEVKIT: wcscat_s(buff, L" (Xbox Series X|S Dev Kit)"); break;
}
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DeviceId", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
// Requires the linker settings to include /DELAYLOAD:api-ms-win-gaming-expandedresources-l1-1-0.dll
//
// Note: You can avoid the need for delay loading if you require 10.0.16299 as your minimum OS version
// and/or you restrict your package to the Xbox device family
//
// For PC, "Game Mode" is deprecated as of Windows 10 Version 1803. It's still used for UWP on Xbox.
if (QueryOptionalDelayLoadedAPI(reinterpret_cast<HMODULE>(&__ImageBase),
"api-ms-win-gaming-expandedresources-l1-1-0.dll",
"HasExpandedResources",
0))
{
gamingapis = true;
BOOL expandedResources = FALSE;
if SUCCEEDED(HasExpandedResources(&expandedResources))
{
y += m_smallFont->GetLineSpacing() * m_scale;
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Game Mode", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), expandedResources ? L"Enabled" : L"Disabled", right, y, m_scale);
}
}
#endif
if (!gamingapis)
{
y += DrawStringCenter(m_batch.get(), m_smallFont.get(), L"These APIs require Windows 10 (16299) or later", mid, y, ATG::Colors::Orange, m_scale);
}
}
break;
case InfoPage::APICONTRACT_PAGE:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"IsApiContractPresent", mid, y, ATG::Colors::LightGrey, m_scale);
using namespace Windows::Foundation::Metadata;
const bool isfoundation2 = ApiInformation::IsApiContractPresent("Windows.Foundation.FoundationContract", 2, 0);
const bool isfoundation3 = ApiInformation::IsApiContractPresent("Windows.Foundation.FoundationContract", 3, 0);
const bool isfoundation4 = ApiInformation::IsApiContractPresent("Windows.Foundation.FoundationContract", 4, 0);
const bool isuniversal2 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 2, 0);
const bool isuniversal3 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 3, 0);
const bool isuniversal4 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 4, 0);
const bool isuniversal5 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5, 0);
const bool isuniversal6 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6, 0);
const bool isuniversal7 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 7, 0);
const bool isuniversal8 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8, 0);
const bool isuniversal9 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 9, 0);
const bool isuniversal10 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 10, 0);
const bool isuniversal11 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 11, 0);
const bool isuniversal12 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 12, 0);
const bool isuniversal13 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 13, 0);
const bool isuniversal14 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 14, 0);
const bool isuniversal15 = ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 15, 0);
const bool isphone = ApiInformation::IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0);
const bool isstore2 = ApiInformation::IsApiContractPresent("Windows.Services.Store.StoreContract", 2, 0);
const bool isstore3 = ApiInformation::IsApiContractPresent("Windows.Services.Store.StoreContract", 3, 0);
const bool isstore4 = ApiInformation::IsApiContractPresent("Windows.Services.Store.StoreContract", 4, 0);
const bool xliveStorage = ApiInformation::IsApiContractPresent("Windows.Gaming.XboxLive.StorageApiContract", 1, 0);
const bool xliveSecure = ApiInformation::IsApiContractPresent("Windows.Networking.XboxLive.XboxLiveSecureSocketsContract", 1, 0);
assert(ApiInformation::IsApiContractPresent("Windows.Foundation.FoundationContract", 1, 0));
wchar_t contracts[256] = L"1.0";
if (isfoundation2) { wcscat_s(contracts, L", 2.0"); }
if (isfoundation3) { wcscat_s(contracts, L", 3.0"); }
if (isfoundation4) { wcscat_s(contracts, L", 4.0"); }
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"FoundationContract", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), contracts, right, y, m_scale);
assert(ApiInformation::IsApiContractPresent("Windows.Foundation.UniversalApiContract", 1, 0));
wcscpy_s(contracts, L"1.0");
if (isuniversal15) { wcscat_s(contracts, L" - 15.0"); }
else if (isuniversal14) { wcscat_s(contracts, L" - 14.0"); }
else if (isuniversal13) { wcscat_s(contracts, L"- 13.0"); }
else if (isuniversal12) { wcscat_s(contracts, L"- 12.0"); }
else if (isuniversal11) { wcscat_s(contracts, L"- 11.0"); }
else if (isuniversal10) { wcscat_s(contracts, L"- 10.0"); }
else
{
if (isuniversal2) { wcscat_s(contracts, L", 2.0"); }
if (isuniversal3) { wcscat_s(contracts, L", 3.0"); }
if (isuniversal4) { wcscat_s(contracts, L", 4.0"); }
if (isuniversal5) { wcscat_s(contracts, L", 5.0"); }
if (isuniversal6) { wcscat_s(contracts, L", 6.0"); }
if (isuniversal7) { wcscat_s(contracts, L", 7.0"); }
if (isuniversal8) { wcscat_s(contracts, L", 8.0"); }
if (isuniversal9) { wcscat_s(contracts, L", 9.0"); }
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"UniversalApiContract", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), contracts, right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"PhoneContract", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), isphone ? L"1.0" : L"n/a", right, y, m_scale);
assert(ApiInformation::IsApiContractPresent("Windows.Services.Store.StoreContract", 1, 0));
wcscpy_s(contracts, L"1.0");
if (isstore2) { wcscat_s(contracts, L", 2.0"); }
if (isstore3) { wcscat_s(contracts, L", 3.0"); }
if (isstore4) { wcscat_s(contracts, L", 4.0"); }
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"StoreContract", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), contracts, right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"XboxLive StorageApiContract", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), xliveStorage ? L"1.0" : L"", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"XboxLive SecureSocketsContract", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), xliveSecure ? L"1.0" : L"", right, y, m_scale);
}
break;
case InfoPage::CPUSETS:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"GetSystemCpuSetInformation", mid, y, ATG::Colors::LightGrey, m_scale);
ULONG retsize = 0;
std::ignore = GetSystemCpuSetInformation(nullptr, 0, &retsize, GetCurrentProcess(), 0);
std::unique_ptr<uint8_t[]> data(new uint8_t[retsize]);
if (GetSystemCpuSetInformation(
reinterpret_cast<PSYSTEM_CPU_SET_INFORMATION>(data.get()),
retsize, &retsize, GetCurrentProcess(), 0))
{
size_t logicalProcessors = 0;
size_t parkedProcessors = 0;
size_t allocatedProcessors = 0;
size_t allocatedElsewhere = 0;
size_t availableProcessors = 0;
std::set<DWORD> cores;
bool moreThanOneGroup = false;
uint8_t const * ptr = data.get();
for (DWORD size = 0; size < retsize; )
{
auto info = reinterpret_cast<const SYSTEM_CPU_SET_INFORMATION*>(ptr);
if (info->Type == CpuSetInformation)
{
if (info->CpuSet.Group > 0)
{
moreThanOneGroup = true;
}
else
{
++logicalProcessors;
if (info->CpuSet.Parked)
{
++parkedProcessors;
}
else
{
if (info->CpuSet.Allocated)
{
if (info->CpuSet.AllocatedToTargetProcess)
{
++allocatedProcessors;
++availableProcessors;
cores.insert(info->CpuSet.CoreIndex);
}
else
{
++allocatedElsewhere;
}
}
else
{
++availableProcessors;
cores.insert(info->CpuSet.CoreIndex);
}
}
}
}
ptr += info->Size;
size += info->Size;
}
wchar_t buff[128] = {};
swprintf_s(buff, L"%zu", logicalProcessors);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Total logical processors", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
if (parkedProcessors > 0)
{
swprintf_s(buff, L"%zu", parkedProcessors);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Parked processors", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
if (allocatedElsewhere > 0)
{
swprintf_s(buff, L"%zu", allocatedElsewhere);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Allocated to other processes", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
swprintf_s(buff, L"%zu", availableProcessors);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Available logical processors", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
if (allocatedProcessors > 0)
{
swprintf_s(buff, L"%zu", allocatedProcessors);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Allocated logical processors", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
swprintf_s(buff, L"%zu", cores.size());
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Available physical cores", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
if (moreThanOneGroup)
{
y += m_smallFont->GetLineSpacing() * m_scale;
y += DrawStringCenter(m_batch.get(), m_smallFont.get(), L"Note more than one group found; ignored extra groups!", mid, y, ATG::Colors::Orange, m_scale);
}
}
}
break;
case InfoPage::DISPLAYINFO:
{
using namespace Windows::Graphics::Display;
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"DisplayInformation", mid, y, ATG::Colors::LightGrey, m_scale);
auto displayInformation = DisplayInformation::GetForCurrentView();
wchar_t buff[128] = {};
swprintf_s(buff, L"%u %%", displayInformation->ResolutionScale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Resolution Scale", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%.f (X:%.f Y:%.f)", displayInformation->LogicalDpi, displayInformation->RawDpiX, displayInformation->RawDpiY);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Dots Per Inch (DPI)", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
try
{
swprintf_s(buff, L"%u x %u (pixels)", displayInformation->ScreenWidthInRawPixels, displayInformation->ScreenHeightInRawPixels);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Screen Size", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
catch (...)
{
y += DrawStringCenter(m_batch.get(), m_smallFont.get(), L"Screen size requires Windows 10 (14393) or later", mid, y, ATG::Colors::Orange, m_scale);
}
const wchar_t* orientation = nullptr;
switch (displayInformation->CurrentOrientation)
{
case DisplayOrientations::Landscape: orientation = L"Landscape"; break;
case DisplayOrientations::LandscapeFlipped: orientation = L"Landscape (flipped)"; break;
case DisplayOrientations::Portrait: orientation = L"Portrait"; break;
case DisplayOrientations::PortraitFlipped: orientation = L"Portrait (flipped)"; break;
default: orientation = L"None"; break;
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Current Orientation", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), orientation, right, y, m_scale);
switch (displayInformation->NativeOrientation)
{
case DisplayOrientations::Landscape: orientation = L"Landscape"; break;
case DisplayOrientations::LandscapeFlipped: orientation = L"Landscape (flipped)"; break;
case DisplayOrientations::Portrait: orientation = L"Portrait"; break;
case DisplayOrientations::PortraitFlipped: orientation = L"Portrait (flipped)"; break;
default: orientation = L"None"; break;
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Native Orientation", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), orientation, right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Stereoscopic 3D", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), displayInformation->StereoEnabled ? L"Enabled" : L"Disabled", right, y, m_scale);
}
break;
case InfoPage::DXGI:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"DXGI", mid, y, ATG::Colors::LightGrey, m_scale);
y += DrawStringCenter(m_batch.get(), m_smallFont.get(), L"DXGI_OUTPUT_DESC", mid, y, ATG::Colors::OffWhite, m_scale);
ComPtr<IDXGIOutput> output;
HRESULT hr = m_deviceResources->GetSwapChain()->GetContainingOutput(output.GetAddressOf());
if (SUCCEEDED(hr))
{
DXGI_OUTPUT_DESC outputDesc = {};
DX::ThrowIfFailed(output->GetDesc(&outputDesc));
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DeviceName", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), outputDesc.DeviceName, right, y, m_scale);
wchar_t buff[128] = {};
swprintf_s(buff, L"%u,%u,%u,%u", outputDesc.DesktopCoordinates.left, outputDesc.DesktopCoordinates.top, outputDesc.DesktopCoordinates.right, outputDesc.DesktopCoordinates.bottom );
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DesktopCoordinates", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
const wchar_t* rotation = L"UNSPECIFIED";
switch (outputDesc.Rotation)
{
case DXGI_MODE_ROTATION_IDENTITY: rotation = L"IDENTITY"; break;
case DXGI_MODE_ROTATION_ROTATE90: rotation = L"ROTATE90"; break;
case DXGI_MODE_ROTATION_ROTATE180: rotation = L"ROTATE180"; break;
case DXGI_MODE_ROTATION_ROTATE270: rotation = L"ROTATION270"; break;
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Rotation", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), rotation, right, y, m_scale) * 1.25f;
#if defined(NTDDI_WIN10_RS2) && (NTDDI_VERSION >= NTDDI_WIN10_RS2)
ComPtr<IDXGIOutput6> output6;
if (SUCCEEDED(output.As(&output6)))
{
DXGI_OUTPUT_DESC1 outputDesc6;
DX::ThrowIfFailed(output6->GetDesc1(&outputDesc6));
const wchar_t* colorSpace = L"sRGB";
switch (outputDesc6.ColorSpace)
{
case DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020: colorSpace = L"HDR10"; break;
case DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709: colorSpace = L"Linear"; break;
}
y += DrawStringCenter(m_batch.get(), m_smallFont.get(), L"DXGI_OUTPUT_DESC1", mid, y, ATG::Colors::OffWhite, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"ColorSpace", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), colorSpace, right, y, m_scale);
}
#endif
y += DrawStringCenter(m_batch.get(), m_smallFont.get(), L"DXGI_ADAPTER_DESC", mid, y, ATG::Colors::OffWhite, m_scale);
ComPtr<IDXGIAdapter> adapter;
if (SUCCEEDED(output->GetParent(IID_PPV_ARGS(adapter.GetAddressOf()))))
{
DXGI_ADAPTER_DESC adapterDesc = {};
DX::ThrowIfFailed(adapter->GetDesc(&adapterDesc));
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Description", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), adapterDesc.Description, right, y, m_scale);
swprintf_s(buff, L"%04X / %04X", adapterDesc.VendorId, adapterDesc.DeviceId);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"VendorId / DeviceId", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%08X / %u", adapterDesc.SubSysId, adapterDesc.Revision);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"SubSysId / Revision", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
auto dvm = static_cast<uint32_t>(adapterDesc.DedicatedVideoMemory / (1024 * 1024));
auto dsm = static_cast<uint32_t>(adapterDesc.DedicatedSystemMemory / (1024 * 1024));
auto ssm = static_cast<uint32_t>(adapterDesc.SharedSystemMemory / (1024 * 1024));
swprintf_s(buff, L"%u (MiB)", dvm);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DedicatedVideoMemory", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
swprintf_s(buff, L"%u (MiB) / %u (MiB)", dsm, ssm);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Dedicated / Shared SystemMemory", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), buff, right, y, m_scale);
}
}
else
{
wchar_t buff[128] = {};
swprintf_s(buff, L"GetContainingOutput failed with %08X", static_cast<unsigned int>(hr));
y += DrawStringCenter(m_batch.get(), m_smallFont.get(), buff, mid, y, ATG::Colors::Orange, m_scale);
}
y += m_smallFont->GetLineSpacing() * m_scale;
ComPtr<IDXGIDevice3> dxgiDevice;
if (SUCCEEDED(m_deviceResources->GetD3DDevice()->QueryInterface(IID_PPV_ARGS(dxgiDevice.GetAddressOf()))))
{
ComPtr<IDXGIAdapter> dxgiAdapter;
if (SUCCEEDED(dxgiDevice->GetAdapter(dxgiAdapter.GetAddressOf())))
{
ComPtr<IDXGIFactory5> dxgiFactory;
if (SUCCEEDED(dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.GetAddressOf()))))
{
BOOL allowTearing = FALSE;
if (SUCCEEDED(dxgiFactory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allowTearing, sizeof(BOOL))))
{
const wchar_t* dxgiver = L"DXGI 1.5";
#if defined(NTDDI_WIN10_RS4) && (NTDDI_VERSION >= NTDDI_WIN10_RS4)
{
ComPtr<IDXGIFactory6> dxgiFactory6;
if (SUCCEEDED(dxgiFactory.As(&dxgiFactory6)))
{
dxgiver = L"DXGI 1.6";
}
}
#endif
y += DrawStringCenter(m_batch.get(), m_smallFont.get(), dxgiver, mid, y, ATG::Colors::OffWhite, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Allow Tearing", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), allowTearing ? L"true" : L"false", right, y, m_scale);
}
}
}
}
}
break;
case InfoPage::DIRECT3D11_1:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"Direct3D 11.1", mid, y, ATG::Colors::LightGrey, m_scale);
const wchar_t* featLevel = L"Unknown";
switch (m_deviceResources->GetDeviceFeatureLevel())
{
case D3D_FEATURE_LEVEL_9_1: featLevel = L"9.1"; break;
case D3D_FEATURE_LEVEL_9_2: featLevel = L"9.2"; break;
case D3D_FEATURE_LEVEL_9_3: featLevel = L"9.3"; break;
case D3D_FEATURE_LEVEL_10_0: featLevel = L"10.0"; break;
case D3D_FEATURE_LEVEL_10_1: featLevel = L"10.1"; break;
case D3D_FEATURE_LEVEL_11_0: featLevel = L"11.0"; break;
case D3D_FEATURE_LEVEL_11_1: featLevel = L"11.1"; break;
case D3D_FEATURE_LEVEL_12_0: featLevel = L"12.0"; break;
case D3D_FEATURE_LEVEL_12_1: featLevel = L"12.1"; break;
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"Hardware Feature Level", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), featLevel, right, y, m_scale);
auto device = m_deviceResources->GetD3DDevice();
D3D11_FEATURE_DATA_DOUBLES doubles = {};
if (SUCCEEDED(device->CheckFeatureSupport(D3D11_FEATURE_DOUBLES, &doubles, sizeof(doubles))))
{
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DoublePrecisionFloatShaderOps", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), doubles.DoublePrecisionFloatShaderOps ? L"true" : L"false", right, y, m_scale);
}
D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS d3d10compute = {};
if (FAILED(device->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &d3d10compute, sizeof(d3d10compute))))
{
memset(&d3d10compute, 0, sizeof(d3d10compute));
}
const wchar_t* directcompute = L"No";
if (m_deviceResources->GetDeviceFeatureLevel() >= D3D_FEATURE_LEVEL_11_0)
{
directcompute = L"5.0";
}
else if (d3d10compute.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x)
{
directcompute = (m_deviceResources->GetDeviceFeatureLevel() >= D3D_FEATURE_LEVEL_10_1) ? L"4.1" : L"4.0";
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"DirectCompute", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), directcompute, right, y, m_scale);
D3D11_FEATURE_DATA_D3D11_OPTIONS d3d11opts = {};
if (SUCCEEDED(device->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &d3d11opts, sizeof(d3d11opts))))
{
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"OutputMergerLogicOp", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts.OutputMergerLogicOp ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"ClearView", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts.ClearView ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"CBPartialUpdate", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts.ConstantBufferPartialUpdate ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"CBOffsetting", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts.ConstantBufferOffsetting ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"MapNoOverwriteOnDynamicCB", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts.MapNoOverwriteOnDynamicConstantBuffer ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"MapNoOverwriteOnDynamicSRV", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts.MapNoOverwriteOnDynamicBufferSRV ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"SAD4ShaderInstructions", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts.SAD4ShaderInstructions ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"ExtendedDoublesShaderInstructions", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts.ExtendedDoublesShaderInstructions ? L"true" : L"false", right, y, m_scale);
}
D3D11_FEATURE_DATA_ARCHITECTURE_INFO arch = {};
if (SUCCEEDED(device->CheckFeatureSupport(D3D11_FEATURE_ARCHITECTURE_INFO, &arch, sizeof(arch))))
{
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"TileBasedDeferredRenderer", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), arch.TileBasedDeferredRenderer ? L"true" : L"false", right, y, m_scale);
}
}
break;
case InfoPage::DIRECT3D11_2:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"Direct3D 11.2", mid, y, ATG::Colors::LightGrey, m_scale);
auto device = m_deviceResources->GetD3DDevice();
D3D11_FEATURE_DATA_D3D11_OPTIONS1 d3d11opts1 = {};
if (SUCCEEDED(device->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS1, &d3d11opts1, sizeof(d3d11opts1))))
{
const wchar_t* tiledTier = L"Unknown";
switch (d3d11opts1.TiledResourcesTier)
{
case D3D11_TILED_RESOURCES_NOT_SUPPORTED: tiledTier = L"Not supported"; break;
case D3D11_TILED_RESOURCES_TIER_1: tiledTier = L"Tier 1"; break;
case D3D11_TILED_RESOURCES_TIER_2: tiledTier = L"Tier 2"; break;
case D3D11_TILED_RESOURCES_TIER_3: tiledTier = L"Tier 3"; break;
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"TiledResourcesTier", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), tiledTier, right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"MinMaxFiltering", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts1.MinMaxFiltering ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"ClearView(...)DepthOnlyFormats", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts1.ClearViewAlsoSupportsDepthOnlyFormats ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"MapOnDefaultBuffers", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts1.MapOnDefaultBuffers ? L"true" : L"false", right, y, m_scale);
}
}
break;
case InfoPage::DIRECT3D11_3:
{
y += DrawStringCenter(m_batch.get(), m_largeFont.get(), L"Direct3D 11.3", mid, y, ATG::Colors::LightGrey, m_scale);
auto device = m_deviceResources->GetD3DDevice();
D3D11_FEATURE_DATA_D3D11_OPTIONS2 d3d11opts2 = {};
if (SUCCEEDED(device->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS2, &d3d11opts2, sizeof(d3d11opts2))))
{
const wchar_t* cRastTier = L"Unknown";
switch (d3d11opts2.ConservativeRasterizationTier)
{
case D3D11_CONSERVATIVE_RASTERIZATION_NOT_SUPPORTED: cRastTier = L"Not supported"; break;
case D3D11_CONSERVATIVE_RASTERIZATION_TIER_1: cRastTier = L"Tier 1"; break;
case D3D11_CONSERVATIVE_RASTERIZATION_TIER_2: cRastTier = L"Tier 2"; break;
case D3D11_CONSERVATIVE_RASTERIZATION_TIER_3: cRastTier = L"Tier 3"; break;
}
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"ConservativeRasterizationTier", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), cRastTier, right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"PSSpecifiedStencilRefSupported", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts2.PSSpecifiedStencilRefSupported ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"TypedUAVLoadAdditionalFormats", left, y, m_scale);
y += DrawStringRight(m_batch.get(), m_smallFont.get(), d3d11opts2.TypedUAVLoadAdditionalFormats ? L"true" : L"false", right, y, m_scale);
DrawStringLeft(m_batch.get(), m_smallFont.get(), L"ROVsSupported", left, y, m_scale);