[DX11] Full Screen Quad

Started by
5 comments, last by simotix 13 years, 4 months ago
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, 1Position1 = -1,  1, 1Position2 =  1, -1, 1Position3 =  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 codeSetInputLayoutToRender(..)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);}


Advertisement
Your indices seems to be wrong..

should be 0,1,2 and 1,3,2 for clock-wise orientation...
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?
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.
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 ...
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.
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

This topic is closed to new replies.

Advertisement