<p>Recently I've switched from FXC to DXC to compile shader model 6.0. It compiles well without errors (and runs well) but I can't debug shaders because on my netbook PIX says &quot;failed to load PDB file&quot;, and on my main laptop PIX can't even start analysis and it shows the error &quot;Timing Data Error&quot;.</p>
<p><a href="https://i.sstatic.net/9HiGI.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9HiGI.jpg" alt="PIX error" /></a></p>
<p>What am I missing? The compilation generates PDB files (I can see them in the folder with the .exe) but PIX can't find them for some reason. I compile shaders like this:</p>
<pre><code>    // Create compiler and utils.
    CComPtr&lt;IDxcUtils&gt; pUtils;
    CComPtr&lt;IDxcCompiler3&gt; pCompiler;
    DxcCreateInstance(CLSID_DxcUtils, IID_PPV_ARGS(&amp;pUtils));
    DxcCreateInstance(CLSID_DxcCompiler, IID_PPV_ARGS(&amp;pCompiler));

    // Create default include handler.
    CComPtr&lt;IDxcIncludeHandler&gt; pIncludeHandler;
    pUtils-&gt;CreateDefaultIncludeHandler(&amp;pIncludeHandler);


    std::vector&lt;LPCWSTR&gt; vArgs;
    vArgs.push_back(sPathToShader.c_str());
    vArgs.push_back(L&quot;-E&quot;);
    vArgs.push_back(sShaderEntryPoint.c_str());
    vArgs.push_back(L&quot;-T&quot;);
    vArgs.push_back(sShaderModel.c_str());
    vArgs.push_back(DXC_ARG_DEBUG);
    vArgs.push_back(DXC_ARG_SKIP_OPTIMIZATIONS);


    // Open source file.  
    CComPtr&lt;IDxcBlobEncoding&gt; pSource = nullptr;
    pUtils-&gt;LoadFile(sPathToShader.c_str(), nullptr, &amp;pSource);
    DxcBuffer Source;
    Source.Ptr = pSource-&gt;GetBufferPointer();
    Source.Size = pSource-&gt;GetBufferSize();
    Source.Encoding = DXC_CP_ACP;

    // Compile it with specified arguments.
    CComPtr&lt;IDxcResult&gt; pResults;
    pCompiler-&gt;Compile(
        &amp;Source,
        vArgs.data(),
        vArgs.size(),
        pIncludeHandler,
        IID_PPV_ARGS(&amp;pResults)
    );


    // Print errors if present.
    CComPtr&lt;IDxcBlobUtf8&gt; pErrors = nullptr;
    pResults-&gt;GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&amp;pErrors), nullptr);
    if (pErrors != nullptr &amp;&amp; pErrors-&gt;GetStringLength() != 0)
    {
        OutputDebugStringA(pErrors-&gt;GetStringPointer());
    }


    // Quit if the compilation failed.
    HRESULT hrStatus;
    pResults-&gt;GetStatus(&amp;hrStatus);
    if (FAILED(hrStatus))
    {
        return;
    }


    // Save shader binary.
    CComPtr&lt;IDxcBlob&gt; pShader = nullptr;
    CComPtr&lt;IDxcBlobUtf16&gt; pShaderName = nullptr;
    pResults-&gt;GetOutput(DXC_OUT_OBJECT, IID_PPV_ARGS(&amp;pShader), &amp;pShaderName);
    if (pShader == nullptr)
    {
        return;
    }


    // Save pdb.
    CComPtr&lt;IDxcBlob&gt; pPDB = nullptr;
    CComPtr&lt;IDxcBlobUtf16&gt; pPDBName = nullptr;
    pResults-&gt;GetOutput(DXC_OUT_PDB, IID_PPV_ARGS(&amp;pPDB), &amp;pPDBName);
    {
        FILE* fp = NULL;
        _wfopen_s(&amp;fp, pPDBName-&gt;GetStringPointer(), L&quot;wb&quot;);
        fwrite(pPDB-&gt;GetBufferPointer(), pPDB-&gt;GetBufferSize(), 1, fp);
        fclose(fp);
    }
</code></pre>

CC BY-SA 4.0
2021-03-07T18:25:10.130Z
About the PDBs, check in the PIX settings for the PDB search path and make sure it includes the directory where your PDBs are. For the error message - just guessing, but is your laptop one with both discrete and integrated GPUs? You might need to select the correct GPU in PIX to run analysis on (the same one you did the capture on). Otherwise, try using the in-app feedback button to send a bug report; the PIX team at MS might be able to give more insight.
Nathan Reed
CC BY-SA 4.0
2021-03-08T17:17:19.317Z
@NathanReed yep, the PDB search path helped, thanks, I was searching for it in the 'debug' tab for some reason :) About the error, well, I will try this later (I'm not on my laptop right now). Could you post an answer so I can mark it as a solution?
Flone
<c++><hlsl><directx12>
Weird PIX behavior with DXC
Flone
# Weird PIX behavior with DXC

(Asked by: username_0 on 2021-03-07)

Recently I've switched from FXC to DXC to compile shader model 6.0. It compiles well without errors (and runs well) but I can't debug shaders because on my netbook PIX says "failed to load PDB file", and on my main laptop PIX can't even start analysis and it shows the error "Timing Data Error".

[![PIX error](https://i.sstatic.net/9HiGI.jpg)](https://i.sstatic.net/9HiGI.jpg)

What am I missing? The compilation generates PDB files (I can see them in the folder with the .exe) but PIX can't find them for some reason. I compile shaders like this:

```
    // Create compiler and utils.
    CComPtr<IDxcUtils> pUtils;
    CComPtr<IDxcCompiler3> pCompiler;
    DxcCreateInstance(CLSID_DxcUtils, IID_PPV_ARGS(&pUtils));
    DxcCreateInstance(CLSID_DxcCompiler, IID_PPV_ARGS(&pCompiler));

    // Create default include handler.
    CComPtr<IDxcIncludeHandler> pIncludeHandler;
    pUtils->CreateDefaultIncludeHandler(&pIncludeHandler);

    std::vector<LPCWSTR> vArgs;
    vArgs.push_back(sPathToShader.c_str());
    vArgs.push_back(L"-E");
    vArgs.push_back(sShaderEntryPoint.c_str());
    vArgs.push_back(L"-T");
    vArgs.push_back(sShaderModel.c_str());
    vArgs.push_back(DXC_ARG_DEBUG);
    vArgs.push_back(DXC_ARG_SKIP_OPTIMIZATIONS);

    // Open source file.  
    CComPtr<IDxcBlobEncoding> pSource = nullptr;
    pUtils->LoadFile(sPathToShader.c_str(), nullptr, &pSource);
    DxcBuffer Source;
    Source.Ptr = pSource->GetBufferPointer();
    Source.Size = pSource->GetBufferSize();
    Source.Encoding = DXC_CP_ACP;

    // Compile it with specified arguments.
    CComPtr<IDxcResult> pResults;
    pCompiler->Compile(
        &Source,
        vArgs.data(),
        vArgs.size(),
        pIncludeHandler,
        IID_PPV_ARGS(&pResults)
    );

    // Print errors if present.
    CComPtr<IDxcBlobUtf8> pErrors = nullptr;
    pResults->GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&pErrors), nullptr);
    if (pErrors != nullptr && pErrors->GetStringLength() != 0)
    {
        OutputDebugStringA(pErrors->GetStringPointer());
    }

    // Quit if the compilation failed.
    HRESULT hrStatus;
    pResults->GetStatus(&hrStatus);
    if (FAILED(hrStatus))
    {
        return;
    }

    // Save shader binary.
    CComPtr<IDxcBlob> pShader = nullptr;
    CComPtr<IDxcBlobUtf16> pShaderName = nullptr;
    pResults->GetOutput(DXC_OUT_OBJECT, IID_PPV_ARGS(&pShader), &pShaderName);
    if (pShader == nullptr)
    {
        return;
    }

    // Save pdb.
    CComPtr<IDxcBlob> pPDB = nullptr;
    CComPtr<IDxcBlobUtf16> pPDBName = nullptr;
    pResults->GetOutput(DXC_OUT_PDB, IID_PPV_ARGS(&pPDB), &pPDBName);
    {
        FILE* fp = NULL;
        _wfopen_s(&fp, pPDBName->GetStringPointer(), L"wb");
        fwrite(pPDB->GetBufferPointer(), pPDB->GetBufferSize(), 1, fp);
        fclose(fp);
    }

```

**Tags:** c++, hlsl, directx12

> **Comments:**
> **username_1**: About the PDBs, check in the PIX settings for the PDB search path and make sure it includes the directory where your PDBs are. For the error message - just guessing, but is your laptop one with both discrete and integrated GPUs? You might need to select the correct GPU in PIX to run analysis on (the same one you did the capture on). Otherwise, try using the in-app feedback button to send a bug report; the PIX team at MS might be able to give more insight.  
> **username_0**: @username_1 yep, the PDB search path helped, thanks, I was searching for it in the 'debug' tab for some reason :) About the error, well, I will try this later (I'm not on my laptop right now). Could you post an answer so I can mark it as a solution?  

---

## 0 answers

