https://github.com/shader-slang/slang
Raw File
Tip revision: c7d7a965c14318c07bd5b8ec60b960c2e95dfebd authored by Yong He on 14 March 2024, 21:58:24 UTC
Support `#include` with angle brackets. (#3773)
Tip revision: c7d7a96
generics-simple.slang
//TEST(smoke,compute):COMPARE_COMPUTE: -shaderobj
//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj

// Confirm that generics syntax can be used in user
// code and generates valid output.

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
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