yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeFix `ApplyExtensionToType` on own type being extended. (#2430)364e43264

master
613 B28 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
2
3//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
4RWStructuredBuffer<int> outputBuffer;
5
6interface IFoo
7{
8  static This myAdd(This v, float val);   
9}
10
11__generic<let N : int>
12extension vector<float, N> : IFoo
13{
14  static vector<float, N> myAdd(vector<float, N> v, float val)
15  {
16    return v + vector<float, N>(val);
17  }
18}
19
20[numthreads(4, 1, 1)]
21void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
22{
23  int index = int(dispatchThreadID.x);
24  float2 v = 1.0;
25  v = float2.myAdd(v, 2.0);
26  outputBuffer[index] = int(v.x);
27}
28