Jump to content
  • Advertisement
Sign in to follow this  
eppo

DrawIndexed : StartIndexLocation / IASetVertexBuffers : Offset

This topic is 2019 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,

 

My renderer has this issue where I get an DEVICE_DRAW_INDEX_BUFFER_TOO_SMALL warning when using DrawIndexed(Instanced)().

 

I use 16 bit index buffers that refer to max 2^16 vertices chunks in a vertex buffer. Whenever I pass a BaseVertexLocation > 0 to DrawIndexed(), this warning is output. However, if I set StartIndexLocation to zero and instead pass an index buffer offset to IASetIndexBuffer(), the warning disappears. For both cases the rendered scene looks fine.

 

Any ideas what could be causing this?

 

Share this post


Link to post
Share on other sites
Advertisement
As far as I know, StartIndexLocation and Index Buffer Offset is almost the same thing. The difference is that the offset is in bytes so you have to take the index size (16 bit vs 32 bit) into account. They both accomplish the same thing, ie. defining where to start reading the indices. Both can be used in the same time or just one of them. Typically I define the location of the indices only with the byte offset.

The BaseVertexLocation however is another kind of offset. The MSDN says that "BaseVertexLocation is a value added to each index before reading a vertex from the vertex buffer." So this offset is changing the index which is used to access the vertex buffer.

The error message you get is related to the situation where your drawing call is "out of bounds" ie. trying to read indices outside of the index buffer.

Changing just BaseVertexLocation shouldn't give this error since it doesn't affect the starting point of reading or the amount of reading from the index buffer. However, messing with all the three values (BaseVertexLocation, StartIndexLocation, Index Buffer Offset) are a good source of errors and incorrect output.

You should look into the the program logic again and verify that you are reading the index buffer from desired location with the amount of indices that resides inside the buffer.

Enable Direct3d debugging and enable the break points so that you can halt the program at the point which creates the error.

Cheers! Edited by kauna

Share this post


Link to post
Share on other sites

You're right. I was led off course by the fact that using an offset in IASetIndexBuffer() doesn't generate an error, making me think it was something API related. It turns out there was a bug in my offset calculations.

 

I prefer to pass the offsets to DrawIndexed() as it involves less state changes when using the same index buffer.

Share this post


Link to post
Share on other sites

[quote name='eppo' timestamp='1357130387' post='5016666']
I prefer to pass the offsets to DrawIndexed() as it involves less state changes when using the same index buffer.
[/quote]

 

Putting it that way, I guess you are right. 

 

Cheers!

Share this post


Link to post
Share on other sites

Update: my offsets were correct after all.

 

There is a known bug in the D3D11 debug layer that generates the "Index buffer has not enough space!" warning when both the StartIndexLocation and BaseVertexLocation arguments to DrawIndexed() are non-zero.

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!