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.
Merge request reports
Activity
To repeat the discussion had in IRC, I don't like this approach towards conversion. I think it would be better to ship-of-Theseus the sm1_instruction structure into vsir_instruction field by field, eventually replacing it with vsir_instruction completely, and then eventually use vsir helpers to initialize the instruction. I had written several patches toward this end.
Francisco pushed back on this, essentially because these patches are already written and should eventually result in similar enough code. I'm not sure the effort is going to be that much, but I'm not going to argue against already completed work at this juncture.
To repeat the discussion had in IRC, I don't like this approach towards conversion. I think it would be better to ship-of-Theseus the sm1_instruction structure into vsir_instruction field by field, eventually replacing it with vsir_instruction completely, and then eventually use vsir helpers to initialize the instruction. I had written several patches toward this end.
I will keep in mind to add a patch at the end of the translation to completely remove sm1_instruction and replace it with vsir_instruction. At that point sm1_instruction is a subset of vsir_instruction so that replacement should be trivial.
added 51 commits
-
d715d31a...ba0fec4c - 44 commits from branch
wine:master
- b9086c35 - vkd3d-shader/hlsl: Introduce hlsl_ir_vsir_instruction_ref.
- a2daefe8 - vkd3d-shader/hlsl: Store SM1 constant dcls on the vsir_program.
- 1edf929b - vkd3d-shader/hlsl: Store SM1 sampler dcls on the vsir_program.
- 3917f0f3 - vkd3d-shader/hlsl: Save hlsl_ir_constants in the vsir_program for SM1.
- 926e27f7 - vkd3d-shader/hlsl: Save hlsl_ir_loads in the vsir_program for SM1.
- 4412820a - vkd3d-shader/hlsl: Save hlsl_ir_stores in the vsir_program for SM1.
- 0a262e54 - vkd3d-shader/hlsl: Save hlsl_ir_swizzles in the vsir_program for SM1.
Toggle commit list-
d715d31a...ba0fec4c - 44 commits from branch
added 145 commits
-
0a262e54...52796658 - 138 commits from branch
wine:master
- c0a4b44b - vkd3d-shader/hlsl: Introduce hlsl_ir_vsir_instruction_ref.
- 85fc3a1f - vkd3d-shader/hlsl: Store SM1 constant dcls on the vsir_program.
- 13a5206e - vkd3d-shader/hlsl: Store SM1 sampler dcls on the vsir_program.
- e5468644 - vkd3d-shader/hlsl: Save hlsl_ir_constants in the vsir_program for SM1.
- cf25adf0 - vkd3d-shader/hlsl: Save hlsl_ir_loads in the vsir_program for SM1.
- eb778de6 - vkd3d-shader/hlsl: Save hlsl_ir_stores in the vsir_program for SM1.
- a706530c - vkd3d-shader/hlsl: Save hlsl_ir_swizzles in the vsir_program for SM1.
Toggle commit list-
0a262e54...52796658 - 138 commits from branch
added 21 commits
-
a706530c...3d8fc1a4 - 14 commits from branch
wine:master
- 7abf3c3a - vkd3d-shader/hlsl: Introduce hlsl_ir_vsir_instruction_ref.
- 9a564872 - vkd3d-shader/hlsl: Store SM1 constant dcls on the vsir_program.
- a61846c2 - vkd3d-shader/hlsl: Store SM1 sampler dcls on the vsir_program.
- 23e3ec84 - vkd3d-shader/hlsl: Save hlsl_ir_constants in the vsir_program for SM1.
- 9aace1ac - vkd3d-shader/hlsl: Save hlsl_ir_loads in the vsir_program for SM1.
- b46eac35 - vkd3d-shader/hlsl: Save hlsl_ir_stores in the vsir_program for SM1.
- 379cd9b7 - vkd3d-shader/hlsl: Save hlsl_ir_swizzles in the vsir_program for SM1.
Toggle commit list-
a706530c...3d8fc1a4 - 14 commits from branch