https://github.com/shader-slang/slang
Raw File
Tip revision: 87c50cf1644454cdc9e7f6d1262bee29bfc86e80 authored by Tim Foley on 29 March 2018, 22:47:58 UTC
Avoid crash when bad argument given to [instance(...)] attribute (#464)
Tip revision: 87c50cf
generics-simple.slang
//TEST(smoke,compute):COMPARE_COMPUTE:
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
// Confirm that generics syntax can be used in user
// code and generates valid output.

RWStructuredBuffer<float> outputBuffer;


__generic<T>
T test(T val)
{
	return val;
}


[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
	uint tid = dispatchThreadID.x;

	float inVal = float(tid);

	float outVal = test<float>(inVal);

	outputBuffer[tid] = outVal;
}
back to top