[spv-in] change const indexes to signed int

This commit is contained in:
Dzmitry Malyshau 2021-03-29 00:37:29 -04:00 committed by Dzmitry Malyshau
parent ca6876b7a0
commit f06583ca7d
3 changed files with 37 additions and 15 deletions

View File

@ -1503,11 +1503,33 @@ impl<I: Iterator<Item = u32>> Parser<I> {
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<I: Iterator<Item = u32>> Parser<I> {
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<I: Iterator<Item = u32>> Parser<I> {
specialization: None,
inner: crate::ConstantInner::Scalar {
width: 4,
value: crate::ScalarValue::Uint(i),
value: crate::ScalarValue::Sint(i),
},
});
self.index_constants.push(handle);

View File

@ -5,12 +5,12 @@ expression: msl
#include <metal_stdlib>
#include <simd/simd.h>
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;

View File

@ -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),
),
),
(