mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[hlsl-out] Fix countOneBits and reverseBits for signed integers
This commit is contained in:
committed by
Teodor Tanasoaia
parent
60ae549fe1
commit
571302e3ff
@@ -6,7 +6,7 @@ use super::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
back,
|
back,
|
||||||
proc::{self, NameKey},
|
proc::{self, NameKey},
|
||||||
valid, Handle, Module, ShaderStage, TypeInner,
|
valid, Handle, Module, ScalarKind, ShaderStage, TypeInner,
|
||||||
};
|
};
|
||||||
use std::{fmt, mem};
|
use std::{fmt, mem};
|
||||||
|
|
||||||
@@ -2190,6 +2190,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
|||||||
Asincosh { is_sin: bool },
|
Asincosh { is_sin: bool },
|
||||||
Atanh,
|
Atanh,
|
||||||
Regular(&'static str),
|
Regular(&'static str),
|
||||||
|
MissingIntOverload(&'static str),
|
||||||
}
|
}
|
||||||
|
|
||||||
let fun = match fun {
|
let fun = match fun {
|
||||||
@@ -2251,8 +2252,8 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
|||||||
Mf::Transpose => Function::Regular("transpose"),
|
Mf::Transpose => Function::Regular("transpose"),
|
||||||
Mf::Determinant => Function::Regular("determinant"),
|
Mf::Determinant => Function::Regular("determinant"),
|
||||||
// bits
|
// bits
|
||||||
Mf::CountOneBits => Function::Regular("countbits"),
|
Mf::CountOneBits => Function::MissingIntOverload("countbits"),
|
||||||
Mf::ReverseBits => Function::Regular("reversebits"),
|
Mf::ReverseBits => Function::MissingIntOverload("reversebits"),
|
||||||
Mf::FindLsb => Function::Regular("firstbitlow"),
|
Mf::FindLsb => Function::Regular("firstbitlow"),
|
||||||
Mf::FindMsb => Function::Regular("firstbithigh"),
|
Mf::FindMsb => Function::Regular("firstbithigh"),
|
||||||
_ => return Err(Error::Unimplemented(format!("write_expr_math {:?}", fun))),
|
_ => return Err(Error::Unimplemented(format!("write_expr_math {:?}", fun))),
|
||||||
@@ -2295,6 +2296,21 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
|||||||
}
|
}
|
||||||
write!(self.out, ")")?
|
write!(self.out, ")")?
|
||||||
}
|
}
|
||||||
|
Function::MissingIntOverload(fun_name) => {
|
||||||
|
let scalar_kind = &func_ctx.info[arg]
|
||||||
|
.ty
|
||||||
|
.inner_with(&module.types)
|
||||||
|
.scalar_kind();
|
||||||
|
if let Some(ScalarKind::Sint) = *scalar_kind {
|
||||||
|
write!(self.out, "asint({}(asuint(", fun_name)?;
|
||||||
|
self.write_expr(module, arg, func_ctx)?;
|
||||||
|
write!(self.out, ")))")?;
|
||||||
|
} else {
|
||||||
|
write!(self.out, "{}(", fun_name)?;
|
||||||
|
self.write_expr(module, arg, func_ctx)?;
|
||||||
|
write!(self.out, ")")?;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expression::Swizzle {
|
Expression::Swizzle {
|
||||||
|
|||||||
Reference in New Issue
Block a user