Require vertex shaders to return builtin(position)

Fixup many tests that were just returning void.

Change-Id: Ic93db5b187c679dc1c24a356b48a64e41ba9a823
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48560
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2021-04-21 16:13:42 +00:00
committed by Commit Bot service account
parent 98c2cf0e91
commit 2dd393729c
26 changed files with 357 additions and 281 deletions

View File

@@ -32,7 +32,7 @@ struct SB {
var<storage> sb : [[access(read)]] SB;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var len : u32 = arrayLength(sb.arr);
}
@@ -50,7 +50,7 @@ fn tint_symbol(buffer : SB, result : ptr<function, u32>)
var<storage> sb : [[access(read)]] SB;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var tint_symbol_1 : u32 = 0u;
tint_symbol(sb, tint_symbol_1);
@@ -74,7 +74,7 @@ struct SB {
var<storage> sb : [[access(read)]] SB;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var a : u32 = arrayLength(sb.arr);
var b : u32 = arrayLength(sb.arr);
@@ -94,7 +94,7 @@ fn tint_symbol(buffer : SB, result : ptr<function, u32>)
var<storage> sb : [[access(read)]] SB;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var tint_symbol_1 : u32 = 0u;
tint_symbol(sb, tint_symbol_1);
@@ -121,7 +121,7 @@ struct SB {
var<storage> sb : [[access(read)]] SB;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var len : u32 = arrayLength(sb.arr);
}
@@ -140,7 +140,7 @@ fn tint_symbol(buffer : SB, result : ptr<function, u32>)
var<storage> sb : [[access(read)]] SB;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var tint_symbol_1 : u32 = 0u;
tint_symbol(sb, tint_symbol_1);
@@ -164,7 +164,7 @@ struct SB {
var<storage> sb : [[access(read)]] SB;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
if (true) {
var len : u32 = arrayLength(sb.arr);
@@ -188,7 +188,7 @@ fn tint_symbol(buffer : SB, result : ptr<function, u32>)
var<storage> sb : [[access(read)]] SB;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
if (true) {
var tint_symbol_1 : u32 = 0u;
@@ -229,7 +229,7 @@ var<storage> sb1 : [[access(read)]] SB1;
var<storage> sb2 : [[access(read)]] SB2;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var len1 : u32 = arrayLength(sb1.arr1);
var len2 : u32 = arrayLength(sb2.arr2);
@@ -260,7 +260,7 @@ var<storage> sb1 : [[access(read)]] SB1;
var<storage> sb2 : [[access(read)]] SB2;
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var tint_symbol_1 : u32 = 0u;
tint_symbol(sb1, tint_symbol_1);

View File

@@ -28,8 +28,9 @@ fn non_entry_a() {
}
[[stage(vertex)]]
fn entry() {
fn entry() -> [[builtin(position)]] vec4<f32> {
var builtin_assignments_should_happen_before_this : f32;
return vec4<f32>();
}
fn non_entry_b() {
@@ -43,42 +44,10 @@ fn non_entry_a() {
}
[[stage(vertex)]]
fn entry() {
fn entry() -> [[builtin(position)]] vec4<f32> {
tint_pointsize = 1.0;
var builtin_assignments_should_happen_before_this : f32;
}
fn non_entry_b() {
}
)";
auto got = Run<EmitVertexPointSize>(src);
EXPECT_EQ(expect, str(got));
}
TEST_F(EmitVertexPointSizeTest, VertexStageEmpty) {
auto* src = R"(
fn non_entry_a() {
}
[[stage(vertex)]]
fn entry() {
}
fn non_entry_b() {
}
)";
auto* expect = R"(
[[builtin(pointsize)]] var<out> tint_pointsize : f32;
fn non_entry_a() {
}
[[stage(vertex)]]
fn entry() {
tint_pointsize = 1.0;
return vec4<f32>();
}
fn non_entry_b() {
@@ -119,8 +88,9 @@ fn compute_entry() {
TEST_F(EmitVertexPointSizeTest, AttemptSymbolCollision) {
auto* src = R"(
[[stage(vertex)]]
fn entry() {
fn entry() -> [[builtin(position)]] vec4<f32> {
var tint_pointsize : f32;
return vec4<f32>();
}
)";
@@ -128,9 +98,10 @@ fn entry() {
[[builtin(pointsize)]] var<out> tint_pointsize_1 : f32;
[[stage(vertex)]]
fn entry() {
fn entry() -> [[builtin(position)]] vec4<f32> {
tint_pointsize_1 = 1.0;
var tint_pointsize : f32;
return vec4<f32>();
}
)";

View File

@@ -52,8 +52,9 @@ fn test(vert_idx : u32) -> u32 {
}
[[stage(vertex)]]
fn entry([[builtin(vertex_index)]] vert_idx : u32) {
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
test(vert_idx);
return vec4<f32>();
}
)";
@@ -70,8 +71,9 @@ fn test(vert_idx : u32) -> u32 {
}
[[stage(vertex)]]
fn entry([[builtin(vertex_index)]] vert_idx : u32) {
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
test((vert_idx + tint_symbol_1.first_vertex_index));
return vec4<f32>();
}
)";
@@ -97,8 +99,9 @@ fn test(inst_idx : u32) -> u32 {
}
[[stage(vertex)]]
fn entry([[builtin(instance_index)]] inst_idx : u32) {
fn entry([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
test(inst_idx);
return vec4<f32>();
}
)";
@@ -115,8 +118,9 @@ fn test(inst_idx : u32) -> u32 {
}
[[stage(vertex)]]
fn entry([[builtin(instance_index)]] inst_idx : u32) {
fn entry([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
test((inst_idx + tint_symbol_1.first_instance_index));
return vec4<f32>();
}
)";
@@ -147,8 +151,9 @@ struct Inputs {
};
[[stage(vertex)]]
fn entry(inputs : Inputs) {
fn entry(inputs : Inputs) -> [[builtin(position)]] vec4<f32> {
test(inputs.instance_idx, inputs.vert_idx);
return vec4<f32>();
}
)";
@@ -173,8 +178,9 @@ struct Inputs {
};
[[stage(vertex)]]
fn entry(inputs : Inputs) {
fn entry(inputs : Inputs) -> [[builtin(position)]] vec4<f32> {
test((inputs.instance_idx + tint_symbol_1.first_instance_index), (inputs.vert_idx + tint_symbol_1.first_vertex_index));
return vec4<f32>();
}
)";
@@ -204,8 +210,9 @@ fn func2(vert_idx : u32) -> u32 {
}
[[stage(vertex)]]
fn entry([[builtin(vertex_index)]] vert_idx : u32) {
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
func2(vert_idx);
return vec4<f32>();
}
)";
@@ -226,8 +233,9 @@ fn func2(vert_idx : u32) -> u32 {
}
[[stage(vertex)]]
fn entry([[builtin(vertex_index)]] vert_idx : u32) {
fn entry([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
func2((vert_idx + tint_symbol_1.first_vertex_index));
return vec4<f32>();
}
)";
@@ -253,18 +261,21 @@ fn func(i : u32) -> u32 {
}
[[stage(vertex)]]
fn entry_a([[builtin(vertex_index)]] vert_idx : u32) {
fn entry_a([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
func(vert_idx);
return vec4<f32>();
}
[[stage(vertex)]]
fn entry_b([[builtin(vertex_index)]] vert_idx : u32, [[builtin(instance_index)]] inst_idx : u32) {
fn entry_b([[builtin(vertex_index)]] vert_idx : u32, [[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
func(vert_idx + inst_idx);
return vec4<f32>();
}
[[stage(vertex)]]
fn entry_c([[builtin(instance_index)]] inst_idx : u32) {
fn entry_c([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
func(inst_idx);
return vec4<f32>();
}
)";
@@ -282,18 +293,21 @@ fn func(i : u32) -> u32 {
}
[[stage(vertex)]]
fn entry_a([[builtin(vertex_index)]] vert_idx : u32) {
fn entry_a([[builtin(vertex_index)]] vert_idx : u32) -> [[builtin(position)]] vec4<f32> {
func((vert_idx + tint_symbol_1.first_vertex_index));
return vec4<f32>();
}
[[stage(vertex)]]
fn entry_b([[builtin(vertex_index)]] vert_idx : u32, [[builtin(instance_index)]] inst_idx : u32) {
fn entry_b([[builtin(vertex_index)]] vert_idx : u32, [[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
func(((vert_idx + tint_symbol_1.first_vertex_index) + (inst_idx + tint_symbol_1.first_instance_index)));
return vec4<f32>();
}
[[stage(vertex)]]
fn entry_c([[builtin(instance_index)]] inst_idx : u32) {
fn entry_c([[builtin(instance_index)]] inst_idx : u32) -> [[builtin(position)]] vec4<f32> {
func((inst_idx + tint_symbol_1.first_instance_index));
return vec4<f32>();
}
)";
@@ -316,6 +330,8 @@ TEST_F(FirstIndexOffsetTest, OLD_BasicModuleVertexIndex) {
auto* src = R"(
[[builtin(vertex_index)]] var<in> vert_idx : u32;
[[builtin(position)]] var<out> pos : vec4<f32>;
fn test() -> u32 {
return vert_idx;
}
@@ -323,6 +339,7 @@ fn test() -> u32 {
[[stage(vertex)]]
fn entry() {
test();
pos = vec4<f32>();
}
)";
@@ -336,6 +353,8 @@ struct tint_symbol {
[[builtin(vertex_index)]] var<in> vert_idx : u32;
[[builtin(position)]] var<out> pos : vec4<f32>;
fn test() -> u32 {
return (vert_idx + tint_symbol_1.first_vertex_index);
}
@@ -343,6 +362,7 @@ fn test() -> u32 {
[[stage(vertex)]]
fn entry() {
test();
pos = vec4<f32>();
}
)";
@@ -363,6 +383,8 @@ TEST_F(FirstIndexOffsetTest, OLD_BasicModuleInstanceIndex) {
auto* src = R"(
[[builtin(instance_index)]] var<in> inst_idx : u32;
[[builtin(position)]] var<out> pos : vec4<f32>;
fn test() -> u32 {
return inst_idx;
}
@@ -370,6 +392,7 @@ fn test() -> u32 {
[[stage(vertex)]]
fn entry() {
test();
pos = vec4<f32>();
}
)";
@@ -383,6 +406,8 @@ struct tint_symbol {
[[builtin(instance_index)]] var<in> inst_idx : u32;
[[builtin(position)]] var<out> pos : vec4<f32>;
fn test() -> u32 {
return (inst_idx + tint_symbol_1.first_instance_index);
}
@@ -390,6 +415,7 @@ fn test() -> u32 {
[[stage(vertex)]]
fn entry() {
test();
pos = vec4<f32>();
}
)";
@@ -410,6 +436,7 @@ TEST_F(FirstIndexOffsetTest, OLD_BasicModuleBothIndex) {
auto* src = R"(
[[builtin(instance_index)]] var<in> instance_idx : u32;
[[builtin(vertex_index)]] var<in> vert_idx : u32;
[[builtin(position)]] var<out> pos : vec4<f32>;
fn test() -> u32 {
return instance_idx + vert_idx;
@@ -418,6 +445,7 @@ fn test() -> u32 {
[[stage(vertex)]]
fn entry() {
test();
pos = vec4<f32>();
}
)";
@@ -434,6 +462,8 @@ struct tint_symbol {
[[builtin(vertex_index)]] var<in> vert_idx : u32;
[[builtin(position)]] var<out> pos : vec4<f32>;
fn test() -> u32 {
return ((instance_idx + tint_symbol_1.first_instance_index) + (vert_idx + tint_symbol_1.first_vertex_index));
}
@@ -441,6 +471,7 @@ fn test() -> u32 {
[[stage(vertex)]]
fn entry() {
test();
pos = vec4<f32>();
}
)";
@@ -460,6 +491,7 @@ fn entry() {
TEST_F(FirstIndexOffsetTest, OLD_NestedCalls) {
auto* src = R"(
[[builtin(vertex_index)]] var<in> vert_idx : u32;
[[builtin(position)]] var<out> pos : vec4<f32>;
fn func1() -> u32 {
return vert_idx;
@@ -472,6 +504,7 @@ fn func2() -> u32 {
[[stage(vertex)]]
fn entry() {
func2();
pos = vec4<f32>();
}
)";
@@ -485,6 +518,8 @@ struct tint_symbol {
[[builtin(vertex_index)]] var<in> vert_idx : u32;
[[builtin(position)]] var<out> pos : vec4<f32>;
fn func1() -> u32 {
return (vert_idx + tint_symbol_1.first_vertex_index);
}
@@ -496,6 +531,7 @@ fn func2() -> u32 {
[[stage(vertex)]]
fn entry() {
func2();
pos = vec4<f32>();
}
)";

View File

@@ -130,7 +130,7 @@ void Hlsl::AddEmptyEntryPoint(CloneContext& ctx) const {
ctx.dst->Func(
ctx.dst->Symbols().New("tint_unused_entry_point"), {},
ctx.dst->ty.void_(), {},
{ctx.dst->create<ast::StageDecoration>(ast::PipelineStage::kVertex)});
{ctx.dst->create<ast::StageDecoration>(ast::PipelineStage::kCompute)});
}
} // namespace transform

View File

@@ -24,7 +24,7 @@ using HlslTest = TransformTest;
TEST_F(HlslTest, PromoteArrayInitializerToConstVar_Basic) {
auto* src = R"(
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var f0 : f32 = 1.0;
var f1 : f32 = 2.0;
@@ -35,7 +35,7 @@ fn main() {
)";
auto* expect = R"(
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var f0 : f32 = 1.0;
var f1 : f32 = 2.0;
@@ -59,7 +59,7 @@ struct S {
c : vec3<f32>;
};
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var x : f32 = S(1, 2.0, vec3<f32>()).b;
}
@@ -72,7 +72,7 @@ struct S {
c : vec3<f32>;
};
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
let tint_symbol : S = S(1, 2.0, vec3<f32>());
var x : f32 = tint_symbol.b;
@@ -86,14 +86,14 @@ fn main() {
TEST_F(HlslTest, PromoteArrayInitializerToConstVar_ArrayInArray) {
auto* src = R"(
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var i : f32 = array<array<f32, 2>, 2>(array<f32, 2>(1.0, 2.0), array<f32, 2>(3.0, 4.0))[0][1];
}
)";
auto* expect = R"(
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
let tint_symbol : array<f32, 2> = array<f32, 2>(1.0, 2.0);
let tint_symbol_1 : array<f32, 2> = array<f32, 2>(3.0, 4.0);
@@ -123,7 +123,7 @@ struct S3 {
a : S2;
};
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var x : i32 = S3(S2(1, S1(2), 3)).a.b.a;
}
@@ -144,7 +144,7 @@ struct S3 {
a : S2;
};
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
let tint_symbol : S1 = S1(2);
let tint_symbol_1 : S2 = S2(1, tint_symbol, 3);
@@ -168,7 +168,7 @@ struct S2 {
a : array<S1, 3>;
};
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var x : i32 = S2(array<S1, 3>(S1(1), S1(2), S1(3))).a[1].a;
}
@@ -183,7 +183,7 @@ struct S2 {
a : array<S1, 3>;
};
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
let tint_symbol : S1 = S1(1);
let tint_symbol_1 : S1 = S1(2);
@@ -207,7 +207,7 @@ struct S {
c : i32;
};
[[stage(vertex)]]
[[stage(compute)]]
fn main() {
var local_arr : array<f32, 4> = array<f32, 4>(0.0, 1.0, 2.0, 3.0);
var local_str : S = S(1, 2.0, 3);
@@ -281,7 +281,7 @@ TEST_F(HlslTest, AddEmptyEntryPoint) {
auto* src = R"()";
auto* expect = R"(
[[stage(vertex)]]
[[stage(compute)]]
fn tint_unused_entry_point() {
}
)";

View File

@@ -49,8 +49,9 @@ fn test() -> u32 {
}
[[stage(vertex)]]
fn entry() {
fn entry() -> [[builtin(position)]] vec4<f32> {
test();
return vec4<f32>();
}
)";
@@ -62,8 +63,9 @@ fn tint_symbol_1() -> u32 {
}
[[stage(vertex)]]
fn tint_symbol_2() {
fn tint_symbol_2() -> [[builtin(position)]] vec4<f32> {
tint_symbol_1();
return vec4<f32>();
}
)";

View File

@@ -307,8 +307,8 @@ struct Interface {
[[location(1)]] value : f32;
};
[[stage(vertex)]]
fn vert_main(inputs : Interface) -> Interface {
[[stage(fragment)]]
fn frag_main(inputs : Interface) -> Interface {
return inputs;
}
)";
@@ -326,8 +326,8 @@ fn tint_symbol_4(tint_symbol_2 : Interface) {
tint_symbol_3 = tint_symbol_2.value;
}
[[stage(vertex)]]
fn vert_main() {
[[stage(fragment)]]
fn frag_main() {
let tint_symbol_1 : Interface = Interface(tint_symbol);
tint_symbol_4(tint_symbol_1);
return;
@@ -342,12 +342,13 @@ fn vert_main() {
TEST_F(SpirvTest, HandleEntryPointIOTypes_SharedStruct_DifferentShaders) {
auto* src = R"(
struct Interface {
[[builtin(position)]] pos : vec4<f32>;
[[location(1)]] value : f32;
};
[[stage(vertex)]]
fn vert_main() -> Interface {
return Interface(42.0);
return Interface(vec4<f32>(), 42.0);
}
[[stage(fragment)]]
@@ -358,27 +359,33 @@ fn frag_main(inputs : Interface) {
auto* expect = R"(
struct Interface {
pos : vec4<f32>;
value : f32;
};
[[location(1)]] var<out> tint_symbol_1 : f32;
[[builtin(position)]] var<out> tint_symbol_1 : vec4<f32>;
fn tint_symbol_2(tint_symbol : Interface) {
tint_symbol_1 = tint_symbol.value;
[[location(1)]] var<out> tint_symbol_2 : f32;
fn tint_symbol_3(tint_symbol : Interface) {
tint_symbol_1 = tint_symbol.pos;
tint_symbol_2 = tint_symbol.value;
}
[[stage(vertex)]]
fn vert_main() {
tint_symbol_2(Interface(42.0));
tint_symbol_3(Interface(vec4<f32>(), 42.0));
return;
}
[[location(1)]] var<in> tint_symbol_3 : f32;
[[builtin(position)]] var<in> tint_symbol_4 : vec4<f32>;
[[location(1)]] var<in> tint_symbol_5 : f32;
[[stage(fragment)]]
fn frag_main() {
let tint_symbol_4 : Interface = Interface(tint_symbol_3);
var x : f32 = tint_symbol_4.value;
let tint_symbol_6 : Interface = Interface(tint_symbol_4, tint_symbol_5);
var x : f32 = tint_symbol_6.value;
}
)";

View File

@@ -39,7 +39,9 @@ TEST_F(VertexPullingTest, Error_NoEntryPoint) {
TEST_F(VertexPullingTest, Error_InvalidEntryPoint) {
auto* src = R"(
[[stage(vertex)]]
fn main() {}
fn main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
)";
auto* expect = "error: Vertex stage entry point not found";
@@ -75,7 +77,9 @@ fn main() {}
TEST_F(VertexPullingTest, BasicModule) {
auto* src = R"(
[[stage(vertex)]]
fn main() {}
fn main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
)";
auto* expect = R"(
@@ -85,10 +89,11 @@ struct TintVertexData {
};
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
{
var tint_pulling_pos : u32;
}
return vec4<f32>();
}
)";
@@ -107,7 +112,9 @@ TEST_F(VertexPullingTest, OneAttribute) {
[[location(0)]] var<in> var_a : f32;
[[stage(vertex)]]
fn main() {}
fn main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
)";
auto* expect = R"(
@@ -123,12 +130,13 @@ struct TintVertexData {
var<private> var_a : f32;
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
{
var tint_pulling_pos : u32;
tint_pulling_pos = ((tint_pulling_vertex_index * 4u) + 0u);
var_a = bitcast<f32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(tint_pulling_pos / 4u)]);
}
return vec4<f32>();
}
)";
@@ -149,7 +157,9 @@ TEST_F(VertexPullingTest, OneInstancedAttribute) {
[[location(0)]] var<in> var_a : f32;
[[stage(vertex)]]
fn main() {}
fn main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
)";
auto* expect = R"(
@@ -165,12 +175,13 @@ struct TintVertexData {
var<private> var_a : f32;
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
{
var tint_pulling_pos : u32;
tint_pulling_pos = ((tint_pulling_instance_index * 4u) + 0u);
var_a = bitcast<f32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(tint_pulling_pos / 4u)]);
}
return vec4<f32>();
}
)";
@@ -191,7 +202,9 @@ TEST_F(VertexPullingTest, OneAttributeDifferentOutputSet) {
[[location(0)]] var<in> var_a : f32;
[[stage(vertex)]]
fn main() {}
fn main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
)";
auto* expect = R"(
@@ -207,12 +220,13 @@ struct TintVertexData {
var<private> var_a : f32;
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
{
var tint_pulling_pos : u32;
tint_pulling_pos = ((tint_pulling_vertex_index * 4u) + 0u);
var_a = bitcast<f32>(tint_pulling_vertex_buffer_0.tint_vertex_data[(tint_pulling_pos / 4u)]);
}
return vec4<f32>();
}
)";
@@ -238,7 +252,9 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) {
[[builtin(instance_index)]] var<in> custom_instance_index : u32;
[[stage(vertex)]]
fn main() {}
fn main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
)";
auto* expect = R"(
@@ -260,7 +276,7 @@ var<private> var_b : f32;
[[builtin(instance_index)]] var<in> custom_instance_index : u32;
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
{
var tint_pulling_pos : u32;
tint_pulling_pos = ((custom_vertex_index * 4u) + 0u);
@@ -268,6 +284,7 @@ fn main() {
tint_pulling_pos = ((custom_instance_index * 4u) + 0u);
var_b = bitcast<f32>(tint_pulling_vertex_buffer_1.tint_vertex_data[(tint_pulling_pos / 4u)]);
}
return vec4<f32>();
}
)";
@@ -299,7 +316,9 @@ TEST_F(VertexPullingTest, TwoAttributesSameBuffer) {
[[location(1)]] var<in> var_b : vec4<f32>;
[[stage(vertex)]]
fn main() {}
fn main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
)";
auto* expect = R"(
@@ -317,7 +336,7 @@ var<private> var_a : f32;
var<private> var_b : vec4<f32>;
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
{
var tint_pulling_pos : u32;
tint_pulling_pos = ((tint_pulling_vertex_index * 16u) + 0u);
@@ -325,6 +344,7 @@ fn main() {
tint_pulling_pos = ((tint_pulling_vertex_index * 16u) + 0u);
var_b = vec4<f32>(bitcast<f32>(tint_pulling_vertex_buffer_0.tint_vertex_data[((tint_pulling_pos + 0u) / 4u)]), bitcast<f32>(tint_pulling_vertex_buffer_0.tint_vertex_data[((tint_pulling_pos + 4u) / 4u)]), bitcast<f32>(tint_pulling_vertex_buffer_0.tint_vertex_data[((tint_pulling_pos + 8u) / 4u)]), bitcast<f32>(tint_pulling_vertex_buffer_0.tint_vertex_data[((tint_pulling_pos + 12u) / 4u)]));
}
return vec4<f32>();
}
)";
@@ -349,7 +369,9 @@ TEST_F(VertexPullingTest, FloatVectorAttributes) {
[[location(2)]] var<in> var_c : vec4<f32>;
[[stage(vertex)]]
fn main() {}
fn main() -> [[builtin(position)]] vec4<f32> {
return vec4<f32>();
}
)";
auto* expect = R"(
@@ -373,7 +395,7 @@ var<private> var_b : vec3<f32>;
var<private> var_c : vec4<f32>;
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
{
var tint_pulling_pos : u32;
tint_pulling_pos = ((tint_pulling_vertex_index * 8u) + 0u);
@@ -383,6 +405,7 @@ fn main() {
tint_pulling_pos = ((tint_pulling_vertex_index * 16u) + 0u);
var_c = vec4<f32>(bitcast<f32>(tint_pulling_vertex_buffer_2.tint_vertex_data[((tint_pulling_pos + 0u) / 4u)]), bitcast<f32>(tint_pulling_vertex_buffer_2.tint_vertex_data[((tint_pulling_pos + 4u) / 4u)]), bitcast<f32>(tint_pulling_vertex_buffer_2.tint_vertex_data[((tint_pulling_pos + 8u) / 4u)]), bitcast<f32>(tint_pulling_vertex_buffer_2.tint_vertex_data[((tint_pulling_pos + 12u) / 4u)]));
}
return vec4<f32>();
}
)";
@@ -407,11 +430,12 @@ TEST_F(VertexPullingTest, AttemptSymbolCollision) {
[[location(1)]] var<in> var_b : vec4<f32>;
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
var tint_pulling_vertex_index : i32;
var tint_pulling_vertex_buffer_0 : i32;
var tint_vertex_data : i32;
var tint_pulling_pos : i32;
return vec4<f32>();
}
)";
@@ -430,7 +454,7 @@ var<private> var_a : f32;
var<private> var_b : vec4<f32>;
[[stage(vertex)]]
fn main() {
fn main() -> [[builtin(position)]] vec4<f32> {
{
var tint_pulling_pos_1 : u32;
tint_pulling_pos_1 = ((tint_pulling_vertex_index_1 * 16u) + 0u);
@@ -442,6 +466,7 @@ fn main() {
var tint_pulling_vertex_buffer_0 : i32;
var tint_vertex_data : i32;
var tint_pulling_pos : i32;
return vec4<f32>();
}
)";