Jump to content
  • Advertisement
Sign in to follow this  
blackfe2010

DX11 How to debug in DirectX11

This topic is 2181 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

Hi

I have wrt an game using DX11.
I want display a trangle, but only background color displayed.

And I use the InfoQueue to catch the error message
[source lang="cpp"] HRESULT hr=S_OK;
if(m_device==NULL)
EXCEPTION("Device not created")

hr=m_device->QueryInterface(__uuidof(ID3D11Debug),(LPVOID*)&m_debug);
if(FAILED(hr))
EXCEPTION("Create ID3D11Debug failed")

hr=m_debug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);
if(FAILED(hr))
EXCEPTION("Set ReportLiveDeviceObjects failed")

hr=m_device->QueryInterface(__uuidof(ID3D11InfoQueue),(LPVOID*)&m_infoQueue);
if(FAILED(hr))
EXCEPTION("Create ID3D11InfoQueue failed")

m_infoQueue->ClearStoredMessages();
m_infoQueue->ClearRetrievalFilter();
m_infoQueue->ClearStorageFilter();

D3D11_INFO_QUEUE_FILTER filter;
ZeroMemory(&filter, sizeof(D3D11_INFO_QUEUE_FILTER));
D3D11_MESSAGE_SEVERITY severity;
severity=D3D11_MESSAGE_SEVERITY_ERROR;
filter.DenyList.NumSeverities=1;
filter.DenyList.pSeverityList=&severity;
m_infoQueue->AddStorageFilterEntries(&filter);
m_infoQueue->AddRetrievalFilterEntries(&filter);[/source]


In the log file:

Create RenderTargetView: Name="unnamed", Addr=0x00FDB034, ExtRef=1, IntRef=0
Create Texture2D: Name="unnamed", Addr=0x00FDB15C, ExtRef=1, IntRef=0
Create DepthStencilState: Name="unnamed", Addr=0x00FDB334, ExtRef=1, IntRef=0
Create DepthStencilView: Name="unnamed", Addr=0x00FDB42C, ExtRef=1, IntRef=0
[/quote]
But I don't know what's the meaning of it.
Because when I create the RenderTargetView,Texture2D,DepthStencilState and DepthStencilView, ther are all return S_OK.

How can I detect the bug?

And here is an other question.

Every function in ID3D11Device interface will return the HRESULT. so I can know the function run success or failed.
But the function in ID3D11DeviceContext interface have no return value.
How can I know the result?

Share this post


Link to post
Share on other sites
Advertisement
You can debug direct3d shaders directly from Visual Studio 2012.

http://blogs.msdn.com/b/vcblog/archive/2012/09/25/directx-graphics-development-with-visual-studio-2012.aspx

Share this post


Link to post
Share on other sites
Hi, all

I found the problem. Because of i use the ID3D11DepthStencilView.

If I use the code:
[source lang="cpp"]deviceContext->OMSetRenderTargets(1, &defaultRenderTargetView, NULL);[/source]
everything is ok.

What's wrong with ID3D11DepthStencilView in my code?

[source lang="cpp"]
// Initialize the description of the depth buffer.
ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc));

// Set up the description of the depth buffer.

depthBufferDesc.Width = m_screenWidth;
depthBufferDesc.Height = m_screenHeight;
depthBufferDesc.MipLevels = 1;
depthBufferDesc.ArraySize = 1;
depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthBufferDesc.SampleDesc.Count = 1;
depthBufferDesc.SampleDesc.Quality = 0;
depthBufferDesc.Usage = D3D11_USAGE_DEFAULT;
depthBufferDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthBufferDesc.CPUAccessFlags = 0;
depthBufferDesc.MiscFlags = 0;

// Create the texture for the depth buffer using the filled out description.
hr = m_device->CreateTexture2D(&depthBufferDesc, NULL, &defaultDepthStencilBuffer);
CHECK_FAILED(hr)

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

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

depthStencilDesc.StencilEnable = true;
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;

// Create the depth stencil state.
hr = m_device->CreateDepthStencilState(&depthStencilDesc, &defaultDepthStencilState);
CHECK_FAILED(hr)

deviceContext->OMSetDepthStencilState(defaultDepthStencilState, 1);

// Initialize the depth stencil view.
ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));

// Set up the depth stencil view description.
depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
depthStencilViewDesc.Texture2D.MipSlice = 0;

// Create the depth stencil view.
hr = m_device->CreateDepthStencilView(defaultDepthStencilBuffer, &depthStencilViewDesc, &defaultDepthStencilView);
CHECK_FAILED(hr)

deviceContext->OMSetRenderTargets(1, &defaultRenderTargetView, defaultDepthStencilView);[/source]

Share this post


Link to post
Share on other sites
I don't see anything obvious, though I wonder if you really want stencil enabled. Also, as BCullis noted, provide the shader source, and, since you now want to use depth test/write other relevant info (vertices, rasterizer state, transformations, especially the projection).

And I use the InfoQueue to catch the error message...[/quote]

I haven't dabbled with the info queue much, but I think by clearing the filters and adding D3D11_MESSAGE_SEVERITY_ERROR to the DenyList you actually disabled error reporting altogether. Rather leave it as is, creating the device in debug mode is probably enough.

And: Yeah, PIX (or the graphics debugger from VS 2012) is your friend. Get familiar with it now. To get a feeling, PIX-debug a working applications (e.g. Tutorial #5 of the SDK samples is a good start, since it uses depth).

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!