Skip to content

SysWin DXGI Interfaces

Paul Squires edited this page Oct 31, 2026 · 1 revision

Home › All Categories › sys/win › sys/win/direct2d › DXGI interfaces and types

DXGI interfaces and types

Lists the DXGI interfaces, enumerations and structures of sys/win/direct2d.

DXGI, the DirectX Graphics Infrastructure, is the layer under Direct3D and Direct2D that knows the graphics adapters, the monitors attached to them, and the surfaces and swap chains that frames are drawn into and presented from. sys/win/direct2d declares its interfaces up to the sixth factory so that Direct2D can be pointed at DXGI objects; it does not create Direct3D devices.

Where the objects meet sys/win. The Direct2D classes take and give DXGI pointers: CD2D1Factory makes a render target on an IDXGISurface (CreateDxgiSurfaceRenderTarget), its later versions build a Direct2D device on an IDXGIDevice (CreateDevice … CreateDevice7), and CID2D1Bitmap1.GetSurface returns the IDXGISurface behind a bitmap. The IDXGIDevice itself comes from a Direct3D device, by QueryInterface with IID_IDXGIDevice.

A factory of your own. To list adapters and outputs without Direct3D, create a DXGI factory. sys/win/direct2d declares one entry point, declare function CreateDXGIFactory2 lib "Dxgi" alias "CreateDXGIFactory2" ( byval flags as UINT, byref factory as any ptr ) as HRESULT, without the interface identifier that Windows' CreateDXGIFactory2 expects between the two: calling it as declared ended the test program with an access violation. Declare CreateDXGIFactory1 yourself, as the example does.

Calling a method. Each interface IDXGIX is a name for the type IDXGIX_, which declares the methods and extends its parent, so p->Method( ... ) calls one, and an IDXGIFactory1 ptr also has every IDXGIFactory and IDXGIObject method. A parameter that receives an object is byref ... ptr: pass the pointer variable. IID_IDXGIObject … IID_IDXGIFactory7 are GUID variables. Every pointer handed out holds one reference: call Release when done.

Constants. Besides the enumerations below, the module declares the DXGI_USAGE_*, DXGI_PRESENT_*, DXGI_MWA_* (window association), DXGI_MAP_*, DXGI_ENUM_MODES_*, DXGI_RESOURCE_PRIORITY_* and DXGI_SHARED_RESOURCE_* values as constants.

Importing

#import "sys/win"
#import "sys/win/direct2d"
using win, direct2d

Example

A console program that lists the graphics adapters, with their dedicated video memory, and the outputs (monitors) of each:

#import "sys/win"
#import "sys/win/direct2d"
using win, direct2d

' The factory entry point that takes an interface identifier.
declare function CreateDXGIFactory1 lib "dxgi" alias "CreateDXGIFactory1" ( byref riid as IID, byref ppFactory as any ptr ) as HRESULT

function main() as long
    dim pFactory as IDXGIFactory1 ptr
    dim hr as HRESULT = CreateDXGIFactory1( IID_IDXGIFactory1, pFactory )
    if hr <> S_OK then print "CreateDXGIFactory1 failed: &h"; hex( hr ) : return 1

    ' Walk the graphics adapters, then the outputs (monitors) of each.
    dim i as UINT = 0
    dim pAdapter as IDXGIAdapter1 ptr
    while pFactory->EnumAdapters1( i, pAdapter ) = S_OK
        dim desc as DXGI_ADAPTER_DESC1
        pAdapter->GetDesc1( desc )
        dim sName as ustring = desc.Description
        print "adapter "; i; ": "; sName; ", "; desc.DedicatedVideoMemory \ ( 1024 * 1024 ); " MB";
        if desc.Flags and DXGI_ADAPTER_FLAG_SOFTWARE then print " (software)" else print
        dim j as UINT = 0
        dim pOutput as IDXGIOutput ptr
        while pAdapter->EnumOutputs( j, pOutput ) = S_OK
            dim od as DXGI_OUTPUT_DESC
            pOutput->GetDesc( od )
            with od.DesktopCoordinates
                print "    output "; j; ":"; .right - .left; " x"; .bottom - .top
            end with
            pOutput->Release()
            j += 1
        wend
        pAdapter->Release()
        i += 1
    wend
    pFactory->Release()
    return 0
end function

end main()

On a laptop it printed:

adapter 0: Intel(R) Arc(TM) 140V GPU (8GB), 128 MB
    output 0: 1646 x 1029
adapter 1: Microsoft Basic Render Driver, 0 MB (software)

The program is not DPI aware, so the desktop rectangle is in scaled pixels; call SetProcessDpiAwareness first for physical ones. The last adapter is the software renderer that Windows provides.

Types

The enumeration types are longs; their values are separate constants, written bare after using direct2d. DXGI_FORMAT, DXGI_MODE_DESC, DXGI_SAMPLE_DESC, DXGI_RATIONAL, DXGI_RGB and the other types shared with Direct2D are declared with it: see Direct2D interfaces.

Interfaces

Interface Methods declared in Extends Is Microsoft Learn
IDXGIObject IDXGIObject_ ComUnknown The base of every DXGI object: private data and the parent object. IDXGIObject
IDXGIDeviceSubObject IDXGIDeviceSubObject_ IDXGIObject The base of objects that belong to a device: gives the device back. IDXGIDeviceSubObject
IDXGIResource IDXGIResource_ IDXGIDeviceSubObject A resource that can be shared between devices: shared handle, usage, eviction priority. IDXGIResource
IDXGIKeyedMutex IDXGIKeyedMutex_ IDXGIDeviceSubObject A lock on a shared surface, acquired and released with a key. IDXGIKeyedMutex
IDXGISurface IDXGISurface_ IDXGIDeviceSubObject A 2D image: its description, and mapping its pixels into memory. A Direct2D bitmap or DXGI render target draws on one. IDXGISurface
IDXGISurface1 IDXGISurface1_ IDXGISurface Adds a GDI device context for the surface (GetDC, ReleaseDC). IDXGISurface1
IDXGIOutput IDXGIOutput_ IDXGIObject A display output (a monitor): its description, display modes, vertical blank, gamma. IDXGIOutput
IDXGIAdapter IDXGIAdapter_ IDXGIObject A display adapter (a graphics card or a software renderer): its outputs and description. IDXGIAdapter
IDXGISwapChain IDXGISwapChain_ IDXGIDeviceSubObject The buffers a window is presented from: Present, GetBuffer, ResizeBuffers, full-screen state. IDXGISwapChain
IDXGIFactory IDXGIFactory_ IDXGIObject Enumerates adapters and creates swap chains. IDXGIFactory
IDXGIDevice IDXGIDevice_ IDXGIObject The DXGI side of a Direct3D device: its adapter, GPU thread priority. Direct2D builds its device on one. IDXGIDevice
IDXGIAdapter1 IDXGIAdapter1_ IDXGIAdapter Adds a description with adapter flags (GetDesc1). IDXGIAdapter1
IDXGIDevice1 IDXGIDevice1_ IDXGIDevice Adds the maximum frame latency. IDXGIDevice1
IDXGIFactory1 IDXGIFactory1_ IDXGIFactory Adds EnumAdapters1 and a test for whether the factory is current. IDXGIFactory1
IDXGIOutputDuplication IDXGIOutputDuplication_ IDXGIObject A copy of the desktop image of one output, frame by frame, for screen capture. IDXGIOutputDuplication
IDXGISurface2 IDXGISurface2_ IDXGISurface1 Adds the resource a subresource surface belongs to. IDXGISurface2
IDXGIResource1 IDXGIResource1_ IDXGIResource Adds subresource surfaces and named shared handles. IDXGIResource1
IDXGIDisplayControl IDXGIDisplayControl_ ComUnknown Turns stereo display on and off. IDXGIDisplayControl
IDXGIDevice2 IDXGIDevice2_ IDXGIDevice1 Adds offering and reclaiming resources, and an event when the queue is done. IDXGIDevice2
IDXGISwapChain1 IDXGISwapChain1_ IDXGISwapChain Adds a second-generation description, Present1, background colour and rotation. IDXGISwapChain1
IDXGIFactory2 IDXGIFactory2_ IDXGIFactory1 Adds swap chains for a window (CreateSwapChainForHwnd), for a core window and for composition, and stereo and occlusion notifications. IDXGIFactory2
IDXGIAdapter2 IDXGIAdapter2_ IDXGIAdapter1 Adds a description with preemption granularity (GetDesc2). IDXGIAdapter2
IDXGIOutput1 IDXGIOutput1_ IDXGIOutput Adds display modes in the second-generation format and DuplicateOutput. IDXGIOutput1
IDXGIDevice3 IDXGIDevice3_ IDXGIDevice2 Adds Trim, which frees memory a suspended app no longer needs. IDXGIDevice3
IDXGISwapChain2 IDXGISwapChain2_ IDXGISwapChain1 Adds source size, frame latency waitable object and matrix transform. IDXGISwapChain2
IDXGIOutput2 IDXGIOutput2_ IDXGIOutput1 Adds a test for multiplane overlay support. IDXGIOutput2
IDXGIFactory3 IDXGIFactory3_ IDXGIFactory2 Adds the flags the factory was created with. IDXGIFactory3
IDXGIDecodeSwapChain IDXGIDecodeSwapChain_ ComUnknown A swap chain that presents decoded video buffers. IDXGIDecodeSwapChain
IDXGIFactoryMedia IDXGIFactoryMedia_ ComUnknown Creates swap chains from a composition surface handle, for video. IDXGIFactoryMedia
IDXGISwapChainMedia IDXGISwapChainMedia_ ComUnknown Media frame statistics and custom present duration. IDXGISwapChainMedia
IDXGIOutput3 IDXGIOutput3_ IDXGIOutput2 Adds the overlay support test for a format. IDXGIOutput3
IDXGISwapChain3 IDXGISwapChain3_ IDXGISwapChain2 Adds the current back-buffer index and colour spaces. IDXGISwapChain3
IDXGIOutput4 IDXGIOutput4_ IDXGIOutput3 Adds the overlay colour-space support test. IDXGIOutput4
IDXGIFactory4 IDXGIFactory4_ IDXGIFactory3 Adds finding an adapter by LUID and the WARP software adapter. IDXGIFactory4
IDXGIAdapter3 IDXGIAdapter3_ IDXGIAdapter2 Adds video memory budgets and reservations, and content protection notices. IDXGIAdapter3
IDXGIOutput5 IDXGIOutput5_ IDXGIOutput4 Adds output duplication for a list of formats. IDXGIOutput5
IDXGISwapChain4 IDXGISwapChain4_ IDXGISwapChain3 Adds HDR metadata. IDXGISwapChain4
IDXGIDevice4 IDXGIDevice4_ IDXGIDevice3 Adds offering and reclaiming resources with flags. IDXGIDevice4
IDXGIFactory5 IDXGIFactory5_ IDXGIFactory4 Adds a feature test, such as tearing support. IDXGIFactory5
IDXGIAdapter4 IDXGIAdapter4_ IDXGIAdapter3 Adds a description with the third-generation flags (GetDesc3). IDXGIAdapter4
IDXGIOutput6 IDXGIOutput6_ IDXGIOutput5 Adds a description with colour data (GetDesc1) and hardware composition support. IDXGIOutput6
IDXGIFactory6 IDXGIFactory6_ IDXGIFactory5 Adds enumerating adapters by GPU preference (low power or high performance). IDXGIFactory6
— IDXGIFactory7_ IDXGIFactory6 Adds an event raised when adapters are added or removed. The methods are there under IDXGIFactory7_; no IDXGIFactory7 name is declared. IDXGIFactory7

Enumerations

Type Values Is Microsoft Learn
DXGI_SWAP_EFFECT DXGI_SWAP_EFFECT_* How presented buffers are handled: discard, sequential, flip-sequential, flip-discard. DXGI_SWAP_EFFECT
DXGI_RESIDENCY DXGI_RESIDENCY_* Whether a resource is in video memory, shared memory or evicted. DXGI_RESIDENCY
DXGI_SWAP_CHAIN_FLAG DXGI_SWAP_CHAIN_FLAG_* Swap-chain options: GDI compatible, allow mode switch, waitable object, allow tearing … DXGI_SWAP_CHAIN_FLAG
DXGI_ADAPTER_FLAG DXGI_ADAPTER_FLAG_* Kind of adapter: remote or software. DXGI_ADAPTER_FLAG
DXGI_OFFER_RESOURCE_PRIORITY DXGI_OFFER_RESOURCE_PRIORITY_* How important an offered resource is. DXGI_OFFER_RESOURCE_PRIORITY
DXGI_ALPHA_MODE DXGI_ALPHA_MODE_* How a swap chain treats alpha: unspecified, premultiplied, straight, ignore. DXGI_ALPHA_MODE
DXGI_OUTDUPL_POINTER_SHAPE_TYPE DXGI_OUTDUPL_POINTER_SHAPE_TYPE_* The kind of mouse pointer shape in a duplicated frame. DXGI_OUTDUPL_POINTER_SHAPE_TYPE
DXGI_SCALING DXGI_SCALING_* How the back buffer is fitted to the target: stretch, none, aspect-ratio stretch. DXGI_SCALING
DXGI_GRAPHICS_PREEMPTION_GRANULARITY DXGI_GRAPHICS_PREEMPTION_* How finely the GPU can interrupt graphics work. DXGI_GRAPHICS_PREEMPTION_GRANULARITY
DXGI_COMPUTE_PREEMPTION_GRANULARITY DXGI_COMPUTE_PREEMPTION_* How finely the GPU can interrupt compute work. DXGI_COMPUTE_PREEMPTION_GRANULARITY
DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAG_* YCbCr options of a decode swap chain: nominal range, BT.709, xvYCC. DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS
DXGI_FRAME_PRESENTATION_MODE DXGI_FRAME_PRESENTATION_MODE_* How a frame of a media swap chain was shown: composed, overlay, none, composition failure. DXGI_FRAME_PRESENTATION_MODE
DXGI_OVERLAY_SUPPORT_FLAG DXGI_OVERLAY_SUPPORT_FLAG_* Overlay support: direct, scaling. DXGI_OVERLAY_SUPPORT_FLAG
DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_* Whether a colour space can be presented, or presented in an overlay. DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG
DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG_* Whether an overlay supports a colour space. DXGI_OVERLAY_COLOR_SPACE_SUPPORT_FLAG
DXGI_MEMORY_SEGMENT_GROUP DXGI_MEMORY_SEGMENT_GROUP_* Local (dedicated) or non-local video memory. DXGI_MEMORY_SEGMENT_GROUP
DXGI_OUTDUPL_FLAG DXGI_OUTDUPL_COMPOSITED_UI_CAPTURE_ONLY Output duplication option: capture only the composited UI. —
DXGI_HDR_METADATA_TYPE DXGI_HDR_METADATA_TYPE_* Kind of HDR metadata: none, HDR10, HDR10+. DXGI_HDR_METADATA_TYPE
DXGI_OFFER_RESOURCE_FLAGS DXGI_OFFER_RESOURCE_FLAG_ALLOW_DECOMMIT Options for offering resources: allow decommit. DXGI_OFFER_RESOURCE_FLAGS
DXGI_RECLAIM_RESOURCE_RESULTS DXGI_RECLAIM_RESOURCE_RESULT_* What happened to a reclaimed resource: OK, discarded, not committed. DXGI_RECLAIM_RESOURCE_RESULTS
DXGI_FEATURE DXGI_FEATURE_* A feature to test with CheckFeatureSupport: tearing. DXGI_FEATURE
DXGI_ADAPTER_FLAG3 DXGI_ADAPTER_FLAG3_* Adapter flags of DXGI_ADAPTER_DESC3: remote, software, ACG compatible, fences, keyed-mutex conformance DXGI_ADAPTER_FLAG3
DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAGS DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_* Hardware composition support: full screen, windowed, cursor stretched. DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAGS
DXGI_GPU_PREFERENCE DXGI_GPU_PREFERENCE_* Which adapter to list first: unspecified, minimum power, high performance. DXGI_GPU_PREFERENCE

Structures

Type Is Microsoft Learn
DXGI_SURFACE_DESC Width, height, format and multisampling of a surface. DXGI_SURFACE_DESC
DXGI_MAPPED_RECT The pitch and pixel pointer of a mapped surface. DXGI_MAPPED_RECT
DXGI_OUTPUT_DESC Device name, desktop rectangle, rotation and monitor handle of an output. DXGI_OUTPUT_DESC
DXGI_FRAME_STATISTICS Present and refresh counts and their timestamps. DXGI_FRAME_STATISTICS
DXGI_ADAPTER_DESC Adapter name, vendor and device ids, memory sizes and LUID. DXGI_ADAPTER_DESC
DXGI_SWAP_CHAIN_DESC Everything CreateSwapChain needs: buffer mode, sample count, usage, buffer count, window, swap effect. DXGI_SWAP_CHAIN_DESC
DXGI_SHARED_RESOURCE A shared resource handle. DXGI_SHARED_RESOURCE
DXGI_ADAPTER_DESC1 DXGI_ADAPTER_DESC plus DXGI_ADAPTER_FLAG flags. DXGI_ADAPTER_DESC1
DXGI_DISPLAY_COLOR_SPACE Primary and white-point coordinates of a display. DXGI_DISPLAY_COLOR_SPACE
DXGI_OUTDUPL_MOVE_RECT A region moved from one place of the desktop to another. DXGI_OUTDUPL_MOVE_RECT
DXGI_OUTDUPL_DESC Mode, rotation and memory location of a duplicated desktop image. DXGI_OUTDUPL_DESC
DXGI_OUTDUPL_POINTER_POSITION Position and visibility of the mouse pointer. DXGI_OUTDUPL_POINTER_POSITION
DXGI_OUTDUPL_POINTER_SHAPE_INFO Type, size, pitch and hot spot of the pointer shape. DXGI_OUTDUPL_POINTER_SHAPE_INFO
DXGI_OUTDUPL_FRAME_INFO Timestamps, frame counts and pointer data of a duplicated frame. DXGI_OUTDUPL_FRAME_INFO
DXGI_MODE_DESC1 A display mode, with stereo. DXGI_MODE_DESC1
DXGI_SWAP_CHAIN_DESC1 The description CreateSwapChainForHwnd takes: size, format, buffers, scaling, swap effect, alpha mode. DXGI_SWAP_CHAIN_DESC1
DXGI_SWAP_CHAIN_FULLSCREEN_DESC Refresh rate, scan-line order, scaling and windowed state of a full-screen swap chain. DXGI_SWAP_CHAIN_FULLSCREEN_DESC
DXGI_PRESENT_PARAMETERS Dirty rectangles and scroll information for Present1. DXGI_PRESENT_PARAMETERS
DXGI_ADAPTER_DESC2 Adds preemption granularity to the adapter description. DXGI_ADAPTER_DESC2
DXGI_MATRIX_3X2_F A 3 × 2 transform matrix for a swap chain. DXGI_MATRIX_3X2_F
DXGI_DECODE_SWAP_CHAIN_DESC Flags of a decode swap chain. DXGI_DECODE_SWAP_CHAIN_DESC
DXGI_FRAME_STATISTICS_MEDIA Frame statistics with the composition mode and approved duration. DXGI_FRAME_STATISTICS_MEDIA
DXGI_QUERY_VIDEO_MEMORY_INFO Video memory budget, usage and reservations. DXGI_QUERY_VIDEO_MEMORY_INFO
DXGI_HDR_METADATA_HDR10 HDR10 mastering-display and content light levels. DXGI_HDR_METADATA_HDR10
DXGI_HDR_METADATA_HDR10PLUS An HDR10+ metadata block (72 bytes). —
DXGI_ADAPTER_DESC3 The adapter description with DXGI_ADAPTER_FLAG3 flags. DXGI_ADAPTER_DESC3
DXGI_OUTPUT_DESC1 The output description with bits per colour, colour space, primaries and luminance. DXGI_OUTPUT_DESC1

Other types

Type Declared as Is Microsoft Learn
DXGI_USAGE UINT Usage flags of a surface or back buffer: the DXGI_USAGE_* constants (DXGI_USAGE_RENDER_TARGET_OUTPUT …). DXGI_USAGE

Using the interfaces

The parent of an object, by identifier: here the factory an adapter belongs to.

Example

dim pAdapter as IDXGIAdapter ptr       ' from IDXGIFactory.EnumAdapters
dim pParent as IDXGIFactory ptr
if pAdapter then pAdapter->GetParent( IID_IDXGIFactory, pParent )

The adapter a Direct3D device runs on, from its IDXGIDevice:

Example

dim pDxgiDevice as IDXGIDevice ptr     ' QueryInterface of a Direct3D device with IID_IDXGIDevice
dim pAdapter as IDXGIAdapter ptr
if pDxgiDevice then pDxgiDevice->GetAdapter( pAdapter )

IDXGIFactory7 is not declared as a name; its methods are on IDXGIFactory7_:

Example

dim pF7 as IDXGIFactory7_ ptr          ' QueryInterface with IID_IDXGIFactory7
dim dwCookie as DWORD
if pF7 then pF7->RegisterAdaptersChangedEvent( CreateEventW( NULL, false, false, NULL ), dwCookie )

Microsoft Learn: DXGI, CreateDXGIFactory1, CreateDXGIFactory2

See also

Clone this wiki locally