dx11 drawIndexed cost overhead time

Started by
5 comments, last by Hodgman 7 years, 8 months ago

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

The biggest difference I think is my engine open a c++ console for printing message.

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?

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.

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.

This topic is closed to new replies.

Advertisement