|
| 1 | +// RUN: %dxc -T vs_6_0 %s -E main | FileCheck %s |
| 2 | +// RUN: not %dxc -T vs_6_0 %s -E main -DNO_FOLD 2>&1 | FileCheck %s --check-prefixes=NO_FOLD |
| 3 | + |
| 4 | +// The code path for this case asserts, but the assert does not indicate a |
| 5 | +// serious problem with internal state. The invalid overload will either be |
| 6 | +// constant folded away, or caught by the validator. |
| 7 | +// UNSUPPORTED: asserts |
| 8 | + |
| 9 | +// Ensure fmod is constant evaluated during codegen, or dxil const eval |
| 10 | +// TODO: handle fp specials properly! |
| 11 | + |
| 12 | +RWBuffer<float4> results : register(u0); |
| 13 | + |
| 14 | +[shader("vertex")] |
| 15 | +void main(bool b : B) { |
| 16 | + uint i = 0; |
| 17 | + |
| 18 | + // Literal float |
| 19 | + // 2.5, -2.5, 2.5, -2.5 |
| 20 | + // CHECK: call void @dx.op.bufferStore.f32(i32 69, %dx.types.Handle %{{.+}}, i32 0, i32 undef, float 2.500000e+00, float -2.500000e+00, float 2.500000e+00, float -2.500000e+00, i8 15) |
| 21 | + results[i++] = float4(fmod(5.5, 3.0), |
| 22 | + fmod(-5.5, 3.0), |
| 23 | + fmod(5.5, -3.0), |
| 24 | + fmod(-5.5, -3.0)); |
| 25 | + |
| 26 | + // Explicit float |
| 27 | + // 2.5, -2.5, 2.5, -2.5 |
| 28 | + // CHECK: call void @dx.op.bufferStore.f32(i32 69, %dx.types.Handle %{{.+}}, i32 1, i32 undef, float 2.500000e+00, float -2.500000e+00, float 2.500000e+00, float -2.500000e+00, i8 15) |
| 29 | + results[i++] = float4(fmod(5.5f, 3.0f), |
| 30 | + fmod(-5.5f, 3.0f), |
| 31 | + fmod(5.5f, -3.0f), |
| 32 | + fmod(-5.5f, -3.0f)); |
| 33 | + |
| 34 | +#ifdef NO_FOLD |
| 35 | + // Currently, we rely on constant folding of DXIL ops to get rid of illegal |
| 36 | + // double overloads. If this doesn't happen, we expect a validation error. |
| 37 | + // Ternary operator can return literal type, while not being foldable due |
| 38 | + // non-constant condition. |
| 39 | + // NO_FOLD: error: validation errors |
| 40 | + // NO_FOLD: error: DXIL intrinsic overload must be valid. |
| 41 | + float result = fmod(-5.5, b ? 1.5 : 0.5); |
| 42 | + results[i++] = float4(result, 0, 0, 0); |
| 43 | +#endif // NO_FOLD |
| 44 | +} |
0 commit comments