summaryrefslogtreecommitdiff
path: root/tests/hlsl-intrinsic/vector-double-reduced-intrinsic.slang
blob: a2ca3ffcc26fe81529c47735daac866bc5aba685 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj
// TODO(JS):
// On CI systems DX11 test failed, so disable for now
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -shaderobj -render-feature hardware-device
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj -render-feature double
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj

//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<double4> outputBuffer;

typedef double Float;

typedef vector<Float, 3> FloatVector;
typedef vector<int, 3> IntVector;
typedef vector<uint, 3> UIntVector;

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

    Float vf = idx * (1.0f / (4.0f));
     
    FloatVector f = FloatVector(0.1f, vf, vf + 0.2f);
    
    // Operate over all values
    FloatVector ft = {};

    // TODO(JS):
    // fmod - disabled not available on D3D for double
    //ft += FloatVector(IntVector(((f % 0.11f) * 100) + 0.5));
            
    {
        // Vector specific
        FloatVector nv = normalize(f);
        ft += nv;
        
        FloatVector perp = cross(nv, f.zxy); 
        ft += perp;
  
           
        // TODO(JS): 
        // Disabled because dotwith a double vector fails on dxc, with validation error (!)
        //ft += dot(perp, f.zyx);

        ft += length(f);
  
        // TODO(JS):
        // Disabled because reflect with double fails on dxc
        //ft += reflect(f, FloatVector(0, 1, 0));
    }    
    
    // Reduced set of intrinsics that should work on all targets
    
#if 0   
    // TODO(JS):
    // Disabled because not supported on VK (glsl) in vector form    
    ft += rcp(1.0l + f);
#endif
    
    ft += sign(f - 0.5l);
    
    ft += saturate(f * 4 - 2.0l);
       
    ft += abs(f * 4 - 2.0l);
           
    ft += min(0.5l, f);
    ft += max(f, 0.75l);

    ft += clamp(f, 0.1l, 0.3l);
        
    outputBuffer[idx] = vector<Float, 4>(ft, 0);
}