mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
shader_ir: Add float helpers
This commit is contained in:
parent
6b9eea3fe5
commit
833d0806f9
2 changed files with 24 additions and 0 deletions
|
@ -121,6 +121,25 @@ Node ShaderIR::GetLocalMemory(Node address) {
|
||||||
return StoreNode(LmemNode(address));
|
return StoreNode(LmemNode(address));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node ShaderIR::GetOperandAbsNegFloat(Node value, bool absolute, bool negate) {
|
||||||
|
if (absolute) {
|
||||||
|
value = Operation(OperationCode::FAbsolute, NO_PRECISE, value);
|
||||||
|
}
|
||||||
|
if (negate) {
|
||||||
|
value = Operation(OperationCode::FNegate, NO_PRECISE, value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node ShaderIR::GetSaturatedFloat(Node value, bool saturate) {
|
||||||
|
if (!saturate) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
const Node positive_zero = Immediate(std::copysignf(0, 1));
|
||||||
|
const Node positive_one = Immediate(1.0f);
|
||||||
|
return Operation(OperationCode::FClamp, NO_PRECISE, value, positive_zero, positive_one);
|
||||||
|
}
|
||||||
|
|
||||||
void ShaderIR::SetRegister(BasicBlock& bb, Register dest, Node src) {
|
void ShaderIR::SetRegister(BasicBlock& bb, Register dest, Node src) {
|
||||||
bb.push_back(Operation(OperationCode::Assign, GetRegister(dest), src));
|
bb.push_back(Operation(OperationCode::Assign, GetRegister(dest), src));
|
||||||
}
|
}
|
||||||
|
|
|
@ -643,6 +643,11 @@ private:
|
||||||
/// Sets a local memory address. address and value must be a number-evaluated node
|
/// Sets a local memory address. address and value must be a number-evaluated node
|
||||||
void SetLocalMemory(BasicBlock& bb, Node address, Node value);
|
void SetLocalMemory(BasicBlock& bb, Node address, Node value);
|
||||||
|
|
||||||
|
/// Conditionally absolute/negated float. Absolute is applied first
|
||||||
|
Node GetOperandAbsNegFloat(Node value, bool absolute, bool negate);
|
||||||
|
/// Conditionally saturates a float
|
||||||
|
Node GetSaturatedFloat(Node value, bool saturate = true);
|
||||||
|
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
inline Node Operation(OperationCode code, const T*... operands) {
|
inline Node Operation(OperationCode code, const T*... operands) {
|
||||||
return StoreNode(OperationNode(code, operands...));
|
return StoreNode(OperationNode(code, operands...));
|
||||||
|
|
Loading…
Reference in a new issue