mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[glsl-in] Check type dimensions in function calls
This commit is contained in:
committed by
Dzmitry Malyshau
parent
9e61390626
commit
105a2ae5e1
@@ -696,20 +696,54 @@ impl Program<'_> {
|
||||
let decl_inner = &self.module.types[*decl_arg].inner;
|
||||
let call_inner = self.resolve_type(ctx, call_arg.0, call_arg.1)?;
|
||||
|
||||
if decl_inner != call_inner {
|
||||
exact = false;
|
||||
if decl_inner == call_inner {
|
||||
continue;
|
||||
}
|
||||
|
||||
match (
|
||||
decl_inner.scalar_kind().and_then(type_power),
|
||||
call_inner.scalar_kind().and_then(type_power),
|
||||
) {
|
||||
(Some(decl_power), Some(call_power)) => {
|
||||
if decl_power < call_power {
|
||||
continue 'outer;
|
||||
}
|
||||
}
|
||||
_ => continue 'outer,
|
||||
exact = false;
|
||||
|
||||
let (decl_kind, call_kind) = match (decl_inner, call_inner) {
|
||||
(
|
||||
&TypeInner::Scalar {
|
||||
kind: decl_kind, ..
|
||||
},
|
||||
&TypeInner::Scalar {
|
||||
kind: call_kind, ..
|
||||
},
|
||||
) => (decl_kind, call_kind),
|
||||
(
|
||||
&TypeInner::Vector {
|
||||
kind: decl_kind,
|
||||
size: decl_size,
|
||||
..
|
||||
},
|
||||
&TypeInner::Vector {
|
||||
kind: call_kind,
|
||||
size: call_size,
|
||||
..
|
||||
},
|
||||
) if decl_size == call_size => (decl_kind, call_kind),
|
||||
(
|
||||
&TypeInner::Matrix {
|
||||
rows: decl_rows,
|
||||
columns: decl_columns,
|
||||
..
|
||||
},
|
||||
&TypeInner::Matrix {
|
||||
rows: call_rows,
|
||||
columns: call_columns,
|
||||
..
|
||||
},
|
||||
) if decl_columns == call_columns && decl_rows == call_rows => {
|
||||
(ScalarKind::Float, ScalarKind::Float)
|
||||
}
|
||||
_ => continue 'outer,
|
||||
};
|
||||
|
||||
match (type_power(decl_kind), type_power(call_kind)) {
|
||||
(Some(decl_power), Some(call_power))
|
||||
if decl_power > call_power => {}
|
||||
_ => continue 'outer,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,14 @@ void exact(int a) {}
|
||||
void implicit(float a) {}
|
||||
void implicit(int a) {}
|
||||
|
||||
// All satisfy the kind condition but they have different dimensions
|
||||
void implicit_dims(float v) { }
|
||||
void implicit_dims(vec2 v) { }
|
||||
void implicit_dims(vec3 v) { }
|
||||
void implicit_dims(vec4 v) { }
|
||||
|
||||
void main() {
|
||||
exact(1);
|
||||
implicit(1u);
|
||||
implicit_dims(ivec3(1));
|
||||
}
|
||||
|
||||
@@ -26,9 +26,38 @@ fn implicit1(a6: i32) {
|
||||
return;
|
||||
}
|
||||
|
||||
fn implicit_dims(v: f32) {
|
||||
var v1: f32;
|
||||
|
||||
v1 = v;
|
||||
return;
|
||||
}
|
||||
|
||||
fn implicit_dims1(v2: vec2<f32>) {
|
||||
var v3: vec2<f32>;
|
||||
|
||||
v3 = v2;
|
||||
return;
|
||||
}
|
||||
|
||||
fn implicit_dims2(v4: vec3<f32>) {
|
||||
var v5: vec3<f32>;
|
||||
|
||||
v5 = v4;
|
||||
return;
|
||||
}
|
||||
|
||||
fn implicit_dims3(v6: vec4<f32>) {
|
||||
var v7: vec4<f32>;
|
||||
|
||||
v7 = v6;
|
||||
return;
|
||||
}
|
||||
|
||||
fn main1() {
|
||||
exact1(1);
|
||||
implicit(f32(1u));
|
||||
implicit_dims2(vec3<f32>(vec3<i32>(1)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user