2021-08-22 19:52:27 +00:00
|
|
|
// Tests for `naga::back::BoundsCheckPolicy::ReadZeroSkipWrite`.
|
2021-05-27 22:02:38 +00:00
|
|
|
|
|
|
|
struct Globals {
|
2022-03-12 21:48:10 +00:00
|
|
|
a: array<f32, 10>,
|
|
|
|
v: vec4<f32>,
|
|
|
|
m: mat3x4<f32>,
|
|
|
|
d: array<f32>,
|
2022-03-27 05:35:08 +00:00
|
|
|
}
|
2021-05-27 22:02:38 +00:00
|
|
|
|
2022-01-19 15:33:06 +00:00
|
|
|
@group(0) @binding(0) var<storage, read_write> globals: Globals;
|
2021-05-27 22:02:38 +00:00
|
|
|
|
|
|
|
fn index_array(i: i32) -> f32 {
|
|
|
|
return globals.a[i];
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:59 +00:00
|
|
|
fn index_dynamic_array(i: i32) -> f32 {
|
|
|
|
return globals.d[i];
|
|
|
|
}
|
|
|
|
|
2021-05-27 22:02:38 +00:00
|
|
|
fn index_vector(i: i32) -> f32 {
|
|
|
|
return globals.v[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
fn index_vector_by_value(v: vec4<f32>, i: i32) -> f32 {
|
|
|
|
return v[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
fn index_matrix(i: i32) -> vec4<f32> {
|
|
|
|
return globals.m[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
fn index_twice(i: i32, j: i32) -> f32 {
|
|
|
|
return globals.m[i][j];
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:59 +00:00
|
|
|
fn index_expensive(i: i32) -> f32 {
|
|
|
|
return globals.a[i32(sin(f32(i) / 100.0) * 100.0)];
|
|
|
|
}
|
|
|
|
|
|
|
|
fn index_in_bounds() -> f32 {
|
|
|
|
return globals.a[9] + globals.v[3] + globals.m[2][3];
|
|
|
|
}
|
|
|
|
|
2021-05-27 22:02:38 +00:00
|
|
|
fn set_array(i: i32, v: f32) {
|
|
|
|
globals.a[i] = v;
|
|
|
|
}
|
|
|
|
|
2021-10-19 16:37:59 +00:00
|
|
|
fn set_dynamic_array(i: i32, v: f32) {
|
|
|
|
globals.d[i] = v;
|
|
|
|
}
|
|
|
|
|
2021-05-27 22:02:38 +00:00
|
|
|
fn set_vector(i: i32, v: f32) {
|
|
|
|
globals.v[i] = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_matrix(i: i32, v: vec4<f32>) {
|
|
|
|
globals.m[i] = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_index_twice(i: i32, j: i32, v: f32) {
|
|
|
|
globals.m[i][j] = v;
|
|
|
|
}
|
2021-10-19 16:37:59 +00:00
|
|
|
|
|
|
|
fn set_expensive(i: i32, v: f32) {
|
|
|
|
globals.a[i32(sin(f32(i) / 100.0) * 100.0)] = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_in_bounds(v: f32) {
|
|
|
|
globals.a[9] = v;
|
|
|
|
globals.v[3] = v;
|
|
|
|
globals.m[2][3] = v;
|
|
|
|
}
|
2024-10-01 19:02:24 +00:00
|
|
|
|
|
|
|
fn index_dynamic_array_constant_index() -> f32 {
|
|
|
|
return globals.d[1000];
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_dynamic_array_constant_index(v: f32) {
|
|
|
|
globals.d[1000] = v;
|
|
|
|
}
|