-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_bugs.js
More file actions
87 lines (74 loc) · 12.4 KB
/
test_bugs.js
File metadata and controls
87 lines (74 loc) · 12.4 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
function oct_27_2014()
{
// var exp = JSON.parse('{"type":"set","guid":1149,"parents":[{"type":"discardIf","guid":1146,"parents":[{"type":"mul","guid":1145,"parents":[{"type":"mix","guid":1144,"parents":[{"type":"ifelse","guid":1143,"parents":[{"type":"ne","guid":1142,"parents":[{"type":"parameter","guid":288,"parents":[],"parameterType":"float"},{"type":"constant","guid":1141,"parents":[],"values":[0]}]},{"type":"ifelse","guid":1140,"parents":[{"type":"and","guid":1139,"parents":[{"type":"and","guid":1138,"parents":[{"type":"ge","guid":1137,"parents":[{"type":"add","guid":1135,"parents":[{"type":"mul","guid":1134,"parents":[{"type":"sub","guid":1133,"parents":[{"type":"index","guid":1132,"parents":[{"type":"texture2D","guid":1131,"parents":[{"type":"parameter","guid":109,"parents":[],"parameterType":"sampler2D"},{"type":"div","guid":1130,"parents":[{"type":"add","guid":1129,"parents":[{"type":"swizzle{xy}","guid":1128,"parents":[{"type":"vec","guid":1120,"parents":[{"type":"mod","guid":1119,"parents":[{"type":"floor","guid":1115,"parents":[{"type":"div","guid":1114,"parents":[{"type":"parameter","guid":294,"parents":[],"parameterType":"float"},{"type":"constant","guid":1113,"parents":[],"values":[4]}]}]},{"type":"constant","guid":1118,"parents":[],"values":[1]}]},{"type":"floor","guid":1117,"parents":[{"type":"div","guid":1116,"parents":[{"type":"reference","guid":1115},{"type":"constant","guid":1112,"parents":[],"values":[1]}]}]},{"type":"mod","guid":1111,"parents":[{"type":"reference","guid":294},{"type":"constant","guid":1110,"parents":[],"values":[4]}]}]}]},{"type":"constant","guid":1127,"parents":[],"values":{"0":0.5,"1":0.5}}]},{"type":"constant","guid":1124,"parents":[],"values":{"0":1,"1":0}}]}]},{"type":"swizzle{z}","guid":1121,"parents":[{"type":"reference","guid":1120}]}]},{"type":"index","guid":1104,"parents":[{"type":"array","guid":1062,"parents":[{"type":"constant","guid":1061,"parents":[],"values":[4.3]},{"type":"constant","guid":1060,"parents":[],"values":[2]},{"type":"constant","guid":1059,"parents":[],"values":[1]},{"type":"constant","guid":1058,"parents":[],"values":[0.1]}]},{"type":"reference","guid":294}]}]},{"type":"div","guid":1109,"parents":[{"type":"constant","guid":1108,"parents":[],"values":[0.8]},{"type":"sub","guid":1106,"parents":[{"type":"index","guid":1105,"parents":[{"type":"array","guid":1068,"parents":[{"type":"constant","guid":1067,"parents":[],"values":[7.9]},{"type":"constant","guid":1066,"parents":[],"values":[4.4]},{"type":"constant","guid":1065,"parents":[],"values":[6.9]},{"type":"constant","guid":1064,"parents":[],"values":[2.5]}]},{"type":"reference","guid":294}]},{"type":"reference","guid":1104}]}]}]},{"type":"constant","guid":1103,"parents":[],"values":[0.1]}]},{"type":"min","guid":358,"parents":[{"type":"parameter","guid":289,"parents":[],"parameterType":"float"},{"type":"parameter","guid":290,"parents":[],"parameterType":"float"}]}]},{"type":"le","guid":1136,"parents":[{"type":"reference","guid":1135},{"type":"max","guid":360,"parents":[{"type":"reference","guid":289},{"type":"reference","guid":290}]}]}]},{"type":"and","guid":1102,"parents":[{"type":"ge","guid":1101,"parents":[{"type":"add","guid":1099,"parents":[{"type":"mul","guid":1098,"parents":[{"type":"sub","guid":1097,"parents":[{"type":"index","guid":1096,"parents":[{"type":"texture2D","guid":1095,"parents":[{"type":"reference","guid":109},{"type":"div","guid":1094,"parents":[{"type":"add","guid":1093,"parents":[{"type":"swizzle{xy}","guid":1092,"parents":[{"type":"vec","guid":1084,"parents":[{"type":"mod","guid":1083,"parents":[{"type":"floor","guid":1079,"parents":[{"type":"div","guid":1078,"parents":[{"type":"parameter","guid":293,"parents":[],"parameterType":"float"},{"type":"constant","guid":1077,"parents":[],"values":[4]}]}]},{"type":"constant","guid":1082,"parents":[],"values":[1]}]},{"type":"floor","guid":1081,"parents":[{"type":"div","guid":1080,"parents":[{"type":"reference","guid":1079},{"type":"constant","guid":1076,"parents":[],"values":[1]}]}]},{"type":"mod","guid":1075,"parents":[{"type":"reference","guid":293},{"type":"constant","guid":1074,"parents":[],"values":[4]}]}]}]},{"type":"constant","guid":1091,"parents":[],"values":{"0":0.5,"1":0.5}}]},{"type":"constant","guid":1088,"parents":[],"values":{"0":1,"1":0}}]}]},{"type":"swizzle{z}","guid":1085,"parents":[{"type":"reference","guid":1084}]}]},{"type":"index","guid":1063,"parents":[{"type":"reference","guid":1062},{"type":"reference","guid":293}]}]},{"type":"div","guid":1073,"parents":[{"type":"constant","guid":1072,"parents":[],"values":[0.8]},{"type":"sub","guid":1070,"parents":[{"type":"index","guid":1069,"parents":[{"type":"reference","guid":1068},{"type":"reference","guid":293}]},{"type":"reference","guid":1063}]}]}]},{"type":"constant","guid":1057,"parents":[],"values":[0.1]}]},{"type":"min","guid":399,"parents":[{"type":"parameter","guid":291,"parents":[],"parameterType":"float"},{"type":"parameter","guid":292,"parents":[],"parameterType":"float"}]}]},{"type":"le","guid":1100,"parents":[{"type":"reference","guid":1099},{"type":"max","guid":401,"parents":[{"type":"reference","guid":291},{"type":"reference","guid":292}]}]}]}]},{"type":"index","guid":1051,"parents":[{"type":"array","guid":1050,"parents":[{"type":"constant","guid":1049,"parents":[],"values":{"0":0.8941176533699036,"1":0.10196078568696976,"2":0.10980392247438431,"3":0.5}},{"type":"constant","guid":1044,"parents":[],"values":{"0":0.21568627655506134,"1":0.4941176474094391,"2":0.7215686440467834,"3":0.5}},{"type":"constant","guid":1039,"parents":[],"values":{"0":0.3019607961177826,"1":0.686274528503418,"2":0.29019609093666077,"3":0.5}},{"type":"constant","guid":1034,"parents":[],"values":{"0":0.5960784554481506,"1":0.30588236451148987,"2":0.6392157077789307,"3":0.5}},{"type":"constant","guid":1029,"parents":[],"values":{"0":1,"1":0.49803921580314636,"2":0,"3":0.5}},{"type":"constant","guid":1024,"parents":[],"values":{"0":1,"1":1,"2":0.20000000298023224,"3":0.5}},{"type":"constant","guid":1019,"parents":[],"values":{"0":0.6509804129600525,"1":0.33725491166114807,"2":0.1568627506494522,"3":0.5}},{"type":"constant","guid":1014,"parents":[],"values":{"0":0.9686274528503418,"1":0.5058823823928833,"2":0.7490196228027344,"3":0.5}},{"type":"constant","guid":1009,"parents":[],"values":{"0":0.6000000238418579,"1":0.6000000238418579,"2":0.6000000238418579,"3":0.5}}]},{"type":"cast(int)","guid":1004,"parents":[{"type":"floor","guid":1003,"parents":[{"type":"clamp","guid":1002,"parents":[{"type":"add","guid":1001,"parents":[{"type":"swizzle{x}","guid":1000,"parents":[{"type":"texture2D","guid":999,"parents":[{"type":"reference","guid":109},{"type":"constant","guid":998,"parents":[],"values":{"0":0.5,"1":null}}]}]},{"type":"constant","guid":977,"parents":[],"values":[0.5]}]},{"type":"constant","guid":976,"parents":[],"values":[0]},{"type":"constant","guid":975,"parents":[],"values":[8]}]}]}]}]},{"type":"constant","guid":1056,"parents":[],"values":{"0":0.501960813999176,"1":0.501960813999176,"2":0.501960813999176,"3":0.30000001192092896}}]},{"type":"reference","guid":1051}]},{"type":"reference","guid":1143},{"type":"clamp","guid":974,"parents":[{"type":"sub","guid":973,"parents":[{"type":"constant","guid":972,"parents":[],"values":[3]},{"type":"sub","guid":962,"parents":[{"type":"constant","guid":952,"parents":[],"values":[10]},{"type":"mul","guid":958,"parents":[{"type":"norm","guid":957,"parents":[{"type":"sub","guid":956,"parents":[{"type":"pointCoord","guid":520,"parents":[]},{"type":"constant","guid":955,"parents":[],"values":{"0":0.5,"1":0.5}}]}]},{"type":"constant","guid":951,"parents":[],"values":[20]}]}]}]},{"type":"constant","guid":969,"parents":[],"values":[0]},{"type":"constant","guid":968,"parents":[],"values":[1]}]}]},{"type":"vec","guid":967,"parents":[{"type":"constant","guid":966,"parents":[],"values":[1]},{"type":"constant","guid":965,"parents":[],"values":[1]},{"type":"constant","guid":964,"parents":[],"values":[1]},{"type":"clamp","guid":963,"parents":[{"type":"reference","guid":962},{"type":"constant","guid":961,"parents":[],"values":[0]},{"type":"constant","guid":960,"parents":[],"values":[1]}]}]}]},{"type":"gt","guid":959,"parents":[{"type":"reference","guid":958},{"type":"reference","guid":952}]}]}]}');
// exp = Shade.Debug.fromJson(exp);
// debugger;
// var cc = Shade.CompilationContext(Shade.FRAGMENT_PROGRAM_COMPILE);
// cc.compile(exp);
}
function aug_17_2013()
{
var exp = {"type":"mul","guid":98,"parents":[
{"type":"swizzle{x}","guid":96,"parents":[
{"type":"sub","guid":95,"parents":[
{"type":"mul","guid":93,"parents":[
{"type":"div","guid":91,"parents":[
{"type":"swizzle{xy}","guid":90,"parents":[
{"type":"fragCoord","guid":89,"parents":[]}]},
{"type":"parameter","guid":79,"parents":[],"parameterType":"vec2"}]},
{"type":"constant","guid":92,"parents":[],"values":[2]}]},
{"type":"constant","guid":94,"parents":[],"values":[1]}]}]},
{"type":"swizzle{x}","guid":97,"parents":[{"type":"reference","guid":79}]}]};
exp = Shade.Debug.fromJson(exp);
console.log(exp.debugPrint());
exp.isConstant();
}
test("Tests from previous Lux bugs", function() {
var exp = {"type": "vec", guid: 227, "parents": [
{"type": "parameter", "parameterType": "float", "guid":9999, "parents": []},
{"type": "constant", "guid":9998, "parents": [], "values": [0]},
{"type": "constant", "guid":9997, "parents": [], "values": [0]},
{"type": "constant", "guid":9996, "parents": [], "values": [1]}]};
var condition = {"type":"gt","guid":245,"parents":[
{"type":"swizzle{z}","guid":243,"parents":[
{"type":"dFdx","guid":235,"parents":[
{"type":"div","guid":234,"parents":[
{"type":"swizzle{xyz}","guid":232,"parents":[{"type":"reference","guid":227}]},
{"type":"swizzle{w}","guid":233,"parents":[{"type":"reference","guid":227}]}]}]}]},
{"type":"constant","guid":244,"parents":[],"values":[0]}]};
var node = {"type":"discardIf","guid":246,"parents":[exp,condition]};
var nodeExp = Shade.Debug.fromJson(node);
var prog = { position: nodeExp,
color: Shade.vec(0,0,0,1) };
ok(Shade.program(prog), "discard expressions should be hoisted to fragment program");
var condition2 = {"type":"gt","guid":245,"parents":[
{"type":"swizzle{z}","guid":243,"parents":[
{"type":"cross","guid":242,"parents":[
{"type":"normalize","guid":238,"parents":[
{"type":"cross","guid":237,"parents":[
{"type":"dFdx","guid":235,"parents":[
{"type":"div","guid":234,"parents":[
{"type":"swizzle{xyz}","guid":232,"parents":[exp]},
{"type":"swizzle{w}","guid":233,"parents":[{"type":"reference","guid":227}]}]}]},
{"type":"dFdy","guid":236,"parents":[{"type":"reference","guid":234}]}]}]},
{"type":"vec","guid":241,"parents":[
{"type":"constant","guid":239,"parents":[],"values":[0]},
{"type":"constant","guid":240,"parents":[],"values":[0]},
{"type":"constant","guid":241,"parents":[],"values":[1]}]}]}]},
{"type":"constant","guid":244,"parents":[],"values":[0]}]};
var condExp = Shade.Debug.fromJson(condition2);
var prog2 = { position: Shade.vec(0,0,0,0),
color: condExp.ifelse(Shade.vec(1,0,0,0),
Shade.vec(0,1,0,0)) };
ok(Shade.program(prog2), "backface culling should not crash optimizer");
aug_17_2013();
ok(Shade.Colors.darken(0.5)(Shade.vec(1,1,1,1)), "shade darken should accept vec4");
ok(Shade.Colors.darken(0.5)(Shade.vec(1,1,1)), "shade darken should accept vec3");
ok(Shade.Colors.brighten(0.5)(Shade.vec(1,1,1,1)), "shade brighten should accept vec4");
ok(Shade.Colors.brighten(0.5)(Shade.vec(1,1,1)), "shade brighten should accept vec3");
ok(Shade.Colors.desaturate(0.5)(Shade.vec(1,1,1,1)), "shade desaturate should accept vec4");
ok(Shade.Colors.desaturate(0.5)(Shade.vec(1,1,1)), "shade desaturate should accept vec3");
ok(Shade.Colors.invert(Shade.vec(1,1,1,1)), "shade invert should accept vec4");
ok(Shade.Colors.invert(Shade.vec(1,1,1)), "shade invert should accept vec3");
oct_27_2014();
});