writer/hlsl: Inline fallthrough case statements

FXC does not support fallthrough case statements (DXC does).

Fixed: tint:1082
Change-Id: I82e1add5455e438056259f773f34bf9db05970b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60480
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2021-08-02 12:58:19 +00:00 committed by Tint LUCI CQ
parent 8ebff3dc85
commit c0fbce65d8
43 changed files with 385 additions and 142 deletions

View File

@ -58,15 +58,6 @@ namespace {
const char kTempNamePrefix[] = "tint_tmp"; const char kTempNamePrefix[] = "tint_tmp";
const char kSpecConstantPrefix[] = "WGSL_SPEC_CONSTANT_"; const char kSpecConstantPrefix[] = "WGSL_SPEC_CONSTANT_";
bool last_is_break_or_fallthrough(const ast::BlockStatement* stmts) {
if (stmts->empty()) {
return false;
}
return stmts->last()->Is<ast::BreakStatement>() ||
stmts->last()->Is<ast::FallthroughStatement>();
}
const char* image_format_to_rwtexture_type(ast::ImageFormat image_format) { const char* image_format_to_rwtexture_type(ast::ImageFormat image_format) {
switch (image_format) { switch (image_format) {
case ast::ImageFormat::kRgba8Unorm: case ast::ImageFormat::kRgba8Unorm:
@ -2019,7 +2010,8 @@ std::string GeneratorImpl::generate_builtin_name(
return ""; return "";
} }
bool GeneratorImpl::EmitCase(ast::CaseStatement* stmt) { bool GeneratorImpl::EmitCase(ast::SwitchStatement* s, size_t case_idx) {
auto* stmt = s->body()[case_idx];
if (stmt->IsDefault()) { if (stmt->IsDefault()) {
line() << "default: {"; line() << "default: {";
} else { } else {
@ -2036,17 +2028,32 @@ bool GeneratorImpl::EmitCase(ast::CaseStatement* stmt) {
} }
} }
{ increment_indent();
ScopedIndent si(this); TINT_DEFER({
decrement_indent();
line() << "}";
});
// Emit the case statement
if (!EmitStatements(stmt->body()->statements())) { if (!EmitStatements(stmt->body()->statements())) {
return false; return false;
} }
if (!last_is_break_or_fallthrough(stmt->body())) {
line() << "break;"; // Inline all fallthrough case statements. FXC cannot handle fallthroughs.
while (tint::Is<ast::FallthroughStatement>(stmt->body()->last())) {
case_idx++;
stmt = s->body()[case_idx];
// Generate each fallthrough case statement in a new block. This is done to
// prevent symbol collision of variables declared in these cases statements.
if (!EmitBlock(stmt->body())) {
return false;
} }
} }
line() << "}"; if (!tint::IsAnyOf<ast::BreakStatement, ast::FallthroughStatement>(
stmt->body()->last())) {
line() << "break;";
}
return true; return true;
} }
@ -2900,8 +2907,8 @@ bool GeneratorImpl::EmitSwitch(ast::SwitchStatement* stmt) {
{ {
ScopedIndent si(this); ScopedIndent si(this);
for (auto* s : stmt->body()) { for (size_t i = 0; i < stmt->body().size(); i++) {
if (!EmitCase(s)) { if (!EmitCase(stmt, i)) {
return false; return false;
} }
} }

View File

@ -196,9 +196,10 @@ class GeneratorImpl : public TextGenerator {
ast::CallExpression* expr, ast::CallExpression* expr,
const sem::Intrinsic* intrinsic); const sem::Intrinsic* intrinsic);
/// Handles a case statement /// Handles a case statement
/// @param stmt the statement /// @param s the switch statement
/// @param case_idx the index of the switch case in the switch statement
/// @returns true if the statement was emitted successfully /// @returns true if the statement was emitted successfully
bool EmitCase(ast::CaseStatement* stmt); bool EmitCase(ast::SwitchStatement* s, size_t case_idx);
/// Handles generating constructor expressions /// Handles generating constructor expressions
/// @param out the output of the expression stream /// @param out the output of the expression stream
/// @param expr the constructor expression /// @param expr the constructor expression

View File

@ -31,7 +31,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
gen.increment_indent(); gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body()[0])) << gen.error(); ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.error();
EXPECT_EQ(gen.result(), R"( case 5: { EXPECT_EQ(gen.result(), R"( case 5: {
break; break;
} }
@ -46,7 +46,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
gen.increment_indent(); gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body()[0])) << gen.error(); ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.error();
EXPECT_EQ(gen.result(), R"( case 5: { EXPECT_EQ(gen.result(), R"( case 5: {
break; break;
} }
@ -55,7 +55,9 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) { TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
auto* s = auto* s =
Switch(1, Case(Literal(5), Block(create<ast::FallthroughStatement>())), Switch(1, //
Case(Literal(4), Block(create<ast::FallthroughStatement>())), //
Case(Literal(5), Block(create<ast::ReturnStatement>())), //
DefaultCase()); DefaultCase());
WrapInFunction(s); WrapInFunction(s);
@ -63,9 +65,13 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
gen.increment_indent(); gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body()[0])) << gen.error(); ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.error();
EXPECT_EQ(gen.result(), R"( case 5: { EXPECT_EQ(gen.result(), R"( case 4: {
/* fallthrough */ /* fallthrough */
{
return;
}
break;
} }
)"); )");
} }
@ -80,7 +86,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
gen.increment_indent(); gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body()[0])) << gen.error(); ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.error();
EXPECT_EQ(gen.result(), R"( case 5: EXPECT_EQ(gen.result(), R"( case 5:
case 6: { case 6: {
break; break;
@ -96,7 +102,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_Default) {
gen.increment_indent(); gen.increment_indent();
ASSERT_TRUE(gen.EmitCase(s->body()[0])) << gen.error(); ASSERT_TRUE(gen.EmitCase(s, 0)) << gen.error();
EXPECT_EQ(gen.result(), R"( default: { EXPECT_EQ(gen.result(), R"( default: {
break; break;
} }

View File

@ -1,11 +1,12 @@
SKIP: FAILED
[numthreads(1, 1, 1)] [numthreads(1, 1, 1)]
void f() { void f() {
int i = 0; int i = 0;
switch(i) { switch(i) {
case 0: { case 0: {
/* fallthrough */ /* fallthrough */
{
break;
}
} }
default: { default: {
break; break;
@ -13,5 +14,3 @@ void f() {
} }
return; return;
} }
C:\src\tint\test\Shader@0x000001AF1A4F6940(5,5): error X3533: non-empty case statements must have break or return

View File

@ -4,6 +4,9 @@ void main_1() {
switch(42u) { switch(42u) {
case 20u: { case 20u: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 40u: { case 40u: {
break; break;

View File

@ -4,6 +4,9 @@ void main_1() {
switch(42u) { switch(42u) {
case 20u: { case 20u: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
default: { default: {
break; break;

View File

@ -4,6 +4,9 @@ void main_1() {
switch(42u) { switch(42u) {
default: { default: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 40u: { case 40u: {
break; break;

View File

@ -10,6 +10,13 @@ void main_1() {
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
if (false) {
} else {
break;
}
}
break;
} }
case 50u: { case 50u: {
if (false) { if (false) {

View File

@ -9,9 +9,22 @@ void main_1() {
break; break;
} }
/* fallthrough */ /* fallthrough */
{
/* fallthrough */
}
{
if (false) {
}
}
break;
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
if (false) {
}
}
break;
} }
case 50u: { case 50u: {
if (false) { if (false) {

View File

@ -9,6 +9,11 @@ void main_1() {
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
if (false) {
}
}
break;
} }
case 50u: { case 50u: {
if (false) { if (false) {

View File

@ -4,12 +4,18 @@ void main_1() {
switch(42u) { switch(42u) {
case 30u: { case 30u: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 50u: { case 50u: {
break; break;
} }
case 20u: { case 20u: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 40u: { case 40u: {
break; break;

View File

@ -4,9 +4,18 @@ void main_1() {
switch(42u) { switch(42u) {
case 20u: { case 20u: {
/* fallthrough */ /* fallthrough */
{
/* fallthrough */
}
{
}
break;
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 30u: { case 30u: {
break; break;

View File

@ -7,9 +7,18 @@ void main_1() {
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
/* fallthrough */
}
{
}
break;
} }
case 30u: { case 30u: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 40u: { case 40u: {
break; break;

View File

@ -4,12 +4,18 @@ void main_1() {
switch(42u) { switch(42u) {
case 30u: { case 30u: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 50u: { case 50u: {
break; break;
} }
case 20u: { case 20u: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 40u: { case 40u: {
break; break;

View File

@ -10,6 +10,9 @@ void main_1() {
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 30u: { case 30u: {
break; break;

View File

@ -6,6 +6,10 @@ void main_1() {
case 20u: { case 20u: {
var_1 = 20u; var_1 = 20u;
/* fallthrough */ /* fallthrough */
{
var_1 = 30u;
}
break;
} }
case 30u: { case 30u: {
var_1 = 30u; var_1 = 30u;

View File

@ -9,6 +9,10 @@ void main_1() {
break; break;
} }
/* fallthrough */ /* fallthrough */
{
var_1 = 30u;
}
break;
} }
case 30u: { case 30u: {
var_1 = 30u; var_1 = 30u;

View File

@ -10,6 +10,10 @@ void main_1() {
break; break;
} }
/* fallthrough */ /* fallthrough */
{
var_1 = 30u;
}
break;
} }
case 30u: { case 30u: {
var_1 = 30u; var_1 = 30u;

View File

@ -6,6 +6,10 @@ void main_1() {
case 20u: { case 20u: {
var_1 = 20u; var_1 = 20u;
/* fallthrough */ /* fallthrough */
{
var_1 = 30u;
}
break;
} }
case 30u: { case 30u: {
var_1 = 30u; var_1 = 30u;

View File

@ -13,6 +13,10 @@ void main_1() {
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
var_1 = 30u;
}
break;
} }
case 30u: { case 30u: {
var_1 = 30u; var_1 = 30u;

View File

@ -4,6 +4,9 @@ void main_1() {
switch(42u) { switch(42u) {
default: { default: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 200u: { case 200u: {
break; break;

View File

@ -4,6 +4,9 @@ void main_1() {
switch(42u) { switch(42u) {
case 20u: { case 20u: {
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 30u: { case 30u: {
break; break;

View File

@ -7,9 +7,30 @@ void main_1() {
switch(1u) { switch(1u) {
default: { default: {
/* fallthrough */ /* fallthrough */
{
/* fallthrough */
}
{
if (true) {
} else {
x_41_phi = 0u;
break;
}
x_41_phi = 1u;
}
break;
} }
case 0u: { case 0u: {
/* fallthrough */ /* fallthrough */
{
if (true) {
} else {
x_41_phi = 0u;
break;
}
x_41_phi = 1u;
}
break;
} }
case 1u: { case 1u: {
if (true) { if (true) {

View File

@ -1,4 +1,4 @@
SKIP: FAILED SKIP: https://github.com/microsoft/DirectXShaderCompiler/issues/3894
static float4 gl_FragCoord = float4(0.0f, 0.0f, 0.0f, 0.0f); static float4 gl_FragCoord = float4(0.0f, 0.0f, 0.0f, 0.0f);
static float array0[3] = (float[3])0; static float array0[3] = (float[3])0;
@ -31,6 +31,11 @@ void main_1() {
} }
array0[c] = 1.0f; array0[c] = 1.0f;
/* fallthrough */ /* fallthrough */
{
array1[0] = 1.0f;
array1[c] = 1.0f;
}
break;
} }
case 61: { case 61: {
array1[0] = 1.0f; array1[0] = 1.0f;
@ -72,13 +77,3 @@ tint_symbol_2 main(tint_symbol_1 tint_symbol) {
const tint_symbol_2 tint_symbol_5 = {tint_symbol_3.x_GLF_color_1}; const tint_symbol_2 tint_symbol_5 = {tint_symbol_3.x_GLF_color_1};
return tint_symbol_5; return tint_symbol_5;
} }
C:\src\tint\test\Shader@0x0000019491823870(15,8-20): warning X3556: integer modulus may be much slower, try using uints if possible.
C:\src\tint\test\Shader@0x0000019491823870(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000019491823870(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000019491823870(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000019491823870(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000019491823870(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000019491823870(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000019491823870(23,9): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x0000019491823870(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll

View File

@ -1,4 +1,4 @@
SKIP: FAILED SKIP: https://github.com/microsoft/DirectXShaderCompiler/issues/3894
static float4 gl_FragCoord = float4(0.0f, 0.0f, 0.0f, 0.0f); static float4 gl_FragCoord = float4(0.0f, 0.0f, 0.0f, 0.0f);
static float array0[3] = (float[3])0; static float array0[3] = (float[3])0;
@ -31,6 +31,11 @@ void main_1() {
} }
array0[c] = 1.0f; array0[c] = 1.0f;
/* fallthrough */ /* fallthrough */
{
array1[0] = 1.0f;
array1[c] = 1.0f;
}
break;
} }
case 61: { case 61: {
array1[0] = 1.0f; array1[0] = 1.0f;
@ -72,13 +77,3 @@ tint_symbol_2 main(tint_symbol_1 tint_symbol) {
const tint_symbol_2 tint_symbol_5 = {tint_symbol_3.x_GLF_color_1}; const tint_symbol_2 tint_symbol_5 = {tint_symbol_3.x_GLF_color_1};
return tint_symbol_5; return tint_symbol_5;
} }
C:\src\tint\test\Shader@0x0000026803D7D2F0(15,8-20): warning X3556: integer modulus may be much slower, try using uints if possible.
C:\src\tint\test\Shader@0x0000026803D7D2F0(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000026803D7D2F0(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000026803D7D2F0(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000026803D7D2F0(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000026803D7D2F0(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000026803D7D2F0(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll
C:\src\tint\test\Shader@0x0000026803D7D2F0(23,9): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x0000026803D7D2F0(24,11-22): warning X3557: loop doesn't seem to do anything, forcing loop to unroll

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[5]; uint4 x_6[5];
}; };
@ -27,6 +25,10 @@ void main_1() {
case 1: { case 1: {
count0 = (count0 + 1); count0 = (count0 + 1);
/* fallthrough */ /* fallthrough */
{
count1 = (count1 + 1);
}
break;
} }
case 2: case 2:
case 3: { case 3: {
@ -78,6 +80,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x000001CD53C8DD00(24,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000001CD53C8DD00(28,7): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[5]; uint4 x_6[5];
}; };
@ -27,6 +25,10 @@ void main_1() {
case 1: { case 1: {
count0 = (count0 + 1); count0 = (count0 + 1);
/* fallthrough */ /* fallthrough */
{
count1 = (count1 + 1);
}
break;
} }
case 2: case 2:
case 3: { case 3: {
@ -78,6 +80,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x000001A41A83AF00(24,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000001A41A83AF00(28,7): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -17,8 +17,7 @@ void main_1() {
return; return;
} }
/* fallthrough */ /* fallthrough */
} {
case 1: {
if (true) { if (true) {
const uint scalar_offset_1 = ((16u * uint(0))) / 4; const uint scalar_offset_1 = ((16u * uint(0))) / 4;
const int x_40 = asint(x_6[scalar_offset_1 / 4][scalar_offset_1 % 4]); const int x_40 = asint(x_6[scalar_offset_1 / 4][scalar_offset_1 % 4]);
@ -49,6 +48,40 @@ void main_1() {
} }
} }
} }
}
break;
}
case 1: {
if (true) {
const uint scalar_offset_4 = ((16u * uint(0))) / 4;
const int x_40 = asint(x_6[scalar_offset_4 / 4][scalar_offset_4 % 4]);
const int x_43 = asint(x_6[1].x);
const int x_46 = asint(x_6[1].x);
const uint scalar_offset_5 = ((16u * uint(0))) / 4;
const int x_49 = asint(x_6[scalar_offset_5 / 4][scalar_offset_5 % 4]);
x_GLF_color = float4(float(x_40), float(x_43), float(x_46), float(x_49));
if (false) {
const uint scalar_offset_6 = ((16u * uint(0))) / 4;
const int x_55 = asint(x_6[scalar_offset_6 / 4][scalar_offset_6 % 4]);
const float x_56 = float(x_55);
x_GLF_color = float4(x_56, x_56, x_56, x_56);
while (true) {
x_GLF_global_loop_count = (x_GLF_global_loop_count + 1);
if (false) {
return;
}
if (true) {
return;
}
{
if ((x_GLF_global_loop_count < 100)) {
} else {
break;
}
}
}
}
}
break; break;
} }
default: { default: {

View File

@ -17,8 +17,7 @@ void main_1() {
return; return;
} }
/* fallthrough */ /* fallthrough */
} {
case 1: {
if (true) { if (true) {
const uint scalar_offset_1 = ((16u * uint(0))) / 4; const uint scalar_offset_1 = ((16u * uint(0))) / 4;
const int x_40 = asint(x_6[scalar_offset_1 / 4][scalar_offset_1 % 4]); const int x_40 = asint(x_6[scalar_offset_1 / 4][scalar_offset_1 % 4]);
@ -49,6 +48,40 @@ void main_1() {
} }
} }
} }
}
break;
}
case 1: {
if (true) {
const uint scalar_offset_4 = ((16u * uint(0))) / 4;
const int x_40 = asint(x_6[scalar_offset_4 / 4][scalar_offset_4 % 4]);
const int x_43 = asint(x_6[1].x);
const int x_46 = asint(x_6[1].x);
const uint scalar_offset_5 = ((16u * uint(0))) / 4;
const int x_49 = asint(x_6[scalar_offset_5 / 4][scalar_offset_5 % 4]);
x_GLF_color = float4(float(x_40), float(x_43), float(x_46), float(x_49));
if (false) {
const uint scalar_offset_6 = ((16u * uint(0))) / 4;
const int x_55 = asint(x_6[scalar_offset_6 / 4][scalar_offset_6 % 4]);
const float x_56 = float(x_55);
x_GLF_color = float4(x_56, x_56, x_56, x_56);
while (true) {
x_GLF_global_loop_count = (x_GLF_global_loop_count + 1);
if (false) {
return;
}
if (true) {
return;
}
{
if ((x_GLF_global_loop_count < 100)) {
} else {
break;
}
}
}
}
}
break; break;
} }
default: { default: {

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
}; };
@ -31,9 +29,20 @@ void main_1() {
const float4 x_43 = func_(); const float4 x_43 = func_();
x_GLF_color = x_43; x_GLF_color = x_43;
/* fallthrough */ /* fallthrough */
{
/* fallthrough */
}
{
x_GLF_color.y = 0.0f;
}
break;
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
x_GLF_color.y = 0.0f;
}
break;
} }
case 0: { case 0: {
x_GLF_color.y = 0.0f; x_GLF_color.y = 0.0f;
@ -60,8 +69,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x00000183AD3AB240(28,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x00000183AD3AB240(33,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x00000183AD3AB240(32,7): error X3537: Fall-throughs in switch statements are not allowed.
C:\src\tint\test\Shader@0x00000183AD3AB240(35,7): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
}; };
@ -31,9 +29,20 @@ void main_1() {
const float4 x_43 = func_(); const float4 x_43 = func_();
x_GLF_color = x_43; x_GLF_color = x_43;
/* fallthrough */ /* fallthrough */
{
/* fallthrough */
}
{
x_GLF_color.y = 0.0f;
}
break;
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
x_GLF_color.y = 0.0f;
}
break;
} }
case 0: { case 0: {
x_GLF_color.y = 0.0f; x_GLF_color.y = 0.0f;
@ -60,8 +69,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x0000021C30D8F880(28,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x0000021C30D8F880(33,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x0000021C30D8F880(32,7): error X3537: Fall-throughs in switch statements are not allowed.
C:\src\tint\test\Shader@0x0000021C30D8F880(35,7): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
}; };
@ -14,6 +12,9 @@ void main_1() {
case 3: { case 3: {
a = 1; a = 1;
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 4: { case 4: {
break; break;
@ -44,6 +45,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x0000025EFE826FC0(11,5): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x0000025EFE826FC0(15,5): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
}; };
@ -14,6 +12,9 @@ void main_1() {
case 3: { case 3: {
a = 1; a = 1;
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 4: { case 4: {
break; break;
@ -44,6 +45,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x000001FDE7828C30(11,5): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000001FDE7828C30(15,5): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
}; };
@ -21,6 +19,11 @@ void main_1() {
case 0: { case 0: {
x_43_phi = 1.0f; x_43_phi = 1.0f;
/* fallthrough */ /* fallthrough */
{
data[x_39] = x_43_phi;
x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
}
break;
} }
case 1: { case 1: {
data[x_39] = x_43_phi; data[x_39] = x_43_phi;
@ -48,6 +51,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x0000027AB59F7F40(19,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x0000027AB59F7F40(22,7): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
}; };
@ -21,6 +19,11 @@ void main_1() {
case 0: { case 0: {
x_43_phi = 1.0f; x_43_phi = 1.0f;
/* fallthrough */ /* fallthrough */
{
data[x_39] = x_43_phi;
x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
}
break;
} }
case 1: { case 1: {
data[x_39] = x_43_phi; data[x_39] = x_43_phi;
@ -48,6 +51,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x0000020777179050(19,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x0000020777179050(22,7): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f); static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
@ -26,6 +24,9 @@ void main_1() {
} }
} }
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 42: { case 42: {
break; break;
@ -55,6 +56,3 @@ tint_symbol_2 main(tint_symbol_1 tint_symbol) {
const tint_symbol_2 tint_symbol_5 = {tint_symbol_3.x_GLF_color_1}; const tint_symbol_2 tint_symbol_5 = {tint_symbol_3.x_GLF_color_1};
return tint_symbol_5; return tint_symbol_5;
} }
C:\src\tint\test\Shader@0x000001A268ED57F0(11,5): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000001A268ED57F0(27,5): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f); static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
@ -26,6 +24,9 @@ void main_1() {
} }
} }
/* fallthrough */ /* fallthrough */
{
}
break;
} }
case 42: { case 42: {
break; break;
@ -55,6 +56,3 @@ tint_symbol_2 main(tint_symbol_1 tint_symbol) {
const tint_symbol_2 tint_symbol_5 = {tint_symbol_3.x_GLF_color_1}; const tint_symbol_2 tint_symbol_5 = {tint_symbol_3.x_GLF_color_1};
return tint_symbol_5; return tint_symbol_5;
} }
C:\src\tint\test\Shader@0x00000267DEB27120(11,5): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x00000267DEB27120(27,5): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -45,6 +45,10 @@ void main_1() {
break; break;
} }
/* fallthrough */ /* fallthrough */
{
i = (i - 3);
}
break;
} }
default: { default: {
i = (i - 3); i = (i - 3);
@ -72,6 +76,5 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x00000259291CFD70(11,5): error X3533: non-empty case statements must have break or return O:\src\chrome\src\third_party\dawn\third_party\tint\test\Shader@0x0000028C1CDAABD0(26,13-21): error X3708: continue cannot be used in a switch
C:\src\tint\test\Shader@0x00000259291CFD70(26,13-21): error X3708: continue cannot be used in a switch

View File

@ -45,6 +45,10 @@ void main_1() {
break; break;
} }
/* fallthrough */ /* fallthrough */
{
i = (i - 3);
}
break;
} }
default: { default: {
i = (i - 3); i = (i - 3);
@ -72,6 +76,5 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x000001E28E944DC0(11,5): error X3533: non-empty case statements must have break or return O:\src\chrome\src\third_party\dawn\third_party\tint\test\Shader@0x0000015D2C356900(26,13-21): error X3708: continue cannot be used in a switch
C:\src\tint\test\Shader@0x000001E28E944DC0(26,13-21): error X3708: continue cannot be used in a switch

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
}; };
@ -31,15 +29,48 @@ void main_1() {
y = x_54; y = x_54;
x_55_phi = x_54; x_55_phi = x_54;
/* fallthrough */ /* fallthrough */
{
const float x_47 = clamp(1.0f, 0.5f, x_55_phi);
y = x_47;
x_46_phi = x_47;
/* fallthrough */
}
{
/* fallthrough */
}
{
if ((x_46_phi == 1.0f)) {
x_GLF_color = float4(float((x_31 + 1)), 0.0f, 0.0f, 1.0f);
return;
}
}
break;
} }
case 1: { case 1: {
const float x_47 = clamp(1.0f, 0.5f, x_55_phi); const float x_47 = clamp(1.0f, 0.5f, x_55_phi);
y = x_47; y = x_47;
x_46_phi = x_47; x_46_phi = x_47;
/* fallthrough */ /* fallthrough */
{
/* fallthrough */
}
{
if ((x_46_phi == 1.0f)) {
x_GLF_color = float4(float((x_31 + 1)), 0.0f, 0.0f, 1.0f);
return;
}
}
break;
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
if ((x_46_phi == 1.0f)) {
x_GLF_color = float4(float((x_31 + 1)), 0.0f, 0.0f, 1.0f);
return;
}
}
break;
} }
case 2: { case 2: {
if ((x_46_phi == 1.0f)) { if ((x_46_phi == 1.0f)) {
@ -71,10 +102,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x000002EAE8878270(27,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000002EAE8878270(33,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000002EAE8878270(39,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000002EAE8878270(32,7): error X3537: Fall-throughs in switch statements are not allowed.
C:\src\tint\test\Shader@0x000002EAE8878270(38,7): error X3537: Fall-throughs in switch statements are not allowed.
C:\src\tint\test\Shader@0x000002EAE8878270(41,7): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -1,5 +1,3 @@
SKIP: FAILED
cbuffer cbuffer_x_6 : register(b0, space0) { cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[1]; uint4 x_6[1];
}; };
@ -31,15 +29,48 @@ void main_1() {
y = x_54; y = x_54;
x_55_phi = x_54; x_55_phi = x_54;
/* fallthrough */ /* fallthrough */
{
const float x_47 = clamp(1.0f, 0.5f, x_55_phi);
y = x_47;
x_46_phi = x_47;
/* fallthrough */
}
{
/* fallthrough */
}
{
if ((x_46_phi == 1.0f)) {
x_GLF_color = float4(float((x_31 + 1)), 0.0f, 0.0f, 1.0f);
return;
}
}
break;
} }
case 1: { case 1: {
const float x_47 = clamp(1.0f, 0.5f, x_55_phi); const float x_47 = clamp(1.0f, 0.5f, x_55_phi);
y = x_47; y = x_47;
x_46_phi = x_47; x_46_phi = x_47;
/* fallthrough */ /* fallthrough */
{
/* fallthrough */
}
{
if ((x_46_phi == 1.0f)) {
x_GLF_color = float4(float((x_31 + 1)), 0.0f, 0.0f, 1.0f);
return;
}
}
break;
} }
default: { default: {
/* fallthrough */ /* fallthrough */
{
if ((x_46_phi == 1.0f)) {
x_GLF_color = float4(float((x_31 + 1)), 0.0f, 0.0f, 1.0f);
return;
}
}
break;
} }
case 2: { case 2: {
if ((x_46_phi == 1.0f)) { if ((x_46_phi == 1.0f)) {
@ -71,10 +102,3 @@ tint_symbol main() {
const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1}; const tint_symbol tint_symbol_3 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_3; return tint_symbol_3;
} }
C:\src\tint\test\Shader@0x000001B3F8915FF0(27,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000001B3F8915FF0(33,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000001B3F8915FF0(39,7): error X3533: non-empty case statements must have break or return
C:\src\tint\test\Shader@0x000001B3F8915FF0(32,7): error X3537: Fall-throughs in switch statements are not allowed.
C:\src\tint\test\Shader@0x000001B3F8915FF0(38,7): error X3537: Fall-throughs in switch statements are not allowed.
C:\src\tint\test\Shader@0x000001B3F8915FF0(41,7): error X3537: Fall-throughs in switch statements are not allowed.

View File

@ -25,6 +25,10 @@ void main_1() {
while (true) { while (true) {
} }
/* fallthrough */ /* fallthrough */
{
data[0] = 2.0f;
}
break;
} }
case 0: { case 0: {
data[0] = 2.0f; data[0] = 2.0f;

View File

@ -25,6 +25,10 @@ void main_1() {
while (true) { while (true) {
} }
/* fallthrough */ /* fallthrough */
{
data[0] = 2.0f;
}
break;
} }
case 0: { case 0: {
data[0] = 2.0f; data[0] = 2.0f;