Skip to content

vkd3d-shader/d3dbc: Compile HLSL to d3dbc through vsir, part 2.

Second part of the hlsl->vsir->d3dbc translation. The remaining patches are in my hlsl2vsir5 branch.

For good or bad, I coded this translation using a per-intruction-type approach rather than a per-field approach, specifically, this means that every patch takes care of translating one hlsl instruction type at the time rather than translating one of the fields in sm1_instruction to vsir_instruction.

This per-intruction-type approach is more complicated than the alternative as both the vsir_program and the hlsl_block must coexist at the same time until everything is translated. This is achieved by introducing the hlsl_ir_vsir_instruction_ref instruction node type, which can be introduced like every other hlsl_ir_node in the hlsl_block but points to an instruction in the vsir_program.

But bear with me!

This node type is completely removed in one of the last patches of the translation (fcasas/vkd3d@e547cdc7) and so are the other HLSL constructs in d3dbc.c. So the oddity goes away in the end.

At least, this approach has some upsides:

  • It is more granular, if I missed something in the translation there are more commits to bisect to identify what is broken, of course I did my best to preempt this, but.
  • Commit changes are more localized instead of spread.
  • The hlsl->vsir->tpf translation will have to deal with a chicken-egg problem because registers can have other registers as indexes (non-constant derefs). If we use this same approach for it we can somewhat avoid this problem by leaving the instructions that contain relative addressing as hlsl_ir_nodes instead of vsir_instructions until all other instructions types have been translated.
  • Well, it has the virtue of already existing.
Edited by Francisco Casas

Merge request reports

Loading