IddCxSwapChainSetDevice2, fonction (iddcx.h)

Important

Certaines informations concernent un produit de préversion qui peut être sensiblement modifié avant sa publication commerciale. Microsoft n’offre aucune garantie, expresse ou implicite, en ce qui concerne les informations fournies ici.

Fonction de rappel du système d’exploitation que le pilote appelle dans sa routine SetSwapChain pour configurer la chaîne d’échange avec un appareil DXGI particulier.

Syntaxe

HRESULT IddCxSwapChainSetDevice2(
  [in] IDDCX_SWAPCHAIN                    SwapChainObject,
  [in] const IDARG_IN_SWAPCHAINSETDEVICE2 *pInArgs
);

Paramètres

[in] SwapChainObject

Objet IDDCX_SWAPCHAIN précédemment passé au pilote dans un appel à EVT_IDD_CX_MONITOR_ASSIGN_SWAPCHAIN.

[in] pInArgs

Pointeur vers une structure IDARG_IN_SWAPCHAINSETDEVICE2 qui contient les arguments d’entrée de la fonction.

Valeur retournée

La méthode retourne S_OK si l’opération réussit, sinon un code d’erreur HRESULT approprié.

Remarques

Un pilote peut appeler IddCxSwapChainSetDevice2 pour associer un objet d’appareil utilisé pour traiter les objets surface de la chaîne d’échange. Le pilote doit définir le champ IDARG_IN_SWAPCHAINSETDEVICE2 ::Type et le pointeur correspondant dans l’union IDARG_IN_SWAPCHAINSETDEVICE2 ::D evice .

Note

Un pilote est chargé de vérifier l’adaptateur spécifié par IDARG_IN_SETSWAPCHAIN. RenderAdapterLuid dans un appel au rappel EVT_IDD_CX_MONITOR_ASSIGN_SWAPCHAIN du pilote prend en charge D3D12 et, dans le cas où D3D12 n’est pas disponible, D3D11 peut toujours être utilisé. Les pilotes peuvent rechercher la prise en charge D3D12 de plusieurs façons, dont l’un consiste à obtenir un objet IDXGIAdapter à l’aide d’EnumAdapterByLuid , puis essayer d’appeler D3D12CreateDevice.

    ComPtr<IDXGIFactory4> pFactory;
    ComPtr<IDXGIAdapter3> pRenderAdapter;
    ComPtr<ID3D12Device> pD3d12Device;

    HRESULT Result = CreateDXGIFactory2(0, IID_PPV_ARGS(&pFactory));
    if (!FAILED(Result))
    {
        // Assume RenderAdapterLuid is obtained from IDARG_IN_SETSWAPCHAIN and passed to this routine
        LUID renderAdapterLuid = /* obtain from IDARG_IN_SETSWAPCHAIN */;
        
        Result = pFactory->EnumAdapterByLuid(renderAdapterLuid, IID_PPV_ARGS(&pRenderAdapter));
        if (!FAILED(Result))
        {
            Result = D3D12CreateDevice(pRenderAdapter.Get(), D3D_FEATURE_LEVEL_12_0, IID_PPV_ARGS(&pD3d12Device));

            if (FAILED(Result))
            {
                // No D3D12, fall back to using D3D11
            }
            else
            {
                // D3D12 can be used with this swapchain
            }
        }
    }

Note

Un pilote IddCx 1.11 peut toujours appeler IddCxSwapChainSetDevice pour associer un objet IDXGIDevice à une chaîne d’échange.

Exigences

Prérequis Valeur
Client minimum requis Windows 11, 26H1 (IddCx 1.11)
plateforme cible Fenêtres
En-tête iddcx.h

Voir également

IDDCX_SWAPCHAIN_DEVICE_TYPE

IDARG_IN_SWAPCHAINSETDEVICE2

Versions iddCx