Skip to content

Commit

Permalink
Nested loop test
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Feb 29, 2024
1 parent 9ca3e93 commit 8bda25c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ Bottom level categories:
#### DX12
- Fix `panic!` when dropping `Instance` without `InstanceFlags::VALIDATION`. By @hakolao in [#5134](https://github.com/gfx-rs/wgpu/pull/5134)

## v0.19.1 (2024-01-21)
#### glsl-in

### Bug Fixes
- Fix code generation from nested loops. By @cwfitzgerald and @teoxoy in [#5311](https://github.com/gfx-rs/wgpu/pull/5311)

## v0.19.1 (2024-01-21)

#### WGL

Expand Down
2 changes: 1 addition & 1 deletion naga/src/front/glsl/parser/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ impl<'source> ParsingContext<'source> {

if self.bump_if(frontend, TokenValue::Semicolon).is_none() {
if self.peek_type_name(frontend) || self.peek_type_qualifier(frontend) {
self.parse_declaration(frontend, ctx, false, false)?;
self.parse_declaration(frontend, ctx, false, is_inside_loop)?;
} else {
let mut stmt = ctx.stmt_ctx();
let expr = self.parse_expression(frontend, ctx, &mut stmt)?;
Expand Down
12 changes: 12 additions & 0 deletions naga/tests/in/glsl/5246-dual-iteration.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// AUTHOR: cwfitzgerald
// ISSUE: #5246

void main() {
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
for (int z = 0; z < 10; z++) {
;
}
}
}
}
51 changes: 51 additions & 0 deletions naga/tests/out/wgsl/5246-dual-iteration.frag.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
fn main_1() {
var x: i32 = 0i;
var y: i32;
var z: i32;

loop {
let _e2 = x;
if !((_e2 < 10i)) {
break;
}
{
y = 0i;
loop {
let _e11 = y;
if !((_e11 < 10i)) {
break;
}
{
z = 0i;
loop {
let _e20 = z;
if !((_e20 < 10i)) {
break;
}
{
}
continuing {
let _e24 = z;
z = (_e24 + 1i);
}
}
}
continuing {
let _e15 = y;
y = (_e15 + 1i);
}
}
}
continuing {
let _e6 = x;
x = (_e6 + 1i);
}
}
return;
}

@fragment
fn main() {
main_1();
return;
}

0 comments on commit 8bda25c

Please sign in to comment.