Skip to content

nir, microsoft: Various fixes for spirv_to_dxil

Jesse Natalie requested to merge jenatali/mesa:spirv-to-dxil-doubles-fp16 into master

I'm working through a large HLSL dataset, converting to SPIR-V and trying to convert the result to DXIL, currently stopping and diving in when I hit an assert. Here's some fixes to address asserts:

  • Lower globals to function_temp after inlining to allow vars_to_ssa to work on them. Specifically, I need this to work on the globals inserted by lower_io_to_temporaries
  • Lower I/O arrays, with guaranteed no indirects since we lower to temp first
  • Handle fp16 I/O vars, b2f16, casts to fp16, and fp16 constants
  • Handle doubles

The series for doubles is interesting mainly because I want to preserve the semantics of HLSL. DXIL does have cast and bitcast intrinsics for doubles, but in HLSL there's no way to access the bitcast intrinsics. Instead, you use asdouble(uint, uint) to combine two 32bit values and bitcast the result to double, and asuint(double, out uint, out uint) to split it back apart. In SPIR-V/NIR, this ends up as just an integer [un]pack+bitcast, but then that requires the resulting shader to have int64 support in addition to doubles, in order to construct that temporary value.

So, I added dedicated opcodes which match the HLSL asdouble and asuint semantics, which we can insert in a new lowering pass, and which can be handed to the backend to use the MakeDouble and SplitDouble intrinsics.

/cc @tangm @egalli

/cc @jekstrand for the NIR opcode

Merge request reports