mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[glsl-out] Handle wgsl vector version of select
This commit is contained in:
committed by
Dzmitry Malyshau
parent
2ff7dcb417
commit
b2e51c97c8
@@ -2115,12 +2115,30 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
accept,
|
||||
reject,
|
||||
} => {
|
||||
write!(self.out, "(")?;
|
||||
self.write_expr(condition, ctx)?;
|
||||
write!(self.out, " ? ")?;
|
||||
self.write_expr(accept, ctx)?;
|
||||
write!(self.out, " : ")?;
|
||||
self.write_expr(reject, ctx)?;
|
||||
let cond_ty = ctx.info[condition].ty.inner_with(&self.module.types);
|
||||
let vec_select = if let TypeInner::Vector { .. } = *cond_ty {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
// TODO: Boolean mix on desktop required GL_EXT_shader_integer_mix
|
||||
if vec_select {
|
||||
write!(self.out, "mix(")?;
|
||||
self.write_expr(accept, ctx)?;
|
||||
write!(self.out, ", ")?;
|
||||
self.write_expr(reject, ctx)?;
|
||||
write!(self.out, ", ")?;
|
||||
self.write_expr(condition, ctx)?;
|
||||
} else {
|
||||
write!(self.out, "(")?;
|
||||
self.write_expr(condition, ctx)?;
|
||||
write!(self.out, " ? ")?;
|
||||
self.write_expr(accept, ctx)?;
|
||||
write!(self.out, " : ")?;
|
||||
self.write_expr(reject, ctx)?;
|
||||
}
|
||||
|
||||
write!(self.out, ")")?
|
||||
}
|
||||
// `Derivative` is a function call to a glsl provided function
|
||||
|
||||
Reference in New Issue
Block a user