Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
[glsl-in] disable modf & frexp
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed Oct 2, 2023
1 parent 9f3cdb6 commit 8208e94
Showing 1 changed file with 57 additions and 56 deletions.
113 changes: 57 additions & 56 deletions src/front/glsl/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,62 +1408,63 @@ fn inject_common_builtin(
declaration.overloads.push(module.add_builtin(args, fun))
}
}
"modf" | "frexp" => {
// bits layout
// bit 0 through 1 - dims
for bits in 0..0b100 {
let size = match bits {
0b00 => None,
0b01 => Some(VectorSize::Bi),
0b10 => Some(VectorSize::Tri),
_ => Some(VectorSize::Quad),
};

let ty = module.types.insert(
Type {
name: None,
inner: match size {
Some(size) => TypeInner::Vector {
size,
kind: Sk::Float,
width: float_width,
},
None => TypeInner::Scalar {
kind: Sk::Float,
width: float_width,
},
},
},
Span::default(),
);

let parameters = vec![ty, ty];

let fun = match name {
"modf" => MacroCall::MathFunction(MathFunction::Modf),
"frexp" => MacroCall::MathFunction(MathFunction::Frexp),
_ => unreachable!(),
};

declaration.overloads.push(Overload {
parameters,
parameters_info: vec![
ParameterInfo {
qualifier: ParameterQualifier::In,
depth: false,
},
ParameterInfo {
qualifier: ParameterQualifier::Out,
depth: false,
},
],
kind: FunctionKind::Macro(fun),
defined: false,
internal: true,
void: false,
})
}
}
// TODO: https://github.com/gfx-rs/naga/issues/2526
// "modf" | "frexp" => {
// // bits layout
// // bit 0 through 1 - dims
// for bits in 0..0b100 {
// let size = match bits {
// 0b00 => None,
// 0b01 => Some(VectorSize::Bi),
// 0b10 => Some(VectorSize::Tri),
// _ => Some(VectorSize::Quad),
// };

// let ty = module.types.insert(
// Type {
// name: None,
// inner: match size {
// Some(size) => TypeInner::Vector {
// size,
// kind: Sk::Float,
// width: float_width,
// },
// None => TypeInner::Scalar {
// kind: Sk::Float,
// width: float_width,
// },
// },
// },
// Span::default(),
// );

// let parameters = vec![ty, ty];

// let fun = match name {
// "modf" => MacroCall::MathFunction(MathFunction::Modf),
// "frexp" => MacroCall::MathFunction(MathFunction::Frexp),
// _ => unreachable!(),
// };

// declaration.overloads.push(Overload {
// parameters,
// parameters_info: vec![
// ParameterInfo {
// qualifier: ParameterQualifier::In,
// depth: false,
// },
// ParameterInfo {
// qualifier: ParameterQualifier::Out,
// depth: false,
// },
// ],
// kind: FunctionKind::Macro(fun),
// defined: false,
// internal: true,
// void: false,
// })
// }
// }
"cross" => {
let args = vec![
TypeInner::Vector {
Expand Down

0 comments on commit 8208e94

Please sign in to comment.