1 module directx.dxgiddi;
2 /*==========================================================================;
3 *
4 *  Copyright (C) Microsoft Corporation.  All Rights Reserved.
5 *
6 *  Content: DXGI Basic Device Driver Interface Definitions
7 *
8 ***************************************************************************/
9 
10 public import directx.dxgitype;
11 
12 import std.bitmanip : bitfields;
13 
14 import directx.dxgi;
15 import directx.d3dukmdt;
16 
17 //--------------------------------------------------------------------------------------------------------
18 // DXGI error codes
19 //--------------------------------------------------------------------------------------------------------
20 enum _FACDXGI_DDI = 0x87b;
21 
22 pure nothrow @safe @nogc {
23     HRESULT MAKE_DXGI_DDI_HRESULT(UINT code) {
24         return MAKE_HRESULT(1, _FACDXGI_DDI, code);
25     }
26 
27     HRESULT MAKE_DXGI_DDI_STATUS(UINT code) {
28         return MAKE_HRESULT(0, _FACDXGI_DDI, code);
29     }
30 }
31 
32 // DXGI DDI error codes have moved to winerror.h
33 
34 //========================================================================================================
35 // This is the standard DDI that any DXGI-enabled user-mode driver should support
36 //
37 
38 //--------------------------------------------------------------------------------------------------------
39 alias UINT_PTR DXGI_DDI_HDEVICE;
40 alias UINT_PTR DXGI_DDI_HRESOURCE;
41 
42 //--------------------------------------------------------------------------------------------------------
43 alias DWORD DXGI_DDI_RESIDENCY;
44 enum : DXGI_DDI_RESIDENCY
45 {
46     DXGI_DDI_RESIDENCY_FULLY_RESIDENT = 1,
47     DXGI_DDI_RESIDENCY_RESIDENT_IN_SHARED_MEMORY = 2,
48     DXGI_DDI_RESIDENCY_EVICTED_TO_DISK = 3,
49 }
50 
51 //--------------------------------------------------------------------------------------------------------
52 alias DWORD DXGI_DDI_FLIP_INTERVAL_TYPE;
53 enum : DXGI_DDI_FLIP_INTERVAL_TYPE
54 {
55     DXGI_DDI_FLIP_INTERVAL_IMMEDIATE = 0,
56     DXGI_DDI_FLIP_INTERVAL_ONE       = 1,
57     DXGI_DDI_FLIP_INTERVAL_TWO       = 2,
58     DXGI_DDI_FLIP_INTERVAL_THREE     = 3,
59     DXGI_DDI_FLIP_INTERVAL_FOUR      = 4,
60 }
61 
62 //--------------------------------------------------------------------------------------------------------
63 struct DXGI_DDI_PRESENT_FLAGS
64 {
65     union
66     {
67         mixin(bitfields!(UINT, "Blt",           1,
68                          UINT, "Flip",          1,
69                          UINT, "PreferRight",   1,
70                          UINT, "TemporaryMono", 1,
71                          UINT, "Reserved",     28));
72         UINT    Value;
73     }
74 }
75 
76 //--------------------------------------------------------------------------------------------------------
77 struct DXGI_DDI_ARG_PRESENT
78 {
79     DXGI_DDI_HDEVICE            hDevice;             //in
80     DXGI_DDI_HRESOURCE          hSurfaceToPresent;   //in
81     UINT                        SrcSubResourceIndex; // Index of surface level
82     DXGI_DDI_HRESOURCE          hDstResource;        // if non-zero, it's the destination of the present
83     UINT                        DstSubResourceIndex; // Index of surface level
84     void *                      pDXGIContext;        // opaque: Pass this to the Present callback
85     DXGI_DDI_PRESENT_FLAGS      Flags;               // Presentation flags.
86     DXGI_DDI_FLIP_INTERVAL_TYPE FlipInterval;        // Presentation interval (flip only)
87 }
88 
89 //--------------------------------------------------------------------------------------------------------
90 struct DXGI_DDI_ARG_ROTATE_RESOURCE_IDENTITIES
91 {
92     DXGI_DDI_HDEVICE hDevice; //in
93     const(DXGI_DDI_HRESOURCE)* pResources; //in: Array of Resources to rotate identities; 0 <= 1, 1 <= 2, etc.
94     UINT Resources;
95 }
96 
97 struct DXGI_DDI_ARG_GET_GAMMA_CONTROL_CAPS
98 {
99     DXGI_DDI_HDEVICE                        hDevice;                    //in
100     DXGI_GAMMA_CONTROL_CAPABILITIES *   pGammaCapabilities; //in/out
101 }
102 
103 struct DXGI_DDI_ARG_SET_GAMMA_CONTROL
104 {
105     DXGI_DDI_HDEVICE                        hDevice;                    //in
106     DXGI_GAMMA_CONTROL                  GammaControl;       //in
107 }
108 
109 struct DXGI_DDI_ARG_SETDISPLAYMODE
110 {
111     DXGI_DDI_HDEVICE                hDevice;                        //in
112     DXGI_DDI_HRESOURCE          hResource;              // Source surface
113     UINT                        SubResourceIndex;       // Index of surface level
114 }
115 
116 struct DXGI_DDI_ARG_SETRESOURCEPRIORITY
117 {
118     DXGI_DDI_HDEVICE            hDevice;                //in
119     DXGI_DDI_HRESOURCE          hResource;              //in
120     UINT                        Priority;               //in
121 }
122 
123 struct DXGI_DDI_ARG_QUERYRESOURCERESIDENCY
124 {
125     DXGI_DDI_HDEVICE            hDevice;                //in
126     const(DXGI_DDI_HRESOURCE)*  pResources;             //in
127     DXGI_DDI_RESIDENCY *        pStatus;                //out
128     SIZE_T                      Resources;              //in
129 }
130 
131 //--------------------------------------------------------------------------------------------------------
132 // Remarks: Fractional value used to represent vertical and horizontal frequencies of a video mode
133 //          (i.e. VSync and HSync). Vertical frequencies are stored in Hz. Horizontal frequencies
134 //          are stored in KHz.
135 //          The dynamic range of this encoding format, given 10^-7 resolution is {0..(2^32 - 1) / 10^7},
136 //          which translates to {0..428.4967296} [Hz] for vertical frequencies and {0..428.4967296} [KHz]
137 //          for horizontal frequencies. This sub-microseconds precision range should be acceptable even
138 //          for a pro-video application (error in one microsecond for video signal synchronization would
139 //          imply a time drift with a cycle of 10^7/(60*60*24) = 115.741 days.
140 //
141 //          If rational number with a finite fractional sequence, use denominator of form 10^(length of fractional sequence).
142 //          If rational number without a finite fractional sequence, or a sequence exceeding the precision allowed by the
143 //          dynamic range of the denominator, or an irrational number, use an appropriate ratio of integers which best
144 //          represents the value.
145 //
146 struct DXGI_DDI_RATIONAL
147 {
148     UINT Numerator;
149     UINT Denominator;
150 }
151 
152 //--------------------------------------------------------------------------------------------------------
153 alias DWORD DXGI_DDI_MODE_SCANLINE_ORDER;
154 enum : DXGI_DDI_MODE_SCANLINE_ORDER
155 {
156     DXGI_DDI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0,
157     DXGI_DDI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1,
158     DXGI_DDI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2,
159     DXGI_DDI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3,
160 }
161 
162 alias DWORD DXGI_DDI_MODE_SCALING;
163 enum : DXGI_DDI_MODE_SCALING
164 {
165     DXGI_DDI_MODE_SCALING_UNSPECIFIED = 0,
166     DXGI_DDI_MODE_SCALING_STRETCHED = 1,
167     DXGI_DDI_MODE_SCALING_CENTERED = 2,
168 }
169 
170 alias DWORD DXGI_DDI_MODE_ROTATION;
171 enum : DXGI_DDI_MODE_ROTATION
172 {
173     DXGI_DDI_MODE_ROTATION_UNSPECIFIED = 0,
174         DXGI_DDI_MODE_ROTATION_IDENTITY = 1,
175         DXGI_DDI_MODE_ROTATION_ROTATE90 = 2,
176         DXGI_DDI_MODE_ROTATION_ROTATE180 = 3,
177         DXGI_DDI_MODE_ROTATION_ROTATE270 = 4,
178 }
179 
180 struct DXGI_DDI_MODE_DESC
181 {
182     UINT Width;
183     UINT Height;
184     DXGI_FORMAT Format;
185     DXGI_DDI_RATIONAL RefreshRate;
186     DXGI_DDI_MODE_SCANLINE_ORDER ScanlineOrdering;
187     DXGI_DDI_MODE_ROTATION Rotation;
188     DXGI_DDI_MODE_SCALING Scaling;
189 }
190 
191 // Bit indicates that UMD has the option to prevent this Resource from ever being a Primary
192 // UMD can prevent the actual flip (from optional primary to regular primary) and use a copy
193 // operation, during Present. Thus, it's possible the UMD can opt out of this Resource being
194 // actually used as a primary.
195 enum DXGI_DDI_PRIMARY_OPTIONAL = 0x1;
196 
197 // Bit indicates that the Primary really represents the IDENTITY rotation, eventhough it will
198 // be used with non-IDENTITY display modes, since the application will take on the burden of
199 // honoring the output orientation by rotating, say the viewport and projection matrix.
200 enum DXGI_DDI_PRIMARY_NONPREROTATED = 0x2;
201 
202 // Bit indicates that the primary is stereoscopic.
203 enum DXGI_DDI_PRIMARY_STEREO = 0x4;
204 
205 // Bit indicates that this primary will be used for indirect presentation
206 enum DXGI_DDI_PRIMARY_INDIRECT = 0x8;
207 
208 // Bit indicates that the driver cannot tolerate setting any subresource of the specified
209 // resource as a primary. The UMD should set this bit at resource creation time if it
210 // chooses to implement presentation from this surface via a copy operation. The DXGI
211 // runtime will not employ flip-style presentation if this bit is set
212 enum DXGI_DDI_PRIMARY_DRIVER_FLAG_NO_SCANOUT = 0x1;
213 
214 struct DXGI_DDI_PRIMARY_DESC
215 {
216     UINT                           Flags;                       // [in]
217     D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;       // [in]
218     DXGI_DDI_MODE_DESC             ModeDesc;            // [in]
219     UINT                                                   DriverFlags;         // [out] Filled by the driver
220 }
221 
222 struct DXGI_DDI_ARG_BLT_FLAGS
223 {
224     union
225     {
226         mixin(bitfields!(UINT, "Resolve",   1,
227                          UINT, "Convert",   1,
228                          UINT, "Stretch",   1,
229                          UINT, "Present",   1,
230                          UINT, "Reserved", 28));
231         UINT Value;
232     }
233 }
234 
235 struct DXGI_DDI_ARG_BLT
236 {
237     DXGI_DDI_HDEVICE            hDevice;                //in
238     DXGI_DDI_HRESOURCE          hDstResource;           //in
239     UINT                        DstSubresource;         //in
240     UINT                        DstLeft;                //in
241     UINT                        DstTop;                 //in
242     UINT                        DstRight;               //in
243     UINT                        DstBottom;              //in
244     DXGI_DDI_HRESOURCE          hSrcResource;           //in
245     UINT                        SrcSubresource;         //in
246     DXGI_DDI_ARG_BLT_FLAGS      Flags;                  //in
247     DXGI_DDI_MODE_ROTATION      Rotate;                 //in
248 }
249 
250 struct DXGI_DDI_ARG_RESOLVESHAREDRESOURCE
251 {
252     DXGI_DDI_HDEVICE            hDevice;                //in
253     DXGI_DDI_HRESOURCE          hResource;              //in
254 }
255 
256 struct DXGI_DDI_ARG_BLT1
257 {
258     DXGI_DDI_HDEVICE            hDevice;                //in
259     DXGI_DDI_HRESOURCE          hDstResource;           //in
260     UINT                        DstSubresource;         //in
261     UINT                        DstLeft;                //in
262     UINT                        DstTop;                 //in
263     UINT                        DstRight;               //in
264     UINT                        DstBottom;              //in
265     DXGI_DDI_HRESOURCE          hSrcResource;           //in
266     UINT                        SrcSubresource;         //in
267     UINT                        SrcLeft;                //in
268     UINT                        SrcTop;                 //in
269     UINT                        SrcRight;               //in
270     UINT                        SrcBottom;              //in
271     DXGI_DDI_ARG_BLT_FLAGS      Flags;                  //in
272     DXGI_DDI_MODE_ROTATION      Rotate;                 //in
273 }
274 
275 struct DXGI_DDI_ARG_OFFERRESOURCES {
276     DXGI_DDI_HDEVICE hDevice;                           //in:  device that created the resources
277     const(DXGI_DDI_HRESOURCE)* pResources;               //in:  array of resources to reset
278     UINT Resources;                                     //in:  number of elements in pResources
279     D3DDDI_OFFER_PRIORITY Priority;                     //in:  priority with which to reset the resources
280 }
281 
282 struct DXGI_DDI_ARG_RECLAIMRESOURCES {
283     DXGI_DDI_HDEVICE hDevice;                           //in:  device that created the resources
284     const(DXGI_DDI_HRESOURCE)* pResources;               //in:  array of resources to reset
285     BOOL* pDiscarded;                                   //out: optional array of booleans specifying whether each resource was discarded
286     UINT Resources;                                     //in:  number of elements in pResources and pDiscarded
287 }
288 
289 //-----------------------------------------------------------------------------------------------------------
290 // Multi Plane Overlay DDI
291 //
292 
293 enum DXGI_DDI_MAX_MULTIPLANE_OVERLAY_ALLOCATIONS = 16;
294 
295 struct DXGI_DDI_MULTIPLANE_OVERLAY_CAPS
296 {
297     UINT MaxPlanes;                  // Total number of planes supported (including the DWM's primary)
298     UINT NumCapabilityGroups;        // Number of plane types supported.
299 }
300 
301 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS;
302 enum : DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS
303 {
304     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_ROTATION_WITHOUT_INDEPENDENT_FLIP = 0x1,
305     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_VERTICAL_FLIP                     = 0x2,
306     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_HORIZONTAL_FLIP                   = 0x4,
307     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_DEINTERLACE                       = 0x8,
308     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_STEREO                            = 0x10,    // D3D10 or above only.
309     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_RGB                               = 0x20,
310     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_YUV                               = 0x40,
311     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_BILINEAR_FILTER                   = 0x80,    // Can do bilinear stretching
312     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_HIGH_FILTER                       = 0x100,   // Can do better than bilinear stretching
313     DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS_ROTATION                          = 0x200,
314 }
315 
316 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_CAPS;
317 enum : DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_CAPS
318 {
319     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_CAPS_SEPARATE           = 0x1,
320     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_CAPS_ROW_INTERLEAVED    = 0x4,
321     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_CAPS_COLUMN_INTERLEAVED = 0x8,
322     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_CAPS_CHECKERBOARD       = 0x10,
323     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_CAPS_FLIP_MODE          = 0x20,
324 }
325 
326 struct DXGI_DDI_MULTIPLANE_OVERLAY_GROUP_CAPS
327 {
328     UINT  NumPlanes;
329     float MaxStretchFactor;
330     float MaxShrinkFactor;
331     UINT  OverlayCaps;       // DXGI_DDI_MULTIPLANE_OVERLAY_FEATURE_CAPS
332     UINT  StereoCaps;        // DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_CAPS
333 }
334 
335 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_FLAGS;
336 enum : DXGI_DDI_MULTIPLANE_OVERLAY_FLAGS
337 {
338     DXGI_DDI_MULTIPLANE_OVERLAY_FLAG_VERTICAL_FLIP                 = 0x1,
339     DXGI_DDI_MULTIPLANE_OVERLAY_FLAG_HORIZONTAL_FLIP               = 0x2,
340 }
341 
342 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_BLEND;
343 enum : DXGI_DDI_MULTIPLANE_OVERLAY_BLEND
344 {
345     DXGI_DDI_MULTIPLANE_OVERLAY_BLEND_OPAQUE     = 0x0,
346     DXGI_DDI_MULTIPLANE_OVERLAY_BLEND_ALPHABLEND = 0x1,
347 }
348 
349 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_VIDEO_FRAME_FORMAT;
350 enum : DXGI_DDI_MULTIPLANE_OVERLAY_VIDEO_FRAME_FORMAT
351 {
352     DXGI_DDI_MULIIPLANE_OVERLAY_VIDEO_FRAME_FORMAT_PROGRESSIVE                   = 0,
353     DXGI_DDI_MULTIPLANE_OVERLAY_VIDEO_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST    = 1,
354     DXGI_DDI_MULTIPLANE_OVERLAY_VIDEO_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST = 2
355 }
356 
357 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_YCbCr_FLAGS;
358 enum : DXGI_DDI_MULTIPLANE_OVERLAY_YCbCr_FLAGS
359 {
360     DXGI_DDI_MULTIPLANE_OVERLAY_YCbCr_FLAG_NOMINAL_RANGE = 0x1, // 16 - 235 vs. 0 - 255
361     DXGI_DDI_MULTIPLANE_OVERLAY_YCbCr_FLAG_BT709         = 0x2, // BT.709 vs. BT.601
362     DXGI_DDI_MULTIPLANE_OVERLAY_YCbCr_FLAG_xvYCC         = 0x4, // xvYCC vs. conventional YCbCr
363 }
364 
365 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT;
366 enum : DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT
367 {
368     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT_MONO               = 0,
369     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT_HORIZONTAL         = 1,
370     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT_VERTICAL           = 2,
371     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT_SEPARATE           = 3,
372     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT_MONO_OFFSET        = 4,
373     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT_ROW_INTERLEAVED    = 5,
374     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT_COLUMN_INTERLEAVED = 6,
375     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT_CHECKERBOARD       = 7
376 }
377 
378 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FLIP_MODE;
379 enum : DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FLIP_MODE
380 {
381     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FLIP_NONE   = 0,
382     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FLIP_FRAME0 = 1,
383     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FLIP_FRAME1 = 2,
384 }
385 
386 alias DWORD DXGI_DDI_MULTIPLANE_OVERLAY_STRETCH_QUALITY;
387 enum : DXGI_DDI_MULTIPLANE_OVERLAY_STRETCH_QUALITY
388 {
389     DXGI_DDI_MULTIPLANE_OVERLAY_STRETCH_QUALITY_BILINEAR        = 0x1,  // Bilinear
390     DXGI_DDI_MULTIPLANE_OVERLAY_STRETCH_QUALITY_HIGH            = 0x2,  // Maximum
391 }
392 
393 struct DXGI_DDI_MULTIPLANE_OVERLAY_ATTRIBUTES
394 {
395     UINT                                           Flags;      // DXGI_DDI_MULTIPLANE_OVERLAY_FLAGS
396     RECT                                           SrcRect;
397     RECT                                           DstRect;
398     //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) // M1
399     RECT                                           ClipRect;
400     //#endif
401     DXGI_DDI_MODE_ROTATION                         Rotation;
402     DXGI_DDI_MULTIPLANE_OVERLAY_BLEND              Blend;
403     //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) // MP
404     UINT                                           DirtyRectCount;
405     RECT*                                          pDirtyRects;
406     //#else
407     //UINT                                           NumFilters;
408     //void*                                          pFilters;
409     //#endif
410     DXGI_DDI_MULTIPLANE_OVERLAY_VIDEO_FRAME_FORMAT VideoFrameFormat;
411     UINT                                           YCbCrFlags; // DXGI_DDI_MULTIPLANE_OVERLAY_YCbCr_FLAGS
412     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT      StereoFormat;
413     BOOL                                           StereoLeftViewFrame0;
414     BOOL                                           StereoBaseViewFrame0;
415     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FLIP_MODE   StereoFlipMode;
416     //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) // M1
417     DXGI_DDI_MULTIPLANE_OVERLAY_STRETCH_QUALITY    StretchQuality;
418     //#endif
419 }
420 
421 struct DXGI_DDI_ARG_GETMULTIPLANEOVERLAYCAPS
422 {
423     DXGI_DDI_HDEVICE                       hDevice;
424     D3DDDI_VIDEO_PRESENT_SOURCE_ID         VidPnSourceId;
425     DXGI_DDI_MULTIPLANE_OVERLAY_CAPS       MultiplaneOverlayCaps;
426 }
427 
428 struct DXGI_DDI_ARG_GETMULTIPLANEOVERLAYGROUPCAPS
429 {
430     DXGI_DDI_HDEVICE                        hDevice;
431     D3DDDI_VIDEO_PRESENT_SOURCE_ID          VidPnSourceId;
432     UINT                                    GroupIndex;
433     DXGI_DDI_MULTIPLANE_OVERLAY_GROUP_CAPS  MultiplaneOverlayGroupCaps;
434 }
435 
436 struct DXGI_DDI_CHECK_MULTIPLANE_OVERLAY_SUPPORT_PLANE_INFO
437 {
438     DXGI_DDI_HRESOURCE                     hResource;
439     UINT                                   SubResourceIndex;
440     DXGI_DDI_MULTIPLANE_OVERLAY_ATTRIBUTES PlaneAttributes;
441 }
442 
443 struct DXGI_DDI_ARG_CHECKMULTIPLANEOVERLAYSUPPORT
444 {
445     DXGI_DDI_HDEVICE                                      hDevice;
446     D3DDDI_VIDEO_PRESENT_SOURCE_ID                        VidPnSourceId;
447     UINT                                                  NumPlaneInfo;
448     DXGI_DDI_CHECK_MULTIPLANE_OVERLAY_SUPPORT_PLANE_INFO* pPlaneInfo;
449     BOOL                                                  Supported; // out: driver to fill TRUE/FALSE
450 }
451 
452 struct DXGI_DDI_PRESENT_MULTIPLANE_OVERLAY
453 {
454     UINT                                 LayerIndex;
455     BOOL                                 Enabled;
456     DXGI_DDI_HRESOURCE                   hResource;
457     UINT                                 SubResourceIndex;
458     DXGI_DDI_MULTIPLANE_OVERLAY_ATTRIBUTES PlaneAttributes;
459 }
460 
461 struct DXGI_DDI_ARG_PRESENTMULTIPLANEOVERLAY
462 {
463     DXGI_DDI_HDEVICE                     hDevice;
464     void *                               pDXGIContext;
465 
466     D3DDDI_VIDEO_PRESENT_SOURCE_ID       VidPnSourceId;
467     DXGI_DDI_PRESENT_FLAGS               Flags;
468     DXGI_DDI_FLIP_INTERVAL_TYPE          FlipInterval;
469 
470     UINT                                 PresentPlaneCount;
471     DXGI_DDI_PRESENT_MULTIPLANE_OVERLAY* pPresentPlanes;
472     //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) // M1
473     UINT                                 Reserved;
474     //#endif
475 }
476 
477 struct DXGI_DDI_ARG_CHECKPRESENTDURATIONSUPPORT
478 {
479     DXGI_DDI_HDEVICE                hDevice;
480     D3DDDI_VIDEO_PRESENT_SOURCE_ID  VidPnSourceId;
481     UINT                            DesiredPresentDuration;
482     UINT                            ClosestSmallerDuration;  // out
483     UINT                            ClosestLargerDuration;   //out
484 }
485 
486 struct DXGI_DDI_ARG_PRESENTSURFACE
487 {
488     DXGI_DDI_HRESOURCE hSurface;         // In
489     UINT               SubResourceIndex; // Index of surface level
490 }
491 
492 struct DXGI_DDI_ARG_PRESENT1
493 {
494     DXGI_DDI_HDEVICE                   hDevice;             //in
495     const(DXGI_DDI_ARG_PRESENTSURFACE)* phSurfacesToPresent; //in
496     UINT                               SurfacesToPresent;   //in
497     DXGI_DDI_HRESOURCE                 hDstResource;        // if non-zero, it's the destination of the present
498     UINT                               DstSubResourceIndex; // Index of surface level
499     void *                             pDXGIContext;        // opaque: Pass this to the Present callback
500     DXGI_DDI_PRESENT_FLAGS             Flags;               // Presentation flags.
501     DXGI_DDI_FLIP_INTERVAL_TYPE        FlipInterval;        // Presentation interval (flip only)
502     UINT                               Reserved;
503     const(RECT)*                        pDirtyRects;         // in: Array of dirty rects
504     UINT                               DirtyRects;          // in: Number of dirty rects
505 
506     //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WDDM2_0)
507     // out: for LDA only.
508     // Only WDDM2.0 drivers should write this value
509     // The number of physical back buffer per logical back buffer.
510     UINT                               BackBufferMultiplicity;
511     //#endif
512 }
513 
514 struct DXGI_DDI_ARG_TRIMRESIDENCYSET
515 {
516     DXGI_DDI_HDEVICE                hDevice;
517     D3DDDI_TRIMRESIDENCYSET_FLAGS   TrimFlags;
518     UINT64                          NumBytesToTrim;
519 }
520 
521 struct DXGI_DDI_ARG_CHECKMULTIPLANEOVERLAYCOLORSPACESUPPORT
522 {
523     DXGI_DDI_HDEVICE                hDevice;
524     D3DDDI_VIDEO_PRESENT_SOURCE_ID  VidPnSourceId;
525     DXGI_FORMAT                     Format;
526     D3DDDI_COLOR_SPACE_TYPE         ColorSpace;
527     BOOL                            Supported;      // out
528 }
529 
530 struct DXGI_DDI_MULTIPLANE_OVERLAY_ATTRIBUTES1
531 {
532     UINT                                           Flags;   // DXGI_DDI_MULTIPLANE_OVERLAY_FLAGS
533     RECT                                           SrcRect;
534     RECT                                           DstRect;
535     RECT                                           ClipRect;
536     DXGI_DDI_MODE_ROTATION                         Rotation;
537     DXGI_DDI_MULTIPLANE_OVERLAY_BLEND              Blend;
538     UINT                                           DirtyRectCount;
539     RECT*                                          pDirtyRects;
540     DXGI_DDI_MULTIPLANE_OVERLAY_VIDEO_FRAME_FORMAT VideoFrameFormat;
541     D3DDDI_COLOR_SPACE_TYPE                        ColorSpace;
542     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FORMAT      StereoFormat;
543     BOOL                                           StereoLeftViewFrame0;
544     BOOL                                           StereoBaseViewFrame0;
545     DXGI_DDI_MULTIPLANE_OVERLAY_STEREO_FLIP_MODE   StereoFlipMode;
546     DXGI_DDI_MULTIPLANE_OVERLAY_STRETCH_QUALITY    StretchQuality;
547     UINT                                           ColorKey;
548 }
549 
550 struct DXGI_DDI_PRESENT_MULTIPLANE_OVERLAY1
551 {
552     UINT                                    LayerIndex;
553     BOOL                                    Enabled;
554     DXGI_DDI_HRESOURCE                      hResource;
555     UINT                                    SubResourceIndex;
556     DXGI_DDI_MULTIPLANE_OVERLAY_ATTRIBUTES1 PlaneAttributes;
557 }
558 
559 struct DXGI_DDI_ARG_PRESENTMULTIPLANEOVERLAY1
560 {
561     DXGI_DDI_HDEVICE                      hDevice;
562     void *                                pDXGIContext;
563 
564     D3DDDI_VIDEO_PRESENT_SOURCE_ID        VidPnSourceId;
565     DXGI_DDI_PRESENT_FLAGS                Flags;
566     DXGI_DDI_FLIP_INTERVAL_TYPE           FlipInterval;
567 
568     UINT                                  PresentPlaneCount;
569     DXGI_DDI_PRESENT_MULTIPLANE_OVERLAY1* pPresentPlanes;
570 }
571 
572 //--------------------------------------------------------------------------------------------------------
573 struct DXGI_DDI_BASE_FUNCTIONS
574 {
575     extern (Windows):
576     HRESULT function(DXGI_DDI_ARG_PRESENT*) pfnPresent;
577     HRESULT function(DXGI_DDI_ARG_GET_GAMMA_CONTROL_CAPS*) pfnGetGammaCaps;
578     HRESULT function(DXGI_DDI_ARG_SETDISPLAYMODE*) pfnSetDisplayMode;
579     HRESULT function(DXGI_DDI_ARG_SETRESOURCEPRIORITY*) pfnSetResourcePriority;
580     HRESULT function(DXGI_DDI_ARG_QUERYRESOURCERESIDENCY*) pfnQueryResourceResidency;
581     HRESULT function(DXGI_DDI_ARG_ROTATE_RESOURCE_IDENTITIES*) pfnRotateResourceIdentities;
582     HRESULT function(DXGI_DDI_ARG_BLT*) pfnBlt;
583 }
584 
585 //--------------------------------------------------------------------------------------------------------
586 struct DXGI1_1_DDI_BASE_FUNCTIONS
587 {
588     extern (Windows):
589     HRESULT function(DXGI_DDI_ARG_PRESENT*) pfnPresent;
590     HRESULT function(DXGI_DDI_ARG_GET_GAMMA_CONTROL_CAPS*) pfnGetGammaCaps;
591     HRESULT function(DXGI_DDI_ARG_SETDISPLAYMODE*) pfnSetDisplayMode;
592     HRESULT function(DXGI_DDI_ARG_SETRESOURCEPRIORITY*) pfnSetResourcePriority;
593     HRESULT function(DXGI_DDI_ARG_QUERYRESOURCERESIDENCY*) pfnQueryResourceResidency;
594     HRESULT function(DXGI_DDI_ARG_ROTATE_RESOURCE_IDENTITIES*) pfnRotateResourceIdentities;
595     HRESULT function(DXGI_DDI_ARG_BLT*) pfnBlt;
596     HRESULT function(DXGI_DDI_ARG_RESOLVESHAREDRESOURCE*) pfnResolveSharedResource;
597 }
598 
599 //--------------------------------------------------------------------------------------------------------
600 struct DXGI1_2_DDI_BASE_FUNCTIONS
601 {
602     extern (Windows):
603     HRESULT function(DXGI_DDI_ARG_PRESENT*) pfnPresent;
604     HRESULT function(DXGI_DDI_ARG_GET_GAMMA_CONTROL_CAPS*) pfnGetGammaCaps;
605     HRESULT function(DXGI_DDI_ARG_SETDISPLAYMODE*) pfnSetDisplayMode;
606     HRESULT function(DXGI_DDI_ARG_SETRESOURCEPRIORITY*) pfnSetResourcePriority;
607     HRESULT function(DXGI_DDI_ARG_QUERYRESOURCERESIDENCY*) pfnQueryResourceResidency;
608     HRESULT function(DXGI_DDI_ARG_ROTATE_RESOURCE_IDENTITIES*) pfnRotateResourceIdentities;
609     HRESULT function(DXGI_DDI_ARG_BLT*) pfnBlt;
610     HRESULT function(DXGI_DDI_ARG_RESOLVESHAREDRESOURCE*) pfnResolveSharedResource;
611     HRESULT function(DXGI_DDI_ARG_BLT1*) pfnBlt1;
612     HRESULT function(DXGI_DDI_ARG_OFFERRESOURCES*) pfnOfferResources;
613     HRESULT function(DXGI_DDI_ARG_RECLAIMRESOURCES*) pfnReclaimResources;
614     // Use IS_DXGI_MULTIPLANE_OVERLAY_FUNCTIONS macro to determine these functions fields are available
615     HRESULT function(DXGI_DDI_ARG_GETMULTIPLANEOVERLAYCAPS*) pfnGetMultiplaneOverlayCaps;
616     HRESULT function(void*) pfnGetMultiplaneOverlayFilterRange;
617     HRESULT function(DXGI_DDI_ARG_CHECKMULTIPLANEOVERLAYSUPPORT*) pfnCheckMultiplaneOverlaySupport;
618     HRESULT function(DXGI_DDI_ARG_PRESENTMULTIPLANEOVERLAY*) pfnPresentMultiplaneOverlay;
619 }
620 
621 //--------------------------------------------------------------------------------------------------------
622 struct DXGI1_3_DDI_BASE_FUNCTIONS
623 {
624     extern (Windows):
625     HRESULT function(DXGI_DDI_ARG_PRESENT*) pfnPresent;
626     HRESULT function(DXGI_DDI_ARG_GET_GAMMA_CONTROL_CAPS*) pfnGetGammaCaps;
627     HRESULT function(DXGI_DDI_ARG_SETDISPLAYMODE*) pfnSetDisplayMode;
628     HRESULT function(DXGI_DDI_ARG_SETRESOURCEPRIORITY*) pfnSetResourcePriority;
629     HRESULT function(DXGI_DDI_ARG_QUERYRESOURCERESIDENCY*) pfnQueryResourceResidency;
630     HRESULT function(DXGI_DDI_ARG_ROTATE_RESOURCE_IDENTITIES*) pfnRotateResourceIdentities;
631     HRESULT function(DXGI_DDI_ARG_BLT*) pfnBlt;
632     HRESULT function(DXGI_DDI_ARG_RESOLVESHAREDRESOURCE*) pfnResolveSharedResource;
633     HRESULT function(DXGI_DDI_ARG_BLT1*) pfnBlt1;
634     HRESULT function(DXGI_DDI_ARG_OFFERRESOURCES*) pfnOfferResources;
635     HRESULT function(DXGI_DDI_ARG_RECLAIMRESOURCES*) pfnReclaimResources;
636     HRESULT function(DXGI_DDI_ARG_GETMULTIPLANEOVERLAYCAPS*) pfnGetMultiplaneOverlayCaps;
637     HRESULT function(DXGI_DDI_ARG_GETMULTIPLANEOVERLAYGROUPCAPS*) pfnGetMultiplaneOverlayGroupCaps;
638     HRESULT function(void*) pfnReserved1;
639     HRESULT function(DXGI_DDI_ARG_PRESENTMULTIPLANEOVERLAY*) pfnPresentMultiplaneOverlay;
640     HRESULT function(void*) pfnReserved2;
641     HRESULT function(DXGI_DDI_ARG_PRESENT1*) pfnPresent1;
642     HRESULT function(DXGI_DDI_ARG_CHECKPRESENTDURATIONSUPPORT*) pfnCheckPresentDurationSupport;
643 }
644 
645 //--------------------------------------------------------------------------------------------------------
646 struct DXGI1_4_DDI_BASE_FUNCTIONS
647 {
648     extern (Windows):
649     HRESULT function(DXGI_DDI_ARG_PRESENT*) pfnPresent;
650     HRESULT function(DXGI_DDI_ARG_GET_GAMMA_CONTROL_CAPS*) pfnGetGammaCaps;
651     HRESULT function(DXGI_DDI_ARG_SETDISPLAYMODE*) pfnSetDisplayMode;
652     HRESULT function(DXGI_DDI_ARG_SETRESOURCEPRIORITY*) pfnSetResourcePriority;
653     HRESULT function(DXGI_DDI_ARG_QUERYRESOURCERESIDENCY*) pfnQueryResourceResidency;
654     HRESULT function(DXGI_DDI_ARG_ROTATE_RESOURCE_IDENTITIES*) pfnRotateResourceIdentities;
655     HRESULT function(DXGI_DDI_ARG_BLT*) pfnBlt;
656     HRESULT function(DXGI_DDI_ARG_RESOLVESHAREDRESOURCE*) pfnResolveSharedResource;
657     HRESULT function(DXGI_DDI_ARG_BLT1*) pfnBlt1;
658     HRESULT function(DXGI_DDI_ARG_OFFERRESOURCES*) pfnOfferResources;
659     HRESULT function(DXGI_DDI_ARG_RECLAIMRESOURCES*) pfnReclaimResources;
660     HRESULT function(DXGI_DDI_ARG_GETMULTIPLANEOVERLAYCAPS*) pfnGetMultiplaneOverlayCaps;
661     HRESULT function(DXGI_DDI_ARG_GETMULTIPLANEOVERLAYGROUPCAPS*) pfnGetMultiplaneOverlayGroupCaps;
662     HRESULT function(void*) pfnReserved1;
663     HRESULT function(DXGI_DDI_ARG_PRESENTMULTIPLANEOVERLAY*) pfnPresentMultiplaneOverlay;
664     HRESULT function(void*) pfnReserved2;
665     HRESULT function(DXGI_DDI_ARG_PRESENT1*) pfnPresent1;
666     HRESULT function(DXGI_DDI_ARG_CHECKPRESENTDURATIONSUPPORT*) pfnCheckPresentDurationSupport;
667     HRESULT function(DXGI_DDI_ARG_TRIMRESIDENCYSET*) pfnTrimResidencySet;
668     HRESULT function(DXGI_DDI_ARG_CHECKMULTIPLANEOVERLAYCOLORSPACESUPPORT*) pfnCheckMultiplaneOverlayColorSpaceSupport;
669     HRESULT function(DXGI_DDI_ARG_PRESENTMULTIPLANEOVERLAY1*) pfnPresentMultiplaneOverlay1;
670 }
671 
672 //========================================================================================================
673 // DXGI callback definitions.
674 //
675 
676 //--------------------------------------------------------------------------------------------------------
677 struct DXGIDDICB_PRESENT
678 {
679     D3DKMT_HANDLE   hSrcAllocation;             // in: The allocation of which content will be presented
680     D3DKMT_HANDLE   hDstAllocation;             // in: if non-zero, it's the destination allocation of the present
681     void *          pDXGIContext;               // opaque: Fill this with the value in DXGI_DDI_ARG_PRESENT.pDXGIContext
682     HANDLE          hContext;                   // in: Context being submitted to.
683     UINT            BroadcastContextCount;      // in: Specifies the number of context
684     //     to broadcast this present operation to.
685     //     Only supported for flip operation.
686     HANDLE[D3DDDI_MAX_BROADCAST_CONTEXT]          BroadcastContext; // in: Specifies the handle of the context to
687     //     broadcast to.
688     D3DKMT_HANDLE*              BroadcastSrcAllocation;                         // in: LDA
689     D3DKMT_HANDLE*              BroadcastDstAllocation;                         // in: LDA
690     UINT                        PrivateDriverDataSize;                          // in:
691     PVOID                       pPrivateDriverData;                             // in: Private driver data to pass to DdiPresent and DdiSetVidPnSourceAddress
692     BOOLEAN                     bOptimizeForComposition;                        // out: DWM is involved in composition
693 }
694 
695 struct DXGIDDI_MULTIPLANE_OVERLAY_ALLOCATION_INFO
696 {
697     D3DKMT_HANDLE PresentAllocation;
698     UINT SubResourceIndex;
699 }
700 
701 struct DXGIDDICB_PRESENT_MULTIPLANE_OVERLAY
702 {
703     void *          pDXGIContext;               // opaque: Fill this with the value in DXGI_DDI_ARG_PRESENT.pDXGIContext
704     HANDLE          hContext;
705 
706     UINT            BroadcastContextCount;
707     HANDLE[D3DDDI_MAX_BROADCAST_CONTEXT]          BroadcastContext;
708 
709     DWORD           AllocationInfoCount;
710     DXGIDDI_MULTIPLANE_OVERLAY_ALLOCATION_INFO[DXGI_DDI_MAX_MULTIPLANE_OVERLAY_ALLOCATIONS] AllocationInfo;
711 }
712 
713 extern (Windows) {
714     alias HRESULT function(HANDLE hDevice, DXGIDDICB_PRESENT*) PFNDDXGIDDI_PRESENTCB;
715 
716     alias HRESULT function(HANDLE hDevice, const(DXGIDDICB_PRESENT_MULTIPLANE_OVERLAY)*) PFNDDXGIDDI_PRESENT_MULTIPLANE_OVERLAYCB;
717 }
718 
719 //--------------------------------------------------------------------------------------------------------
720 struct DXGI_DDI_BASE_CALLBACKS
721 {
722     PFNDDXGIDDI_PRESENTCB                pfnPresentCb;
723     //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WIN8)
724     // Use IS_DXGI_MULTIPLANE_OVERLAY_FUNCTIONS macro to check if field is available.
725     PFNDDXGIDDI_PRESENT_MULTIPLANE_OVERLAYCB pfnPresentMultiplaneOverlayCb;
726     //#endif // (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WIN8)
727 }
728 
729 //========================================================================================================
730 // DXGI basic DDI device creation arguments
731 
732 struct DXGI_DDI_BASE_ARGS
733 {
734     DXGI_DDI_BASE_CALLBACKS *pDXGIBaseCallbacks;            // in: The driver should record this pointer for later use
735     union
736     {
737         //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WDDM2_0)
738         DXGI1_4_DDI_BASE_FUNCTIONS *pDXGIDDIBaseFunctions5; // in/out: The driver should fill the denoted struct with DXGI base driver entry points
739         //#endif
740         //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WDDM1_3) // M1
741         DXGI1_3_DDI_BASE_FUNCTIONS *pDXGIDDIBaseFunctions4; // in/out: The driver should fill the denoted struct with DXGI base driver entry points
742         //#endif
743         //#if (D3D_UMD_INTERFACE_VERSION >= D3D_UMD_INTERFACE_VERSION_WIN8)
744         DXGI1_2_DDI_BASE_FUNCTIONS *pDXGIDDIBaseFunctions3; // in/out: The driver should fill the denoted struct with DXGI base driver entry points
745         //#endif
746         DXGI1_1_DDI_BASE_FUNCTIONS *pDXGIDDIBaseFunctions2; // in/out: The driver should fill the denoted struct with DXGI base driver entry points
747         DXGI_DDI_BASE_FUNCTIONS *pDXGIDDIBaseFunctions;     // in/out: The driver should fill the denoted struct with DXGI base driver entry points
748     }
749 }