yum-mirror/slang

Making it easier to work with shaders

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

Harsh Aggarwal (NVIDIA)Fix 7723 - Add autodiff tests (#7919)d10732742

master
1.3 KiB39 linesraw
1//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
3//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type
4
5// outputBuffer is defined in IBSDF.slang
6//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
7
8import MaterialSystem;
9import DiffuseMaterial;
10import DiffuseMaterialInstance;
11import GlossyMaterial;
12import GlossyMaterialInstance;
13import MxLayeredMaterial;
14import MxLayeredMaterialInstance;
15
16//TEST_INPUT: type_conformance DiffuseMaterial:IMaterial = 0
17//TEST_INPUT: type_conformance GlossyMaterial:IMaterial = 1
18//TEST_INPUT: type_conformance MxLayeredMaterial:IMaterial = 2
19
20[BackwardDifferentiable]
21float3 evalBSDF(int type)
22{
23    float3 wi = normalize(float3(0.5, 0.2, 0.8));
24    float3 wo = normalize(float3(-0.1, -0.3, 0.9));
25
26    IMaterial material = createMaterialClassConformance(type, float3(0.9f, 0.6f, 0.2f));
27    MaterialInstanceData miData;
28    let mi = material.setupMaterialInstance(miData);
29    float3 f = mi.eval(miData, wi, wo);
30    return f;
31}
32
33[numthreads(1, 1, 1)]
34void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
35{
36    __bwd_diff(evalBSDF)(0, float3(1.f));
37    __bwd_diff(evalBSDF)(1, float3(1.f));
38    __bwd_diff(evalBSDF)(2, float3(1.f));
39}