1
\$\begingroup\$

I'm trying to set up a minimal D3D11 renderer but fail to get the pixel shader stage to run. The available answers here or the ones I found through Google couldn't help me, unfortunately.

Using Visual Studio's Graphics Debugger I could verify that my vertices are set correctly and the vertex shader also runs as expected. The debug layer doesn't report any issues either. As a test I disabled depth testing, stencil testing and backface culling as shown below with no changes.

I made sure that the viewport is set correctly as well as this seems to be a common source of this problem.

At this moment I can't think of any other cause for this issue and would be happy about any advice of what else to look out for.

  • Disable depth/stencil test:

    D3D11_DEPTH_STENCIL_DESC dsstate_desc = {};
    dsstate_desc.DepthEnable             = false;
    dsstate_desc.StencilEnable           = false;
    dsstate_desc.DepthFunc               = D3D11_COMPARISON_ALWAYS;
    dsstate_desc.DepthWriteMask          = D3D11_DEPTH_WRITE_MASK_ALL;
    dsstate_desc.BackFace.StencilFailOp  = D3D11_STENCIL_OP_KEEP;
    dsstate_desc.BackFace.StencilPassOp  = D3D11_STENCIL_OP_KEEP;
    dsstate_desc.BackFace.StencilFunc    = D3D11_COMPARISON_ALWAYS;
    dsstate_desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
    dsstate_desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
    dsstate_desc.FrontFace.StencilFunc   = D3D11_COMPARISON_ALWAYS;
    d3d11device->CreateDepthStencilState(&ds_state, &this->ds_state);
    d3d11context->OMSetDepthStencilState(this->ds_state, 0);
    
  • Disable backface culling:

    D3D11_RASTERIZER_DESC rasterizer_desc = {};
    rasterizer_desc.AntialiasedLineEnable = false;
    rasterizer_desc.CullMode              = D3D11_CULL_NONE;
    rasterizer_desc.DepthBias             = 0;
    rasterizer_desc.DepthBiasClamp        = 0.0f;
    rasterizer_desc.DepthClipEnable       = false;
    rasterizer_desc.FillMode              = D3D11_FILL_SOLID;
    rasterizer_desc.FrontCounterClockwise = true;
    rasterizer_desc.MultisampleEnable     = false;
    rasterizer_desc.ScissorEnable         = false;
    rasterizer_desc.SlopeScaledDepthBias  = 0.0f;
    d3d11device->CreateRasterizerState(&rasterizer_desc, &this->rasterizer_state);
    d3d11context->RSSetState(this->rasterizer_state);
    
  • Pipeline view in debugger:

Pipeline stages

  • Vertex shader transformation:

enter image description here

  • Vertex shader:

    struct VertexIn
    {
        float3 position : POSITION;
        float3 normal   : NORMAL;
        float4 color    : COLOR;
    };
    
    struct VertexOut
    {
        float4 color    : COLOR;
        float4 position : SV_POSITION;
    };
    
    VertexOut main(VertexIn i)
    {
        VertexOut o;
        o.position = float4(i.position, 1.0f);
        o.color = i.color;
        return o;
    }
    
  • Pixel shader:

    struct FragmentIn
    {
        float4 color    : COLOR;
        float4 pos      : SV_POSITION;
    };
    
    float4 main(FragmentIn i) : SV_TARGET
    {
        return float4(1.0f, 0.0f, 0.0f, 1.0f);
    }
    
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Found the problem, for future readers: I Failed to set up a correct blend state. For some reason I forgot to set the write mask for the render target. Works perfectly after setting

blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; 
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .