[hlsl] Fix loop tests for DXC validation.
This CL updates the loop tests to terminate. This fixes an issue where
the test doesn't validate with DXC. DXC dead-code eliminates the `break`
if the conditional is set to true.
Bug: 42250042, 42251045
Change-Id: Id0bad867db33943050ecfd6645078bba6131ff99
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/196957
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/hlsl/writer/loop_test.cc b/src/tint/lang/hlsl/writer/loop_test.cc
index d52fffc..d84c3ce 100644
--- a/src/tint/lang/hlsl/writer/loop_test.cc
+++ b/src/tint/lang/hlsl/writer/loop_test.cc
@@ -86,16 +86,14 @@
)");
}
-// TODO(dsinclair): DXC error
-// `hlsl.hlsl:3: error: Loop must have break.`
-TEST_F(HlslWriterTest, DISABLED_LoopBodyVarInContinue) {
+TEST_F(HlslWriterTest, LoopBodyVarInContinue) {
auto* func = b.Function("a", ty.void_(), core::ir::Function::PipelineStage::kCompute);
func->SetWorkgroupSize(1, 1, 1);
b.Append(func->Block(), [&] {
auto* l = b.Loop();
b.Append(l->Body(), [&] {
- auto* v = b.Var("v", b.Zero<bool>());
+ auto* v = b.Var("v", true);
b.Continue(l);
b.Append(l->Continuing(), [&] { b.BreakIf(l, v); });
@@ -109,7 +107,7 @@
void a() {
{
while(true) {
- bool v = false;
+ bool v = true;
{
if (v) { break; }
}
@@ -121,16 +119,14 @@
)");
}
-// TODO(dsinclair): DXC Error:
-// `hlsl.hlsl:3: error: Loop must have break.`
-TEST_F(HlslWriterTest, DISABLED_LoopInitializer) {
+TEST_F(HlslWriterTest, LoopInitializer) {
auto* func = b.Function("a", ty.void_(), core::ir::Function::PipelineStage::kCompute);
func->SetWorkgroupSize(1, 1, 1);
b.Append(func->Block(), [&] {
auto* l = b.Loop();
b.Append(l->Initializer(), [&] {
- auto* v = b.Var("v", b.Zero<bool>());
+ auto* v = b.Var("v", true);
b.NextIteration(l);
b.Append(l->Body(), [&] { b.Continue(l); });
@@ -144,7 +140,7 @@
[numthreads(1, 1, 1)]
void a() {
{
- bool v = false;
+ bool v = true;
while(true) {
{
if (v) { break; }