Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I managed to get the part but it seems to be in a different format:
ComPtr<IDxcContainerReflection> reflection; DXCHECK(DxcCreateInstance(CLSID_DxcContainerReflection, __uuidof(IDxcContainerReflection), (void**)&reflection)); DXCHECK(reflection->Load(vs.Get())); UINT32 shaderIdx; DXCHECK(reflection->FindFirstPartKind(DFCC_RootSignature, &shaderIdx)); ComPtr<IDxcBlob> rootSignatureBlob; DXCHECK(reflection->GetPartContent(shaderIdx, &rootSignatureBlob)); // gets 112 bytes ComPtr<ID3D12RootSignature> rootSignature; DXCHECK(device->CreateRootSignature(0, rootSignatureBlob->GetBufferPointer(), rootSignatureBlob->GetBufferSize(), IID_PPV_ARGS(&rootSignature)));
The last line returns
The shader hasn't been changed since it was compiled with fxc. What's the correct way to do this? Couldn't find any documentation or sample, unfortunately.
I believe the API expects a signed blob container with a root signature part which is the result of fxc's direct root signature target compilation or /extractrootsignature operation (which repackages the signature in a signed DXBC container). The container reflection just returns the raw serialized root signature, not wrapped in any container. It may be valid to just pass the shader blob itself to CreateRootSignature, since that's a signed blob container with a root signature part.
Indeed, it works when you pass the compiled shader blob directly to CreateRootSignature! Same with D3D12CreateRootSignatureDeserializer for root signature reflection. Thanks!
ComPtr<ID3D12RootSignature> rootSignature; DXCHECK(device->CreateRootSignature(0, vs->GetBufferPointer(), vs->GetBufferSize(), IID_PPV_ARGS(&rootSignature))); ComPtr<ID3D12RootSignatureDeserializer> deserializer; DXCHECK(D3D12CreateRootSignatureDeserializer(vs->GetBufferPointer(), vs->GetBufferSize(), IID_PPV_ARGS(&deserializer)));
PS: I noticed that #pragma pack_matrix(row_major) doesn't seem to work anymore. Fortunately, you can use the -Zpr compile option instead.