1
$\begingroup$

Can i have a root signature with 3 root parameters all being of the UAV type? Because what I am trying to do is, add two buffers and put the output of that in a output buffer.

In the following snippet I am trying to do the afroementioned. However, I get an error at the line calling D3DX12SerializeVersionedRootSignature()

Is it because I am not allowed to have 3 uav ranges?

CD3DX12_DESCRIPTOR_RANGE1 ranges_madhu[3];
ranges_madhu[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE);
ranges_madhu[1].Init(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE);
ranges_madhu[2].Init(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE);

CD3DX12_ROOT_PARAMETER1 rootParameters_madhu[ComputeRootParametersCount_madhu]; // this is 3   (thus all 3 ranges have been initialized as UAVs)
rootParameters_madhu[ComputeRootUAVTable_in1].InitAsDescriptorTable(1, &ranges_madhu[0], D3D12_SHADER_VISIBILITY_ALL);
rootParameters_madhu[ComputeRootUAVTable_in2].InitAsDescriptorTable(1, &ranges_madhu[1], D3D12_SHADER_VISIBILITY_ALL);
rootParameters_madhu[ComputeRootUAVTable_outp1].InitAsDescriptorTable(1, &ranges_madhu[2], D3D12_SHADER_VISIBILITY_ALL);

CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC computeRootSignatureDesc_madhu;
computeRootSignatureDesc_madhu.Init_1_1(_countof(rootParameters_madhu), rootParameters_madhu, 0, nullptr);

ComPtr<ID3DBlob> signature1;
ComPtr<ID3DBlob> error1;

ThrowIfFailed(D3DX12SerializeVersionedRootSignature(&computeRootSignatureDesc_madhu, featureData_madhu.HighestVersion, &signature1, &error1));
ThrowIfFailed(m_device->CreateRootSignature(0, signature1->GetBufferPointer(), signature1->GetBufferSize(), IID_PPV_ARGS(&m_computeRootSignature1)));
NAME_D3D12_OBJECT(m_computeRootSignature1);
$\endgroup$
6
  • $\begingroup$ What is the error you get? Do you have the debug layer turned on? $\endgroup$ Apr 10, 2017 at 22:00
  • $\begingroup$ Yes, I have debug layer enabled. when this is called : ThrowIfFailed(D3DX12SerializeVersionedRootSignature(&computeRootSignatureDesc_madhu, featureData_madhu.HighestVersion, &signature1, &error1)); an exception occures, stepping through the code I see that the handle returned into the signature is invalid $\endgroup$
    – Madhu
    Apr 10, 2017 at 22:38
  • $\begingroup$ Ok. So is there any output from the debug layer about the error? If you're using Visual Studio, it would show up in the Output pane. Alternatively, is there any error message generated in the error1 blob? $\endgroup$ Apr 10, 2017 at 22:44
  • $\begingroup$ Not sure how to check the error from "error1" blob. But the return value is E_INVALIDARG- one or more arguments are invalid. $\endgroup$
    – Madhu
    Apr 10, 2017 at 22:50
  • $\begingroup$ You can print the error blob to the output pane like this: if (error1) { OutputDebugStringA((char *)error1->GetBufferPointer()); } $\endgroup$ Apr 10, 2017 at 23:04

1 Answer 1

2
$\begingroup$

You're trying to map all three UAVs to the same descriptor slot (slot 0).

ranges_madhu[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE);
ranges_madhu[1].Init(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE);
ranges_madhu[2].Init(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE);

The baseShaderRegister value (the third parameter to these calls) indicates which descriptor slot to use. You have all of them set to 0, which won't work. They need to be distinct. For example, they could be 0, 1, and 2.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.