0

I am Currently Working on Direct11 Graphics API, I am Wondering Why Index buffer has This Formula?

Start of Index Buffer = Index Buffer Base Address + Offset (bytes) + StartIndexLocation * ElementSize (bytes);

I am Wondering What Does This Mean . Someone please Help Me With This

Full Reference Docs -> https://learn.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-resources-buffers-intro

MMS 05
  • 9
  • 4
  • 1
    @ChuckWalbourn Will probably be able to provide an in-depth answer, but at the same time, The question is unclear as to what you are confused about. The documentation you linked to explains each part of the algorithm. It's my understanding that the algorithm is designed in such a way that you can interleave the various buffers in to one array, but in practice I've not seen it done. – Casey Oct 27 '20 at 07:08
  • Please Explain Me About that Index Buffer Alone like How That Stuff Works @ChuckWalbourn – MMS 05 Oct 27 '20 at 07:13
  • I can assume that the GPU does some optimizations when you supply an offset into a very big index buffer, since the offset is in bytes, it doesnt matter what type the index is and the GPU can just skip the bytes without knowing the actual type. Just an assumption. – Raildex Oct 27 '20 at 08:26

1 Answers1

0

The indices you gonna fetch depend on the following pieces of data.

  1. The content of the index buffer.

  2. Offset that you have passed to IASetIndexBuffer. That value is in bytes.

  3. StartIndexLocation that you have passed when you submit a draw call such as DrawIndexed. That one is in elements, not in bytes. Direct3D 11 only supports uint16_t and uint32_t index formats, this means element size in the formula is either 2 or 4 bytes, depending on what you have passed in Format argument of IASetIndexBuffer.

After you called DrawIndexed, when GPU is doing what you asked, it combines these pieces of data to fetch a continuous range of primitives from the index buffer. The formula specifies where that range starts.

Soonts
  • 20,079
  • 9
  • 57
  • 130