1
$\begingroup$

When I use the CreateGraphicsPipelineState function in DX12, there's an error "E_INVALIDARG One or more arguments are invalid." returned by the function, but there isn't detailed information on which argument is wrong. I'm sure I opened the debug layer, here is the code:

#if defined(DEBUG) || defined(_DEBUG) 
    {
        ComPtr<ID3D12Debug> debugController;
        if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController))))
        {
            debugController->EnableDebugLayer();
        }
    }
#endif

I also opened the debug layer in the DirectX Control Panel. And it also has no detailed error information in the output window. I really can not find which argument is wrong. Here is my code:

//
// PSO for shadow map pass.
//
D3D12_GRAPHICS_PIPELINE_STATE_DESC shadowPsoDesc = basePsoDesc;
shadowPsoDesc.RasterizerState.DepthBias = 100000;
shadowPsoDesc.RasterizerState.DepthBiasClamp = 0.0f;
shadowPsoDesc.RasterizerState.SlopeScaledDepthBias = 1.0f;
shadowPsoDesc.pRootSignature = mRootSignature.Get();
shadowPsoDesc.VS =
{
    reinterpret_cast<BYTE*>(mShaders["ShadowVS"]->GetBufferPointer()),
    mShaders["ShadowVS"]->GetBufferSize()
};
shadowPsoDesc.PS =
{
    reinterpret_cast<BYTE*>(mShaders["ShadowPS"]->GetBufferPointer()),
    mShaders["ShadowPS"]->GetBufferSize()
};

// Shadow map pass does not have a render target.
shadowPsoDesc.RTVFormats[0] = DXGI_FORMAT_UNKNOWN;
shadowPsoDesc.NumRenderTargets = 0;
HRESULT hr = md3dDevice->CreateGraphicsPipelineState(&shadowPsoDesc, IID_PPV_ARGS(&mPSOs["Shadow"]));
ThrowIfFailed(hr);

basePsoDesc is used for creating test pso:

D3D12_GRAPHICS_PIPELINE_STATE_DESC basePsoDesc;
    ZeroMemory(&basePsoDesc, sizeof(D3D12_GRAPHICS_PIPELINE_STATE_DESC));
    basePsoDesc.InputLayout = { mLoadModelInputLayout.data(), (UINT)mLoadModelInputLayout.size() };
    basePsoDesc.pRootSignature = mRootSignature.Get();
    basePsoDesc.VS =
    {
        reinterpret_cast<BYTE*>(mShaders["testVS"]->GetBufferPointer()),
        mShaders["testVS"]->GetBufferSize()
    };
    basePsoDesc.PS =
    {
        reinterpret_cast<BYTE*>(mShaders["testPS"]->GetBufferPointer()),
        mShaders["testPS"]->GetBufferSize()
    };
    basePsoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
    basePsoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
    basePsoDesc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT);
    basePsoDesc.SampleMask = UINT_MAX;
    basePsoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
    basePsoDesc.NumRenderTargets = 1;
    basePsoDesc.RTVFormats[0] = mBackBufferFormat;
    basePsoDesc.SampleDesc.Count = m4xMsaaState ? 4 : 1;
    basePsoDesc.SampleDesc.Quality = m4xMsaaState ? (m4xMsaaQuality - 1) : 0;
    basePsoDesc.DSVFormat = mDepthStencilFormat;
    ThrowIfFailed(md3dDevice->CreateGraphicsPipelineState(&basePsoDesc, IID_PPV_ARGS(&mPSOs["test"]))); 

Shader input layout code:

mLoadModelInputLayout =
    {
        { "POSITION",     0, DXGI_FORMAT_R32G32B32_FLOAT,   0,   0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
        { "NORMAL",       0, DXGI_FORMAT_R32G32B32_FLOAT,   1,   0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
        { "TANGENT",      0, DXGI_FORMAT_R32G32B32_FLOAT,   2,   0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
        { "TEXCOORD",     0, DXGI_FORMAT_R32G32_FLOAT,      3,   0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
    };

And the Shadow shader code:

struct VertexIn
{
    float3 posL : POSITION;
};

struct VertexOut
{
    float4 posH : SV_POSITION;
};

VertexOut VS(VertexIn vin)
{
    VertexOut vout;
    float4 posW = mul(float4(vin.posL, 1.0f), mxWorld);
    vout.posH = mul(posW, mxViewProj);
    return vout;
}

void PS(VertexOut vout)
{

}

who can tell me why there is no detailed error information output or where the code is wrong? thanks

$\endgroup$
5
  • $\begingroup$ Just to be sure - you're looking in the Output pane in Visual Studio, with the VS debugger attached to the app? The debug layer output doesn't get printed to the console, but only to the debugger output. $\endgroup$ Oct 9 at 16:44
  • $\begingroup$ Also, one thing that might be amiss is that you have a pixel shader, but zero render targets for the shadow pass. Ordinarily in that case there would just not be a pixel shader (shadowPsoDesc.PS = { nullptr, 0 }). (Although you still could have a pixel shader if you wanted to use discard or modify the written depth, so this is not necessarily an error.) $\endgroup$ Oct 9 at 16:46
  • $\begingroup$ well, the output plane only displayed the "E_INVALIDARG" and "_com_error". It doesn't display detailed error information. I guess there may be a pointer error but I don't know which one it is. $\endgroup$
    – typpe C
    Oct 10 at 1:14
  • $\begingroup$ Oh, I just remembered that on Windows 10 there's a special extra thing you have to turn on in order to get the debug layer: docs.microsoft.com/en-us/windows/win32/direct3d11/… - see "enable the "Graphics Tools" optional feature". Have you done that? $\endgroup$ Oct 10 at 1:49
  • $\begingroup$ yes, Graphics tools are already installed on my system. $\endgroup$
    – typpe C
    Oct 10 at 2:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.