https://github.com/shader-slang/slang
Raw File
Tip revision: 652a3c987d2b42d069bf54ba251126208d00d9e7 authored by Tim Foley on 01 February 2018, 22:41:34 UTC
Fix a bug in import handling (#394)
Tip revision: 652a3c9
nested-generics2.slang
//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir
//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