https://github.com/shader-slang/slang
Raw File
Tip revision: 135eaff6b892fc91a398714ddcf7ef377cd4cccb authored by Tim Foley on 07 December 2018, 21:31:06 UTC
Change how buffers are emitted (#741)
Tip revision: 135eaff
nested-generics2.slang
//TEST(compute):COMPARE_COMPUTE:
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out

// test specialization of nested generic functions

RWStructuredBuffer<int> outputBuffer;

interface IBRDF
{
    float getF();
}

interface ILight
{
    float illum<B:IBRDF>(B b);
};

struct B0 : IBRDF
{
    float getF() { return 1.0; }
};

struct L0 : ILight
{
    float illum<B:IBRDF>(B b) { return b.getF(); }
};

struct L1<L:ILight> : ILight
{
    L l;
    float illum<BXX:IBRDF>(BXX bxx) { return l.illum<BXX>(bxx); }
};


[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
	uint tid = dispatchThreadID.x;
    L1<L0> light;
    B0 b0;
	float outVal = light.illum<B0>(b0);
	outputBuffer[tid] = int(outVal);
}
back to top