-
Notifications
You must be signed in to change notification settings - Fork 1
/
DXGI.cs
1487 lines (1330 loc) · 55.9 KB
/
DXGI.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using GlobalStructures;
namespace DXGI
{
[ComImport]
[Guid("aec22fb8-76f3-4639-9be0-28eb43a67a2e")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIObject
{
HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
}
[ComImport]
[Guid("3d3e0379-f9de-4d58-bb6c-18d62992f1a6")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIDeviceSubObject : IDXGIObject
{
#region <IDXGIObject>
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
HRESULT GetDevice(ref Guid riid, out IntPtr ppDevice);
}
[ComImport]
[Guid("2411e7e1-12ac-4ccf-bd14-9798e8534dc0")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIAdapter : IDXGIObject
{
#region IDXGIObject
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
[PreserveSig]
HRESULT EnumOutputs(uint Output, ref IDXGIOutput ppOutput);
HRESULT GetDesc(out DXGI_ADAPTER_DESC pDesc);
HRESULT CheckInterfaceSupport(ref Guid InterfaceName, out LARGE_INTEGER pUMDVersion);
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DXGI_ADAPTER_DESC
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string Description;
public uint VendorId;
public uint DeviceId;
public uint SubSysId;
public uint Revision;
public uint DedicatedVideoMemory;
public uint DedicatedSystemMemory;
public uint SharedSystemMemory;
public LUID AdapterLuid;
}
[StructLayout(LayoutKind.Sequential)]
public struct LUID
{
uint LowPart;
int HighPart;
}
[ComImport]
[Guid("ae02eedb-c735-4690-8d52-5a8dc20213aa")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIOutput : IDXGIObject
{
#region IDXGIObject
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
HRESULT GetDesc(out DXGI_OUTPUT_DESC pDesc);
HRESULT GetDisplayModeList(DXGI_FORMAT EnumFormat, uint Flags, ref uint pNumModes, DXGI_MODE_DESC pDesc);
//HRESULT FindClosestMatchingMode(DXGI_MODE_DESC pModeToMatch, out DXGI_MODE_DESC pClosestMatch, IUnknown pConcernedDevice);
HRESULT FindClosestMatchingMode(DXGI_MODE_DESC pModeToMatch, out DXGI_MODE_DESC pClosestMatch, IntPtr pConcernedDevice);
HRESULT WaitForVBlank();
//HRESULT TakeOwnership(IUnknown pDevice, bool Exclusive);
HRESULT TakeOwnership(IntPtr pDevice, bool Exclusive);
void ReleaseOwnership();
HRESULT GetGammaControlCapabilities(out DXGI_GAMMA_CONTROL_CAPABILITIES pGammaCaps);
HRESULT SetGammaControl(DXGI_GAMMA_CONTROL pArray);
HRESULT GetGammaControl(out DXGI_GAMMA_CONTROL pArray);
HRESULT SetDisplaySurface(IDXGISurface pScanoutSurface);
HRESULT GetDisplaySurfaceData(IDXGISurface pDestination);
HRESULT GetFrameStatistics(out DXGI_FRAME_STATISTICS pStats);
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DXGI_OUTPUT_DESC
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
string DeviceName;
public RECT DesktopCoordinates;
public bool AttachedToDesktop;
public DXGI_MODE_ROTATION Rotation;
public IntPtr Monitor;
}
public enum DXGI_MODE_ROTATION
{
DXGI_MODE_ROTATION_UNSPECIFIED = 0,
DXGI_MODE_ROTATION_IDENTITY = 1,
DXGI_MODE_ROTATION_ROTATE90 = 2,
DXGI_MODE_ROTATION_ROTATE180 = 3,
DXGI_MODE_ROTATION_ROTATE270 = 4
}
public enum DXGI_FORMAT
{
DXGI_FORMAT_UNKNOWN = 0,
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
DXGI_FORMAT_R32G32B32A32_UINT = 3,
DXGI_FORMAT_R32G32B32A32_SINT = 4,
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
DXGI_FORMAT_R32G32B32_FLOAT = 6,
DXGI_FORMAT_R32G32B32_UINT = 7,
DXGI_FORMAT_R32G32B32_SINT = 8,
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
DXGI_FORMAT_R16G16B16A16_UINT = 12,
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
DXGI_FORMAT_R16G16B16A16_SINT = 14,
DXGI_FORMAT_R32G32_TYPELESS = 15,
DXGI_FORMAT_R32G32_FLOAT = 16,
DXGI_FORMAT_R32G32_UINT = 17,
DXGI_FORMAT_R32G32_SINT = 18,
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
DXGI_FORMAT_R10G10B10A2_UINT = 25,
DXGI_FORMAT_R11G11B10_FLOAT = 26,
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
DXGI_FORMAT_R8G8B8A8_UINT = 30,
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
DXGI_FORMAT_R8G8B8A8_SINT = 32,
DXGI_FORMAT_R16G16_TYPELESS = 33,
DXGI_FORMAT_R16G16_FLOAT = 34,
DXGI_FORMAT_R16G16_UNORM = 35,
DXGI_FORMAT_R16G16_UINT = 36,
DXGI_FORMAT_R16G16_SNORM = 37,
DXGI_FORMAT_R16G16_SINT = 38,
DXGI_FORMAT_R32_TYPELESS = 39,
DXGI_FORMAT_D32_FLOAT = 40,
DXGI_FORMAT_R32_FLOAT = 41,
DXGI_FORMAT_R32_UINT = 42,
DXGI_FORMAT_R32_SINT = 43,
DXGI_FORMAT_R24G8_TYPELESS = 44,
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
DXGI_FORMAT_R8G8_TYPELESS = 48,
DXGI_FORMAT_R8G8_UNORM = 49,
DXGI_FORMAT_R8G8_UINT = 50,
DXGI_FORMAT_R8G8_SNORM = 51,
DXGI_FORMAT_R8G8_SINT = 52,
DXGI_FORMAT_R16_TYPELESS = 53,
DXGI_FORMAT_R16_FLOAT = 54,
DXGI_FORMAT_D16_UNORM = 55,
DXGI_FORMAT_R16_UNORM = 56,
DXGI_FORMAT_R16_UINT = 57,
DXGI_FORMAT_R16_SNORM = 58,
DXGI_FORMAT_R16_SINT = 59,
DXGI_FORMAT_R8_TYPELESS = 60,
DXGI_FORMAT_R8_UNORM = 61,
DXGI_FORMAT_R8_UINT = 62,
DXGI_FORMAT_R8_SNORM = 63,
DXGI_FORMAT_R8_SINT = 64,
DXGI_FORMAT_A8_UNORM = 65,
DXGI_FORMAT_R1_UNORM = 66,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
DXGI_FORMAT_BC1_TYPELESS = 70,
DXGI_FORMAT_BC1_UNORM = 71,
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
DXGI_FORMAT_BC2_TYPELESS = 73,
DXGI_FORMAT_BC2_UNORM = 74,
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
DXGI_FORMAT_BC3_TYPELESS = 76,
DXGI_FORMAT_BC3_UNORM = 77,
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
DXGI_FORMAT_BC4_TYPELESS = 79,
DXGI_FORMAT_BC4_UNORM = 80,
DXGI_FORMAT_BC4_SNORM = 81,
DXGI_FORMAT_BC5_TYPELESS = 82,
DXGI_FORMAT_BC5_UNORM = 83,
DXGI_FORMAT_BC5_SNORM = 84,
DXGI_FORMAT_B5G6R5_UNORM = 85,
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
DXGI_FORMAT_BC6H_TYPELESS = 94,
DXGI_FORMAT_BC6H_UF16 = 95,
DXGI_FORMAT_BC6H_SF16 = 96,
DXGI_FORMAT_BC7_TYPELESS = 97,
DXGI_FORMAT_BC7_UNORM = 98,
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
DXGI_FORMAT_AYUV = 100,
DXGI_FORMAT_Y410 = 101,
DXGI_FORMAT_Y416 = 102,
DXGI_FORMAT_NV12 = 103,
DXGI_FORMAT_P010 = 104,
DXGI_FORMAT_P016 = 105,
DXGI_FORMAT_420_OPAQUE = 106,
DXGI_FORMAT_YUY2 = 107,
DXGI_FORMAT_Y210 = 108,
DXGI_FORMAT_Y216 = 109,
DXGI_FORMAT_NV11 = 110,
DXGI_FORMAT_AI44 = 111,
DXGI_FORMAT_IA44 = 112,
DXGI_FORMAT_P8 = 113,
DXGI_FORMAT_A8P8 = 114,
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
DXGI_FORMAT_FORCE_UINT = unchecked((int)0xffffffff)
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_MODE_DESC
{
public uint Width;
public uint Height;
public DXGI_RATIONAL RefreshRate;
public DXGI_FORMAT Format;
public DXGI_MODE_SCANLINE_ORDER ScanlineOrdering;
public DXGI_MODE_SCALING Scaling;
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_RATIONAL
{
public uint Numerator;
public uint Denominator;
}
public enum DXGI_MODE_SCANLINE_ORDER
{
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0,
DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1,
DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2,
DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3
}
public enum DXGI_MODE_SCALING
{
DXGI_MODE_SCALING_UNSPECIFIED = 0,
DXGI_MODE_SCALING_CENTERED = 1,
DXGI_MODE_SCALING_STRETCHED = 2
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_GAMMA_CONTROL_CAPABILITIES
{
public bool ScaleAndOffsetSupported;
public float MaxConvertedValue;
public float MinConvertedValue;
public uint NumGammaControlPoints;
[MarshalAs(UnmanagedType.R4, SizeConst = 1025)]
float ControlPointPositions;
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_GAMMA_CONTROL
{
public DXGI_RGB Scale;
public DXGI_RGB Offset;
[MarshalAs(UnmanagedType.Struct, SizeConst = 1025)]
DXGI_RGB GammaCurve;
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_RGB
{
public float Red;
public float Green;
public float Blue;
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_FRAME_STATISTICS
{
public uint PresentCount;
public uint PresentRefreshCount;
public uint SyncRefreshCount;
public LARGE_INTEGER SyncQPCTime;
public LARGE_INTEGER SyncGPUTime;
}
[ComImport]
[Guid("cafcb56c-6ac3-4889-bf47-9e23bbd260ec")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGISurface : IDXGIDeviceSubObject
{
#region <IDXGIDeviceSubObject>
#region <IDXGIObject>
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
new HRESULT GetDevice(ref Guid riid, out IntPtr ppDevice);
#endregion
HRESULT GetDesc(out DXGI_SURFACE_DESC pDesc);
[PreserveSig]
HRESULT Map(out DXGI_MAPPED_RECT pLockedRect, uint MapFlags);
[PreserveSig]
HRESULT Unmap();
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_SURFACE_DESC
{
public uint Width;
public uint Height;
public DXGI_FORMAT Format;
public DXGI_SAMPLE_DESC SampleDesc;
};
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_MAPPED_RECT
{
public int Pitch;
public IntPtr pBits;
};
[ComImport]
[Guid("7b7166ec-21c7-44ae-b21a-c9ae321ae369")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIFactory : IDXGIObject
{
#region <IDXGIObject>
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
HRESULT EnumAdapters(uint Adapter, out IDXGIAdapter ppAdapter);
HRESULT MakeWindowAssociation(IntPtr WindowHandle, uint Flags);
HRESULT GetWindowAssociation(out IntPtr pWindowHandle);
[PreserveSig]
HRESULT CreateSwapChain(IntPtr pDevice, DXGI_SWAP_CHAIN_DESC pDesc, out IDXGISwapChain ppSwapChain);
HRESULT CreateSoftwareAdapter(IntPtr Module, out IDXGIAdapter ppAdapter);
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_SWAP_CHAIN_DESC
{
public DXGI_MODE_DESC BufferDesc;
public DXGI_SAMPLE_DESC SampleDesc;
public uint BufferUsage;
public uint BufferCount;
public IntPtr OutputWindow;
public bool Windowed;
public DXGI_SWAP_EFFECT SwapEffect;
public uint Flags;
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_SAMPLE_DESC
{
public uint Count;
public uint Quality;
};
public enum DXGI_SWAP_EFFECT
{
DXGI_SWAP_EFFECT_DISCARD = 0,
DXGI_SWAP_EFFECT_SEQUENTIAL = 1,
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3,
DXGI_SWAP_EFFECT_FLIP_DISCARD = 4
}
[ComImport]
[Guid("310d36a0-d2e7-4c0a-aa04-6a9d23b8886a")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGISwapChain : IDXGIDeviceSubObject
{
#region IDXGIDeviceSubObject
#region IDXGIObject
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
new HRESULT GetDevice(ref Guid riid, out IntPtr ppDevice);
#endregion
[PreserveSig]
HRESULT Present(uint SyncInterval, uint Flags);
HRESULT GetBuffer(uint Buffer, ref Guid riid, out IntPtr ppSurface);
HRESULT SetFullscreenState(bool Fullscreen, IDXGIOutput pTarget);
HRESULT GetFullscreenState(out bool pFullscreen, out IDXGIOutput ppTarget);
HRESULT GetDesc(out DXGI_SWAP_CHAIN_DESC pDesc);
HRESULT ResizeBuffers(uint BufferCount, uint Width, uint Height, DXGI_FORMAT NewFormat, uint SwapChainFlags);
HRESULT ResizeTarget(DXGI_MODE_DESC pNewTargetParameters);
HRESULT GetContainingOutput(out IDXGIOutput ppOutput);
HRESULT GetFrameStatistics(out DXGI_FRAME_STATISTICS pStats);
HRESULT GetLastPresentCount(out uint pLastPresentCount);
}
[ComImport]
[Guid("770aae78-f26f-4dba-a829-253c83d1b387")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIFactory1 : IDXGIFactory
{
#region <IDXGIObject>
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
#region <IDXGIFactory>
new HRESULT EnumAdapters(uint Adapter, out IDXGIAdapter ppAdapter);
new HRESULT MakeWindowAssociation(IntPtr WindowHandle, uint Flags);
new HRESULT GetWindowAssociation(out IntPtr pWindowHandle);
[PreserveSig]
new HRESULT CreateSwapChain(IntPtr pDevice, DXGI_SWAP_CHAIN_DESC pDesc, out IDXGISwapChain ppSwapChain);
new HRESULT CreateSoftwareAdapter(IntPtr Module, out IDXGIAdapter ppAdapter);
#endregion
HRESULT EnumAdapters1(uint Adapter, out IDXGIAdapter1 ppAdapter);
bool IsCurrent();
}
[ComImport]
[Guid("29038f61-3839-4626-91fd-086879011a05")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIAdapter1 : IDXGIAdapter
{
#region IDXGIAdapter
#region IDXGIObject
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
[PreserveSig]
new HRESULT EnumOutputs(uint Output, ref IDXGIOutput ppOutput);
new HRESULT GetDesc(out DXGI_ADAPTER_DESC pDesc);
new HRESULT CheckInterfaceSupport(ref Guid InterfaceName, out LARGE_INTEGER pUMDVersion);
#endregion
HRESULT GetDesc1(DXGI_ADAPTER_DESC1 pDesc);
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_ADAPTER_DESC1
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string Description;
public uint VendorId;
public uint DeviceId;
public uint SubSysId;
public uint Revision;
public uint DedicatedVideoMemory;
public uint DedicatedSystemMemory;
public uint SharedSystemMemory;
public LUID AdapterLuid;
public uint Flags;
}
[ComImport]
[Guid("50c83a1c-e072-4c48-87b0-3630fa36a6d0")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIFactory2 : IDXGIFactory1
{
#region <IDXGIFactory1>
#region <IDXGIObject>
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
#region <IDXGIFactory>
new HRESULT EnumAdapters(uint Adapter, out IDXGIAdapter ppAdapter);
new HRESULT MakeWindowAssociation(IntPtr WindowHandle, uint Flags);
new HRESULT GetWindowAssociation(out IntPtr pWindowHandle);
[PreserveSig]
new HRESULT CreateSwapChain(IntPtr pDevice, DXGI_SWAP_CHAIN_DESC pDesc, out IDXGISwapChain ppSwapChain);
new HRESULT CreateSoftwareAdapter(IntPtr Module, out IDXGIAdapter ppAdapter);
#endregion
new HRESULT EnumAdapters1(uint Adapter, out IDXGIAdapter1 ppAdapter);
new bool IsCurrent();
#endregion
bool IsWindowedStereoEnabled();
//HRESULT CreateSwapChainForHwnd(IntPtr pDevice, IntPtr hWnd, DXGI_SWAP_CHAIN_DESC1 pDesc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC pFullscreenDesc, IDXGIOutput pRestrictToOutput, out IDXGISwapChain1 ppSwapChain);
[PreserveSig]
HRESULT CreateSwapChainForHwnd(IntPtr pDevice, IntPtr hWnd, ref DXGI_SWAP_CHAIN_DESC1 pDesc, IntPtr pFullscreenDesc, IDXGIOutput pRestrictToOutput, out IDXGISwapChain1 ppSwapChain);
[PreserveSig]
HRESULT CreateSwapChainForCoreWindow(IntPtr pDevice, IntPtr pWindow, ref DXGI_SWAP_CHAIN_DESC1 pDesc, IDXGIOutput pRestrictToOutput, out IDXGISwapChain1 ppSwapChain);
HRESULT GetSharedResourceAdapterLuid(IntPtr hResource, out LUID pLuid);
HRESULT RegisterStereoStatusWindow(IntPtr WindowHandle, uint wMsg, out uint pdwCookie);
HRESULT RegisterStereoStatusEvent(IntPtr hEvent, out uint pdwCookie);
void UnregisterStereoStatus(uint dwCookie);
HRESULT RegisterOcclusionStatusWindow(IntPtr WindowHandle, uint wMsg, out uint pdwCookie);
HRESULT RegisterOcclusionStatusEvent(IntPtr hEvent, out uint pdwCookie);
void UnregisterOcclusionStatus(uint dwCookie);
[PreserveSig]
HRESULT CreateSwapChainForComposition(IntPtr pDevice, ref DXGI_SWAP_CHAIN_DESC1 pDesc, IDXGIOutput pRestrictToOutput, out IDXGISwapChain1 ppSwapChain);
}
[ComImport]
[Guid("790a45f7-0d42-4876-983a-0a55cfe6f4aa")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGISwapChain1 : IDXGISwapChain
{
#region IDXGISwapChain
#region IDXGIDeviceSubObject
#region IDXGIObject
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
new HRESULT GetDevice(ref Guid riid, out IntPtr ppDevice);
#endregion
[PreserveSig]
new HRESULT Present(uint SyncInterval, uint Flags);
new HRESULT GetBuffer(uint Buffer, ref Guid riid, out IntPtr ppSurface);
[PreserveSig]
new HRESULT SetFullscreenState(bool Fullscreen, IDXGIOutput pTarget);
new HRESULT GetFullscreenState(out bool pFullscreen, out IDXGIOutput ppTarget);
new HRESULT GetDesc(out DXGI_SWAP_CHAIN_DESC pDesc);
[PreserveSig]
new HRESULT ResizeBuffers(uint BufferCount, uint Width, uint Height, DXGI_FORMAT NewFormat, uint SwapChainFlags);
new HRESULT ResizeTarget(DXGI_MODE_DESC pNewTargetParameters);
new HRESULT GetContainingOutput(out IDXGIOutput ppOutput);
[PreserveSig]
new HRESULT GetFrameStatistics(out DXGI_FRAME_STATISTICS pStats);
new HRESULT GetLastPresentCount(out uint pLastPresentCount);
#endregion
HRESULT GetDesc1(out DXGI_SWAP_CHAIN_DESC1 pDesc);
HRESULT GetFullscreenDesc(out DXGI_SWAP_CHAIN_FULLSCREEN_DESC pDesc);
HRESULT GetIntPtr(out IntPtr pIntPtr);
HRESULT GetCoreWindow(ref Guid refiid, out IntPtr ppUnk);
[PreserveSig]
HRESULT Present1(uint SyncInterval, uint PresentFlags, DXGI_PRESENT_PARAMETERS pPresentParameters);
bool IsTemporaryMonoSupported();
HRESULT GetRestrictToOutput(out IDXGIOutput ppRestrictToOutput);
HRESULT SetBackgroundColor(DXGI_RGBA pColor);
HRESULT GetBackgroundColor(out DXGI_RGBA pColor);
HRESULT SetRotation(DXGI_MODE_ROTATION Rotation);
HRESULT GetRotation(out DXGI_MODE_ROTATION pRotation);
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_SWAP_CHAIN_DESC1
{
public uint Width;
public uint Height;
public DXGI_FORMAT Format;
public bool Stereo;
public DXGI_SAMPLE_DESC SampleDesc;
public uint BufferUsage;
public uint BufferCount;
public DXGI_SCALING Scaling;
public DXGI_SWAP_EFFECT SwapEffect;
public DXGI_ALPHA_MODE AlphaMode;
public DXGI_SWAP_CHAIN_FLAG Flags;
}
public enum DXGI_SCALING
{
DXGI_SCALING_STRETCH = 0,
DXGI_SCALING_NONE = 1,
DXGI_SCALING_ASPECT_RATIO_STRETCH = 2
}
public enum DXGI_ALPHA_MODE : uint
{
DXGI_ALPHA_MODE_UNSPECIFIED = 0,
DXGI_ALPHA_MODE_PREMULTIPLIED = 1,
DXGI_ALPHA_MODE_STRAIGHT = 2,
DXGI_ALPHA_MODE_IGNORE = 3,
DXGI_ALPHA_MODE_FORCE_DWORD = 0xffffffff
}
public enum DXGI_SWAP_CHAIN_FLAG
{
DXGI_SWAP_CHAIN_FLAG_NONPREROTATED = 1,
DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH = 2,
DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE = 4,
DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT = 8,
DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER = 16,
DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY = 32,
DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT = 64,
DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 128,
DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 256,
DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 512,
DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 1024,
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING = 2048,
DXGI_SWAP_CHAIN_FLAG_RESTRICTED_TO_ALL_HOLOGRAPHIC_DISPLAYS = 4096
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_SWAP_CHAIN_FULLSCREEN_DESC
{
public DXGI_RATIONAL RefreshRate;
public DXGI_MODE_SCANLINE_ORDER ScanlineOrdering;
public DXGI_MODE_SCALING Scaling;
public bool Windowed;
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_PRESENT_PARAMETERS
{
public uint DirtyRectsCount;
public RECT pDirtyRects;
public RECT pScrollRect;
public POINT pScrollOffset;
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_RGBA
{
public float r;
public float g;
public float b;
public float a;
}
[ComImport]
[Guid("54ec77fa-1377-44e6-8c32-88fd5f44c84c")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIDevice : IDXGIObject
{
#region IDXGIObject
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
HRESULT GetAdapter(out IDXGIAdapter pAdapter);
HRESULT CreateSurface(DXGI_SURFACE_DESC pDesc, uint NumSurfaces, uint Usage, ref DXGI_SHARED_RESOURCE pSharedResource, out IDXGISurface ppSurface);
HRESULT QueryResourceResidency(IntPtr ppResources, out DXGI_RESIDENCY pResidencyStatus, uint NumResources);
HRESULT SetGPUThreadPriority(int Priority);
HRESULT GetGPUThreadPriority(out int pPriority);
}
[ComImport]
[Guid("77db970f-6276-48ba-ba28-070143b4392c")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGIDevice1 : IDXGIDevice
{
#region IDXGIDevice
#region IDXGIObject
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
new HRESULT GetAdapter(out IDXGIAdapter pAdapter);
new HRESULT CreateSurface(DXGI_SURFACE_DESC pDesc, uint NumSurfaces, uint Usage, ref DXGI_SHARED_RESOURCE pSharedResource, out IDXGISurface ppSurface);
new HRESULT QueryResourceResidency(IntPtr ppResources, out DXGI_RESIDENCY pResidencyStatus, uint NumResources);
new HRESULT SetGPUThreadPriority(int Priority);
new HRESULT GetGPUThreadPriority(out int pPriority);
#endregion
HRESULT SetMaximumFrameLatency(uint MaxLatency);
HRESULT GetMaximumFrameLatency(out uint pMaxLatency);
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_SHARED_RESOURCE
{
public IntPtr Handle;
}
public enum DXGI_RESIDENCY
{
DXGI_RESIDENCY_FULLY_RESIDENT = 1,
DXGI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2,
DXGI_RESIDENCY_EVICTED_TO_DISK = 3
}
[ComImport]
[Guid("eb533d5d-2db6-40f8-97a9-494692014f07")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFDXGIDeviceManager
{
HRESULT CloseDeviceIntPtr(IntPtr hDevice);
HRESULT GetVideoService(IntPtr hDevice, ref Guid riid, out IntPtr ppService);
HRESULT LockDevice(IntPtr hDevice, ref Guid riid, out IntPtr ppUnkDevice, bool fBlock);
HRESULT OpenDeviceHandle(out IntPtr phDevice);
HRESULT ResetDevice(IntPtr pUnkDevice, uint resetToken);
HRESULT TestDevice(IntPtr hDevice);
HRESULT UnlockDevice(IntPtr hDevice, bool fSaveState);
}
[ComImport]
[Guid("9B7E4E00-342C-4106-A19F-4F2704F689F0")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ID3D10Multithread
{
void Enter();
void Leave();
bool SetMultithreadProtected(bool bMTProtect);
bool GetMultithreadProtected();
}
[ComImport]
[Guid("a8be2ac4-199f-4946-b331-79599fb98de7")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGISwapChain2 : IDXGISwapChain1
{
#region IDXGISwapChain1
#region IDXGISwapChain
#region IDXGIDeviceSubObject
#region IDXGIObject
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
//HRESULT SetPrivateDataInterface(ref Guid Name, IUnknown* pUnknown);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
new HRESULT GetDevice(ref Guid riid, out IntPtr ppDevice);
#endregion
[PreserveSig]
new HRESULT Present(uint SyncInterval, uint Flags);
new HRESULT GetBuffer(uint Buffer, ref Guid riid, out IntPtr ppSurface);
new HRESULT SetFullscreenState(bool Fullscreen, IDXGIOutput pTarget);
new HRESULT GetFullscreenState(out bool pFullscreen, out IDXGIOutput ppTarget);
new HRESULT GetDesc(out DXGI_SWAP_CHAIN_DESC pDesc);
[PreserveSig]
new HRESULT ResizeBuffers(uint BufferCount, uint Width, uint Height, DXGI_FORMAT NewFormat, uint SwapChainFlags);
new HRESULT ResizeTarget(DXGI_MODE_DESC pNewTargetParameters);
new HRESULT GetContainingOutput(out IDXGIOutput ppOutput);
new HRESULT GetFrameStatistics(out DXGI_FRAME_STATISTICS pStats);
new HRESULT GetLastPresentCount(out uint pLastPresentCount);
#endregion
new HRESULT GetDesc1(out DXGI_SWAP_CHAIN_DESC1 pDesc);
new HRESULT GetFullscreenDesc(out DXGI_SWAP_CHAIN_FULLSCREEN_DESC pDesc);
new HRESULT GetIntPtr(out IntPtr pIntPtr);
new HRESULT GetCoreWindow(ref Guid refiid, out IntPtr ppUnk);
[PreserveSig]
new HRESULT Present1(uint SyncInterval, uint PresentFlags, DXGI_PRESENT_PARAMETERS pPresentParameters);
new bool IsTemporaryMonoSupported();
new HRESULT GetRestrictToOutput(out IDXGIOutput ppRestrictToOutput);
new HRESULT SetBackgroundColor(DXGI_RGBA pColor);
new HRESULT GetBackgroundColor(out DXGI_RGBA pColor);
new HRESULT SetRotation(DXGI_MODE_ROTATION Rotation);
new HRESULT GetRotation(out DXGI_MODE_ROTATION pRotation);
#endregion
[PreserveSig]
HRESULT SetSourceSize(uint Width, uint Height);
HRESULT GetSourceSize(out uint pWidth, out uint pHeight);
HRESULT SetMaximumFrameLatency(uint MaxLatency);
HRESULT GetMaximumFrameLatency(out uint pMaxLatency);
IntPtr GetFrameLatencyWaitableObject();
[PreserveSig]
HRESULT SetMatrixTransform(ref DXGI_MATRIX_3X2_F pMatrix);
HRESULT GetMatrixTransform(out DXGI_MATRIX_3X2_F pMatrix);
}
[StructLayout(LayoutKind.Sequential)]
public struct DXGI_MATRIX_3X2_F
{
public float _11;
public float _12;
public float _21;
public float _22;
public float _31;
public float _32;
}
[ComImport]
[Guid("4AE63092-6327-4c1b-80AE-BFE12EA32B86")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGISurface1 : IDXGISurface
{
#region <IDXGISurface>
#region <IDXGIDeviceSubObject>
#region <IDXGIObject>
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
new HRESULT GetDevice(ref Guid riid, out IntPtr ppDevice);
#endregion
new HRESULT GetDesc(out DXGI_SURFACE_DESC pDesc);
new HRESULT Map(out DXGI_MAPPED_RECT pLockedRect, uint MapFlags);
new HRESULT Unmap();
#endregion
[PreserveSig]
HRESULT GetDC(bool Discard, out IntPtr phdc);
//HRESULT ReleaseDC( ref RECT pDirtyRect);
HRESULT ReleaseDC(IntPtr pDirtyRect);
}
[ComImport]
[Guid("aba496dd-b617-4cb8-a866-bc44d7eb1fa2")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDXGISurface2 : IDXGISurface1
{
#region <IDXGISurface1>
#region <IDXGISurface>
#region <IDXGIDeviceSubObject>
#region <IDXGIObject>
new HRESULT SetPrivateData(ref Guid Name, uint DataSize, IntPtr pData);
new HRESULT SetPrivateDataInterface(ref Guid Name, IntPtr pUnknown);
new HRESULT GetPrivateData(ref Guid Name, ref uint pDataSize, out IntPtr pData);
new HRESULT GetParent(ref Guid riid, out IntPtr ppParent);
#endregion
new HRESULT GetDevice(ref Guid riid, out IntPtr ppDevice);
#endregion
new HRESULT GetDesc(out DXGI_SURFACE_DESC pDesc);
new HRESULT Map(out DXGI_MAPPED_RECT pLockedRect, uint MapFlags);
new HRESULT Unmap();
#endregion
[PreserveSig]
new HRESULT GetDC(bool Discard, out IntPtr phdc);
//new HRESULT ReleaseDC(ref RECT pDirtyRect);
new HRESULT ReleaseDC(IntPtr pDirtyRect);
#endregion
HRESULT GetResource(ref Guid riid, out IntPtr ppParentResource, out uint pSubresourceIndex);
}
// D3D11
[ComImport]
[Guid("1841e5c8-16b0-489b-bcc8-44cfb0d5deae")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ID3D11DeviceChild
{
//void GetDevice(out ID3D11Device ppDevice);
void GetDevice(out IntPtr ppDevice);
HRESULT GetPrivateData(ref Guid guid, ref uint pDataSize, out IntPtr pData);
HRESULT SetPrivateData(ref Guid guid, uint DataSize, IntPtr pData);
HRESULT SetPrivateDataInterface(ref Guid guid, IntPtr pData);
}
[ComImport]
[Guid("dc8e63f3-d12b-4952-b47b-5e45026a862d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ID3D11Resource : ID3D11DeviceChild
{
#region ID3D11DeviceChild
//new void GetDevice(out ID3D11Device ppDevice);
new void GetDevice(out IntPtr ppDevice);
new HRESULT GetPrivateData(ref Guid guid, ref uint pDataSize, out IntPtr pData);
new HRESULT SetPrivateData(ref Guid guid, uint DataSize, IntPtr pData);
new HRESULT SetPrivateDataInterface(ref Guid guid, IntPtr pData);
#endregion
void GetType(out D3D11_RESOURCE_DIMENSION pResourceDimension);
void SetEvictionPriority(uint EvictionPriority);
uint GetEvictionPriority();
}
public enum D3D11_RESOURCE_DIMENSION
{
D3D11_RESOURCE_DIMENSION_UNKNOWN = 0,
D3D11_RESOURCE_DIMENSION_BUFFER = 1,
D3D11_RESOURCE_DIMENSION_TEXTURE1D = 2,
D3D11_RESOURCE_DIMENSION_TEXTURE2D = 3,
D3D11_RESOURCE_DIMENSION_TEXTURE3D = 4
}
[ComImport]
[Guid("6f15aaf2-d208-4e89-9ab4-489535d34f9c")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ID3D11Texture2D : ID3D11Resource
{
#region ID3D11Resource
#region ID3D11DeviceChild
//new void GetDevice(out ID3D11Device ppDevice);
new void GetDevice(out IntPtr ppDevice);
new HRESULT GetPrivateData(ref Guid guid, ref uint pDataSize, out IntPtr pData);
new HRESULT SetPrivateData(ref Guid guid, uint DataSize, IntPtr pData);
new HRESULT SetPrivateDataInterface(ref Guid guid, IntPtr pData);
#endregion
new void GetType(out D3D11_RESOURCE_DIMENSION pResourceDimension);
new void SetEvictionPriority(uint EvictionPriority);
new uint GetEvictionPriority();
#endregion
void GetDesc(out D3D11_TEXTURE2D_DESC pDesc);
}
[StructLayout(LayoutKind.Sequential)]
public struct D3D11_TEXTURE2D_DESC
{
public uint Width;
public uint Height;
public uint MipLevels;
public uint ArraySize;
public DXGI_FORMAT Format;
public DXGI_SAMPLE_DESC SampleDesc;
public D3D11_USAGE Usage;
public uint BindFlags;
public uint CPUAccessFlags;
public uint MiscFlags;
}
public enum D3D11_USAGE
{
D3D11_USAGE_DEFAULT = 0,
D3D11_USAGE_IMMUTABLE = 1,
D3D11_USAGE_DYNAMIC = 2,
D3D11_USAGE_STAGING = 3
}
[ComImport]
[Guid("e7174cfa-1c9e-48b1-8866-626226bfc258")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFDXGIBuffer
{
HRESULT GetResource(ref Guid riid, out IntPtr ppvObject);
HRESULT GetSubresourceIndex(out uint puSubresource);
HRESULT GetUnknown(ref Guid guid, ref Guid riid, out IntPtr ppvObject);
HRESULT SetUnknown(ref Guid guid, IntPtr pUnkData);
}
public class DXGITools
{
public static Guid IID_ID3D11Texture2D = new Guid("6f15aaf2-d208-4e89-9ab4-489535d34f9c");
[DllImport("DXGI.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern HRESULT CreateDXGIFactory2(uint Flags, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IDXGIFactory2 ppFactory);
public const int DXGI_CREATE_FACTORY_DEBUG = 0x01;
[DllImport("Mfplat.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern HRESULT MFCreateDXGIDeviceManager(out uint resetToken, out IMFDXGIDeviceManager ppDeviceManager);
[DllImport("D3D11.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern HRESULT D3D11CreateDevice(IDXGIAdapter pAdapter, D3D_DRIVER_TYPE DriverType, IntPtr Software, uint Flags, [MarshalAs(UnmanagedType.LPArray)] int[] pFeatureLevels,
uint FeatureLevels, uint SDKVersion, out IntPtr ppDevice, out D3D_FEATURE_LEVEL pFeatureLevel, out IntPtr ppImmediateContext);
public const int D3D11_SDK_VERSION = 7;
public const int DXGI_MAP_READ = 1;
public const int DXGI_MAP_WRITE = 2;
public const int DXGI_MAP_DISCARD = 4;
public enum D3D_DRIVER_TYPE
{