Jump to content
  • Advertisement
Sign in to follow this  
simotix

DX11 [DX11] Full Screen Quad

This topic is 2750 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am attempting to draw a full screen quad in DirectX11 but nothing seems to be rendering. I have disabled the DepthEnable in the DepthStencilState (if I did not, then PIX would tell me that "This pixel was eliminated because: It failed the depth test.".

I will set up the vertex locations with the following


Position0 = -1, -1, 1
Position1 = -1, 1, 1
Position2 = 1, -1, 1
Position3 = 1, 1, 1

I will create the indices this way

index[0] = 0; index[1] = 1; index[2] = 2;
index[3] = 0; index[4] = 2; index[5] = 3;

When I take a look in PIX, and take a look at the Details -> Mesh panel for DrawIndexed I will see the correct values (well, the ones I posted above there. For example, VTX/IDX 0 will be (-1, -1, 1, 1). What I do not see for some strange reason is the DrawIndexed call vertex shader debugging, UNLESS I click on a specific part of the Render, even though all I see is the cleared render target color. For example, if I try to debug the pixel (161, 161) I will see the DrawIndexed primitive event, however, there will be a message telling me that "This pixel was eliminated because: It failed the depth test.". The interesting part to that, is I disable the depth test in the depth stencil state the gets set.

The shader code is simple, I just take the input and send it back out. When I go to render, it is very basic, the steps are like this.


ClearRenderTargetView(...)
ClearDepthStencilView(view, D3D11_CLEAR_DEPTH, 1.0f, 0)

SetVSShader()
SetPSShader()

// FullScreenQuad rendering code
SetInputLayoutToRender(..)
SetVertexBuffers(..)
SetIndexBuffer(...)
DrawIndexedPrimitive(6, 0, 0)

SwapChain->Present(..)


Does anyone know what could be going on here?

Depth stencil state code

D3D11_DEPTH_STENCIL_DESC depthStencilDesc;

// Initialize the description of the stencil state.
ZeroMemory(&depthStencilDesc, sizeof(depthStencilDesc));

// Set up the description of the stencil state.
depthStencilDesc.DepthEnable = false;
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;

depthStencilDesc.StencilEnable = false;
depthStencilDesc.StencilReadMask = 0xFF;
depthStencilDesc.StencilWriteMask = 0xFF;

// Stencil operations if pixel is front-facing.
depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;

// Stencil operations if pixel is back-facing.
depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;

hr = m_pD3D11Device->CreateDepthStencilState(&depthStencilDesc, &m_depthStencilState);



Shader code

struct VertexShaderInput
{
float4 Position : POSITION;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
};

VertexShaderOutput VS(VertexShaderInput input)
{
VertexShaderOutput output;
output.Position = input.Position;
return output;
}

float4 PS(VertexShaderOutput input) : SV_Target
{
return float4(0.0f, 0.0f, 0.0f, 1.0f);
}



Share this post


Link to post
Share on other sites
Advertisement
Unfortunately it seems as if it may be something more than that. I tried changing my indices to that and I still get the same result.

I tried to look on msdn but I could not find anything I was doing wrong to get "This pixel was eliminated because: It failed the depth test.". Has anyone experienced this before?

Share this post


Link to post
Share on other sites
If you view the device details in PIX and check under Output Merger you can see the depth stencil state. Double-check there so there's nothing strange going on. Also click on your Draw call and check the Mesh tab, to see if there is actually any geometry in the viewport.

Share this post


Link to post
Share on other sites
When I have my indices set to


index[0] = 0; index[1] = 1; index[2] = 2;
index[3] = 0; index[4] = 2; index[5] = 3;

Which is wrong, I will see a broken rectangle in the Mesh window, when I set my indicies to the following, I will see nothing in my mesh window.

m_pIndices[0] = 1; m_pIndices[1] = 3; m_pIndices[2] = 2;
m_pIndices[3] = 1; m_pIndices[4] = 0; m_pIndices[5] = 2;

For direct comparison, I debug pixel 161.

Where is the "Output Merger" window in PIX? I have never used it before ...

Share this post


Link to post
Share on other sites
View details for your device context, just like you view a shader or texture. If you view your mesh or the rendered image, then object addresses in the Frame list should appear blue. Double-click them to view details for them. So if you double-click the device context used in the draw you get many new tabs for it, and one of them is the Output Merger tab.

Share this post


Link to post
Share on other sites
Ah, that helped out an incredible amount, I had no idea I could access the information like that.

It turns out that I was creating the state with DepthEnable = false, but never actually setting it to the device.

Everything is working now, for reference to anyone that reads this thread, the complete indices are the following

m_pIndices[0] = 1; m_pIndices[1] = 3; m_pIndices[2] = 2;
m_pIndices[3] = 2; m_pIndices[4] = 0; m_pIndices[5] = 1;

Thank you for the help

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!