summaryrefslogtreecommitdiffstats
path: root/tests/bugs/generic-extension.slang
blob: a3e0398720df277503249b1514958f76964afd90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer;

interface IFoo
{
  static This myAdd(This v, float val);   
}

__generic<let N : int>
extension vector<float, N> : IFoo
{
  static vector<float, N> myAdd(vector<float, N> v, float val)
  {
    return v + vector<float, N>(val);
  }
}

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
{
  int index = int(dispatchThreadID.x);
  float2 v = 1.0;
  v = float2.myAdd(v, 2.0);
  outputBuffer[index] = int(v.x);
}