D3D12SerializeRootSignature function (d3d12.h)

Serializes a root signature version 1.0 that can be passed to ID3D12Device::CreateRootSignature.

Syntax

HRESULT D3D12SerializeRootSignature(
  [in]            const D3D12_ROOT_SIGNATURE_DESC *pRootSignature,
  [in]            D3D_ROOT_SIGNATURE_VERSION      Version,
  [out]           ID3DBlob                        **ppBlob,
  [out, optional] ID3DBlob                        **ppErrorBlob
);

Parameters

[in] pRootSignature

Type: const D3D12_ROOT_SIGNATURE_DESC*

The description of the root signature, as a pointer to a D3D12_ROOT_SIGNATURE_DESC structure.

[in] Version

Type: D3D_ROOT_SIGNATURE_VERSION

A D3D_ROOT_SIGNATURE_VERSION-typed value that specifies the version of root signature.

[out] ppBlob

Type: ID3DBlob**

A pointer to a memory block that receives a pointer to the ID3DBlob interface that you can use to access the serialized root signature.

[out, optional] ppErrorBlob

Type: ID3DBlob**

A pointer to a memory block that receives a pointer to the ID3DBlob interface that you can use to access serializer error messages, or NULL if there are no errors.

Return value

Type: HRESULT

Returns S_OK if successful; otherwise, returns one of the Direct3D 12 Return Codes.

Remarks

This function has been superceded by D3D12SerializeVersionedRootSignature as of the Windows 10 Anniversary Update (14393).

If an application procedurally generates a D3D12_ROOT_SIGNATURE_DESC data structure, it must pass a pointer to this D3D12_ROOT_SIGNATURE_DESC in a call to D3D12SerializeRootSignature to make the serialized form. The application then passes the serialized form to which ppBlob points into ID3D12Device::CreateRootSignature.

If a shader has been authored with a root signature in it, the compiled shader will contain a serialized root signature in it already. In this case, pass the compiled shader blob to ID3D12Device::CreateRootSignature to obtain the runtime root signature object.

The function signature PFN_D3D12_SERIALIZE_ROOT_SIGNATURE is provided as a typedef, so that you can use dynamic linking techniques (GetProcAddress) instead of statically linking.

Examples

Create an empty root signature.

CD3DX12_ROOT_SIGNATURE_DESC rootSignatureDesc;
rootSignatureDesc.Init(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);

ComPtr<ID3DBlob> signature;
ComPtr<ID3DBlob> error;
ThrowIfFailed(D3D12SerializeRootSignature(&rootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error));
ThrowIfFailed(m_device->CreateRootSignature(0, signature->GetBufferPointer(), signature->GetBufferSize(), IID_PPV_ARGS(&m_rootSignature)));

Refer to the Example Code in the D3D12 Reference.

Requirements

Requirement Value
Target Platform Windows
Header d3d12.h
Library D3D12.lib
DLL D3D12.dll

See also

Core Functions

Creating a Root Signature