Revision b1384a9addfdcbc16ae0e11b85ae2f6ba08f999b authored by jsmall-nvidia on 29 October 2021, 21:19:12 UTC, committed by GitHub on 29 October 2021, 21:19:12 UTC
* #include an absolute path didn't work - because paths were taken to always be relative.

* Update slang-llvm deps.
1 parent 22e7f3f
Raw File
assoctype-complex.slang
//TEST(compute):COMPARE_COMPUTE: -cpu -shaderobj
//TEST(compute):COMPARE_COMPUTE: -shaderobj

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

interface IBase
{
     associatedtype V;
     V sub(V a0, V a1);
}
interface ISimple
{
    associatedtype U : IBase;
    U.V add(U v0, U v1);
}

struct Val : IBase
{
    typedef int V;
    int base;
    V sub(V a0, V a1)
    {
        return a0 - a1 + base;
    }
};

struct Simple : ISimple
{
    typedef Val U;
    Val.V add(U v0, U v1)
    {
        return v0.sub(4, v1.sub(1,2));
    }
};

__generic<T:ISimple>
T.U.V test(T simple, T.U v0, T.U v1)
{
    return simple.add(v0, v1);
}

[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    Simple s;
    Val v0, v1;
    v0.base = 1;
    v1.base = 2;
	int outVal = test<Simple>(s, v0, v1); // == 4.0
	outputBuffer[dispatchThreadID.x] = outVal;
}
back to top