shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link

Metal: Opaque type return/inout-param/out-param either infinitely-loops or crashes #4479

Closed ArielG-NV closed 1 day ago

ArielG-NV commented 3 days ago

breaks the following tests (related to #4291)

  1. tests/language-feature/types/opaque/inout-param-opaque-type-in-struct.slang.1 (mtl)
  2. tests/language-feature/types/opaque/out-param-opaque-type-in-struct.slang.1 (mtl)
  3. tests/language-feature/types/opaque/inout-param-opaque-type.slang.1 (mtl)
  4. tests/language-feature/types/opaque/return-opaque-type-in-struct.slang.1 (mtl)
  5. tests/language-feature/types/opaque/out-param-opaque-type.slang.1 (mtl)

Returning/out/inout an opaque type crashes/infinitely-loops.

examples:

[infinitely-loops]

struct Things
{
    int first;
    RWStructuredBuffer<int> rest;
}
void swap(
    inout Things a,
    inout Things b)
{
    Things t = a;
    a = b;
    b = t;
}

[crashes]

struct Things
{
    int first;
    RWStructuredBuffer<int> rest;
}
void swap(
    out Things a,
    out Things b)
{
    Things t = a;
    a = b;
    b = t;
}

[functions correctly]

struct Things
{
    int first;
    RWStructuredBuffer<int> rest;
}
void swap(
    in Things a,
    in Things b)
{
    Things t = a;
    a = b;
    b = t;
}