Jump to content

View more

Image of the Day

#indiedev  #indiegame #screenshotsaturday https://t.co/IwVbswGrhe
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

How to debug in DirectX11

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 blackfe2010   Members   


Posted 29 November 2012 - 08:57 AM


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

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?

#2 BCullis   Members   


Posted 29 November 2012 - 12:37 PM


The PIX tool is beyond useful in debugging directX and shader code.

Also, you don't show us your shader code for the pixel and vertex shaders, which are also essential to draw your triangle. What do those look like?

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

#3 Vexal   Members   


Posted 30 November 2012 - 06:05 PM

You can debug direct3d shaders directly from Visual Studio 2012.


#4 blackfe2010   Members   


Posted 01 December 2012 - 12:05 AM

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]

#5 unbird   Members   


Posted 01 December 2012 - 04:28 AM

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...

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).

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.