0

I've got an unusaul problem - when I am trying to create Compute PSO, function fails with E_INVALIDARGS. It is probably due to no CachedPso available, though I saw on MSDN that Graphics PSO is created without cached data.

So here is the code itself. Both Serializing Root Signature and RS creation report S_OK, but CreateComputePS fails. Shader is compiled by Visual Studio (shader version 5.1), then it is ReadFileToBlob'ed.

COMPTR<ID3DBlob> pSRSignatre = nullptr;
COMPTR<ID3DBlob> pError = nullptr;
D3D12_ROOT_SIGNATURE_DESC RSDesc;
ZeroMemory(&RSDesc, sizeof(D3D12_ROOT_SIGNATURE_DESC)); 
RSDesc.NumParameters = 1;
RSDesc.NumStaticSamplers = 0;
RSDesc.pParameters = &rootParam;
RSDesc.pStaticSamplers = nullptr;
RSDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE;

result = D3D12SerializeRootSignature(
    &RSDesc, 
    D3D_ROOT_SIGNATURE_VERSION_1, 
    pSRSignatre.GetAddressOf(), 
    pError.GetAddressOf()
    );
    #ifdef DEBUG
Report(result, L"Serializaing root signature");
    #endif

COMPTR<ID3D12RootSignature> pRootSign = nullptr;
result = sm_pDevice->CreateRootSignature(
    0, 
    pSRSignatre->GetBufferPointer(), 
    pSRSignatre->GetBufferSize(), 
    IID_PPV_ARGS(pRootSign.GetAddressOf())
    );
    #ifdef DEBUG
Report(result, L"Root signature");
    #endif


COMPTR<ID3D12PipelineState> pState = nullptr;

D3D12_COMPUTE_PIPELINE_STATE_DESC CPSDesc;
ZeroMemory(&CPSDesc, sizeof(D3D12_COMPUTE_PIPELINE_STATE_DESC));
CPSDesc.CS = m_Shader;
CPSDesc.NodeMask = 0;
CPSDesc.pRootSignature = pRootSign.Get();
CPSDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;

result = sm_pDevice->CreateComputePipelineState(&CPSDesc, IID_PPV_ARGS(pState.GetAddressOf()));
    #ifdef DEBUG
Report(result, L"Compute PSO");
    #endif

UPD: There is an error in the output log (no exception actually thrown, just a text message, hard to notice) which appears right after call to CreateCompPS: Exception thrown at 0x774CD928 in DirectComputeInteropLib.exe: Microsoft C++ exception: _com_error at memory location 0x001DEFF4.

Ilia
  • 331
  • 5
  • 12
  • Did you enable the debug layer? Did it report anything? The debug layer is the first place to get more information on "invalid args" errors. Also, a function that returns an HRESULT can fail at any time so you must always check the return result for failure. Only checking for failures in a debug build is not robust. – Chuck Walbourn Mar 03 '16 at 23:45
  • How stupid of me. I forgot to create DebugInterface. D3D12 ERROR: ID3D12Device::CreateComputePipelineState: Root Signature doesn't match Compute Shader: Shader UAV descriptor range (RegisterSpace=0, NumDescriptors=1, BaseShaderRegister=0) is not fully bound in root signature [ STATE_CREATION ERROR #882: CREATECOMPUTEPIPELINESTATE_CS_ROOT_SIGNATURE_MISMATCH] – Ilia Mar 03 '16 at 23:54
  • You can skip the Serialize and use the root signature that is embedded in the shader blob directly into the call to `CreateRootSignature`, it would have save you from the mismatch. – galop1n Mar 04 '16 at 00:24
  • @galop1n, could you please explain, how can I use shader blob directly? At CreateRootSignature should I just use shader pointer and buffer size instead of the buffer output from serialization? – Ilia Mar 04 '16 at 06:57
  • yes, the shader blob is compatible with createrootsignature if it embeds one. if you build the shader with fxc from visual studio (or d3dcompile api), by default it will have one unless you set the option to strip it. there is also options to provide the signature to fxc for reuse between shaders and to define the root signature in the hlsl source. – galop1n Mar 04 '16 at 22:21

0 Answers0