From f06583ca7d6e69be3aea9939ebe52cfe74ce76e1 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 29 Mar 2021 00:37:29 -0400 Subject: [PATCH] [spv-in] change const indexes to signed int --- src/front/spv/mod.rs | 32 +++++++++++++++++++++++++++----- tests/out/quad-vert.msl.snap | 12 ++++++------ tests/out/shadow.ron.snap | 8 ++++---- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index 6bcab546a8..3242558131 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -1503,11 +1503,33 @@ impl> Parser { inst.expect(5)?; self.parse_expr_binary_op(expressions, crate::BinaryOperator::LogicalAnd)?; } - op if inst.op >= Op::IEqual && inst.op <= Op::FUnordGreaterThanEqual => { + Op::IEqual + | Op::INotEqual + | Op::UGreaterThan + | Op::SGreaterThan + | Op::UGreaterThanEqual + | Op::SGreaterThanEqual + | Op::ULessThan + | Op::SLessThan + | Op::ULessThanEqual + | Op::SLessThanEqual + | Op::FOrdEqual + | Op::FUnordEqual + | Op::FOrdNotEqual + | Op::FUnordNotEqual + | Op::FOrdLessThan + | Op::FUnordLessThan + | Op::FOrdGreaterThan + | Op::FUnordGreaterThan + | Op::FOrdLessThanEqual + | Op::FUnordLessThanEqual + | Op::FOrdGreaterThanEqual + | Op::FUnordGreaterThanEqual => { inst.expect(5)?; - self.parse_expr_binary_op(expressions, map_binary_operator(op)?)?; + let operator = map_binary_operator(inst.op)?; + self.parse_expr_binary_op(expressions, operator)?; } - op if inst.op >= Op::Any && inst.op <= Op::IsNormal => { + Op::Any | Op::All | Op::IsNan | Op::IsInf | Op::IsFinite | Op::IsNormal => { inst.expect(4)?; let result_type_id = self.next()?; let result_id = self.next()?; @@ -1516,7 +1538,7 @@ impl> Parser { let arg_lexp = self.lookup_expression.lookup(arg_id)?; let expr = crate::Expression::Relational { - fun: map_relational_fun(op)?, + fun: map_relational_fun(inst.op)?, argument: arg_lexp.handle, }; self.lookup_expression.insert( @@ -1772,7 +1794,7 @@ impl> Parser { specialization: None, inner: crate::ConstantInner::Scalar { width: 4, - value: crate::ScalarValue::Uint(i), + value: crate::ScalarValue::Sint(i), }, }); self.index_constants.push(handle); diff --git a/tests/out/quad-vert.msl.snap b/tests/out/quad-vert.msl.snap index 80b8111412..716b77bbb1 100644 --- a/tests/out/quad-vert.msl.snap +++ b/tests/out/quad-vert.msl.snap @@ -5,12 +5,12 @@ expression: msl #include #include -constexpr constant unsigned const_0u = 0u; -constexpr constant unsigned const_1u = 1u; -constexpr constant unsigned const_2u = 2u; -constexpr constant unsigned const_3u = 3u; -constexpr constant unsigned const_1u1 = 1u; constexpr constant int const_0i = 0; +constexpr constant int const_1i = 1; +constexpr constant int const_2i = 2; +constexpr constant int const_3i = 3; +constexpr constant unsigned const_1u = 1u; +constexpr constant int const_0i1 = 0; constexpr constant float const_0f = 0.0; constexpr constant float const_1f = 1.0; typedef float type; @@ -19,7 +19,7 @@ typedef thread type1 *type2; typedef thread type1 *type3; typedef metal::float4 type4; typedef uint type5; -typedef type type6[const_1u1]; +typedef type type6[const_1u]; struct gl_PerVertex { type4 gl_Position; type gl_PointSize; diff --git a/tests/out/shadow.ron.snap b/tests/out/shadow.ron.snap index 055887ff19..7c05bcee1c 100644 --- a/tests/out/shadow.ron.snap +++ b/tests/out/shadow.ron.snap @@ -458,7 +458,7 @@ expression: output specialization: None, inner: Scalar( width: 4, - value: Uint(0), + value: Sint(0), ), ), ( @@ -466,7 +466,7 @@ expression: output specialization: None, inner: Scalar( width: 4, - value: Uint(1), + value: Sint(1), ), ), ( @@ -474,7 +474,7 @@ expression: output specialization: None, inner: Scalar( width: 4, - value: Uint(2), + value: Sint(2), ), ), ( @@ -482,7 +482,7 @@ expression: output specialization: None, inner: Scalar( width: 4, - value: Uint(3), + value: Sint(3), ), ), (