Skip to content
Snippets Groups Projects

vkd3d-shader/ir: Flatten structured control flow instructions.

Merged Conor McCarthy requested to merge cmccarthy/vkd3d:norm_cf into master

Merge request reports

Checking pipeline status.

Merged by Alexandre JulliardAlexandre Julliard 1 year ago (Jan 17, 2024 9:42pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Author Developer

    I need to recheck this, add more error handling, and set compiler->main_block_open correctly, but it passes all the tests.

    Questions:

    In d3dbc what does the LABEL instruction src parameter contain? I assume this instruction adds a block label so I'm using it for that, and currently emit it with an immediate constant.

    We lose the naming of block label ids. One way to handle this is include the necessary info in the IR to recreate the deleted namings in the backend. Another is add support for names to VSIR. Thoughts?

    The new instruction count sometimes gets ahead of the source count. This is handled by writing everything to a new instruction array, and swapping out the old one at the end. Simple and effective for the moment?

  • Questions:

    In d3dbc what does the LABEL instruction src parameter contain? I assume this instruction adds a block label so I'm using it for that, and currently emit it with an immediate constant.

    These look like "label l0", "label l1", etc. in the disassembler. I.e., using VKD3DSPR_LABEL. They'd get called like "call l0", "call l1", etc. LABEL/CALL isn't terribly common though, to the point that I don't think Wine even has tests for them; the vsa/psa assemblers may be the only way to get them.

    We lose the naming of block label ids. One way to handle this is include the necessary info in the IR to recreate the deleted namings in the backend. Another is add support for names to VSIR. Thoughts?

    I imagine we could do something similar to SPIR-V's OpName if needed, but I don't think we have a strong reason to choose that option over just including e.g. an array with debug names in struct vkd3d_shader_desc.

    The new instruction count sometimes gets ahead of the source count. This is handled by writing everything to a new instruction array, and swapping out the old one at the end. Simple and effective for the moment?

    Sure.

  • Conor McCarthy added 24 commits

    added 24 commits

    • 7f0f75ee...852eefc0 - 20 commits from branch wine:master
    • 2f385a0c - vkd3d-shader/spirv: Emit descriptor offset loads in the function entry block.
    • e257fb7a - vkd3d-shader: Rename shader_instruction_array_add_icb() to...
    • 421ba2b3 - vkd3d-shader/ir: Flatten structured control flow instructions.
    • be1fe74f - vkd3d-shader/ir: Store code block names in struct vkd3d_shader_desc.

    Compare with previous version

  • Author Developer

    The call in vkd3d_shader_normalise() to vsir_validate() no longer validates any control flow instructions because they have been removed, but it's also called in vkd3d_shader_sm4_parser_create() so this should not be an issue.

  • Conor McCarthy marked this merge request as ready

    marked this merge request as ready

  • Author Developer

    Should this be called a flattener or would a lowerer be more accurate?

  • Conor McCarthy added 2 commits

    added 2 commits

    • 62f2ae6e - vkd3d-shader/ir: Flatten structured control flow instructions.
    • ec1af663 - vkd3d-shader/ir: Store code block names in struct vkd3d_shader_desc.

    Compare with previous version

  • Conor McCarthy added 2 commits

    added 2 commits

    • d87273ac - vkd3d-shader/ir: Flatten structured control flow instructions.
    • 0f9f9460 - vkd3d-shader/ir: Store code block names in struct vkd3d_shader_desc.

    Compare with previous version

  • Giovanni Mascellani
  • Giovanni Mascellani
  • Giovanni Mascellani
    • Resolved by Giovanni Mascellani

      So, it seems that the idea is that at any given time a VSIR program either has control flow based on if, loop, etc or based on label and branch (which are endowed with CFG structure information anyway). Is that true, or are cases in which the same program can legally have both types of instructions?

  • Conor McCarthy added 2 commits

    added 2 commits

    • 8cae2150 - vkd3d-shader/ir: Flatten structured control flow instructions.
    • 9a0adf96 - vkd3d-shader/ir: Store code block names in struct vkd3d_shader_desc.

    Compare with previous version

  • Giovanni Mascellani
  • Conor McCarthy added 2 commits

    added 2 commits

    • dc5f2094 - vkd3d-shader/ir: Flatten structured control flow instructions.
    • 81b7c667 - vkd3d-shader/ir: Store code block names in struct vkd3d_shader_desc.

    Compare with previous version

  • Conor McCarthy added 50 commits

    added 50 commits

    • 81b7c667...0c5c18bd - 46 commits from branch wine:master
    • c9a3f2a7 - vkd3d-shader/spirv: Emit descriptor offset loads in the function entry block.
    • 6b9c4bd6 - vkd3d-shader: Rename shader_instruction_array_add_icb() to...
    • 05633773 - vkd3d-shader/ir: Flatten structured control flow instructions.
    • ec3dced4 - vkd3d-shader/ir: Store code block names in struct vkd3d_shader_desc.

    Compare with previous version

  • Giovanni Mascellani
  • Giovanni Mascellani
  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on an outdated change in commit 05633773
  • 1621 return &flattener->control_flow_info[depth];
    1622 }
    1623
    1624 return NULL;
    1625 }
    1626
    1627 static enum vkd3d_result cf_flattener_iterate_instruction_array(struct cf_flattener *flattener)
    1628 {
    1629 struct vkd3d_shader_parser *parser = flattener->parser;
    1630 struct vkd3d_shader_instruction_array *instructions;
    1631 struct vkd3d_shader_instruction *dst_ins;
    1632 bool main_block_open;
    1633 size_t i;
    1634
    1635 instructions = &parser->instructions;
    1636 main_block_open = parser->shader_version.type != VKD3D_SHADER_TYPE_HULL;
  • Giovanni Mascellani
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading