Skip to content

Commit

Permalink
fix smoothstep validation (#3900)
Browse files Browse the repository at this point in the history
'values' test:
* Infer result type instead of explicitly specifying it.   If specified,
  it's used as the explicit type of the result variable.  Infer it
  instead.  This fixes cases where the type is abstract.
* low == high is an error
  gpuweb/gpuweb#4616

'partial_eval_errs' test:
* Test function foo() must be called from the entry point so
  that overrides are validated.

'early_eval_errs' test:
* Fix argument order: low and high args are first and second.

Bug: crbug.com/351378281
  • Loading branch information
dneto0 authored Aug 13, 2024
1 parent d849b67 commit 24725f3
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ Validates that constant evaluation and override evaluation of ${builtin}() rejec
.fn(t => {
const type = kValuesTypes[t.params.type];

// We expect to fail if low >= high as it results in a DBZ
const expectedResult = t.params.value1 >= t.params.value2;
// We expect to fail if low >= high.
const expectedResult = t.params.value1 < t.params.value2;

validateConstOrOverrideBuiltinEval(
t,
builtin,
expectedResult,
[type.create(t.params.value1), type.create(t.params.value2), type.create(0)],
t.params.stage,
/* returnType */ concreteTypeOf(type, [Type.f32])
t.params.stage
);
});

Expand Down Expand Up @@ -141,6 +140,7 @@ fn foo() {
code: wgsl,
constants,
reference: ['o_low', 'o_high'],
statements: ['foo();'],
});
}
});
Expand All @@ -159,10 +159,11 @@ Validates that scalar and vector arguments are rejected by ${builtin}() if not f
})
.fn(t => {
const type = kArgumentTypes[t.params.type];
const expectedResult = isConvertibleToFloatType(elementTypeOf(type));
validateConstOrOverrideBuiltinEval(
t,
builtin,
/* expectedResult */ isConvertibleToFloatType(elementTypeOf(type)),
expectedResult,
[type.create(0), type.create(1), type.create(2)],
'constant',
/* returnType */ concreteTypeOf(type, [Type.f32])
Expand Down Expand Up @@ -344,7 +345,7 @@ g.test('early_eval_errors')
t,
builtin,
/* expectedResult */ t.params.low < t.params.high,
[f32(0), f32(t.params.low), f32(t.params.high)],
[f32(t.params.low), f32(t.params.high), f32(0)],
t.params.stage
);
});

0 comments on commit 24725f3

Please sign in to comment.