Closed aleino-nv closed 1 month ago
You can search for "metal" in hlsl.meta.slang and core.meta.slang and make sure there is a "wgsl" case.
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.
@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
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.
We added all metal intrinsics over the course of 2 weeks.
The spec document lists all built-in functions for WGSL. We should apply them in hlsl.meta.slang from this list.
easy ones numeric (63 functions) data packing (9 functions), unpacking (7 functions)
little tricky ones constructor (19 functions) texture (15 functions) derivative (9 functions), bitcast, all, any, select, arrayLength
potentially tricky ones atomic (3 functions) synchronization (4 functions)
@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.
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.
I have a PR that covers "numeric" part of WGSL functions. https://github.com/shader-slang/slang/pull/5078
The spec document lists all built-in functions for WGSL. We should apply them in hlsl.meta.slang from this list.
- easy ones numeric (63 functions) data packing (9 functions), unpacking (7 functions)
- little tricky ones constructor (19 functions) texture (15 functions) derivative (9 functions), bitcast, all, any, select, arrayLength
- potentially tricky ones atomic (3 functions) synchronization (4 functions)
Splitting into subtasks based on this list: