Gfx: dx12: Support VertexIndex and InstanceIndex semantics

Created on 20 Jan 2019  路  2Comments  路  Source: gfx-rs/gfx

Nonzero base vertex or instance values are reflected properly when translating to HLSL.
Recently a new feature has been added to spirv-cross to support this: https://github.com/KhronosGroup/SPIRV-Cross/pull/816

We need to a new root constant into graphics pipeline layouts for storing these two values and push them on draw calls. The drawIndirectFirstInstance can't be supported it seems.

VkPI

Further investigation needed if we need to restrict it also to base vertex due to the VertexIndex semantic?

DirectX-12 contributor-friendly average Windows ready for work bug medium

Most helpful comment

@termhn Thanks!
Command Signature is unrelated to this (Step 3). It defines the layout of the gpu commands in the buffers for indirect command execution.
To extend on Step 2, see the comment here: https://github.com/gfx-rs/gfx/issues/2604#issuecomment-460385700

These two issues are basically the same, one for graphics pipelines and one for compute pipeline. We have 4 root constants spare IIRC, which will be shared for both pipeline types (basically like an union).
In this case we need to allocate 2 u32 bit constants for these two builtins and patch spirv accordingly.

All 2 comments

Steps for completion:

  1. Familiarize yourself with root descriptors and root constants (https://docs.microsoft.com/en-us/windows/desktop/direct3d12/root-signatures-overview)
  2. Add new root constants here https://github.com/gfx-rs/gfx/blob/master/src/backend/dx12/src/device.rs#L1276
  3. Add to the signature here for the draw command https://github.com/gfx-rs/gfx/blob/master/src/backend/dx12/src/device.rs#L482-L483

(@msiglreith can you check my logic on this? I'm not sure if I'm right or not, not super familiar with d3d12 ;p)

@termhn Thanks!
Command Signature is unrelated to this (Step 3). It defines the layout of the gpu commands in the buffers for indirect command execution.
To extend on Step 2, see the comment here: https://github.com/gfx-rs/gfx/issues/2604#issuecomment-460385700

These two issues are basically the same, one for graphics pipelines and one for compute pipeline. We have 4 root constants spare IIRC, which will be shared for both pipeline types (basically like an union).
In this case we need to allocate 2 u32 bit constants for these two builtins and patch spirv accordingly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clevijoki picture clevijoki  路  3Comments

kvark picture kvark  路  4Comments

torkleyy picture torkleyy  路  4Comments

kvark picture kvark  路  5Comments

mjadczak picture mjadczak  路  4Comments