forked from microsoft/DxCapsViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dxgi.cpp
6547 lines (5504 loc) · 249 KB
/
dxgi.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
//-----------------------------------------------------------------------------
// Name: dxgi.cpp
//
// Desc: DirectX Capabilities Viewer for DXGI (Direct3D 10.x / 11.x / 12.0)
//
// Copyright Microsoft Corporation. All Rights Reserved.
// Licensed under the MIT License.
//
// https://go.microsoft.com/fwlink/?linkid=2136896
//-----------------------------------------------------------------------------
#include "dxview.h"
#ifdef USING_DIRECTX_HEADERS
#include <directx/dxgiformat.h>
#include <directx/d3d12.h>
#else
#include <d3d12.h>
#endif
#include <D3Dcommon.h>
#include <dxgi1_6.h>
#include <d3d10_1.h>
#include <d3d11_4.h>
// Define for some debug output
//#define EXTRA_DEBUG
//-----------------------------------------------------------------------------
enum FLMASK
{
FLMASK_9_1 = 0x1,
FLMASK_9_2 = 0x2,
FLMASK_9_3 = 0x4,
FLMASK_10_0 = 0x8,
FLMASK_10_1 = 0x10,
FLMASK_11_0 = 0x20,
FLMASK_11_1 = 0x40,
FLMASK_12_0 = 0x80,
FLMASK_12_1 = 0x100,
FLMASK_12_2 = 0x200,
};
#if !defined(NTDDI_WIN10_FE) && !defined(USING_D3D12_AGILITY_SDK)
#define D3D_FEATURE_LEVEL_12_2 static_cast<D3D_FEATURE_LEVEL>(0xc200)
#define D3D_SHADER_MODEL_6_7 static_cast<D3D_SHADER_MODEL>(0x67)
#pragma warning(disable : 4063 4702)
#endif
//-----------------------------------------------------------------------------
namespace
{
const char* D3D10_NOTE = "Most Direct3D 10 features are required. Tool only shows optional features.";
const char* D3D10_NOTE1 = "Most Direct3D 10.1 features are required. Tool only shows optional features.";
const char* D3D11_NOTE = "Most Direct3D 11 features are required. Tool only shows optional features.";
const char* D3D11_NOTE1 = "Most Direct3D 11.1 features are required. Tool only shows optional features.";
const char* D3D11_NOTE2 = "Most Direct3D 11.2 features are required. Tool only shows optional features.";
const char* D3D11_NOTE3 = "Most Direct3D 11.3 features are required. Tool only shows optional features.";
const char* D3D11_NOTE4 = "Most Direct3D 11.x features are required. Tool only shows optional features.";
const char* _10L9_NOTE = "Most 10level9 features are required. Tool only shows optional features.";
const char* SEE_D3D10 = "See Direct3D 10 node for device details.";
const char* SEE_D3D10_1 = "See Direct3D 10.1 node for device details.";
const char* SEE_D3D11 = "See Direct3D 11 node for device details.";
const char* SEE_D3D11_1 = "See Direct3D 11.1 node for device details.";
const char* FL_NOTE = "This feature summary is derived from hardware feature level";
static_assert(sizeof(D3D10_NOTE) < 80, "String too long");
static_assert(sizeof(D3D10_NOTE1) < 80, "String too long");
static_assert(sizeof(D3D11_NOTE) < 80, "String too long");
static_assert(sizeof(D3D11_NOTE1) < 80, "String too long");
static_assert(sizeof(D3D11_NOTE2) < 80, "String too long");
static_assert(sizeof(D3D11_NOTE3) < 80, "String too long");
static_assert(sizeof(D3D11_NOTE4) < 80, "String too long");
static_assert(sizeof(_10L9_NOTE) < 80, "String too long");
static_assert(sizeof(SEE_D3D10) < 80, "String too long");
static_assert(sizeof(SEE_D3D10_1) < 80, "String too long");
static_assert(sizeof(SEE_D3D11) < 80, "String too long");
static_assert(sizeof(SEE_D3D11_1) < 80, "String too long");
//-----------------------------------------------------------------------------
using LPCREATEDXGIFACTORY = HRESULT(WINAPI*)(REFIID, void**);
using LPD3D10CREATEDEVICE = HRESULT(WINAPI*)(IDXGIAdapter*, D3D10_DRIVER_TYPE, HMODULE, UINT, UINT32, ID3D10Device**);
IDXGIFactory* g_DXGIFactory = nullptr;
IDXGIFactory1* g_DXGIFactory1 = nullptr;
IDXGIFactory2* g_DXGIFactory2 = nullptr;
IDXGIFactory3* g_DXGIFactory3 = nullptr;
IDXGIFactory4* g_DXGIFactory4 = nullptr;
IDXGIFactory5* g_DXGIFactory5 = nullptr;
HMODULE g_dxgi = nullptr;
LPD3D10CREATEDEVICE g_D3D10CreateDevice = nullptr;
HMODULE g_d3d10 = nullptr;
PFN_D3D10_CREATE_DEVICE1 g_D3D10CreateDevice1 = nullptr;
HMODULE g_d3d10_1 = nullptr;
PFN_D3D11_CREATE_DEVICE g_D3D11CreateDevice = nullptr;
HMODULE g_d3d11 = nullptr;
PFN_D3D12_CREATE_DEVICE g_D3D12CreateDevice = nullptr;
HMODULE g_d3d12 = nullptr;
}
extern DWORD g_dwViewState;
extern const char c_szYes[];
extern const char c_szNo[];
extern const char c_szNA[];
const char c_szOptYes[] = "Optional (Yes)";
const char c_szOptNo[] = "Optional (No)";
namespace
{
const char* szRotation[] =
{
"DXGI_MODE_ROTATION_UNSPECIFIED",
"DXGI_MODE_ROTATION_IDENTITY",
"DXGI_MODE_ROTATION_ROTATE90",
"DXGI_MODE_ROTATION_ROTATE180",
"DXGI_MODE_ROTATION_ROTATE270"
};
// The DXGI formats that can be used as display devices
const DXGI_FORMAT AdapterFormatArray[] =
{
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_R10G10B10A2_UNORM,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, // DXGI 1.1
DXGI_FORMAT_B8G8R8A8_UNORM, // DXGI 1.1
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, // DXGI 1.1
};
const UINT NumAdapterFormats = sizeof(AdapterFormatArray) / sizeof(AdapterFormatArray[0]);
const DXGI_FORMAT g_cfsMSAA_10level9[] =
{
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_D16_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM
};
const DXGI_FORMAT g_cfsMSAA_10[] =
{
DXGI_FORMAT_R32G32B32A32_FLOAT,
DXGI_FORMAT_R32G32B32A32_UINT,
DXGI_FORMAT_R32G32B32A32_SINT,
DXGI_FORMAT_R32G32B32_FLOAT,
DXGI_FORMAT_R32G32B32_UINT,
DXGI_FORMAT_R32G32B32_SINT,
DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_R16G16B16A16_UNORM,
DXGI_FORMAT_R16G16B16A16_UINT,
DXGI_FORMAT_R16G16B16A16_SNORM,
DXGI_FORMAT_R16G16B16A16_SINT,
DXGI_FORMAT_R32G32_FLOAT,
DXGI_FORMAT_R32G32_UINT,
DXGI_FORMAT_R32G32_SINT,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT,
DXGI_FORMAT_R10G10B10A2_UNORM,
DXGI_FORMAT_R10G10B10A2_UINT,
DXGI_FORMAT_R11G11B10_FLOAT,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UINT,
DXGI_FORMAT_R8G8B8A8_SNORM,
DXGI_FORMAT_R8G8B8A8_SINT,
DXGI_FORMAT_R16G16_FLOAT,
DXGI_FORMAT_R16G16_UNORM,
DXGI_FORMAT_R16G16_UINT,
DXGI_FORMAT_R16G16_SNORM,
DXGI_FORMAT_R16G16_SINT,
DXGI_FORMAT_D32_FLOAT,
DXGI_FORMAT_R32_FLOAT,
DXGI_FORMAT_R32_UINT,
DXGI_FORMAT_R32_SINT,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_R8G8_UNORM,
DXGI_FORMAT_R8G8_UINT,
DXGI_FORMAT_R8G8_SNORM,
DXGI_FORMAT_R8G8_SINT,
DXGI_FORMAT_R16_FLOAT,
DXGI_FORMAT_D16_UNORM,
DXGI_FORMAT_R16_UNORM,
DXGI_FORMAT_R16_UINT,
DXGI_FORMAT_R16_SNORM,
DXGI_FORMAT_R16_SINT,
DXGI_FORMAT_R8_UNORM,
DXGI_FORMAT_R8_UINT,
DXGI_FORMAT_R8_SNORM,
DXGI_FORMAT_R8_SINT,
DXGI_FORMAT_A8_UNORM
};
const DXGI_FORMAT g_cfsMSAA_11[] =
{
DXGI_FORMAT_R32G32B32A32_FLOAT,
DXGI_FORMAT_R32G32B32A32_UINT,
DXGI_FORMAT_R32G32B32A32_SINT,
DXGI_FORMAT_R32G32B32_FLOAT,
DXGI_FORMAT_R32G32B32_UINT,
DXGI_FORMAT_R32G32B32_SINT,
DXGI_FORMAT_R16G16B16A16_FLOAT,
DXGI_FORMAT_R16G16B16A16_UNORM,
DXGI_FORMAT_R16G16B16A16_UINT,
DXGI_FORMAT_R16G16B16A16_SNORM,
DXGI_FORMAT_R16G16B16A16_SINT,
DXGI_FORMAT_R32G32_FLOAT,
DXGI_FORMAT_R32G32_UINT,
DXGI_FORMAT_R32G32_SINT,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT,
DXGI_FORMAT_R10G10B10A2_UNORM,
DXGI_FORMAT_R10G10B10A2_UINT,
DXGI_FORMAT_R11G11B10_FLOAT,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
DXGI_FORMAT_R8G8B8A8_UINT,
DXGI_FORMAT_R8G8B8A8_SNORM,
DXGI_FORMAT_R8G8B8A8_SINT,
DXGI_FORMAT_R16G16_FLOAT,
DXGI_FORMAT_R16G16_UNORM,
DXGI_FORMAT_R16G16_UINT,
DXGI_FORMAT_R16G16_SNORM,
DXGI_FORMAT_R16G16_SINT,
DXGI_FORMAT_D32_FLOAT,
DXGI_FORMAT_R32_FLOAT,
DXGI_FORMAT_R32_UINT,
DXGI_FORMAT_R32_SINT,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_R8G8_UNORM,
DXGI_FORMAT_R8G8_UINT,
DXGI_FORMAT_R8G8_SNORM,
DXGI_FORMAT_R8G8_SINT,
DXGI_FORMAT_R16_FLOAT,
DXGI_FORMAT_D16_UNORM,
DXGI_FORMAT_R16_UNORM,
DXGI_FORMAT_R16_UINT,
DXGI_FORMAT_R16_SNORM,
DXGI_FORMAT_R16_SINT,
DXGI_FORMAT_R8_UNORM,
DXGI_FORMAT_R8_UINT,
DXGI_FORMAT_R8_SNORM,
DXGI_FORMAT_R8_SINT,
DXGI_FORMAT_A8_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB,
DXGI_FORMAT_B8G8R8X8_UNORM,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB,
DXGI_FORMAT_B5G6R5_UNORM,
DXGI_FORMAT_B5G5R5A1_UNORM,
DXGI_FORMAT_B4G4R4A4_UNORM,
};
BOOL g_sampCount10[D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT];
BOOL g_sampCount10_1[D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT];
BOOL g_sampCount11[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT];
BOOL g_sampCount11_1[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT];
const D3D_FEATURE_LEVEL g_featureLevels[] =
{
D3D_FEATURE_LEVEL_12_2,
D3D_FEATURE_LEVEL_12_1,
D3D_FEATURE_LEVEL_12_0,
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
D3D_FEATURE_LEVEL_9_1
};
D3D_FEATURE_LEVEL GetD3D12FeatureLevel(_In_ ID3D12Device* device)
{
D3D12_FEATURE_DATA_FEATURE_LEVELS flData = {};
flData.NumFeatureLevels = 5; // D3D12 requires FL 11.0 or greater
flData.pFeatureLevelsRequested = g_featureLevels;
if (SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &flData, sizeof(D3D12_FEATURE_DATA_FEATURE_LEVELS))))
return flData.MaxSupportedFeatureLevel;
return static_cast<D3D_FEATURE_LEVEL>(0);
}
D3D_SHADER_MODEL GetD3D12ShaderModel(_In_opt_ ID3D12Device* device)
{
if (!device)
return D3D_SHADER_MODEL_5_1;
D3D12_FEATURE_DATA_SHADER_MODEL shaderModelOpt = {};
shaderModelOpt.HighestShaderModel = D3D_SHADER_MODEL_6_7;
HRESULT hr = device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModelOpt, sizeof(shaderModelOpt));
while (hr == E_INVALIDARG && shaderModelOpt.HighestShaderModel > D3D_SHADER_MODEL_6_0)
{
shaderModelOpt.HighestShaderModel = static_cast<D3D_SHADER_MODEL>(static_cast<int>(shaderModelOpt.HighestShaderModel) - 1);
hr = device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModelOpt, sizeof(shaderModelOpt));
}
if (FAILED(hr))
{
shaderModelOpt.HighestShaderModel = D3D_SHADER_MODEL_5_1;
}
return shaderModelOpt.HighestShaderModel;
}
const char* D3D12DXRSupported(_In_ ID3D12Device* device)
{
D3D12_FEATURE_DATA_D3D12_OPTIONS5 d3d12opts = {};
if (SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &d3d12opts, sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS5))))
{
switch (d3d12opts.RaytracingTier)
{
case D3D12_RAYTRACING_TIER_NOT_SUPPORTED: break;
case D3D12_RAYTRACING_TIER_1_0: return "Optional (Yes - Tier 1.0)";
case D3D12_RAYTRACING_TIER_1_1: return "Optional (Yes - Tier 1.1)";
default: return c_szOptYes;
}
}
return c_szOptNo;
}
const char* D3D12VRSSupported(_In_ ID3D12Device* device)
{
D3D12_FEATURE_DATA_D3D12_OPTIONS6 d3d12opts = {};
if (SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS6, &d3d12opts, sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS6))))
{
switch (d3d12opts.VariableShadingRateTier)
{
case D3D12_VARIABLE_SHADING_RATE_TIER_NOT_SUPPORTED: break;
case D3D12_VARIABLE_SHADING_RATE_TIER_1: return "Optional (Yes - Tier 1)";
case D3D12_VARIABLE_SHADING_RATE_TIER_2: return "Optional (Yes - Teir 2)";
default: return c_szOptYes;
}
}
return c_szOptNo;
}
bool IsD3D12MeshShaderSupported(_In_ ID3D12Device* device)
{
D3D12_FEATURE_DATA_D3D12_OPTIONS7 d3d12opts = {};
if (SUCCEEDED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &d3d12opts, sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS7))))
{
return d3d12opts.MeshShaderTier != D3D12_MESH_SHADER_TIER_NOT_SUPPORTED;
}
return false;
}
//-----------------------------------------------------------------------------
#define ENUMNAME(a) case a: return TEXT(#a)
const TCHAR* FormatName(DXGI_FORMAT format)
{
switch (format)
{
ENUMNAME(DXGI_FORMAT_R32G32B32A32_TYPELESS);
ENUMNAME(DXGI_FORMAT_R32G32B32A32_FLOAT);
ENUMNAME(DXGI_FORMAT_R32G32B32A32_UINT);
ENUMNAME(DXGI_FORMAT_R32G32B32A32_SINT);
ENUMNAME(DXGI_FORMAT_R32G32B32_TYPELESS);
ENUMNAME(DXGI_FORMAT_R32G32B32_FLOAT);
ENUMNAME(DXGI_FORMAT_R32G32B32_UINT);
ENUMNAME(DXGI_FORMAT_R32G32B32_SINT);
ENUMNAME(DXGI_FORMAT_R16G16B16A16_TYPELESS);
ENUMNAME(DXGI_FORMAT_R16G16B16A16_FLOAT);
ENUMNAME(DXGI_FORMAT_R16G16B16A16_UNORM);
ENUMNAME(DXGI_FORMAT_R16G16B16A16_UINT);
ENUMNAME(DXGI_FORMAT_R16G16B16A16_SNORM);
ENUMNAME(DXGI_FORMAT_R16G16B16A16_SINT);
ENUMNAME(DXGI_FORMAT_R32G32_TYPELESS);
ENUMNAME(DXGI_FORMAT_R32G32_FLOAT);
ENUMNAME(DXGI_FORMAT_R32G32_UINT);
ENUMNAME(DXGI_FORMAT_R32G32_SINT);
ENUMNAME(DXGI_FORMAT_R32G8X24_TYPELESS);
ENUMNAME(DXGI_FORMAT_D32_FLOAT_S8X24_UINT);
ENUMNAME(DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS);
ENUMNAME(DXGI_FORMAT_X32_TYPELESS_G8X24_UINT);
ENUMNAME(DXGI_FORMAT_R10G10B10A2_TYPELESS);
ENUMNAME(DXGI_FORMAT_R10G10B10A2_UNORM);
ENUMNAME(DXGI_FORMAT_R10G10B10A2_UINT);
ENUMNAME(DXGI_FORMAT_R11G11B10_FLOAT);
ENUMNAME(DXGI_FORMAT_R8G8B8A8_TYPELESS);
ENUMNAME(DXGI_FORMAT_R8G8B8A8_UNORM);
ENUMNAME(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB);
ENUMNAME(DXGI_FORMAT_R8G8B8A8_UINT);
ENUMNAME(DXGI_FORMAT_R8G8B8A8_SNORM);
ENUMNAME(DXGI_FORMAT_R8G8B8A8_SINT);
ENUMNAME(DXGI_FORMAT_R16G16_TYPELESS);
ENUMNAME(DXGI_FORMAT_R16G16_FLOAT);
ENUMNAME(DXGI_FORMAT_R16G16_UNORM);
ENUMNAME(DXGI_FORMAT_R16G16_UINT);
ENUMNAME(DXGI_FORMAT_R16G16_SNORM);
ENUMNAME(DXGI_FORMAT_R16G16_SINT);
ENUMNAME(DXGI_FORMAT_R32_TYPELESS);
ENUMNAME(DXGI_FORMAT_D32_FLOAT);
ENUMNAME(DXGI_FORMAT_R32_FLOAT);
ENUMNAME(DXGI_FORMAT_R32_UINT);
ENUMNAME(DXGI_FORMAT_R32_SINT);
ENUMNAME(DXGI_FORMAT_R24G8_TYPELESS);
ENUMNAME(DXGI_FORMAT_D24_UNORM_S8_UINT);
ENUMNAME(DXGI_FORMAT_R24_UNORM_X8_TYPELESS);
ENUMNAME(DXGI_FORMAT_X24_TYPELESS_G8_UINT);
ENUMNAME(DXGI_FORMAT_R8G8_TYPELESS);
ENUMNAME(DXGI_FORMAT_R8G8_UNORM);
ENUMNAME(DXGI_FORMAT_R8G8_UINT);
ENUMNAME(DXGI_FORMAT_R8G8_SNORM);
ENUMNAME(DXGI_FORMAT_R8G8_SINT);
ENUMNAME(DXGI_FORMAT_R16_TYPELESS);
ENUMNAME(DXGI_FORMAT_R16_FLOAT);
ENUMNAME(DXGI_FORMAT_D16_UNORM);
ENUMNAME(DXGI_FORMAT_R16_UNORM);
ENUMNAME(DXGI_FORMAT_R16_UINT);
ENUMNAME(DXGI_FORMAT_R16_SNORM);
ENUMNAME(DXGI_FORMAT_R16_SINT);
ENUMNAME(DXGI_FORMAT_R8_TYPELESS);
ENUMNAME(DXGI_FORMAT_R8_UNORM);
ENUMNAME(DXGI_FORMAT_R8_UINT);
ENUMNAME(DXGI_FORMAT_R8_SNORM);
ENUMNAME(DXGI_FORMAT_R8_SINT);
ENUMNAME(DXGI_FORMAT_A8_UNORM);
ENUMNAME(DXGI_FORMAT_R1_UNORM);
ENUMNAME(DXGI_FORMAT_R9G9B9E5_SHAREDEXP);
ENUMNAME(DXGI_FORMAT_R8G8_B8G8_UNORM);
ENUMNAME(DXGI_FORMAT_G8R8_G8B8_UNORM);
ENUMNAME(DXGI_FORMAT_BC1_TYPELESS);
ENUMNAME(DXGI_FORMAT_BC1_UNORM);
ENUMNAME(DXGI_FORMAT_BC1_UNORM_SRGB);
ENUMNAME(DXGI_FORMAT_BC2_TYPELESS);
ENUMNAME(DXGI_FORMAT_BC2_UNORM);
ENUMNAME(DXGI_FORMAT_BC2_UNORM_SRGB);
ENUMNAME(DXGI_FORMAT_BC3_TYPELESS);
ENUMNAME(DXGI_FORMAT_BC3_UNORM);
ENUMNAME(DXGI_FORMAT_BC3_UNORM_SRGB);
ENUMNAME(DXGI_FORMAT_BC4_TYPELESS);
ENUMNAME(DXGI_FORMAT_BC4_UNORM);
ENUMNAME(DXGI_FORMAT_BC4_SNORM);
ENUMNAME(DXGI_FORMAT_BC5_TYPELESS);
ENUMNAME(DXGI_FORMAT_BC5_UNORM);
ENUMNAME(DXGI_FORMAT_BC5_SNORM);
ENUMNAME(DXGI_FORMAT_B5G6R5_UNORM);
ENUMNAME(DXGI_FORMAT_B5G5R5A1_UNORM);
ENUMNAME(DXGI_FORMAT_B8G8R8A8_UNORM);
ENUMNAME(DXGI_FORMAT_B8G8R8X8_UNORM);
ENUMNAME(DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM);
ENUMNAME(DXGI_FORMAT_B8G8R8A8_TYPELESS);
ENUMNAME(DXGI_FORMAT_B8G8R8A8_UNORM_SRGB);
ENUMNAME(DXGI_FORMAT_B8G8R8X8_TYPELESS);
ENUMNAME(DXGI_FORMAT_B8G8R8X8_UNORM_SRGB);
ENUMNAME(DXGI_FORMAT_BC6H_TYPELESS);
ENUMNAME(DXGI_FORMAT_BC6H_UF16);
ENUMNAME(DXGI_FORMAT_BC6H_SF16);
ENUMNAME(DXGI_FORMAT_BC7_TYPELESS);
ENUMNAME(DXGI_FORMAT_BC7_UNORM);
ENUMNAME(DXGI_FORMAT_BC7_UNORM_SRGB);
ENUMNAME(DXGI_FORMAT_AYUV);
ENUMNAME(DXGI_FORMAT_Y410);
ENUMNAME(DXGI_FORMAT_Y416);
ENUMNAME(DXGI_FORMAT_NV12);
ENUMNAME(DXGI_FORMAT_P010);
ENUMNAME(DXGI_FORMAT_P016);
ENUMNAME(DXGI_FORMAT_420_OPAQUE);
ENUMNAME(DXGI_FORMAT_YUY2);
ENUMNAME(DXGI_FORMAT_Y210);
ENUMNAME(DXGI_FORMAT_Y216);
ENUMNAME(DXGI_FORMAT_NV11);
ENUMNAME(DXGI_FORMAT_AI44);
ENUMNAME(DXGI_FORMAT_IA44);
ENUMNAME(DXGI_FORMAT_P8);
ENUMNAME(DXGI_FORMAT_A8P8);
ENUMNAME(DXGI_FORMAT_B4G4R4A4_UNORM);
ENUMNAME(DXGI_FORMAT_P208);
ENUMNAME(DXGI_FORMAT_V208);
ENUMNAME(DXGI_FORMAT_V408);
default:
return TEXT("DXGI_FORMAT_UNKNOWN");
}
}
const TCHAR* FLName(D3D10_FEATURE_LEVEL1 lvl)
{
switch (lvl)
{
ENUMNAME(D3D10_FEATURE_LEVEL_10_0);
ENUMNAME(D3D10_FEATURE_LEVEL_10_1);
ENUMNAME(D3D10_FEATURE_LEVEL_9_1);
ENUMNAME(D3D10_FEATURE_LEVEL_9_2);
ENUMNAME(D3D10_FEATURE_LEVEL_9_3);
default:
return TEXT("D3D10_FEATURE_LEVEL_UNKNOWN");
}
}
const TCHAR* FLName(D3D_FEATURE_LEVEL lvl)
{
switch (lvl)
{
ENUMNAME(D3D_FEATURE_LEVEL_9_1);
ENUMNAME(D3D_FEATURE_LEVEL_9_2);
ENUMNAME(D3D_FEATURE_LEVEL_9_3);
ENUMNAME(D3D_FEATURE_LEVEL_10_0);
ENUMNAME(D3D_FEATURE_LEVEL_10_1);
ENUMNAME(D3D_FEATURE_LEVEL_11_0);
ENUMNAME(D3D_FEATURE_LEVEL_11_1);
ENUMNAME(D3D_FEATURE_LEVEL_12_0);
ENUMNAME(D3D_FEATURE_LEVEL_12_1);
ENUMNAME(D3D_FEATURE_LEVEL_12_2);
default:
return TEXT("D3D_FEATURE_LEVEL_UNKNOWN");
}
}
//-----------------------------------------------------------------------------
UINT RefreshRate(const DXGI_RATIONAL& Rate)
{
if (Rate.Numerator == 0)
return 0;
else if (Rate.Denominator == 0)
return 0;
else if (Rate.Denominator == 1)
return Rate.Numerator;
else
return (UINT)(float(Rate.Numerator) / float(Rate.Denominator));
}
//-----------------------------------------------------------------------------
HRESULT DXGIAdapterInfo(LPARAM /*lParam1*/, LPARAM lParam2, PRINTCBINFO* pPrintInfo)
{
auto pAdapter = reinterpret_cast<IDXGIAdapter*>(lParam2);
if (!pAdapter)
return S_OK;
if (!pPrintInfo)
{
LVAddColumn(g_hwndLV, 0, "Name", 30);
LVAddColumn(g_hwndLV, 1, "Value", 50);
}
DXGI_ADAPTER_DESC desc;
HRESULT hr = pAdapter->GetDesc(&desc);
if (FAILED(hr))
return hr;
DWORD dvm = (DWORD)(desc.DedicatedVideoMemory / (1024 * 1024));
DWORD dsm = (DWORD)(desc.DedicatedSystemMemory / (1024 * 1024));
DWORD ssm = (DWORD)(desc.SharedSystemMemory / (1024 * 1024));
char szDesc[128];
wcstombs_s(nullptr, szDesc, desc.Description, 128);
if (!pPrintInfo)
{
LVAddText(g_hwndLV, 0, "Description");
LVAddText(g_hwndLV, 1, "%s", szDesc);
LVAddText(g_hwndLV, 0, "VendorId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.VendorId);
LVAddText(g_hwndLV, 0, "DeviceId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.DeviceId);
LVAddText(g_hwndLV, 0, "SubSysId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.SubSysId);
LVAddText(g_hwndLV, 0, "Revision");
LVAddText(g_hwndLV, 1, "%d", desc.Revision);
LVAddText(g_hwndLV, 0, "DedicatedVideoMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", dvm);
LVAddText(g_hwndLV, 0, "DedicatedSystemMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", dsm);
LVAddText(g_hwndLV, 0, "SharedSystemMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", ssm);
}
else
{
PrintStringValueLine("Description", szDesc, pPrintInfo);
PrintHexValueLine("VendorId", desc.VendorId, pPrintInfo);
PrintHexValueLine("DeviceId", desc.DeviceId, pPrintInfo);
PrintHexValueLine("SubSysId", desc.SubSysId, pPrintInfo);
PrintValueLine("Revision", desc.Revision, pPrintInfo);
PrintValueLine("DedicatedVideoMemory (MB)", dvm, pPrintInfo);
PrintValueLine("DedicatedSystemMemory (MB)", dsm, pPrintInfo);
PrintValueLine("SharedSystemMemory (MB)", ssm, pPrintInfo);
}
return S_OK;
}
HRESULT DXGIAdapterInfo1(LPARAM /*lParam1*/, LPARAM lParam2, PRINTCBINFO* pPrintInfo)
{
auto pAdapter = reinterpret_cast<IDXGIAdapter1*>(lParam2);
if (!pAdapter)
return S_OK;
if (!pPrintInfo)
{
LVAddColumn(g_hwndLV, 0, "Name", 30);
LVAddColumn(g_hwndLV, 1, "Value", 50);
}
DXGI_ADAPTER_DESC1 desc;
HRESULT hr = pAdapter->GetDesc1(&desc);
if (FAILED(hr))
return hr;
auto dvm = static_cast<DWORD>(desc.DedicatedVideoMemory / (1024 * 1024));
auto dsm = static_cast<DWORD>(desc.DedicatedSystemMemory / (1024 * 1024));
auto ssm = static_cast<DWORD>(desc.SharedSystemMemory / (1024 * 1024));
char szDesc[128];
wcstombs_s(nullptr, szDesc, desc.Description, 128);
if (!pPrintInfo)
{
LVAddText(g_hwndLV, 0, "Description");
LVAddText(g_hwndLV, 1, "%s", szDesc);
LVAddText(g_hwndLV, 0, "VendorId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.VendorId);
LVAddText(g_hwndLV, 0, "DeviceId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.DeviceId);
LVAddText(g_hwndLV, 0, "SubSysId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.SubSysId);
LVAddText(g_hwndLV, 0, "Revision");
LVAddText(g_hwndLV, 1, "%d", desc.Revision);
LVAddText(g_hwndLV, 0, "DedicatedVideoMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", dvm);
LVAddText(g_hwndLV, 0, "DedicatedSystemMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", dsm);
LVAddText(g_hwndLV, 0, "SharedSystemMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", ssm);
LVAddText(g_hwndLV, 0, "Remote");
LVAddText(g_hwndLV, 1, (desc.Flags & DXGI_ADAPTER_FLAG_REMOTE) ? c_szYes : c_szNo);
}
else
{
PrintStringValueLine("Description", szDesc, pPrintInfo);
PrintHexValueLine("VendorId", desc.VendorId, pPrintInfo);
PrintHexValueLine("DeviceId", desc.DeviceId, pPrintInfo);
PrintHexValueLine("SubSysId", desc.SubSysId, pPrintInfo);
PrintValueLine("Revision", desc.Revision, pPrintInfo);
PrintValueLine("DedicatedVideoMemory (MB)", dvm, pPrintInfo);
PrintValueLine("DedicatedSystemMemory (MB)", dsm, pPrintInfo);
PrintValueLine("SharedSystemMemory (MB)", ssm, pPrintInfo);
PrintStringValueLine("Remote", (desc.Flags & DXGI_ADAPTER_FLAG_REMOTE) ? c_szYes : c_szNo, pPrintInfo);
}
return S_OK;
}
HRESULT DXGIAdapterInfo2(LPARAM /*lParam1*/, LPARAM lParam2, PRINTCBINFO* pPrintInfo)
{
auto pAdapter = reinterpret_cast<IDXGIAdapter2*>(lParam2);
if (!pAdapter)
return S_OK;
if (!pPrintInfo)
{
LVAddColumn(g_hwndLV, 0, "Name", 30);
LVAddColumn(g_hwndLV, 1, "Value", 50);
}
DXGI_ADAPTER_DESC2 desc;
HRESULT hr = pAdapter->GetDesc2(&desc);
if (FAILED(hr))
return hr;
auto dvm = static_cast<DWORD>(desc.DedicatedVideoMemory / (1024 * 1024));
auto dsm = static_cast<DWORD>(desc.DedicatedSystemMemory / (1024 * 1024));
auto ssm = static_cast<DWORD>(desc.SharedSystemMemory / (1024 * 1024));
char szDesc[128];
wcstombs_s(nullptr, szDesc, desc.Description, 128);
const char* gpg = nullptr;
const char* cpg = nullptr;
switch (desc.GraphicsPreemptionGranularity)
{
case DXGI_GRAPHICS_PREEMPTION_DMA_BUFFER_BOUNDARY: gpg = "DMA Buffer"; break;
case DXGI_GRAPHICS_PREEMPTION_PRIMITIVE_BOUNDARY: gpg = "Primitive"; break;
case DXGI_GRAPHICS_PREEMPTION_TRIANGLE_BOUNDARY: gpg = "Triangle"; break;
case DXGI_GRAPHICS_PREEMPTION_PIXEL_BOUNDARY: gpg = "Pixel"; break;
case DXGI_GRAPHICS_PREEMPTION_INSTRUCTION_BOUNDARY: gpg = "Instruction"; break;
default: gpg = "Unknown"; break;
}
switch (desc.ComputePreemptionGranularity)
{
case DXGI_COMPUTE_PREEMPTION_DMA_BUFFER_BOUNDARY: cpg = "DMA Buffer"; break;
case DXGI_COMPUTE_PREEMPTION_DISPATCH_BOUNDARY: cpg = "Dispatch"; break;
case DXGI_COMPUTE_PREEMPTION_THREAD_GROUP_BOUNDARY: cpg = "Thread Group"; break;
case DXGI_COMPUTE_PREEMPTION_THREAD_BOUNDARY: cpg = "Thread"; break;
case DXGI_COMPUTE_PREEMPTION_INSTRUCTION_BOUNDARY: cpg = "Instruction"; break;
default: cpg = "Unknown"; break;
}
if (!pPrintInfo)
{
LVAddText(g_hwndLV, 0, "Description");
LVAddText(g_hwndLV, 1, "%s", szDesc);
LVAddText(g_hwndLV, 0, "VendorId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.VendorId);
LVAddText(g_hwndLV, 0, "DeviceId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.DeviceId);
LVAddText(g_hwndLV, 0, "SubSysId");
LVAddText(g_hwndLV, 1, "0x%08x", desc.SubSysId);
LVAddText(g_hwndLV, 0, "Revision");
LVAddText(g_hwndLV, 1, "%d", desc.Revision);
LVAddText(g_hwndLV, 0, "DedicatedVideoMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", dvm);
LVAddText(g_hwndLV, 0, "DedicatedSystemMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", dsm);
LVAddText(g_hwndLV, 0, "SharedSystemMemory (MB)");
LVAddText(g_hwndLV, 1, "%d", ssm);
LVAddText(g_hwndLV, 0, "Remote");
LVAddText(g_hwndLV, 1, (desc.Flags & DXGI_ADAPTER_FLAG_REMOTE) ? c_szYes : c_szNo);
LVAddText(g_hwndLV, 0, "Graphics Preemption Granularity");
LVAddText(g_hwndLV, 1, gpg);
LVAddText(g_hwndLV, 0, "Compute Preemption Granularity");
LVAddText(g_hwndLV, 1, cpg);
}
else
{
PrintStringValueLine("Description", szDesc, pPrintInfo);
PrintHexValueLine("VendorId", desc.VendorId, pPrintInfo);
PrintHexValueLine("DeviceId", desc.DeviceId, pPrintInfo);
PrintHexValueLine("SubSysId", desc.SubSysId, pPrintInfo);
PrintValueLine("Revision", desc.Revision, pPrintInfo);
PrintValueLine("DedicatedVideoMemory (MB)", dvm, pPrintInfo);
PrintValueLine("DedicatedSystemMemory (MB)", dsm, pPrintInfo);
PrintValueLine("SharedSystemMemory (MB)", ssm, pPrintInfo);
PrintStringValueLine("Remote", (desc.Flags & DXGI_ADAPTER_FLAG_REMOTE) ? c_szYes : c_szNo, pPrintInfo);
PrintStringValueLine("Graphics Preemption Granularity", gpg, pPrintInfo);
PrintStringValueLine("Compute Preemption Granularity", cpg, pPrintInfo);
}
return S_OK;
}
//-----------------------------------------------------------------------------
HRESULT DXGIOutputInfo(LPARAM /*lParam1*/, LPARAM lParam2, PRINTCBINFO* pPrintInfo)
{
auto pOutput = reinterpret_cast<IDXGIOutput*>(lParam2);
if (!pOutput)
return S_OK;
if (!pPrintInfo)
{
LVAddColumn(g_hwndLV, 0, "Name", 30);
LVAddColumn(g_hwndLV, 1, "Value", 30);
}
DXGI_OUTPUT_DESC desc;
HRESULT hr = pOutput->GetDesc(&desc);
if (FAILED(hr))
return hr;
char szDevName[32];
wcstombs_s(nullptr, szDevName, desc.DeviceName, 32);
if (!pPrintInfo)
{
LVAddText(g_hwndLV, 0, "DeviceName");
LVAddText(g_hwndLV, 1, "%s", szDevName);
LVAddText(g_hwndLV, 0, "AttachedToDesktop");
LVAddText(g_hwndLV, 1, desc.AttachedToDesktop ? c_szYes : c_szNo);
LVAddText(g_hwndLV, 0, "Rotation");
LVAddText(g_hwndLV, 1, szRotation[desc.Rotation]);
}
else
{
PrintStringValueLine("DeviceName", szDevName, pPrintInfo);
PrintStringValueLine("AttachedToDesktop", desc.AttachedToDesktop ? c_szYes : c_szNo, pPrintInfo);
PrintStringValueLine("Rotation", szRotation[desc.Rotation], pPrintInfo);
}
return S_OK;
}
//-----------------------------------------------------------------------------
HRESULT DXGIOutputModes(LPARAM /*lParam1*/, LPARAM lParam2, PRINTCBINFO* pPrintInfo)
{
auto pOutput = reinterpret_cast<IDXGIOutput*>(lParam2);
if (!pOutput)
return S_OK;
if (!pPrintInfo)
{
LVAddColumn(g_hwndLV, 0, "Resolution", 10);
LVAddColumn(g_hwndLV, 1, "Pixel Format", 30);
LVAddColumn(g_hwndLV, 2, "Refresh Rate", 10);
}
for (UINT iFormat = 0; iFormat < NumAdapterFormats; ++iFormat)
{
DXGI_FORMAT fmt = AdapterFormatArray[iFormat];
if (!g_DXGIFactory1)
{
switch (fmt)
{
case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
continue;
}
}
UINT num = 0;
const DWORD flags = 0;
HRESULT hr = pOutput->GetDisplayModeList(fmt, flags, &num, 0);
if (SUCCEEDED(hr) && num > 0)
{
auto pDescs = new (std::nothrow) DXGI_MODE_DESC[num];
if (!pDescs)
return E_OUTOFMEMORY;
hr = pOutput->GetDisplayModeList(fmt, flags, &num, pDescs);
if (SUCCEEDED(hr))
{
for (UINT iMode = 0; iMode < num; ++iMode)
{
const DXGI_MODE_DESC* pDesc = &pDescs[iMode];
if (!pPrintInfo)
{
LVAddText(g_hwndLV, 0, "%d x %d", pDesc->Width, pDesc->Height);
LVAddText(g_hwndLV, 1, FormatName(pDesc->Format));
LVAddText(g_hwndLV, 2, "%d", RefreshRate(pDesc->RefreshRate));
}
else
{
char szBuff[80];
DWORD cchLen;
// Calculate Name and Value column x offsets
int x1 = (pPrintInfo->dwCurrIndent * DEF_TAB_SIZE * pPrintInfo->dwCharWidth);
int x2 = x1 + (30 * pPrintInfo->dwCharWidth);
int x3 = x2 + (20 * pPrintInfo->dwCharWidth);
int yLine = (pPrintInfo->dwCurrLine * pPrintInfo->dwLineHeight);
sprintf_s(szBuff, sizeof(szBuff), "%u x %u", pDesc->Width, pDesc->Height);
cchLen = static_cast<DWORD>(_tcslen(szBuff));
if (FAILED(PrintLine(x1, yLine, szBuff, cchLen, pPrintInfo)))
return E_FAIL;
strcpy_s(szBuff, sizeof(szBuff), FormatName(pDesc->Format));
cchLen = static_cast<DWORD>(_tcslen(szBuff));
if (FAILED(PrintLine(x2, yLine, szBuff, cchLen, pPrintInfo)))
return E_FAIL;
sprintf_s(szBuff, sizeof(szBuff), "%u", RefreshRate(pDesc->RefreshRate));
cchLen = static_cast<DWORD>(_tcslen(szBuff));
if (FAILED(PrintLine(x3, yLine, szBuff, cchLen, pPrintInfo)))
return E_FAIL;
// Advance to next line on page
if (FAILED(PrintNextLine(pPrintInfo)))
return E_FAIL;
}
}
}
delete[] pDescs;
}
}
return S_OK;
}
//-----------------------------------------------------------------------------
#define LVYESNO(a,b) \
if ( g_dwViewState == IDM_VIEWALL || (b) ) \
{ \
LVAddText( g_hwndLV, 0, a ); \
LVAddText( g_hwndLV, 1, (b) ? c_szYes : c_szNo ); \
}
#define PRINTYESNO(a,b) \
PrintStringValueLine( a, (b) ? c_szYes : c_szNo, pPrintInfo );
#define LVLINE(a,b) \
if ( g_dwViewState == IDM_VIEWALL || (b != c_szNA && b != c_szNo) ) \
{ \
LVAddText( g_hwndLV, 0, a ); \
LVAddText( g_hwndLV, 1, b ); \
}
#define PRINTLINE(a,b) \
if ( g_dwViewState == IDM_VIEWALL || (b != c_szNA && b != c_szNo) ) \
{ \
PrintStringValueLine( a, b, pPrintInfo ); \
}
#define XTOSTRING(a) #a TOSTRING(a)
#define TOSTRING(a) #a
#define XTOSTRING2(a) #a TOSTRING2(a)
#define TOSTRING2(a) "( " #a " )"
//-----------------------------------------------------------------------------
HRESULT DXGIFeatures(LPARAM /*lParam1*/, LPARAM /*lParam2*/, PRINTCBINFO* pPrintInfo)
{
if (g_DXGIFactory5)
{
if (!pPrintInfo)
{
LVAddColumn(g_hwndLV, 0, "Name", 30);
LVAddColumn(g_hwndLV, 1, "Value", 60);
}
BOOL allowTearing = FALSE;
HRESULT hr = g_DXGIFactory5->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allowTearing, sizeof(BOOL));
if (FAILED(hr))
allowTearing = FALSE;
if (!pPrintInfo)
{
LVYESNO("Allow tearing", allowTearing);
}
else
{
PRINTYESNO("Allow tearing", allowTearing);
}
}
return S_OK;
}
bool IsMSAAPowerOf2(UINT value)
{
// only supports values 0..32
if (value <= 1)
return true;
if (value & 0x1)
return false;
for (UINT mask = 0x2; mask < 0x100; mask <<= 1)
{
if ((value & ~mask) == 0)
return true;
}
return false;
}
//-----------------------------------------------------------------------------
void CheckExtendedFormats(ID3D10Device* pDevice, BOOL& ext, BOOL& x2)
{
ext = x2 = FALSE;
// DXGI 1.1 required for extended formats
if (!g_DXGIFactory1)
return;
UINT fmtSupport = 0;
HRESULT hr = pDevice->CheckFormatSupport(DXGI_FORMAT_B8G8R8A8_UNORM, &fmtSupport);
if (FAILED(hr))
fmtSupport = 0;
if (fmtSupport & D3D10_FORMAT_SUPPORT_RENDER_TARGET)