# How to set root signatures specified in HLSL in my command list?

From Microsoft Docs, I can specify the root signature of my shader in HLSL. How do I use it though?

Since at the beginning of the command list, root signature is undefined. I need to use ID3D12GraphicsCommandList::SetComputeRootSignature(ID3D12RootSignature*) or ID3D12GraphicsCommandList::SetGraphicsRootSignature(ID3D12RootSignature*) set root signature, but having specified in HLSL instead of C++ code, I do not have a pointer to my root signature objects, how should it be done then?

You can provide any compiled shader blob that contains the desired root signature defined in HLSL when creating the root signature object:

Microsoft::WRL::ComPtr<ID3D12RootSignature> m_rootSignature

// Create root signature.

DX::ThrowIfFailed(

The DX::ReadData function just loads the binary blob from disk (source here). The DX::ThrowIfFailed helper is explained here.
If you are using FXC.EXE you can also build a shader with the HLSL defined root signature using the rootsig_1_0 or rootsig_1_1 profile and the resulting compiled binary object will just have the root signature in it.