Jump to content
  • Advertisement
Sign in to follow this  
poigwym

DX11 dx11 drawIndexed cost overhead time

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

The scene is a box draw with  a simple shader.

In a demo the drawIndexed cost 0.000160 ms, but in my engine cost 0.1 ms. 

They use same mesh, same input layout, same shader, same renderstate .

Why drawIndexed cost  so much?  I 'm not sure the if drawIndexed return immediate or not ?

I 'm suspect that the quicker one use a defered context and the slower one use async context, they are in c++ project.

 

However they use the same code to create context :

 

UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)  
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
 
D3D_FEATURE_LEVEL featureLevel;
HRESULT hr = D3D11CreateDevice(
0,                 // default adapter
_driverType,
0,                 // no software device
createDeviceFlags,
0, 0,              // default feature level array
D3D11_SDK_VERSION,
&_device,
&featureLevel,
&_context);
 
 
 
Have you ever meet this situation ? one draw call cost a great num of time.
Would wrong state will cause drawIndexed slower?
Edited by poigwym

Share this post


Link to post
Share on other sites
Advertisement
Yes, all D3D drawing functions are async, in that they just push commands into a queue, and the GPU consumes that queue at a (much) later point in the future.

When you run your game with D3D11_CREATE_DEVICE_DEBUG, do any warnings or errors get printed to the visual studio Output window?
BTW, instead of using an #ifdef for this, I find that it's very useful to allow a command line argument to determine whether this flag will be used, so that it's possible to enable D3D debugging in a release build when required.
 
To make sure that you're not generating any warnings or errors, run this code after you create the device, which tells Visual Studio to trigger a breakpoint when any D3D warnings/errors occur:
ID3D11InfoQueue* m_debugInfoQueue = 0;
m_device->QueryInterface(IID_ID3D11InfoQueue, (void**)&m_debugInfoQueue);
if (m_debugInfoQueue)
{
	m_debugInfoQueue->SetBreakOnSeverity( D3D11_MESSAGE_SEVERITY_CORRUPTION, TRUE );
	m_debugInfoQueue->SetBreakOnSeverity( D3D11_MESSAGE_SEVERITY_ERROR, TRUE );
	m_debugInfoQueue->SetBreakOnSeverity( D3D11_MESSAGE_SEVERITY_WARNING, TRUE );
}
Lastly, are you testing a debug build or a release build? :) Edited by Hodgman

Share this post


Link to post
Share on other sites
 Lastly, are you testing a debug build or a release build? :)

 

I  have not make any product , so all my program are DEBUG version.

How to paste code like yours ? and how to make this thing -> :) ?

 

I shut down all warnings.. I run you code and crash.

Edited by poigwym

Share this post


Link to post
Share on other sites

I  have not make any product , so all my program are DEBUG version.

Debug builds will always be extremely slow - never use them for testing performance.
Specifying the D3D11_CREATE_DEVICE_DEBUG flag when creating a D3D device will ruin performance too.

How to paste code like yours ?

[code]blah[/code]

I run you code and crash.

Where and what kind?

Share this post


Link to post
Share on other sites

 

I  have not make any product , so all my program are DEBUG version.

Debug builds will always be extremely slow - never use them for testing performance.
Specifying the D3D11_CREATE_DEVICE_DEBUG flag when creating a D3D device will ruin performance too.


 

 

You are right !! I shut down the D3D11_CREATE_DEVICE_DEBUG  and can easily draw thousands of boxes over 100 + fps.

But if I switch to RELEASE version, how can I debug ?  Those debug info will be dumped.  I 'm coding on visual stdio 2013.

 

 

Share this post


Link to post
Share on other sites

You should use visual studio's debug builds when you want to use breakpoints to step through your code line by line, and otherwise use release.

You should use the D3D11_CREATE_DEVICE_DEBUG flag to check for errors in your usage of the D3D API, and otherwise disable that flag.

i.e. switch back and forth between these 4 different modes depending on your current task.

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!