Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WGSL: Add support for all intrinsics #5053

Closed
aleino-nv opened this issue Sep 10, 2024 · 10 comments
Closed

WGSL: Add support for all intrinsics #5053

aleino-nv opened this issue Sep 10, 2024 · 10 comments
Assignees

Comments

@aleino-nv
Copy link
Collaborator

aleino-nv commented Sep 10, 2024

  • atomics
  • texture functions
  • etc...
  • for an exhaustive list, search for "metal" in hlsl.meta.slang and core.meta.slang and make sure there is a "wgsl" case
    • This yields about 10k places to consider
@csyonghe
Copy link
Collaborator

You can search for "metal" in hlsl.meta.slang and core.meta.slang and make sure there is a "wgsl" case.

@aleino-nv
Copy link
Collaborator Author

Thanks Yong, I'll make a list and split it tomorrow.
FYI @bmillsNV, this is the task we could put an extra resource on to help hit WGSL milestone 1 on time.

@aleino-nv
Copy link
Collaborator Author

@csyonghe I see about 20k lines that contain "metal" in hlsl.meta.slang.
The vast majority apply to 0.5 functions, so let's say 10k lines that need to be visited and considered for wgsl.

I'm not about to paste 10k entries here just so we can have something to point at when splitting this task.

@jkwak-work If you feel like you want to split this one, I guess you can split it into chunks

  • 1/10 for the first 1k instances
  • 2/10 for the next 1k instances
  • ...

@aleino-nv aleino-nv assigned aleino-nv and jkwak-work and unassigned aleino-nv Sep 11, 2024
@csyonghe
Copy link
Collaborator

I doubt there are 20k of them. You are probably looking at HLSL.meta.slang.h which is the expanded version of it that contains one line for every combination of different texture type parameterization. Actual changes won't be that many.

@csyonghe
Copy link
Collaborator

We added all metal intrinsics over the course of 2 weeks.

@jkwak-work
Copy link
Collaborator

jkwak-work commented Sep 11, 2024

The spec document lists all built-in functions for WGSL.
We should apply them in hlsl.meta.slang from this list.

  1. easy ones
    numeric (63 functions)
    data packing (9 functions), unpacking (7 functions)

  2. little tricky ones
    constructor (19 functions)
    texture (15 functions)
    derivative (9 functions), bitcast, all, any, select, arrayLength

  3. potentially tricky ones
    atomic (3 functions)
    synchronization (4 functions)

@aleino-nv
Copy link
Collaborator Author

@jkwak-work Shouldn't we mainly be looking at the list of intrinsics that Slang needs to support? I think we just need to visit all of the places in hlsl.meta.slang and plug in the corresponding WGSL intrinsics (if any) where we can. In places we can't I suppose it gets a little trickier.

@jkwak-work
Copy link
Collaborator

I assume that there will be many functions that WGSL don't have.
For those functions, we will need to rely on the generic version of the implementation.

As an example, hlsl has a function called "sincos" and WGSL don't have anything directly same one.
We will need to use the "default" implementation as you can see below.

void sincos(matrix<T,N,M> x, out matrix<T,N,M,L1> s, out matrix<T,N,M,L2> c)
{
    __target_switch
    {
    case hlsl: __intrinsic_asm "sincos";
    default:
        s = sin(x);
        c = cos(x);
    }
}

I think it will be easier if we go down a list by what WGSL has rather than what Slang needs.
Once that step is done, we can run down all Slang functions and make sure that the default version works for WGSL.

@jkwak-work
Copy link
Collaborator

I have a PR that covers "numeric" part of WGSL functions.
#5078

@aleino-nv
Copy link
Collaborator Author

The spec document lists all built-in functions for WGSL. We should apply them in hlsl.meta.slang from this list.

  1. easy ones
    numeric (63 functions)
    data packing (9 functions), unpacking (7 functions)
  2. little tricky ones
    constructor (19 functions)
    texture (15 functions)
    derivative (9 functions), bitcast, all, any, select, arrayLength
  3. potentially tricky ones
    atomic (3 functions)
    synchronization (4 functions)

Splitting into subtasks based on this list:

#5079, #5080, #5081, #5082, #5083, #5084, #5085

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants