mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Add support for initialization of local variables to glsl backend (#129)
* Add support for initialization of local variables to glsl backend * Cleanup
This commit is contained in:
@@ -170,15 +170,6 @@ pub fn write(module: &Module, out: &mut impl Write) -> Result<(), Error> {
|
||||
.map(|(handle, local)| (handle, namer(local.name.as_ref())))
|
||||
.collect();
|
||||
|
||||
for (handle, name) in locals.iter() {
|
||||
writeln!(
|
||||
out,
|
||||
"{} {};",
|
||||
write_type(func.local_variables[*handle].ty, &module.types, &structs)?,
|
||||
name
|
||||
)?;
|
||||
}
|
||||
|
||||
let mut builder = StatementBuilder {
|
||||
functions: &functions,
|
||||
globals: &globals_lookup,
|
||||
@@ -194,6 +185,22 @@ pub fn write(module: &Module, out: &mut impl Write) -> Result<(), Error> {
|
||||
locals: &func.local_variables,
|
||||
};
|
||||
|
||||
for (handle, name) in locals.iter() {
|
||||
let ty = write_type(func.local_variables[*handle].ty, &module.types, &structs)?;
|
||||
let init = func.local_variables[*handle].init;
|
||||
if let Some(init) = init {
|
||||
writeln!(
|
||||
out,
|
||||
"{} {} = {init};",
|
||||
ty,
|
||||
name,
|
||||
init = write_expression(&func.expressions[init], &module, &mut builder)?.0,
|
||||
)?;
|
||||
} else {
|
||||
writeln!(out, "{} {};", ty, name,)?;
|
||||
}
|
||||
}
|
||||
|
||||
for sta in func.body.iter() {
|
||||
writeln!(out, "{}", write_statement(sta, module, &mut builder)?)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user