yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

jsmall-nvidiaFeature/test improvements (#934)2896aa39a

master
782 B41 linesraw
1// single-shader-record.slang
2//DIAGNOSTIC_TEST:SIMPLE: -profile sm_6_3 -stage closesthit -entry main -target spirv-assembly
3
4struct ReflectionRay
5{
6    float4 color;
7};
8
9StructuredBuffer<float4> colors;
10
11// There are two constant buffers with shader_record attibuting so should produce and error
12
13layout(shaderRecordNV)
14cbuffer ShaderRecord2
15{
16	uint shaderRecordID2;
17}
18
19[[vk::shader_record]]
20cbuffer ShaderRecord
21{
22	uint shaderRecordID;
23}
24
25void main(
26	BuiltInTriangleIntersectionAttributes 	attributes,
27	in out ReflectionRay 					ioPayload)
28{
29	uint materialID = InstanceIndex()
30		+ InstanceID()
31		+ PrimitiveIndex()
32		+ HitKind()
33		+ shaderRecordID 
34        + shaderRecordID2;
35
36	float4 color = colors[materialID];
37
38	color *= RayTCurrent() - RayTMin();
39
40	ioPayload.color = color;
41}