Skip to content
Snippets Groups Projects

vkd3d-shader/ir: Allow failure in shader_signature_find_element_for_reg().

Merged Giovanni Mascellani requested to merge giomasce/vkd3d:vulcano into master
2 unresolved threads

shader_signature_find_element_for_reg() is also used in the TPF parser, where the program has not been validated yet, so it must not crash on errors.

The I/O normaliser can instead assume that the shader is already validated.

This fixes a crash with a shader used by The Falconeer. The bug is still present, because the shader will be incorrectly rejected, but at least the vkd3d-shader will fail gracefully.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Giovanni Mascellani approved this merge request

    approved this merge request

    • @cmccarthy I don't completely understand the logic behind the second part of shader_signature_find_element_for_reg(), i.e., after the FIXME(). Since with this MR the function now returns a failure instead of crashing, is it possibile that that piece of logic can be moved to the caller instead? As far as I understand that's only to prevent a crash once compilation has already failed.

    • I'm not absolutely certain but I think it covers the case where write_mask from a dcl_indexrange has components not found in all signature elements of the range, but those components are not used, so we find the element using only the lowest component and it will work. This assumes the lowest cannot be the one missing, which may prove incorrect.

    • Ok, I'll leave it as is for the moment, at some point I'll do a scan in my shader collectiojn to see what is triggerinig it.

      Do you perhaps remember the application in which that occurred?

    • It was in the shader collection but I don't remember the source.

    • Please register or sign in to reply
    • @@ -1325,7 +1331,8 @@ static void io_normaliser_add_index_range(struct io_normaliser *normaliser,
       
           reg_idx = reg->idx[reg->idx_count - 1].offset;
           write_mask = range->dst.write_mask;
      -    element_idx = shader_signature_find_element_for_reg(signature, reg_idx, write_mask);
      +    if (!shader_signature_find_element_for_reg(signature, reg_idx, write_mask, &element_idx))
      +        vkd3d_unreachable();
           range_map_set_register_range(range_map, reg_idx, range->register_count,
                   signature->elements[element_idx].mask, true);
       }

      Arguably we should just use vsir_signature_find_element_for_reg() here, if we're not otherwise going to use "element_idx".

    • Ok, done.

    • Please register or sign in to reply
  • added 1 commit

    • 9551e79c - vkd3d-shader/ir: Allow failure in shader_signature_find_element_for_reg().

    Compare with previous version

  • Henri Verbeet approved this merge request

    approved this merge request

  • Henri Verbeet added 10 commits

    added 10 commits

    • 9551e79c...32ced3bd - 9 commits from branch wine:master
    • 637a3cab - vkd3d-shader/ir: Allow failure in shader_signature_find_element_for_reg().

    Compare with previous version

Please register or sign in to reply
Loading