@@ -363,8 +363,6 @@ struct FunctionLocalData<'a> {
363
363
364
364
#[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Clone , Copy ) ]
365
365
pub enum ExpressionKind {
366
- /// If const is also implemented as const
367
- ImplConst ,
368
366
Const ,
369
367
Override ,
370
368
Runtime ,
@@ -392,21 +390,13 @@ impl ExpressionKindTracker {
392
390
}
393
391
394
392
pub fn is_const ( & self , h : Handle < Expression > ) -> bool {
395
- matches ! (
396
- self . type_of( h) ,
397
- ExpressionKind :: Const | ExpressionKind :: ImplConst
398
- )
399
- }
400
-
401
- /// Returns `true` if naga can also evaluate expression as const
402
- pub fn is_impl_const ( & self , h : Handle < Expression > ) -> bool {
403
- matches ! ( self . type_of( h) , ExpressionKind :: ImplConst )
393
+ matches ! ( self . type_of( h) , ExpressionKind :: Const )
404
394
}
405
395
406
396
pub fn is_const_or_override ( & self , h : Handle < Expression > ) -> bool {
407
397
matches ! (
408
398
self . type_of( h) ,
409
- ExpressionKind :: Const | ExpressionKind :: Override | ExpressionKind :: ImplConst
399
+ ExpressionKind :: Const | ExpressionKind :: Override
410
400
)
411
401
}
412
402
@@ -427,14 +417,13 @@ impl ExpressionKindTracker {
427
417
}
428
418
429
419
fn type_of_with_expr ( & self , expr : & Expression ) -> ExpressionKind {
430
- use crate :: MathFunction as Mf ;
431
420
match * expr {
432
421
Expression :: Literal ( _) | Expression :: ZeroValue ( _) | Expression :: Constant ( _) => {
433
- ExpressionKind :: ImplConst
422
+ ExpressionKind :: Const
434
423
}
435
424
Expression :: Override ( _) => ExpressionKind :: Override ,
436
425
Expression :: Compose { ref components, .. } => {
437
- let mut expr_type = ExpressionKind :: ImplConst ;
426
+ let mut expr_type = ExpressionKind :: Const ;
438
427
for component in components {
439
428
expr_type = expr_type. max ( self . type_of ( * component) )
440
429
}
@@ -445,16 +434,13 @@ impl ExpressionKindTracker {
445
434
Expression :: Access { base, index } => self . type_of ( base) . max ( self . type_of ( index) ) ,
446
435
Expression :: Swizzle { vector, .. } => self . type_of ( vector) ,
447
436
Expression :: Unary { expr, .. } => self . type_of ( expr) ,
448
- Expression :: Binary { left, right, .. } => self
449
- . type_of ( left)
450
- . max ( self . type_of ( right) )
451
- . max ( ExpressionKind :: Const ) ,
437
+ Expression :: Binary { left, right, .. } => self . type_of ( left) . max ( self . type_of ( right) ) ,
452
438
Expression :: Math {
453
- fun,
454
439
arg,
455
440
arg1,
456
441
arg2,
457
442
arg3,
443
+ ..
458
444
} => self
459
445
. type_of ( arg)
460
446
. max (
@@ -468,42 +454,16 @@ impl ExpressionKindTracker {
468
454
. max (
469
455
arg3. map ( |arg| self . type_of ( arg) )
470
456
. unwrap_or ( ExpressionKind :: Const ) ,
471
- )
472
- . max (
473
- if matches ! (
474
- fun,
475
- Mf :: Dot
476
- | Mf :: Outer
477
- | Mf :: Distance
478
- | Mf :: Length
479
- | Mf :: Normalize
480
- | Mf :: FaceForward
481
- | Mf :: Reflect
482
- | Mf :: Refract
483
- | Mf :: Ldexp
484
- | Mf :: Modf
485
- | Mf :: Mix
486
- | Mf :: Frexp
487
- ) {
488
- ExpressionKind :: Const
489
- } else {
490
- ExpressionKind :: ImplConst
491
- } ,
492
457
) ,
493
- Expression :: As { convert, expr, .. } => self . type_of ( expr) . max ( if convert. is_some ( ) {
494
- ExpressionKind :: ImplConst
495
- } else {
496
- ExpressionKind :: Const
497
- } ) ,
458
+ Expression :: As { expr, .. } => self . type_of ( expr) ,
498
459
Expression :: Select {
499
460
condition,
500
461
accept,
501
462
reject,
502
463
} => self
503
464
. type_of ( condition)
504
465
. max ( self . type_of ( accept) )
505
- . max ( self . type_of ( reject) )
506
- . max ( ExpressionKind :: Const ) ,
466
+ . max ( self . type_of ( reject) ) ,
507
467
Expression :: Relational { argument, .. } => self . type_of ( argument) ,
508
468
Expression :: ArrayLength ( expr) => self . type_of ( expr) ,
509
469
_ => ExpressionKind :: Runtime ,
@@ -797,7 +757,6 @@ impl<'a> ConstantEvaluator<'a> {
797
757
span : Span ,
798
758
) -> Result < Handle < Expression > , ConstantEvaluatorError > {
799
759
match self . expression_kind_tracker . type_of_with_expr ( & expr) {
800
- ExpressionKind :: ImplConst => self . try_eval_and_append_impl ( & expr, span) ,
801
760
ExpressionKind :: Const => {
802
761
let eval_result = self . try_eval_and_append_impl ( & expr, span) ;
803
762
// We should be able to evaluate `Const` expressions at this
0 commit comments