Skip to content
Snippets Groups Projects

hlsl: Fixes for function definition vs declaration.

Merged Elizabeth Figura requested to merge zfigura/vkd3d:pr1 into master
2 unresolved threads

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
2224 2229 {
2225 2230 struct hlsl_ir_function_decl *decl = RB_ENTRY_VALUE(entry, struct hlsl_ir_function_decl, entry);
2226 2231 struct find_function_call_args *args = context;
2227 const struct hlsl_ir_var *param;
2228 unsigned int i = 0;
2232 unsigned int i;
2229 2233
2230 LIST_FOR_EACH_ENTRY(param, decl->parameters, struct hlsl_ir_var, param_entry)
2234 if (decl->parameters.count > args->params->args_count)
2235 return;
  • Comment on lines +2234 to +2235

    This check should be != now if you are deleting the

    if (i == args->params->args_count)

    check.

    Otherwise we may end up calling this decl even if we provide more arguments than the ones requested.

  • Ah yes, that was a simple error, thanks for catching it.

  • Please register or sign in to reply
  • Elizabeth Figura added 5 commits

    added 5 commits

    • 4df98c22 - vkd3d-shader/hlsl: Store function parameters in an array.
    • e7a29e80 - vkd3d-shader/hlsl: Add a hlsl_cleanup_semantic() helper.
    • 6ae9dbc5 - vkd3d-shader/hlsl: Put synthetic variables into a dummy scope.
    • fd19b5d0 - vkd3d-shader/hlsl: Use the original hlsl_ir_function_decl struct rather than...
    • 927e5211 - vkd3d-shader/hlsl: Add functions to the global list inside the func_prototype rule.

    Compare with previous version

    • Unless I am mistaken, if there is a declaration after a definition, the parameter variables will end up with the name in the last definition, e.g. in:

      float foo(float aa);
      
      float foo(float bb)
      {
          return bb + 1;
      }
      
      float foo(float cc);
      
      float4 main() : sv_target
      {
          return foo(5);
      }

      the parameter will end up with "cc" as its name. I think this could be a problem for error logging.

    • I haven't tested, but I think it may actually be fine, or even preferred? Because the vast majority of errors are done while parsing, references to the parameters from inside the function should print "bb" here, and references to parameters from outside the function (like, say, for a type mismatch) would use the last definition or declaration (so in this case "cc"), which seems like a reasonable or even desirable behaviour.

    • I see. Okay then, I don't have additional remarks.

    • Please register or sign in to reply
  • Francisco Casas approved this merge request

    approved this merge request

  • Giovanni Mascellani
  • Is it intentional that a couple of your commits has very long lines in the message? My understanding is that commit messages are commonly truncated at a somewhat reasonable line length.

  • Elizabeth Figura added 3 commits

    added 3 commits

    • a630a4f4 - vkd3d-shader/hlsl: Put synthetic variables into a dummy scope.
    • dbfd58ea - vkd3d-shader/hlsl: Use the original hlsl_ir_function_decl struct rather than...
    • 9046a03d - vkd3d-shader/hlsl: Add functions to the global list inside the func_prototype rule.

    Compare with previous version

  • Is it intentional that a couple of your commits has very long lines in the message? My understanding is that commit messages are commonly truncated at a somewhat reasonable line length.

    Usually I truncate them manually, but I just forgot. Fixed in v3, thanks.

  • Giovanni Mascellani approved this merge request

    approved this merge request

  • Henri Verbeet approved this merge request

    approved this merge request

  • added 12 commits

    • 9046a03d...898fc9e1 - 6 commits from branch wine:master
    • 721c7aa2 - tests: Add more tests for function definitions.
    • cb2c89a5 - vkd3d-shader/hlsl: Store function parameters in an array.
    • 8755a921 - vkd3d-shader/hlsl: Add a hlsl_cleanup_semantic() helper.
    • 25d49b51 - vkd3d-shader/hlsl: Put synthetic variables into a dummy scope.
    • 4c46075d - vkd3d-shader/hlsl: Use the original hlsl_ir_function_decl struct rather than...
    • 77d716c8 - vkd3d-shader/hlsl: Add functions to the global list inside the func_prototype rule.

    Compare with previous version

  • Alexandre Julliard approved this merge request

    approved this merge request

  • Please register or sign in to reply
    Loading