[Webkit-unassigned] [Bug 199531] [WHLSL] Test standard library

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jul 5 15:15:12 PDT 2019


https://bugs.webkit.org/show_bug.cgi?id=199531

--- Comment #1 from Myles C. Maxfield <mmaxfield at apple.com> ---
Here's a test from HLSL:

RWStructuredBuffer<float> buffer1 : register(u0);
RWStructuredBuffer<float> buffer2 : register(u1);

[numthreads(1, 1, 1)]
void main()
{
        buffer2[0] = sqrt(0);
        buffer2[1] = sqrt(5.0);
        buffer2[2] = sqrt(-5.0);
        buffer2[3] = log2(5.0);
        buffer2[4] = log2(-5.0);
        buffer2[5] = log10(-5.0);
        buffer2[6] = log10(5.0);
        buffer2[7] = frac(5.4);
        buffer2[8] = frac(-5.4);
        buffer2[9] = exp2(-5.0);
        buffer2[10] = exp2(5.0);
        buffer2[11] = degrees(5.0);
        buffer2[12] = radians(5.0);
        buffer2[13] = rcp(5.0);
        buffer2[14] = rcp(-5.0);
        buffer2[15] = rsqrt(5.0);
        buffer2[16] = rsqrt(-5.0);
        buffer2[17] = saturate(5.4);
        buffer2[18] = saturate(5.7);
        buffer2[19] = saturate(-5.4);
        buffer2[20] = saturate(-5.7);
        buffer2[21] = saturate(-0.7);
        buffer2[22] = saturate(0.7);
        buffer2[23] = cos(5.0);
        buffer2[24] = sin(5.0);
        buffer2[25] = tan(5.0);
        buffer2[26] = acos(1.0);
        buffer2[27] = acos(1.0);
        buffer2[28] = atan(5.0);
        buffer2[29] = sinh(5.0);
        buffer2[30] = cosh(5.0);
        buffer2[31] = tanh(5.0);
        buffer2[32] = ceil(5.4);
        buffer2[33] = ceil(5.7);
        buffer2[34] = ceil(-5.4);
        buffer2[35] = ceil(-5.7);
        buffer2[36] = exp(5.0);
        buffer2[37] = floor(5.4);
        buffer2[38] = floor(5.7);
        buffer2[39] = floor(-5.4);
        buffer2[40] = floor(-5.7);
        buffer2[41] = log(5.0);
        buffer2[42] = round(5.4);
        buffer2[43] = round(5.7);
        buffer2[44] = round(-5.4);
        buffer2[45] = round(-5.7);
        buffer2[46] = trunc(5.4);
        buffer2[47] = trunc(5.7);
        buffer2[48] = trunc(-5.4);
        buffer2[49] = trunc(-5.7);
        buffer2[50] = pow(3.0, 5.0);
        buffer2[51] = step(3.0, 5.0);
        buffer2[52] = step(5.0, 3.0);
        buffer2[53] = ldexp(5.0, 3.0);
        buffer2[54] = ldexp(3.0, 5.0);
        buffer2[55] = fmod(3.0, 5.0);
        buffer2[56] = fmod(21.0, 5.0);
        buffer2[57] = smoothstep(0.0, 1.0, 0.5);
        buffer2[58] = smoothstep(0.0, 1.0, -0.5);
        buffer2[59] = smoothstep(0.0, 1.0, 1.5);
        buffer2[60] = smoothstep(0.0, 1.0, 0.75);
        buffer2[61] = smoothstep(0.0, 1.0, 0.25);
        buffer2[62] = lerp(80.0, 160.0, 0.5);
        buffer2[63] = lerp(80.0, 160.0, -0.5);
        buffer2[64] = lerp(80.0, 160.0, 1.5);
        buffer2[65] = lerp(80.0, 160.0, 0.75);
        buffer2[66] = lerp(80.0, 160.0, 0.25);
        buffer2[67] = mad(2.0, 5.0, 7.0);
        buffer2[68] = isfinite(2.0) ? 1.0 : 0.0;
        buffer2[69] = isinf(2.0) ? 1.0 : 0.0;
        buffer2[70] = isnan(2.0) ? 1.0 : 0.0;
        buffer2[71] = atan2(3.0, 4.0);
        sincos(2.0, buffer2[72], buffer2[73]);
        buffer2[74] = any(bool2(true, true)) ? 1.0 : 0.0;
        buffer2[75] = any(bool2(true, false)) ? 1.0 : 0.0;
        buffer2[76] = any(bool2(false, true)) ? 1.0 : 0.0;
        buffer2[77] = any(bool2(false, false)) ? 1.0 : 0.0;
        buffer2[78] = all(bool2(true, true)) ? 1.0 : 0.0;
        buffer2[79] = all(bool2(true, false)) ? 1.0 : 0.0;
        buffer2[80] = all(bool2(false, true)) ? 1.0 : 0.0;
        buffer2[81] = all(bool2(false, false)) ? 1.0 : 0.0;
        buffer2[82] = abs(5.0);
        buffer2[83] = abs(-5.0);
        buffer2[84] = sign(5.0);
        buffer2[85] = sign(0.0);
        buffer2[86] = sign(-5.0);
        buffer2[87] = min(4.0, 5.0);
        buffer2[88] = min(5.0, 4.0);
        buffer2[89] = max(4.0, 5.0);
        buffer2[90] = max(5.0, 4.0);
        buffer2[91] = clamp(100.0, 80.0, 160.0);
        buffer2[92] = clamp(90.0, 80.0, 160.0);
        buffer2[93] = clamp(150.0, 80.0, 160.0);
        buffer2[94] = clamp(200.0, 80.0, 160.0);
        buffer2[95] = modf(3.4, buffer2[96]);
        buffer2[97] = modf(-3.4, buffer2[98]);
        buffer2[99] = float(reversebits(0x00010000));
        buffer2[100] = float(reversebits(0x00008000));
        buffer2[101] = float(countbits(5));
        buffer2[102] = float(countbits(6));
        buffer2[103] = float(countbits(7));
        buffer2[104] = float(countbits(8));
        buffer2[105] = float(firstbithigh(0x00FFFFFF));
        buffer2[106] = float(firstbithigh(0x0FFFFFFF));
        buffer2[107] = float(firstbithigh(0xFFFFFFFF));
        buffer2[108] = float(firstbithigh(0xFFFFFFF0));
        buffer2[109] = float(firstbithigh(0xFFFFFF00));
        buffer2[110] = float(firstbitlow(0x00FFFFFF));
        buffer2[111] = float(firstbitlow(0x0FFFFFFF));
        buffer2[112] = float(firstbitlow(0xFFFFFFFF));
        buffer2[113] = float(firstbitlow(0xFFFFFFF0));
        buffer2[114] = float(firstbitlow(0xFFFFFF00));
        buffer2[115] = float(asint(-1.0));
        buffer2[116] = float(asuint(-1.0));
        buffer2[117] = float(asfloat(0x40000000));
}

And here's the result:

0: 0
1: 2.23607
2: -nan(ind)
3: 2.32193
4: -nan(ind)
5: -nan(ind)
6: 0.69897
7: 0.675
8: -0.675
9: 0.03125
10: 32
11: 286.479
12: 0.0872665
13: 0.2
14: -0.2
15: 0.447214
16: -nan(ind)
17: 1
18: 1
19: 0
20: 0
21: 0
22: 0.7
23: 0.283662
24: -0.958924
25: -3.38052
26: 0
27: 0
28: 1.3734
29: 74.2032
30: 74.2099
31: 0.999909
32: 6
33: 6
34: -5
35: -5
36: 148.413
37: 5
38: 5
39: -6
40: -6
41: 1.60944
42: 5
43: 6
44: -5
45: -6
46: 5
47: 5
48: -5
49: -5
50: 243
51: 1
52: 0
53: 40
54: 96
55: 3
56: 1
57: 0.5
58: 0
59: 1
60: 0.84375
61: 0.15625
62: 120
63: 40
64: 200
65: 140
66: 100
67: 17
68: 1
69: 0
70: 0
71: 0.643501
72: 0.909297
73: -0.416147
74: 1
75: 1
76: 1
77: 0
78: 1
79: 0
80: 0
81: 0
82: 5
83: 5
84: 1
85: 0
86: -1
87: 4
88: 4
89: 5
90: 5
91: 100
92: 90
93: 150
94: 160
95: 0.4
96: 3
97: -0.4
98: -3
99: 32768
100: 65536
101: 2
102: 2
103: 3
104: 1
105: 23
106: 27
107: 31
108: 31
109: 31
110: 0
111: 0
112: 0
113: 4
114: 8
115: -1.08213e+09
116: 3.21284e+09
117: 2

Still needs testing:
mul()
atomic functions
transpose()
refract(), reflect()
normalize()
lit()
length()
faceforward()
dot(), cross(), distance(), dst()
determinant()

Also: it looks like HLSL doesn't have fma(), isnormal(), isordered(), and isunordered(). count_bits() needs to be renamed to countbits(), and asfloat() needs to exist.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190705/c20f2cf6/attachment-0001.html>


More information about the webkit-unassigned mailing list