14
14
. setOutput ( [ 1 ] ) ;
15
15
var result = kernel ( ) ;
16
16
QUnit . assert . equal ( result [ 0 ] , 3 ) ;
17
+ gpu . destroy ( ) ;
17
18
}
18
19
19
20
QUnit . test ( 'add typed functions - vec2 - (auto)' , function ( ) {
20
21
vec2Test ( null ) ;
21
22
} ) ;
23
+ QUnit . test ( 'add typed functions - vec2 - (webgl2)' , function ( ) {
24
+ vec2Test ( 'webgl2' ) ;
25
+ } ) ;
26
+ QUnit . test ( 'add typed functions - vec2 - (webgl)' , function ( ) {
27
+ vec2Test ( 'webgl' ) ;
28
+ } ) ;
29
+ } ) ( ) ;
30
+
31
+ ( function ( ) {
32
+ function vec3Test ( mode ) {
33
+ var gpu = new GPU ( { mode : mode } ) ;
34
+ function typedFunction ( ) {
35
+ return [ 1 , 2 , 3 ] ;
36
+ }
37
+ gpu . addFunction ( typedFunction , {
38
+ returnType : 'vec3'
39
+ } ) ;
40
+ var kernel = gpu . createKernel ( function ( ) {
41
+ var result = typedFunction ( ) ;
42
+ return result [ 0 ] + result [ 1 ] + result [ 2 ] ;
43
+ } )
44
+ . setOutput ( [ 1 ] ) ;
45
+ var result = kernel ( ) ;
46
+ QUnit . assert . equal ( result [ 0 ] , 6 ) ;
47
+ gpu . destroy ( ) ;
48
+ }
49
+
50
+ QUnit . test ( 'add typed functions - vec3 - (auto)' , function ( ) {
51
+ vec3Test ( null ) ;
52
+ } ) ;
53
+ QUnit . test ( 'add typed functions - vec3 - (webgl2)' , function ( ) {
54
+ vec3Test ( 'webgl2' ) ;
55
+ } ) ;
56
+ QUnit . test ( 'add typed functions - vec3 - (webgl)' , function ( ) {
57
+ vec3Test ( 'webgl' ) ;
58
+ } ) ;
59
+ } ) ( ) ;
60
+
61
+ ( function ( ) {
62
+ function vec4Test ( mode ) {
63
+ var gpu = new GPU ( { mode : mode } ) ;
64
+ function typedFunction ( ) {
65
+ return [ 1 , 2 , 3 , 4 ] ;
66
+ }
67
+ gpu . addFunction ( typedFunction , {
68
+ returnType : 'vec4'
69
+ } ) ;
70
+ var kernel = gpu . createKernel ( function ( ) {
71
+ var result = typedFunction ( ) ;
72
+ return result [ 0 ] + result [ 1 ] + result [ 2 ] + result [ 3 ] ;
73
+ } )
74
+ . setOutput ( [ 1 ] ) ;
75
+ var result = kernel ( ) ;
76
+ QUnit . assert . equal ( result [ 0 ] , 10 ) ;
77
+ gpu . destroy ( ) ;
78
+ }
79
+
80
+ QUnit . test ( 'add typed functions - vec4 - (auto)' , function ( ) {
81
+ vec4Test ( null ) ;
82
+ } ) ;
83
+ QUnit . test ( 'add typed functions - vec4 - (webgl2)' , function ( ) {
84
+ vec4Test ( 'webgl2' ) ;
85
+ } ) ;
86
+ QUnit . test ( 'add typed functions - vec4 - (webgl)' , function ( ) {
87
+ vec4Test ( 'webgl' ) ;
88
+ } ) ;
22
89
} ) ( ) ;
0 commit comments