Skip to content
Snippets Groups Projects

vkd3d-shader/ir: Validate signatures, part 2/N.

Merged Giovanni Mascellani requested to merge giomasce/vkd3d:vulcano into master
1 unresolved thread

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

    • +    /* Here we'd likely want to validate that the usage mask is a subset of the
      +     * signature mask. Unfortunately the D3DBC parser sometimes violates this.
      +     * For example I've seen a shader like this:
      +     *   ps_3_0
      +     *   [...]
      +     *   dcl_texcoord0 v0
      +     *   [...]
      +     *   texld r2.xyzw, v0.xyzw, s1.xyzw
      +     *   [...]
      +     *
      +     * The dcl_textcoord0 instruction secretly has a .xy mask, which is used to
      +     * compute the signature mask, but the texld instruction apparently uses all
      +     * the components. Of course the last two components are ignored, but
      +     * formally they seem to be used. So we end up with a signature element with
      +     * mask .xy and usage mask .xyzw.
      +     *
      +     * The correct fix would probably be to make the D3DBC parser aware of which
      +     * components are really used for each instruction, but that would take some
      +     * time. */

      Mostly for what it's worth, note that the "coordinate mask" depends on the sampler type as well. I.e., it's going to be different for "dcl_2d s1" and "dcl_cube s1" or "dcl_colume s1". To make it a little worse, version 1.x fragment shaders don't declare sampler types in the shader itself; they're determined by the environment.

      Also, why does this happen, exactly? add_signature_element() seems to expand both masks at first sight.

    • Mostly for what it's worth, note that the "coordinate mask" depends on the sampler type as well. I.e., it's going to be different for "dcl_2d s1" and "dcl_cube s1" or "dcl_colume s1". To make it a little worse, version 1.x fragment shaders don't declare sampler types in the shader itself; they're determined by the environment.

      That's more or less the reason why I decided to leave this thing alone for the moment and just relax the check. Eventually it would be nice to fix both.

      Also, why does this happen, exactly? add_signature_element() seems to expand both masks at first sight.

      But add_signature_mask(), which is called when the register is used (rather than when it is declared) does not, it affects only used_mask, which becomes larger than mask. I was tempted to change it so that it also change used_mask, but that's going to be used in a lot of places and the situation is already rather brittle (see for example the I/O normaliser) and I didn't want to cause havoc. I might also have changed the code so that used_mask is only extended to a subset of mask, which might have been safer, but still I wasn't sure, and that didn't look like the right way to go anyway. So I decided to leave things alone for the moment.

    • Please register or sign in to reply
  • Henri Verbeet approved this merge request

    approved this merge request

  • Henri Verbeet added 12 commits

    added 12 commits

    • 3e6c09b4...3285d1ad - 5 commits from branch wine:master
    • 71dccc01 - vkd3d-shader/ir: Do not emit an instruction number before starting validating instructions.
    • 6e14d7ab - vkd3d-shader/ir: Validate usage masks in shader signatures.
    • 5034e1ee - vkd3d-shader/ir: Validate system value semantics in shader signatures.
    • 7b1bc5ca - vkd3d-shader/ir: Validate component types in shader signatures.
    • 831a7978 - vkd3d-shader/ir: Validate minimum precision in shader signatures.
    • e366fc3a - vkd3d-shader/ir: Validate interpolation mode in shader signatures.
    • 690c47db - vkd3d-shader/ir: Validate that constant interpolation is used with integer types.

    Compare with previous version

Please register or sign in to reply
Loading