Skip to content
Snippets Groups Projects

hlsl: Return hlsl_ir_node pointers from instruction constructors, part 1.

Merged Elizabeth Figura requested to merge zfigura/vkd3d:pr0 into master
3 unresolved threads

The motivation for this is twofold.

Firstly, this makes code a little nicer to read, by virtue of removing a ubiquitous &(...)->node.

Secondly, and more importantly, this allows for the possibility of constructors returning a different instruction type than intended. The ultimate goal here is to return a preallocated "error" instruction when allocation fails, instead of returning NULL and propagating out-of-memory handling to the caller.

Merge request reports

Checking pipeline status.

Approved by

Merged by Alexandre JulliardAlexandre Julliard 1 year ago (Apr 18, 2023 8:35pm UTC)

Merge details

  • Changes merged into master with 7ee66351.
  • Did not delete 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
1210 1210
1211 struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc)
1211 struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition,
1212 struct hlsl_block *then_block, struct hlsl_block *else_block, const struct vkd3d_shader_location *loc)
1212 1213 {
1213 1214 struct hlsl_ir_if *iff;
1214 1215
1215 1216 if (!(iff = hlsl_alloc(ctx, sizeof(*iff))))
1216 1217 return NULL;
1217 init_node(&iff->node, HLSL_IR_IF, NULL, &loc);
1218 init_node(&iff->node, HLSL_IR_IF, NULL, loc);
1218 1219 hlsl_src_from_node(&iff->condition, condition);
1219 hlsl_block_init(&iff->then_instrs);
1220 hlsl_block_init(&iff->else_instrs);
1220 hlsl_block_init(&iff->then_block);
1221 list_move_tail(&iff->then_block.instrs, &then_block->instrs);
  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on an outdated change in commit b1ba2bb9
  • 1514 1518
    1515 1519 static struct hlsl_ir_node *clone_if(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_if *src)
    1516 1520 {
    1521 struct hlsl_block then_block, else_block;
    1517 1522 struct hlsl_ir_if *dst;
    1518 1523
    1519 if (!(dst = hlsl_new_if(ctx, map_instr(map, src->condition.node), src->node.loc)))
    1524 if (!clone_block(ctx, &then_block, &src->then_block, map))
    1520 1525 return NULL;
    1526 if (!clone_block(ctx, &else_block, &src->else_block, map))
    1527 {
    1528 hlsl_free_instr_list(&then_block.instrs);
  • Giovanni Mascellani approved this merge request

    approved this merge request

  • Giovanni Mascellani unapproved this merge request

    unapproved this merge request

  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on commit b1ba2bb9
  • 1514 1518
    1515 1519 static struct hlsl_ir_node *clone_if(struct hlsl_ctx *ctx, struct clone_instr_map *map, struct hlsl_ir_if *src)
    1516 1520 {
    1521 struct hlsl_block then_block, else_block;
    1517 1522 struct hlsl_ir_if *dst;
    1518 1523
    1519 if (!(dst = hlsl_new_if(ctx, map_instr(map, src->condition.node), src->node.loc)))
    1524 if (!clone_block(ctx, &then_block, &src->then_block, map))
  • Elizabeth Figura added 4 commits

    added 4 commits

    • 111fa894 - vkd3d-shader/hlsl: Introduce a hlsl_block_cleanup() helper.
    • 06df8a91 - vkd3d-shader/hlsl: Initialize the block in clone_block().
    • 1c8ac6f1 - vkd3d-shader/hlsl: Pass hlsl_block pointers to hlsl_new_if().
    • fe5d556d - vkd3d-shader/hlsl: Return an hlsl_ir_node pointer from hlsl_new_if().

    Compare with previous version

  • Giovanni Mascellani approved this merge request

    approved this merge request

  • Henri Verbeet approved this merge request

    approved this merge request

  • Alexandre Julliard approved this merge request

    approved this merge request

  • Please register or sign in to reply
    Loading