Skip to content

d3d12: primitive restart

Erik Faye-Lund requested to merge d3d12-primitive_restart into msclc-d3d12

OK, so there's a couple of things to explain here:

  1. D3D12 only supports primitive-restart indices as 0xffff or 0xffffffff, but OpenGL 3.1 requires specifying arbitrary restart-indices. So we either need to emulate primitive-restart fully, or rewrite the index-buffers. The latter is slightly better than emulating, because we only get the wrong vertex gl_VertexID in the case where the last index is used, which is very unlikely.

  2. We already have helpers for both approaches, but neither is quite what we need.

    • The emulation-code misses a bunch of primitive-types that we support, and is open-coded over and over
    • The emulation-code kicks in whenever we translate index-buffers from 8-bit to 16-bit, which is not needed.
    • The index-buffer rewriting-code is tightly coupled with the rendering-code, does yet another copy (in case we're already translating for some other reason), which isn't ideal.

So here's my attempt at fixing all of the above:

  1. Decouple the index-buffer rewriting code from the rendering-code
  2. Give the emulation-code its own 8-bit to 16-bit expansion code-path
  3. Clean up emulation-code implementation
  4. Add missing emulation-code for needed primitive-types
  5. Teach u_primconvert to translate index-buffers, so we only do a single copy of the index-buffers, and play along nicely with the stream-uploader
  6. Finally, we can implement the driver-bits to trigger all of the above machinery.
Edited by Erik Faye-Lund

Merge request reports

Loading