Skip to content
Snippets Groups Projects

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

Merged Francisco Casas requested to merge fcasas/vkd3d:hlsl2vsir5_part into master
2 unresolved threads

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

Merge request pipeline #31341 skipped

Merge request pipeline skipped for 379cd9b7

Approved by

Merged by Henri VerbeetHenri Verbeet 6 months ago (Sep 4, 2024 4:47pm UTC)

Merge details

  • Changes merged into master with 379cd9b7.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Francisco Casas changed the description

    changed the description

    • 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.

    • Author Developer

      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.

    • Please register or sign in to reply
  • Francisco Casas added 51 commits

    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.

    Compare with previous version

  • Francisco Casas added 145 commits

    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.

    Compare with previous version

  • Elizabeth Figura approved this merge request

    approved this merge request

  • Henri Verbeet approved this merge request

    approved this merge request

  • Henri Verbeet added 21 commits

    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.

    Compare with previous version

Please register or sign in to reply
Loading