mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
validation: limit dynamic indexes to references to matrices and arrays
https://github.com/gpuweb/gpuweb/pull/1801 indexes must be of type 'i32' or 'u32' Bug: tint:867 Change-Id: Ie5bfacf87af5a06d5428dc510145e96fb156c42e Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54720 Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
@@ -52,7 +52,7 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) {
|
||||
auto* src = R"(
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
var<private> b : array<f32, 5>;
|
||||
var<private> b : array<i32, 5>;
|
||||
|
||||
var<private> i : u32;
|
||||
|
||||
@@ -64,7 +64,7 @@ fn f() {
|
||||
auto* expect = R"(
|
||||
var<private> a : array<f32, 3>;
|
||||
|
||||
var<private> b : array<f32, 5>;
|
||||
var<private> b : array<i32, 5>;
|
||||
|
||||
var<private> i : u32;
|
||||
|
||||
|
||||
@@ -225,58 +225,6 @@ let module_str : S = S(1, 2.0, 3);
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PromoteInitializersToConstVarTest, Bug406Array) {
|
||||
// See crbug.com/tint/406
|
||||
auto* src = R"(
|
||||
[[block]]
|
||||
struct Uniforms {
|
||||
transform : mat2x2<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> ubo : Uniforms;
|
||||
|
||||
[[builtin(vertex_index)]] var<in> vertex_index : u32;
|
||||
|
||||
[[builtin(position)]] var<out> position : vec4<f32>;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main() {
|
||||
let transform : mat2x2<f32> = ubo.transform;
|
||||
var coord : vec2<f32> = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
vec2<f32>(-1.0, -1.0)
|
||||
)[vertex_index];
|
||||
position = vec4<f32>(transform * coord, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
[[block]]
|
||||
struct Uniforms {
|
||||
transform : mat2x2<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> ubo : Uniforms;
|
||||
|
||||
[[builtin(vertex_index)]] var<in> vertex_index : u32;
|
||||
|
||||
[[builtin(position)]] var<out> position : vec4<f32>;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main() {
|
||||
let transform : mat2x2<f32> = ubo.transform;
|
||||
let tint_symbol : array<vec2<f32>, 3> = array<vec2<f32>, 3>(vec2<f32>(-1.0, 1.0), vec2<f32>(1.0, 1.0), vec2<f32>(-1.0, -1.0));
|
||||
var coord : vec2<f32> = tint_symbol[vertex_index];
|
||||
position = vec4<f32>((transform * coord), 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto got = Run<PromoteInitializersToConstVar>(src);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(PromoteInitializersToConstVarTest, EmptyModule) {
|
||||
auto* src = "";
|
||||
auto* expect = "";
|
||||
|
||||
Reference in New Issue
Block a user