[spirv-writer] Add a LocalSize execution mode.
In SPIR-V a compute entry point requires a WorkGroup Size constant or a LocalSize execution mode. This CL adds a 1,1,1 execution mode as a starting point. Bug: tint:74 Change-Id: Ie5bf639472033dca9ffe333548e7f31d4d318768 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/21020 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
2287f33424
commit
b1870eff04
|
@ -302,6 +302,11 @@ bool Builder::GenerateExecutionModes(ast::EntryPoint* ep) {
|
||||||
push_preamble(
|
push_preamble(
|
||||||
spv::Op::OpExecutionMode,
|
spv::Op::OpExecutionMode,
|
||||||
{Operand::Int(id), Operand::Int(SpvExecutionModeOriginUpperLeft)});
|
{Operand::Int(id), Operand::Int(SpvExecutionModeOriginUpperLeft)});
|
||||||
|
} else if (ep->stage() == ast::PipelineStage::kCompute) {
|
||||||
|
// TODO(dsinclair): Support LocalSize other then (1, 1, 1)
|
||||||
|
push_preamble(spv::Op::OpExecutionMode,
|
||||||
|
{Operand::Int(id), Operand::Int(SpvExecutionModeLocalSize),
|
||||||
|
Operand::Int(1), Operand::Int(1), Operand::Int(1)});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -39,9 +39,7 @@ TEST_F(BuilderTest, EntryPoint) {
|
||||||
b.set_func_name_to_id("frag_main", 2);
|
b.set_func_name_to_id("frag_main", 2);
|
||||||
ASSERT_TRUE(b.GenerateEntryPoint(&ep));
|
ASSERT_TRUE(b.GenerateEntryPoint(&ep));
|
||||||
|
|
||||||
auto preamble = b.preamble();
|
EXPECT_EQ(DumpInstructions(b.preamble()), R"(OpEntryPoint Fragment %2 "main"
|
||||||
ASSERT_EQ(preamble.size(), 1u);
|
|
||||||
EXPECT_EQ(DumpInstruction(preamble[0]), R"(OpEntryPoint Fragment %2 "main"
|
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +51,7 @@ TEST_F(BuilderTest, EntryPoint_WithoutName) {
|
||||||
b.set_func_name_to_id("compute_main", 3);
|
b.set_func_name_to_id("compute_main", 3);
|
||||||
ASSERT_TRUE(b.GenerateEntryPoint(&ep));
|
ASSERT_TRUE(b.GenerateEntryPoint(&ep));
|
||||||
|
|
||||||
auto preamble = b.preamble();
|
EXPECT_EQ(DumpInstructions(b.preamble()),
|
||||||
ASSERT_EQ(preamble.size(), 1u);
|
|
||||||
EXPECT_EQ(DumpInstruction(preamble[0]),
|
|
||||||
R"(OpEntryPoint GLCompute %3 "compute_main"
|
R"(OpEntryPoint GLCompute %3 "compute_main"
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
@ -153,9 +149,21 @@ TEST_F(BuilderTest, ExecutionModel_Fragment_OriginUpperLeft) {
|
||||||
b.set_func_name_to_id("frag_main", 2);
|
b.set_func_name_to_id("frag_main", 2);
|
||||||
ASSERT_TRUE(b.GenerateExecutionModes(&ep));
|
ASSERT_TRUE(b.GenerateExecutionModes(&ep));
|
||||||
|
|
||||||
auto preamble = b.preamble();
|
EXPECT_EQ(DumpInstructions(b.preamble()),
|
||||||
ASSERT_EQ(preamble.size(), 1u);
|
R"(OpExecutionMode %2 OriginUpperLeft
|
||||||
EXPECT_EQ(DumpInstruction(preamble[0]), R"(OpExecutionMode %2 OriginUpperLeft
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BuilderTest, ExecutionModel_Compute_LocalSize) {
|
||||||
|
ast::EntryPoint ep(ast::PipelineStage::kCompute, "main", "main");
|
||||||
|
|
||||||
|
ast::Module mod;
|
||||||
|
Builder b(&mod);
|
||||||
|
b.set_func_name_to_id("main", 2);
|
||||||
|
ASSERT_TRUE(b.GenerateExecutionModes(&ep));
|
||||||
|
|
||||||
|
EXPECT_EQ(DumpInstructions(b.preamble()),
|
||||||
|
R"(OpExecutionMode %2 LocalSize 1 1 1
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue