@@ -233,17 +233,13 @@ impl Preprocessor {
233
233
& self ,
234
234
shader_str : & str ,
235
235
shader_defs : & HashMap < String , ShaderDefValue > ,
236
- validate_len : bool ,
237
236
) -> Result < PreprocessOutput , ComposerErrorInner > {
238
237
let mut declared_imports = IndexMap :: new ( ) ;
239
238
let mut used_imports = IndexMap :: new ( ) ;
240
239
let mut scope = Scope :: new ( ) ;
241
240
let mut final_string = String :: new ( ) ;
242
241
let mut offset = 0 ;
243
242
244
- #[ cfg( debug) ]
245
- let len = shader_str. len ( ) ;
246
-
247
243
// this code broadly stolen from bevy_render::ShaderProcessor
248
244
let mut lines = shader_str. lines ( ) ;
249
245
let mut lines = lines. replace_comments ( ) . zip ( shader_str. lines ( ) ) . peekable ( ) ;
@@ -371,14 +367,6 @@ impl Preprocessor {
371
367
372
368
scope. finish ( offset) ?;
373
369
374
- #[ cfg( debug) ]
375
- if validate_len {
376
- let revised_len = final_string. len ( ) ;
377
- assert_eq ! ( len, revised_len) ;
378
- }
379
- #[ cfg( not( debug) ) ]
380
- let _ = validate_len;
381
-
382
370
Ok ( PreprocessOutput {
383
371
preprocessed_source : final_string,
384
372
imports : used_imports. into_values ( ) . collect ( ) ,
@@ -576,7 +564,6 @@ fn vertex(
576
564
let result_missing = processor. preprocess (
577
565
WGSL ,
578
566
& [ ( "TEXTURE" . to_owned ( ) , ShaderDefValue :: Bool ( true ) ) ] . into ( ) ,
579
- true ,
580
567
) ;
581
568
582
569
let expected: Result < Preprocessor , ComposerErrorInner > =
@@ -677,7 +664,6 @@ fn vertex(
677
664
. preprocess (
678
665
WGSL ,
679
666
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Int ( 3 ) ) ] . into ( ) ,
680
- true ,
681
667
)
682
668
. unwrap ( ) ;
683
669
assert_eq ! ( result_eq. preprocessed_source, EXPECTED_EQ ) ;
@@ -686,12 +672,11 @@ fn vertex(
686
672
. preprocess (
687
673
WGSL ,
688
674
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Int ( 7 ) ) ] . into ( ) ,
689
- true ,
690
675
)
691
676
. unwrap ( ) ;
692
677
assert_eq ! ( result_neq. preprocessed_source, EXPECTED_NEQ ) ;
693
678
694
- let result_missing = processor. preprocess ( WGSL , & Default :: default ( ) , true ) ;
679
+ let result_missing = processor. preprocess ( WGSL , & Default :: default ( ) ) ;
695
680
696
681
let expected_err: Result <
697
682
( Option < String > , String , Vec < ImportDefWithOffset > ) ,
@@ -705,7 +690,6 @@ fn vertex(
705
690
let result_wrong_type = processor. preprocess (
706
691
WGSL ,
707
692
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( true ) ) ] . into ( ) ,
708
- true ,
709
693
) ;
710
694
711
695
let expected_err: Result <
@@ -814,7 +798,6 @@ fn vertex(
814
798
. preprocess (
815
799
WGSL ,
816
800
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( true ) ) ] . into ( ) ,
817
- true ,
818
801
)
819
802
. unwrap ( ) ;
820
803
assert_eq ! ( result_eq. preprocessed_source, EXPECTED_EQ ) ;
@@ -823,7 +806,6 @@ fn vertex(
823
806
. preprocess (
824
807
WGSL ,
825
808
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( false ) ) ] . into ( ) ,
826
- true ,
827
809
)
828
810
. unwrap ( ) ;
829
811
assert_eq ! ( result_neq. preprocessed_source, EXPECTED_NEQ ) ;
@@ -919,7 +901,6 @@ fn vertex(
919
901
. preprocess (
920
902
WGSL ,
921
903
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( true ) ) ] . into ( ) ,
922
- true ,
923
904
)
924
905
. unwrap ( ) ;
925
906
assert_eq ! ( result_eq. preprocessed_source, EXPECTED_EQ ) ;
@@ -928,12 +909,11 @@ fn vertex(
928
909
. preprocess (
929
910
WGSL ,
930
911
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( false ) ) ] . into ( ) ,
931
- true ,
932
912
)
933
913
. unwrap ( ) ;
934
914
assert_eq ! ( result_neq. preprocessed_source, EXPECTED_NEQ ) ;
935
915
936
- let result_missing = processor. preprocess ( WGSL , & [ ] . into ( ) , true ) ;
916
+ let result_missing = processor. preprocess ( WGSL , & [ ] . into ( ) ) ;
937
917
let expected_err: Result <
938
918
( Option < String > , String , Vec < ImportDefWithOffset > ) ,
939
919
ComposerErrorInner ,
@@ -946,7 +926,6 @@ fn vertex(
946
926
let result_wrong_type = processor. preprocess (
947
927
WGSL ,
948
928
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Int ( 7 ) ) ] . into ( ) ,
949
- true ,
950
929
) ;
951
930
952
931
let expected_err: Result <
@@ -1031,7 +1010,6 @@ fn vertex(
1031
1010
( "SECOND_VALUE" . to_string ( ) , ShaderDefValue :: Int ( 3 ) ) ,
1032
1011
]
1033
1012
. into ( ) ,
1034
- true ,
1035
1013
)
1036
1014
. unwrap ( ) ;
1037
1015
assert_eq ! ( result. preprocessed_source, EXPECTED_REPLACED ) ;
@@ -1060,7 +1038,7 @@ defined
1060
1038
..
1061
1039
} = processor. get_preprocessor_metadata ( & WGSL , true ) . unwrap ( ) ;
1062
1040
println ! ( "defines: {:?}" , shader_defs) ;
1063
- let result = processor. preprocess ( & WGSL , & shader_defs, true ) . unwrap ( ) ;
1041
+ let result = processor. preprocess ( & WGSL , & shader_defs) . unwrap ( ) ;
1064
1042
assert_eq ! ( result. preprocessed_source, EXPECTED ) ;
1065
1043
}
1066
1044
@@ -1103,7 +1081,7 @@ bool: false
1103
1081
..
1104
1082
} = processor. get_preprocessor_metadata ( & WGSL , true ) . unwrap ( ) ;
1105
1083
println ! ( "defines: {:?}" , shader_defs) ;
1106
- let result = processor. preprocess ( & WGSL , & shader_defs, true ) . unwrap ( ) ;
1084
+ let result = processor. preprocess ( & WGSL , & shader_defs) . unwrap ( ) ;
1107
1085
assert_eq ! ( result. preprocessed_source, EXPECTED ) ;
1108
1086
}
1109
1087
@@ -1135,9 +1113,7 @@ fn vertex(
1135
1113
}
1136
1114
" ;
1137
1115
let processor = Preprocessor :: default ( ) ;
1138
- let result = processor
1139
- . preprocess ( & WGSL_ELSE_IFDEF , & [ ] . into ( ) , true )
1140
- . unwrap ( ) ;
1116
+ let result = processor. preprocess ( & WGSL_ELSE_IFDEF , & [ ] . into ( ) ) . unwrap ( ) ;
1141
1117
assert_eq ! (
1142
1118
result
1143
1119
. preprocessed_source
@@ -1214,7 +1190,7 @@ fn vertex(
1214
1190
" ;
1215
1191
let processor = Preprocessor :: default ( ) ;
1216
1192
let result = processor
1217
- . preprocess ( & WGSL_ELSE_IFDEF_NO_ELSE_FALLBACK , & [ ] . into ( ) , true )
1193
+ . preprocess ( & WGSL_ELSE_IFDEF_NO_ELSE_FALLBACK , & [ ] . into ( ) )
1218
1194
. unwrap ( ) ;
1219
1195
assert_eq ! (
1220
1196
result
@@ -1265,7 +1241,6 @@ fn vertex(
1265
1241
. preprocess (
1266
1242
& WGSL_ELSE_IFDEF ,
1267
1243
& [ ( "TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( true ) ) ] . into ( ) ,
1268
- true ,
1269
1244
)
1270
1245
. unwrap ( ) ;
1271
1246
assert_eq ! (
@@ -1314,7 +1289,6 @@ fn vertex(
1314
1289
. preprocess (
1315
1290
& WGSL_ELSE_IFDEF ,
1316
1291
& [ ( "SECOND_TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( true ) ) ] . into ( ) ,
1317
- true ,
1318
1292
)
1319
1293
. unwrap ( ) ;
1320
1294
assert_eq ! (
@@ -1363,7 +1337,6 @@ fn vertex(
1363
1337
. preprocess (
1364
1338
& WGSL_ELSE_IFDEF ,
1365
1339
& [ ( "THIRD_TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( true ) ) ] . into ( ) ,
1366
- true ,
1367
1340
)
1368
1341
. unwrap ( ) ;
1369
1342
assert_eq ! (
@@ -1416,7 +1389,6 @@ fn vertex(
1416
1389
( "THIRD_TEXTURE" . to_string ( ) , ShaderDefValue :: Bool ( true ) ) ,
1417
1390
]
1418
1391
. into ( ) ,
1419
- true ,
1420
1392
)
1421
1393
. unwrap ( ) ;
1422
1394
assert_eq ! (
@@ -1471,7 +1443,6 @@ fn vertex(
1471
1443
. preprocess (
1472
1444
& WGSL_COMPLICATED_ELSE_IFDEF ,
1473
1445
& [ ( "IS_DEFINED" . to_string ( ) , ShaderDefValue :: Bool ( true ) ) ] . into ( ) ,
1474
- true ,
1475
1446
)
1476
1447
. unwrap ( ) ;
1477
1448
assert_eq ! (
@@ -1504,7 +1475,7 @@ fail 3
1504
1475
1505
1476
const EXPECTED : & str = r"ok" ;
1506
1477
let processor = Preprocessor :: default ( ) ;
1507
- let result = processor. preprocess ( & INPUT , & [ ] . into ( ) , true ) . unwrap ( ) ;
1478
+ let result = processor. preprocess ( & INPUT , & [ ] . into ( ) ) . unwrap ( ) ;
1508
1479
assert_eq ! (
1509
1480
result
1510
1481
. preprocessed_source
@@ -1536,11 +1507,7 @@ fail 3
1536
1507
const EXPECTED : & str = r"ok" ;
1537
1508
let processor = Preprocessor :: default ( ) ;
1538
1509
let result = processor
1539
- . preprocess (
1540
- & INPUT ,
1541
- & [ ( "x" . to_owned ( ) , ShaderDefValue :: Int ( 2 ) ) ] . into ( ) ,
1542
- true ,
1543
- )
1510
+ . preprocess ( & INPUT , & [ ( "x" . to_owned ( ) , ShaderDefValue :: Int ( 2 ) ) ] . into ( ) )
1544
1511
. unwrap ( ) ;
1545
1512
assert_eq ! (
1546
1513
result
0 commit comments