@@ -10,7 +10,13 @@ const bool c=true;
10
10
#endif
11
11
uniform float foo,bar;uniform sampler2D map;in vec2 vUv;out vec4 pc_FragColor;
12
12
#include <three_test >
13
- layout(std140)uniform Uniforms1{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} ;layout(std140)uniform Uniforms2{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} d;struct e{ float intensity ;vec3 position ;float one ,two ;} ;uniform e Light[4];void main(){ vec4 f = vec4 (Light [0 ].position .xyz * Light [0 ].intensity ,0.0 );vec4 g = projectionMatrix * modelViewMatrix * vec4 (0 ,0 ,0 ,1 );vec4 h = d .projectionMatrix * d .modelViewMatrix * vec4 (0 ,0 ,0 ,1 );if (false ){}pc_FragColor = vec4 (texture (map ,vUv ).rgb ,0.0 );float i = 0.0 ;pc_FragColor .a += 1.0 + i ;} "
13
+ layout(std140)uniform Uniforms1{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} ;layout(std140)uniform Uniforms2{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} d;struct e{
14
+ #if ! defined (BLA )
15
+ int y ;
16
+ #else
17
+ float z ;
18
+ #endif
19
+ } ;struct f{ float intensity ;vec3 position ;float one ,two ;} ;uniform f Light[4];void main(){ vec4 g = vec4 (Light [0 ].position .xyz * Light [0 ].intensity ,0.0 );vec4 h = projectionMatrix * modelViewMatrix * vec4 (0 ,0 ,0 ,1 );vec4 i = d .projectionMatrix * d .modelViewMatrix * vec4 (0 ,0 ,0 ,1 );if (false ){}pc_FragColor = vec4 (texture (map ,vUv ).rgb ,0.0 );float j = 0.0 ;pc_FragColor .a += 1.0 + j ;} "
14
20
`;
15
21
16
22
exports[`minify > can mangle GLSL 2`] = `
@@ -40,7 +46,13 @@ const bool c=true;
40
46
#endif
41
47
uniform float d,e;uniform sampler2D f;in vec2 g;out vec4 h;
42
48
#include <three_test >
43
- layout(std140)uniform i{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} ;layout(std140)uniform j{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} k;struct l{ float intensity ;vec3 position ;float one ,two ;} ;uniform l m[4];void main(){ vec4 n = vec4 (m [0 ].position .xyz * m [0 ].intensity ,0.0 );vec4 o = projectionMatrix * modelViewMatrix * vec4 (0 ,0 ,0 ,1 );vec4 p = k .projectionMatrix * k .modelViewMatrix * vec4 (0 ,0 ,0 ,1 );if (false ){}h = vec4 (texture (f ,g ).rgb ,0.0 );float e = 0.0 ;h .a += 1.0 + e ;} "
49
+ layout(std140)uniform i{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} ;layout(std140)uniform j{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} k;struct l{
50
+ #if ! defined (BLA )
51
+ int y ;
52
+ #else
53
+ float z ;
54
+ #endif
55
+ } ;struct m{ float intensity ;vec3 position ;float one ,two ;} ;uniform m n[4];void main(){ vec4 o = vec4 (n [0 ].position .xyz * n [0 ].intensity ,0.0 );vec4 p = projectionMatrix * modelViewMatrix * vec4 (0 ,0 ,0 ,1 );vec4 q = k .projectionMatrix * k .modelViewMatrix * vec4 (0 ,0 ,0 ,1 );if (false ){}h = vec4 (texture (f ,g ).rgb ,0.0 );float e = 0.0 ;h .a += 1.0 + e ;} "
44
56
`;
45
57
46
58
exports[`minify > can mangle externals in GLSL 2`] = `
55
67
" Uniforms1" => " i" ,
56
68
" Uniforms2" => " j" ,
57
69
" globals" => " k" ,
58
- " Light" => " m " ,
70
+ " Light" => " n " ,
59
71
}
60
72
`;
61
73
@@ -98,7 +110,13 @@ const bool isTest=true;
98
110
#endif
99
111
uniform float foo,bar;uniform sampler2D map;in vec2 vUv;out vec4 pc_FragColor;
100
112
#include <three_test >
101
- layout(std140)uniform Uniforms1{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} ;layout(std140)uniform Uniforms2{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} globals;struct LightData{ float intensity ;vec3 position ;float one ,two ;} ;uniform LightData Light[4];void main(){ vec4 lightNormal = vec4 (Light [0 ].position .xyz * Light [0 ].intensity ,0.0 );vec4 clipPosition = projectionMatrix * modelViewMatrix * vec4 (0 ,0 ,0 ,1 );vec4 clipPositionGlobals = globals .projectionMatrix * globals .modelViewMatrix * vec4 (0 ,0 ,0 ,1 );if (false ){}pc_FragColor = vec4 (texture (map ,vUv ).rgb ,0.0 );float bar = 0.0 ;pc_FragColor .a += 1.0 + bar ;} "
113
+ layout(std140)uniform Uniforms1{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} ;layout(std140)uniform Uniforms2{ mat4 projectionMatrix ;mat4 modelViewMatrix ;mat3 normalMatrix ;float one ,two ;} globals;struct X{
114
+ #if ! defined (BLA )
115
+ int y ;
116
+ #else
117
+ float z ;
118
+ #endif
119
+ } ;struct LightData{ float intensity ;vec3 position ;float one ,two ;} ;uniform LightData Light[4];void main(){ vec4 lightNormal = vec4 (Light [0 ].position .xyz * Light [0 ].intensity ,0.0 );vec4 clipPosition = projectionMatrix * modelViewMatrix * vec4 (0 ,0 ,0 ,1 );vec4 clipPositionGlobals = globals .projectionMatrix * globals .modelViewMatrix * vec4 (0 ,0 ,0 ,1 );if (false ){}pc_FragColor = vec4 (texture (map ,vUv ).rgb ,0.0 );float bar = 0.0 ;pc_FragColor .a += 1.0 + bar ;} "
102
120
`;
103
121
104
122
exports[`minify > can minify WGSL 1`] = `"struct LightData{ intensity :f32 ,position :vec3 <f32 >,one:f32,two:f32,};struct Uniforms{ projectionMatrix :mat4x4 <f32 >,modelViewMatrix:mat4x4<f32 >,normalMatrix:mat3x3<f32 >,one:f32,two:f32,lights:array<LightData,4>,};@binding(0)@group(0)var<uniform >uniforms:Uniforms;@binding(1)@group(0)var sample:sampler;@binding(2)@group(0)var map:texture_2d<f32 >;struct VertexIn{ @location (0 )position :vec4 <f32 >,@location(1)uv:vec2<f32 >,};struct VertexOut{ @builtin (position )position :vec4 <f32 >,@location(0)uv:vec2<f32 >,};@vertex fn vert_main(input:VertexIn)->VertexOut{ var output :VertexOut ;output .position = input .position ;output .uv = input .uv ;return output ;} @fragment fn frag_main(uv:vec2<f32 >)->vec4<f32 >{ var lightNormal = vec4 <f32 >(uniforms .lights [0 ].position * uniforms .lights [0 ].intensity ,0.0 );var clipPosition = uniforms .projectionMatrix * uniforms .modelViewMatrix * vec4 <f32 >(0.0 ,0.0 ,0.0 ,1.0 );var color = textureSample (map ,sample ,uv );color .a += 1.0 ;return color ;} "`;
@@ -911,6 +929,150 @@ exports[`tokenize > can tokenize GLSL 1`] = `
911
929
" type" : " whitespace" ,
912
930
" value" : "
913
931
932
+ " ,
933
+ } ,
934
+ {
935
+ " type" : " keyword" ,
936
+ " value" : " struct" ,
937
+ } ,
938
+ {
939
+ " type" : " whitespace" ,
940
+ " value" : " " ,
941
+ } ,
942
+ {
943
+ " type" : " identifier" ,
944
+ " value" : " X" ,
945
+ } ,
946
+ {
947
+ " type" : " whitespace" ,
948
+ " value" : " " ,
949
+ } ,
950
+ {
951
+ " type" : " symbol" ,
952
+ " value" : " {" ,
953
+ } ,
954
+ {
955
+ " type" : " whitespace" ,
956
+ " value" : "
957
+ " ,
958
+ } ,
959
+ {
960
+ " type" : " symbol" ,
961
+ " value" : " #" ,
962
+ } ,
963
+ {
964
+ " type" : " keyword" ,
965
+ " value" : " if" ,
966
+ } ,
967
+ {
968
+ " type" : " whitespace" ,
969
+ " value" : " " ,
970
+ } ,
971
+ {
972
+ " type" : " symbol" ,
973
+ " value" : " !" ,
974
+ } ,
975
+ {
976
+ " type" : " keyword" ,
977
+ " value" : " defined" ,
978
+ } ,
979
+ {
980
+ " type" : " symbol" ,
981
+ " value" : " (" ,
982
+ } ,
983
+ {
984
+ " type" : " identifier" ,
985
+ " value" : " BLA" ,
986
+ } ,
987
+ {
988
+ " type" : " symbol" ,
989
+ " value" : " )" ,
990
+ } ,
991
+ {
992
+ " type" : " whitespace" ,
993
+ " value" : "
994
+ " ,
995
+ } ,
996
+ {
997
+ " type" : " keyword" ,
998
+ " value" : " int" ,
999
+ } ,
1000
+ {
1001
+ " type" : " whitespace" ,
1002
+ " value" : " " ,
1003
+ } ,
1004
+ {
1005
+ " type" : " identifier" ,
1006
+ " value" : " y" ,
1007
+ } ,
1008
+ {
1009
+ " type" : " symbol" ,
1010
+ " value" : " ;" ,
1011
+ } ,
1012
+ {
1013
+ " type" : " whitespace" ,
1014
+ " value" : "
1015
+ " ,
1016
+ } ,
1017
+ {
1018
+ " type" : " symbol" ,
1019
+ " value" : " #" ,
1020
+ } ,
1021
+ {
1022
+ " type" : " keyword" ,
1023
+ " value" : " else" ,
1024
+ } ,
1025
+ {
1026
+ " type" : " whitespace" ,
1027
+ " value" : "
1028
+ " ,
1029
+ } ,
1030
+ {
1031
+ " type" : " keyword" ,
1032
+ " value" : " float" ,
1033
+ } ,
1034
+ {
1035
+ " type" : " whitespace" ,
1036
+ " value" : " " ,
1037
+ } ,
1038
+ {
1039
+ " type" : " identifier" ,
1040
+ " value" : " z" ,
1041
+ } ,
1042
+ {
1043
+ " type" : " symbol" ,
1044
+ " value" : " ;" ,
1045
+ } ,
1046
+ {
1047
+ " type" : " whitespace" ,
1048
+ " value" : "
1049
+ " ,
1050
+ } ,
1051
+ {
1052
+ " type" : " symbol" ,
1053
+ " value" : " #" ,
1054
+ } ,
1055
+ {
1056
+ " type" : " keyword" ,
1057
+ " value" : " endif" ,
1058
+ } ,
1059
+ {
1060
+ " type" : " whitespace" ,
1061
+ " value" : "
1062
+ " ,
1063
+ } ,
1064
+ {
1065
+ " type" : " symbol" ,
1066
+ " value" : " }" ,
1067
+ } ,
1068
+ {
1069
+ " type" : " symbol" ,
1070
+ " value" : " ;" ,
1071
+ } ,
1072
+ {
1073
+ " type" : " whitespace" ,
1074
+ " value" : "
1075
+
914
1076
" ,
915
1077
} ,
916
1078
{
0 commit comments