Combining multiple vertex buffers in D3D12

Suppose I have some vertex position data, where several vertices have the exact same (x,y) coordinates, but in general have different z coordinates.

It would then be natural to decompose the vertex storage by indexing into two vertex buffers: one for the (x,y) coordinates, and one for the z coordinate.

For example, if I have the vertices [(0,0,1), (0,0,2), (0,0,3), (1,1,0), (1,1,3), (1,1,7)], I could decompose that as x-y-coordinates: [(0,0), (1,1)], z-coordinates: [1,2,3,0,3,7] with the index buffer: [(0,0), (0,1), (0,2), (1,3), (1,4), (1,5)].

So the indices would be tuples of indices. Alternatively one could of course specify it with two index buffers.


My questions are:

(1) Does Direct3D 12 support this? (How, what's the API for it?)
(2) Does any modern rendering API let me decompose my data in this way?
(3) Is it a bad idea?
 
No PC graphics API supports programmable vertex buffer indexing (from a shader). AMD GPU based consoles have supported it for long time.

You should separate your vertex data to multiple typed buffers (SoA layout). We do this in our renderer (and so do all Mantle games, as Mantle doesn't even support vertex buffers).

Two index buffers are not supported. You need to bit pack your indices to a single 32 bit value and decompose bits from SV_VertexId in the vertex shader. Then load data from your typed buffers using these indices.

This is not a bad idea. It is actually faster on AMD hardware than vertex buffers.
 
Ok, thanks. Shame it's not accessible on PC.

No PC graphics API supports programmable vertex buffer indexing (from a shader). ...
Just to be clear -- I was not envisioning specifying this type of vertex decomposition in the shader, in a fully programmable way.
For me it would be enough if I could specify the decomposition completely on the CPU side, as context for draw calls.
 
Back
Top