mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-24 08:21:25 +01:00
hlsl: fix storage offset, continuing statement
This commit is contained in:
1 parent
a5c2cef9ab
commit
e97c8f9441
5 files changed
+67
-33
No files matched your search
@@ -365,10 +365,17 @@ impl<W: fmt::Write> super::Writer<'_, W> {
|
||||
) -> Result<Handle<crate::GlobalVariable>, Error> {
|
||||
self.temp_access_chain.clear();
|
||||
loop {
|
||||
let stride = func_ctx.info[cur_expr]
|
||||
.ty
|
||||
.inner_with(&module.types)
|
||||
.span(&module.constants);
|
||||
// determine the size of the pontee
|
||||
let stride = match *func_ctx.info[cur_expr].ty.inner_with(&module.types) {
|
||||
crate::TypeInner::Pointer { base, class: _ } => {
|
||||
module.types[base].inner.span(&module.constants)
|
||||
}
|
||||
crate::TypeInner::ValuePointer { size, width, .. } => {
|
||||
size.map_or(1, |s| s as u32) * width as u32
|
||||
}
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
let (next_expr, sub) = match func_ctx.expressions[cur_expr] {
|
||||
crate::Expression::GlobalVariable(handle) => return Ok(handle),
|
||||
crate::Expression::Access { base, index } => (
|
||||
|
||||
+32
-13
@@ -1008,23 +1008,42 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
||||
ref body,
|
||||
ref continuing,
|
||||
} => {
|
||||
write!(self.out, "{}", INDENT.repeat(indent))?;
|
||||
writeln!(self.out, "while(true) {{")?;
|
||||
|
||||
for sta in body.iter().chain(continuing.iter()) {
|
||||
self.write_stmt(module, sta, func_ctx, indent + 1)?;
|
||||
if !continuing.is_empty() {
|
||||
let gate_name = self.namer.call("loop_init");
|
||||
writeln!(
|
||||
self.out,
|
||||
"{}bool {} = true;",
|
||||
INDENT.repeat(indent),
|
||||
gate_name
|
||||
)?;
|
||||
writeln!(self.out, "{}while(true) {{", INDENT.repeat(indent))?;
|
||||
writeln!(
|
||||
self.out,
|
||||
"{}if (!{}) {{",
|
||||
INDENT.repeat(indent + 1),
|
||||
gate_name
|
||||
)?;
|
||||
for sta in continuing.iter() {
|
||||
self.write_stmt(module, sta, func_ctx, indent + 1)?;
|
||||
}
|
||||
writeln!(self.out, "{}}}", INDENT.repeat(indent + 1))?;
|
||||
writeln!(
|
||||
self.out,
|
||||
"{}{} = false;",
|
||||
INDENT.repeat(indent + 1),
|
||||
gate_name
|
||||
)?;
|
||||
} else {
|
||||
writeln!(self.out, "{}while(true) {{", INDENT.repeat(indent))?;
|
||||
}
|
||||
|
||||
for sta in body.iter() {
|
||||
self.write_stmt(module, sta, func_ctx, indent + 1)?;
|
||||
}
|
||||
writeln!(self.out, "{}}}", INDENT.repeat(indent))?
|
||||
}
|
||||
Statement::Break => {
|
||||
write!(self.out, "{}", INDENT.repeat(indent))?;
|
||||
writeln!(self.out, "break;")?
|
||||
}
|
||||
Statement::Continue => {
|
||||
write!(self.out, "{}", INDENT.repeat(indent))?;
|
||||
writeln!(self.out, "continue;")?
|
||||
}
|
||||
Statement::Break => writeln!(self.out, "{}break;", INDENT.repeat(indent))?,
|
||||
Statement::Continue => writeln!(self.out, "{}continue;", INDENT.repeat(indent))?,
|
||||
Statement::Barrier(barrier) => {
|
||||
if barrier.contains(crate::Barrier::STORAGE) {
|
||||
writeln!(
|
||||
|
||||
Reference in new issue
Block a user