Skip to content

Commit 1e62441

Browse files
authored
Update instruction.rs
1 parent fc4715a commit 1e62441

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/compiler/translator/ir/src/instruction.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,18 @@ mod const_fold {
17541754
) -> ConstantId {
17551755
unpack4x8_helper(ir_meta, constant_id, result_type_id, unorm8_to_f32)
17561756
}
1757+
fn create_default_constant(ir_meta: &mut IRMeta, type_id: TypeId) -> ConstantId {
1758+
match ir_meta.types.get(type_id) {
1759+
Type::Float => ir_meta.constants.insert(Constant::Float(0.0)),
1760+
Type::Int => ir_meta.constants.insert(Constant::Int(0)),
1761+
Type::Uint => ir_meta.constants.insert(Constant::Uint(0)),
1762+
Type::Bool => ir_meta.constants.insert(Constant::Bool(false)),
1763+
Type::Vec2 => ir_meta.constants.insert(Constant::Vec2([0.0, 0.0])),
1764+
Type::Vec3 => ir_meta.constants.insert(Constant::Vec3([0.0, 0.0, 0.0])),
1765+
Type::Vec4 => ir_meta.constants.insert(Constant::Vec4([0.0, 0.0, 0.0, 0.0])),
1766+
_ => ir_meta.constants.insert(Constant::Float(0.0)),
1767+
}
1768+
}
17571769
pub fn built_in_unary(
17581770
ir_meta: &mut IRMeta,
17591771
op: UnaryOpCode,

0 commit comments

Comments
 (0)