[wgsl-in] fix incr/decr not matching ValuePointer

This commit is contained in:
teoxoy
2022-05-11 21:13:57 +02:00
committed by Dzmitry Malyshau
parent 8db27c49f8
commit fea33c682e
7 changed files with 534 additions and 493 deletions

View File

@@ -3353,25 +3353,26 @@ impl Parser {
let _ = context.resolve_type(reference.handle)?;
let ty = context.typifier.get(reference.handle, context.types);
let constant_inner = match ty.canonical_form(context.types) {
Some(crate::TypeInner::ValuePointer {
let (kind, width) = match *ty {
crate::TypeInner::ValuePointer {
size: None,
kind,
width,
space: _,
}) => crate::ConstantInner::Scalar {
width,
value: match kind {
crate::ScalarKind::Sint => crate::ScalarValue::Sint(1),
crate::ScalarKind::Uint => crate::ScalarValue::Uint(1),
_ => {
return Err(Error::BadIncrDecrReferenceType(lhs_span));
}
},
..
} => (kind, width),
crate::TypeInner::Pointer { base, .. } => match context.types[base].inner {
crate::TypeInner::Scalar { kind, width } => (kind, width),
_ => return Err(Error::BadIncrDecrReferenceType(lhs_span)),
},
_ => return Err(Error::BadIncrDecrReferenceType(lhs_span)),
};
let constant_inner = crate::ConstantInner::Scalar {
width,
value: match kind {
crate::ScalarKind::Sint => crate::ScalarValue::Sint(1),
crate::ScalarKind::Uint => crate::ScalarValue::Uint(1),
_ => return Err(Error::BadIncrDecrReferenceType(lhs_span)),
},
_ => {
return Err(Error::BadIncrDecrReferenceType(lhs_span));
}
};
let constant = context.constants.append(
crate::Constant {

View File

@@ -277,6 +277,10 @@ fn assignment() {
a++;
a--;
var vec0: vec3<i32> = vec3<i32>();
vec0[1]++;
vec0[1]--;
}
@compute @workgroup_size(1)

View File

@@ -196,6 +196,7 @@ void comparison() {
void assignment() {
int a = 1;
ivec3 vec0_ = ivec3(0, 0, 0);
int _e6 = a;
a = (_e6 + 1);
int _e9 = a;
@@ -222,6 +223,10 @@ void assignment() {
a = (_e36 + 1);
int _e39 = a;
a = (_e39 - 1);
int _e46 = vec0_.y;
vec0_.y = (_e46 + 1);
int _e51 = vec0_.y;
vec0_.y = (_e51 - 1);
return;
}

View File

@@ -224,6 +224,7 @@ void comparison()
void assignment()
{
int a = 1;
int3 vec0_ = int3(0, 0, 0);
int _expr6 = a;
a = (_expr6 + 1);
@@ -251,6 +252,10 @@ void assignment()
a = (_expr36 + 1);
int _expr39 = a;
a = (_expr39 - 1);
int _expr46 = vec0_.y;
vec0_.y = (_expr46 + 1);
int _expr51 = vec0_.y;
vec0_.y = (_expr51 - 1);
return;
}

View File

@@ -28,6 +28,7 @@ constant metal::float3 const_type_4_ = {0.0, 0.0, 0.0};
constant metal::float3x3 const_type_14_ = {const_type_4_, const_type_4_, const_type_4_};
constant metal::float4x3 const_type_15_ = {const_type_4_, const_type_4_, const_type_4_, const_type_4_};
constant metal::float3x4 const_type_16_ = {const_type, const_type, const_type};
constant metal::int3 const_type_17_ = {0, 0, 0};
metal::float4 builtins(
) {
@@ -225,6 +226,7 @@ void comparison(
void assignment(
) {
int a = 1;
metal::int3 vec0_ = const_type_17_;
int _e6 = a;
a = _e6 + 1;
int _e9 = a;
@@ -251,6 +253,10 @@ void assignment(
a = _e36 + 1;
int _e39 = a;
a = _e39 - 1;
int _e46 = vec0_.y;
vec0_.y = _e46 + 1;
int _e51 = vec0_.y;
vec0_.y = _e51 - 1;
return;
}

File diff suppressed because it is too large Load Diff

View File

@@ -194,6 +194,7 @@ fn comparison() {
fn assignment() {
var a: i32 = 1;
var vec0_: vec3<i32> = vec3<i32>(0, 0, 0);
let _e6 = a;
a = (_e6 + 1);
@@ -221,6 +222,10 @@ fn assignment() {
a = (_e36 + 1);
let _e39 = a;
a = (_e39 - 1);
let _e46 = vec0_.y;
vec0_.y = (_e46 + 1);
let _e51 = vec0_.y;
vec0_.y = (_e51 - 1);
return;
}