Expression2 on Sat, 23 Apr 2016 06:19:49

The code was written in C++/CX with Direct3D 11. Run on Windows build 14136.1000.

Both ID3D11DeviceContext::ClearRenderTargetView and ID3D11DeviceContext::DrawIndexed did not report errors, but the view did not have anything drawn.

According to the Visual Studio Graphics Analyzer, the pixel shader stage was not run, saying no output.

In code, ID3D11DeviceContext::OMSetRenderTargets was already called, as seen in event 49.

Frame setup events
32 ID3D11DeviceContext->UpdateSubresource(obj:5,0,nullptr,addr,64,64)
33 ID3D11DeviceContext->UpdateSubresource(obj:6,0,nullptr,addr,64,64)
34 IDXGISwapChain3->GetCurrentBackBufferIndex()=0
35 IDXGISwapChain->GetBuffer(0,{0x51218251, 0x1e33, 0x4617, 0x9c, 0xcb, 0x4d, 0x3a, 0x43, 0x67, 0xe7, 0xbb},obj:17)=S_OK
36 ID3D11Texture2D->GetDesc({Width=2048,Height=1536,MipLevels=1,ArraySize=1,Format=DXGI_FORMAT_B8G8R8A8_UNORM,{Count=1,Quality=0},Usage=D3D11_USAGE_DEFAULT,BindFlags=D3D11_BIND_RENDER_TARGET,CPUAccessFlags=0,MiscFlags=0})
37 ID3D11Device3->CreateRenderTargetView1(obj:17,{Format=DXGI_FORMAT_B8G8R8A8_UNORM,ViewDimension=D3D11_RTV_DIMENSION_TEXTURE2D,{MipSlice=0,PlaneSlice=0}},obj:18)=S_OK
38 ID3D11DeviceContext->ClearRenderTargetView(obj:18,{0,0.5,1,1})
39 ID3D11DeviceContext->ClearDepthStencilView(obj:16,D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0)
40 ID3D11DeviceContext->IASetInputLayout(obj:13)
41 ID3D11DeviceContext->IASetVertexBuffers(0,1,{obj:9},{12},{0})
42 ID3D11DeviceContext->IASetIndexBuffer(obj:11,R32_UINT,0)
43 ID3D11DeviceContext->IASetPrimitiveTopology(TRIANGLELIST)
44 ID3D11DeviceContext->VSSetShader(obj:12,nullptr,0)
45 ID3D11DeviceContext->VSSetConstantBuffers(0,3,{obj:4,obj:5,obj:6})
46 ID3D11DeviceContext->PSSetShader(obj:14,nullptr,0)
47 ID3D11DeviceContext->OMSetDepthStencilState(obj:8,0)
48 ID3D11DeviceContext->RSSetState(obj:10)
49 ID3D11DeviceContext->OMSetRenderTargets(1,{obj:18},obj:16)
50 ID3D11Texture2D->GetDesc({Width=2048,Height=1536,MipLevels=1,ArraySize=1,Format=DXGI_FORMAT_B8G8R8A8_UNORM,{Count=1,Quality=0},Usage=D3D11_USAGE_DEFAULT,BindFlags=D3D11_BIND_RENDER_TARGET,CPUAccessFlags=0,MiscFlags=0})
51 ID3D11RenderTargetView->GetDesc({Format=DXGI_FORMAT_B8G8R8A8_UNORM,ViewDimension=D3D11_RTV_DIMENSION_TEXTURE2D,{MipSlice=0}})
52 ID3D11DeviceContext->RSSetViewports(1,{{TopLeftX=0,TopLeftY=0,Width=2048,Height=1536,MinDepth=0,MaxDepth=1}})
53 ID3D11DeviceContext->DrawIndexed(36,0,0)
56 IDXGISwapChain->Present(1,0)=S_OK

What is missing?




Dmitry Andreev on Sat, 23 Apr 2016 06:40:57

It seems that vertex shader doesn't provide any output to rasterizer.

few ideas:

1) incorrect input to vertex shader (misalignment with constants, for example)  - try to trace Vertex Shader (press green triangle, and debug) - at least one of your vertex have to be translated via MVP matrix and produce correct SV_TARGET pixel. Don't forget to compile your hlsl code with debug info.

2) As you use depth stencil, check z and w values of SV_TARGET vertex shader output, it have to be correctly calculated in range of depth stencil settings.

3) check scissor rects

5) check vertex order of triangles, it have to be front faced, or try use both sides rasterization.

Expression2 on Sat, 23 Apr 2016 06:52:40

  1. Vertex shader input is correct. You can see it in the vertex shader stage preview that the cube has been rotated.
  2. The vertex shader output has one parameter defined with the semantic SV_POSITION, nothing else. The value returned made sense to me.
  3. Scissor rects are not used.
  4. Back-face and front-face culling has been disabled.

skinnybit on Thu, 28 Apr 2016 19:03:26

Did you find the answer to this?  I am having the same issue and my vertex data is correct as well.  I have depth disabled as this is just 2D space.

Edit: I found the problem, I did have a constant misaligned in the vertex shader, which I had overlooked.

Expression2 on Tue, 03 May 2016 11:22:17

I have now rewritten the code, but it still isn't showing anything.


cbuffer CBPerResize : register(b0)
	matrix projectionMatrix;

cbuffer CBPerFrame : register(b1)
	matrix viewMatrix;


#include "Structures.hlsli"

cbuffer CubeCBPerPrimitive : register(b2)
	matrix worldMatrix;

struct CubeVertexShaderInput
	float3 position : POSITION;

typedef struct CubeV2P
	float4 position : SV_POSITION;
} CubeVertexShaderOutput, CubePixelShaderInput;

struct CubePixelShaderOutput
	float4 color : SV_TARGET;


#include "CubeStructures.hlsli"

CubeVertexShaderOutput main(CubeVertexShaderInput input)
	matrix wvp = mul(viewMatrix, worldMatrix);
	wvp = mul(projectionMatrix, wvp);
	CubeVertexShaderOutput output;
	output.position = float4(input.position, 1);
	output.position = mul(wvp, output.position);
	return output;
#include "CubeStructures.hlsli"

CubePixelShaderOutput main(CubePixelShaderInput input)
	CubePixelShaderOutput output;
	output.color = float4(1, 1, 1, 1);
	return output;

Expression2 on Wed, 04 May 2016 11:14:49

Turns out I have accidently a wrong value as the third parameter in the call to ID3D11DeviceContext::ClearDepthStencilView. The clear depth was supposed to be 1 instead of 0.

IH8N8 on Tue, 10 Jan 2017 08:29:58

This helped me figure out my ( unrelated ) bug.

I was calling ID3D11DeviceContext::ClearDepthStencilView with the backbuffer as my argument, instead of my framebuffer's depth buffer.

It helps to set the WKPDID_D3DDebugObjectName before looking through the graphic analyzer's timeline.