PrimitiveBatch EXECUTION WARNING #359: DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL

Feb 14, 2013 at 10:55 PM
While using DirectxTK I stumbled upon the problem with PrimitiveBatch class. After series of Begin/DrawIndexed/End class I start to get following warning in the VS output window:

D3D11: WARNING: ID3D11DeviceContext::DrawIndexed: Index buffer has not enough space! [ EXECUTION WARNING #359: DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL ]

After debugging I found that the warning appears after the

mDeviceContext->DrawIndexed((UINT)(mCurrentIndex - mBaseIndex), (UINT)mBaseIndex, (UINT)mBaseVertex);

call inside PrimitiveBatch.cpp line 267.

Here's the stats of the batch class
mMaxIndices               6144
mMaxVertices              2048
Next to last call (still no warnings)
mCurrentIndex             4920
mCurrentVertex            1232
mBaseIndex      4914
mBaseVertex     1228
Last call before the warning (after executing this call warning appears)
mCurrentIndex             4932
mCurrentVertex            1240
mBaseIndex      4920
mBaseVertex     1232
As you can see I'm not at the max bounds, but warning appears. I've tried to make PrimitiveBatch index capacity (parameter to the constructor) less than default, however I just get warning on earlier calls.
Coordinator
Feb 15, 2013 at 5:00 PM
Hi,

Would it be possible to share a (hopefully simplified as far as possible) repro app that shows this error?

I'm not seeing how this could be possible from reviewing the PrimitiveBatch code and looking at the parameter values you show here, so I think I will need to live debug a test app to understand what is happening.

Thanks!
Coordinator
Feb 18, 2013 at 11:48 PM
Thanks for the repro app.

I think this is a bug in the SDK layers validation in older versions of Windows. I can repro the behavior you describe (even with a much simpler test app) on Server 2K8 R2, but not running on Windows 8 or Windows Phone.
Feb 19, 2013 at 6:08 AM
Windows7 is not really old, hehe. Is there any way to suppress this warning? Because it makes output window unusable for debugging.
Coordinator
Feb 19, 2013 at 7:50 AM
Windows 7 is 4 years old now, so that's 4 whole years of bugfixes that you are missing out on :-)

It's possible that the Platform Update for Windows 7 might include this fix.

If not, I think you can use the ID3D11Debug interface to filter out selected warnings, but I've never tried this myself so don't have any example code to share.
Feb 19, 2013 at 7:19 PM
Apparently Chuck Walbourn has excellent post about using debug interface Direct3D SDK Debug Layer Tricks

One just need to replace warnings array to this:
D3D11_MESSAGE_ID hide [] =
{
    D3D11_MESSAGE_ID_DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL
};
Problem solved, thanks!